This repository has been archived by the owner on May 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
MainActivity.java
219 lines (192 loc) · 10.1 KB
/
MainActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
package com.layoutxml.applistmanager;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.layoutxml.applistmanagerlibrary.AppList;
import com.layoutxml.applistmanagerlibrary.interfaces.ActivityListener;
import com.layoutxml.applistmanagerlibrary.interfaces.AppListener;
import com.layoutxml.applistmanagerlibrary.interfaces.NewActivityListener;
import com.layoutxml.applistmanagerlibrary.interfaces.NewAppListener;
import com.layoutxml.applistmanagerlibrary.interfaces.SortListener;
import com.layoutxml.applistmanagerlibrary.interfaces.UninstalledActivityListener;
import com.layoutxml.applistmanagerlibrary.interfaces.UninstalledAppListener;
import com.layoutxml.applistmanagerlibrary.objects.AppData;
import java.util.List;
public class MainActivity extends AppCompatActivity implements AppListener, NewAppListener, UninstalledAppListener, SortListener, ActivityListener, NewActivityListener, UninstalledActivityListener {
@Override
protected void onPause() {
super.onPause();
AppList.destroy();
}
@Override
protected void onResume() {
super.onResume();
AppList.registerListeners(MainActivity.this,MainActivity.this,MainActivity.this,MainActivity.this,MainActivity.this,MainActivity.this,MainActivity.this);
}
private Button getAllButton;
private Button getNewButton;
private Button getUninstalledButton;
private Button getAllSystemButton;
private Button getActivitiesButton;
private Button getNewActivitiesButton;
private Button getUninstalledActivitiesButton;
private Button showAppButton;
private Button showActivitiesButton;
private TextView getAllText;
private TextView getNewText;
private TextView getUninstalledText;
private TextView getAllSystemText;
private TextView getActivitiesText;
private TextView getNewActivitiesText;
private TextView getUninstalledActivitiesText;
private List<AppData> AllAppsList;
private List<AppData> AllSystemAppsList;
private List<AppData> AllActivitiesList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getAllButton = findViewById(R.id.getAllBtn);
getNewButton = findViewById(R.id.getNewBtn);
getUninstalledButton = findViewById(R.id.getUninstalledBtn);
getAllSystemButton = findViewById(R.id.getAllSystemBtn);
getActivitiesButton = findViewById(R.id.getActivitiesBtn);
getNewActivitiesButton = findViewById(R.id.getNewActivitiesBtn);
getUninstalledActivitiesButton = findViewById(R.id.getUninstalledActivitiesBtn);
showAppButton = findViewById(R.id.showAppsBtn);
showActivitiesButton = findViewById(R.id.showActivitiesBtn);
getAllText = findViewById(R.id.getAllTxt);
getNewText = findViewById(R.id.getNewTxt);
getUninstalledText = findViewById(R.id.getUninstalledTxt);
getAllSystemText = findViewById(R.id.getAllSystemTxt);
getActivitiesText = findViewById(R.id.getActivitiesTxt);
getNewActivitiesText = findViewById(R.id.getNewActivitiesTxt);
getUninstalledActivitiesText = findViewById(R.id.getUninstalledActivitiesTxt);
AppList.registerListeners(MainActivity.this,MainActivity.this,MainActivity.this,MainActivity.this,MainActivity.this,MainActivity.this,MainActivity.this);
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
registerReceiver(new AppList(),AppList.intentFilter);
getAllButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AppList.getAllApps(getApplicationContext(),0);
}
});
getNewButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AppList.getAllNewApps(getApplicationContext(), AllAppsList, 1);
}
});
getUninstalledButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AppList.getAllUninstalledApps(getApplicationContext(), AllAppsList,2);
}
});
getAllSystemButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AppList.getSomeApps(getApplicationContext(), ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP, true, null,false,3);
}
});
getActivitiesButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
AppList.getAllActivities(getApplicationContext(),mainIntent,4);
}
});
getNewActivitiesButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
AppList.getAllNewActivities(getApplicationContext(),AllActivitiesList,mainIntent,5);
}
});
getUninstalledActivitiesButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
AppList.getAllUninstalledActivities(getApplicationContext(),AllActivitiesList,mainIntent,6);
}
});
showAppButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), ListActivity.class);
intent.putExtra("appDataList","apps");
startActivity(intent);
}
});
showActivitiesButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), ListActivity.class);
intent.putExtra("appDataList","activities");
startActivity(intent);
}
});
}
@Override
public void appListener(List<AppData> appDataList, Integer applicationFlags, Boolean applicationFlagsMatch, String[] permissions, Boolean matchPermissions, Integer uniqueIdentifier) {
if (uniqueIdentifier==0) { //Could also be: if (filterFlags == null)
getAllText.setText("There are now " + appDataList.size() + " apps installed.");
AppList.sort(appDataList,AppList.BY_APPNAME,AppList.IN_ASCENDING,0);
}
else if (uniqueIdentifier==3) { //Could also be: else if (filterFlags == (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP))
getAllSystemText.setText("There are now " + appDataList.size() + " apps installed.");
AllSystemAppsList = appDataList;
}
}
@Override
public void newAppListener(List<AppData> appDataList, Integer applicationFlags, Boolean applicationFlagsMatch, Boolean fromReceiver, String[] permissions, Boolean matchPermissions, Integer uniqueIdentifier) {
getNewText.setText(appDataList.size()+" new apps installed.");
if (AllAppsList != null) {
AllAppsList.addAll(appDataList);
getAllText.setText(getAllText.getText() + "\n+ " + appDataList.size() + " (" + AllAppsList.size() + " total).");
}
}
@Override
public void uninstalledAppListener(List<AppData> appDataList, Boolean fromReceiver, Integer applicationFlags, Boolean applicationFlagsMatch, String[] permissions, Boolean matchPermissions, Integer uniqueIdentifier) {
getUninstalledText.setText(appDataList.size()+" apps uninstalled.");
if (AllAppsList!=null) {
AllAppsList.removeAll(appDataList);
getAllText.setText(getAllText.getText()+"\n- "+appDataList.size()+" ("+AllAppsList.size()+" total).");
}
}
@Override
public void sortListener(List<AppData> appDataList, Integer sortBy, Integer inOrder, Integer uniqueIdentifier) {
AllAppsList = appDataList;
}
@Override
public void activityListener(List<AppData> appDataList, Intent intent, Integer activityFlags, Integer applicationFlags, Boolean applicationFlagsMatch, String[] permissions, Boolean matchPermissions, Integer uniqueIdentifier) {
if (uniqueIdentifier==4) {
getActivitiesText.setText("There are now " + appDataList.size() + " activities");
AllActivitiesList = appDataList;
}
}
@Override
public void newActivityListener(List<AppData> appDataList, Intent intent, Integer activityFlags, Integer applicationFlags, Boolean applicationFlagsMatch, Boolean fromReceiver, String[] permissions, Boolean matchPermissions, Integer uniqueIdentifier) {
getNewActivitiesText.setText(appDataList.size()+" activities added");
if (AllActivitiesList!=null) {
AllActivitiesList.addAll(appDataList);
getActivitiesText.setText(getActivitiesText.getText()+"\n+ "+appDataList.size()+" ("+AllActivitiesList.size()+" total).");
}
}
@Override
public void uninstalledActivityListener(List<AppData> appDataList, Intent intent, Integer activityFlags, Integer applicationFlags, Boolean applicationFlagsMatch, Boolean fromReceiver, String[] permissions, Boolean matchPermissions, Integer uniqueIdentifier) {
getUninstalledActivitiesText.setText(appDataList.size()+" activities removed");
if (AllActivitiesList!=null){
AllActivitiesList.removeAll(appDataList);
getActivitiesText.setText(getActivitiesText.getText()+"\n- "+appDataList.size()+" ("+AllActivitiesList.size()+" total).");
}
}
}