prepare filters
This commit is contained in:
parent
8209559012
commit
acfc183eec
|
@ -22,12 +22,15 @@ class ComputeAppListTask extends AsyncTask<Void, Void, List<ApplicationViewModel
|
|||
private final WeakReference<DatabaseManager> databaseManagerRef;
|
||||
private final WeakReference<Listener> listenerRef;
|
||||
|
||||
order userOrderChoice;
|
||||
|
||||
ComputeAppListTask(WeakReference<PackageManager> packageManagerRef,
|
||||
WeakReference<DatabaseManager> databaseManagerRef,
|
||||
WeakReference<Listener> listenerRef) {
|
||||
WeakReference<Listener> listenerRef, order orderCoice) {
|
||||
this.packageManagerRef = packageManagerRef;
|
||||
this.databaseManagerRef = databaseManagerRef;
|
||||
this.listenerRef = listenerRef;
|
||||
userOrderChoice = orderCoice;
|
||||
}
|
||||
|
||||
protected List<ApplicationViewModel> doInBackground(Void... params) {
|
||||
|
@ -39,10 +42,22 @@ class ComputeAppListTask extends AsyncTask<Void, Void, List<ApplicationViewModel
|
|||
List<PackageInfo> installedPackages = packageManager.getInstalledPackages(PackageManager.GET_PERMISSIONS);
|
||||
vms = applyStoreFilter(installedPackages, databaseManager, packageManager);
|
||||
convertPackagesToViewModels(vms, databaseManager, packageManager);
|
||||
}
|
||||
//Reordering should done here
|
||||
if (userOrderChoice != order.DEFAULT) {
|
||||
|
||||
}
|
||||
return vms;
|
||||
}
|
||||
|
||||
public enum order {
|
||||
DEFAULT,
|
||||
MOST_TRACKERS,
|
||||
LESS_TRACKERS,
|
||||
MOST_PERMISSIONS,
|
||||
LESS_PERMISSIONS,
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(List<ApplicationViewModel> vms) {
|
||||
Listener listener = listenerRef.get();
|
||||
|
|
|
@ -190,7 +190,7 @@ public class HomeFragment extends Fragment implements ComputeAppListTask.Listene
|
|||
new ComputeAppListTask(
|
||||
new WeakReference<>(packageManager),
|
||||
new WeakReference<>(DatabaseManager.getInstance(getActivity())),
|
||||
new WeakReference<>(this)
|
||||
new WeakReference<>(this), ComputeAppListTask.order.DEFAULT
|
||||
).execute();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@ import android.os.Bundle;
|
|||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
|
@ -164,8 +163,8 @@ public class ReportFragment extends Fragment implements Updatable {
|
|||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
MenuItem item = menu.findItem(R.id.action_filter);
|
||||
item.setVisible(false);
|
||||
menu.findItem(R.id.action_filter).setVisible(false);
|
||||
menu.findItem(R.id.action_filter_options).setVisible(false);
|
||||
}
|
||||
|
||||
public ApplicationViewModel getModel() {
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.text.Html;
|
|||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
|
@ -97,11 +96,9 @@ public class TrackerFragment extends Fragment implements ComputeAppListTask.List
|
|||
|
||||
@Override
|
||||
public void onPrepareOptionsMenu(Menu menu) {
|
||||
MenuItem item = menu.findItem(R.id.action_filter);
|
||||
item.setVisible(false);
|
||||
item = menu.findItem(R.id.action_settings);
|
||||
item.setVisible(false);
|
||||
|
||||
menu.findItem(R.id.action_filter).setVisible(false);
|
||||
menu.findItem(R.id.action_settings).setVisible(false);
|
||||
menu.findItem(R.id.action_filter_options).setVisible(false);
|
||||
}
|
||||
|
||||
private void displayAppListAsync() {
|
||||
|
@ -118,7 +115,7 @@ public class TrackerFragment extends Fragment implements ComputeAppListTask.List
|
|||
new ComputeAppListTask(
|
||||
new WeakReference<>(packageManager),
|
||||
new WeakReference<>(DatabaseManager.getInstance(getActivity())),
|
||||
new WeakReference<>(this)
|
||||
new WeakReference<>(this), ComputeAppListTask.order.DEFAULT
|
||||
).execute();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z" />
|
||||
</vector>
|
|
@ -7,6 +7,11 @@
|
|||
android:title="@string/menu_action_filter"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
app:showAsAction="always|collapseActionView" />
|
||||
<item
|
||||
android:id="@+id/action_filter_options"
|
||||
android:icon="@drawable/ic_baseline_filter_list_24"
|
||||
android:title="@string/menu_action_filter"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:icon="@drawable/ic_settings"
|
||||
|
|
Loading…
Reference in New Issue