diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java index 82bd21dfc..d7f8eb577 100644 --- a/src/org/fdroid/fdroid/AppDetails.java +++ b/src/org/fdroid/fdroid/AppDetails.java @@ -377,11 +377,13 @@ public class AppDetails extends ListActivity { private void startViews() { // Populate the list... - ApkListAdapter la = (ApkListAdapter) getListAdapter(); - for (DB.Apk apk : app.apks) - if (pref_incompatible || apk.compatible) - la.addItem(apk); - la.notifyDataSetChanged(); + if (!app.filtered) { + ApkListAdapter la = (ApkListAdapter) getListAdapter(); + for (DB.Apk apk : app.apks) + if (pref_incompatible || apk.compatible) + la.addItem(apk); + la.notifyDataSetChanged(); + } // Insert the 'infoView' (which contains the summary, various odds and // ends, and the description) into the appropriate place, if we're in @@ -504,8 +506,10 @@ public class AppDetails extends ListActivity { private void updateViews() { // Refresh the list... - ApkListAdapter la = (ApkListAdapter) getListAdapter(); - la.notifyDataSetChanged(); + if (!app.filtered) { + ApkListAdapter la = (ApkListAdapter) getListAdapter(); + la.notifyDataSetChanged(); + } TextView tv = (TextView) findViewById(R.id.status); if (app.installedVersion == null) diff --git a/src/org/fdroid/fdroid/AppListManager.java b/src/org/fdroid/fdroid/AppListManager.java index c83b6e01e..f0a41de5d 100644 --- a/src/org/fdroid/fdroid/AppListManager.java +++ b/src/org/fdroid/fdroid/AppListManager.java @@ -190,25 +190,21 @@ public class AppListManager { } Date recentDate = calcMaxHistory(); - AppFilter appFilter = new AppFilter(fdroidActivity); - List availApps = new ArrayList(); for (DB.App app : allApps) { boolean isInCategory = isInCategory(app, currentCategory, recentDate); - boolean isFiltered = appFilter.filter(app); // Add it to the list(s). Always to installed and updates, but // only to available if it's not filtered. - if (!isFiltered && isInCategory) { - if (showIncompatible || app.compatible) { - availApps.add(app); - } + if (!app.filtered && isInCategory + && (showIncompatible || app.compatible)) { + availApps.add(app); } if (app.installedVersion != null) { installedApps.addItem(app); - if (!app.ignoreUpdates && app.hasUpdates && - (showIncompatible || app.compatible)) + if (!app.ignoreUpdates && app.hasUpdates && !app.filtered + && (showIncompatible || app.compatible)) canUpgradeApps.addItem(app); } } diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index 7e19e5078..8ccb49d24 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -53,10 +53,12 @@ public class DB { private static Semaphore dbSync = new Semaphore(1, true); static DB dbInstance = null; + private static Context activityContext = null; // Initialise the database. Called once when the application starts up. static void initDB(Context ctx) { dbInstance = new DB(ctx); + activityContext = ctx; } // Get access to the database. Must be called before any database activity, @@ -124,6 +126,7 @@ public class DB { detail_Populated = false; compatible = false; ignoreUpdates = false; + filtered = false; } // True when all the detail fields are populated, False otherwise. @@ -184,6 +187,10 @@ public class DB { // null if there aren't any. public CommaSeparatedList requirements; + // Whether the app is filtered or not based on AntiFeatures and root + // permission (set in the Settings page) + public boolean filtered; + // True if there are new versions (apks) that the user hasn't // explicitly ignored. (We're currently not using the database // field for this - we make the decision on the fly in getApps(). @@ -751,6 +758,7 @@ public class DB { } Map apps = new HashMap(); + AppFilter appFilter = new AppFilter(activityContext); Cursor c = null; long startTime = System.currentTimeMillis(); try { @@ -783,6 +791,7 @@ public class DB { .parse(sLastUpdated); app.compatible = c.getInt(12) == 1; app.ignoreUpdates = c.getInt(13) == 1; + app.filtered = appFilter.filter(app); app.hasUpdates = false; if (getinstalledinfo && systemApks.containsKey(app.id)) { diff --git a/src/org/fdroid/fdroid/SearchResults.java b/src/org/fdroid/fdroid/SearchResults.java index 2443b1915..73a10e56a 100644 --- a/src/org/fdroid/fdroid/SearchResults.java +++ b/src/org/fdroid/fdroid/SearchResults.java @@ -95,7 +95,6 @@ public class SearchResults extends ListActivity { } List apps = new ArrayList(); - AppFilter appfilter = new AppFilter(this); List tapps = ((FDroidApp) getApplication()).getApps(); for (DB.App tapp : tapps) { boolean include = false; @@ -105,7 +104,7 @@ public class SearchResults extends ListActivity { break; } } - if (include && !appfilter.filter(tapp)) + if (include) apps.add(tapp); } diff --git a/src/org/fdroid/fdroid/views/AppListAdapter.java b/src/org/fdroid/fdroid/views/AppListAdapter.java index 640493a46..d7ac6bb55 100644 --- a/src/org/fdroid/fdroid/views/AppListAdapter.java +++ b/src/org/fdroid/fdroid/views/AppListAdapter.java @@ -112,7 +112,7 @@ abstract public class AppListAdapter extends BaseAdapter { // Disable it all if it isn't compatible... View[] views = { convertView, status, summary, license, name }; for (View view : views) { - view.setEnabled(app.compatible); + view.setEnabled(app.compatible && !app.filtered); } return convertView;