From 4109bb270dce74ab2832170ffd26cf615e2e0279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 30 Aug 2013 17:56:29 +0200 Subject: [PATCH] Always keep incompatible apps in the DB Show them under the following circumstances: 1) If showIncompatible is true, show all incompatible apps/apks always 2) Installed tab, Searches and direct links will always show incompatible apps, but NOT apks TODO: onResume should repopulate all lists. And it seems to, lists are reloaded. But the updates don't take effect and so restart is required for a change in showIncompatible to take effect. --- src/org/fdroid/fdroid/AppDetails.java | 5 ++++- src/org/fdroid/fdroid/AppListManager.java | 12 +++++++--- src/org/fdroid/fdroid/DB.java | 22 +++++-------------- src/org/fdroid/fdroid/FDroid.java | 2 -- .../fdroid/fdroid/PreferencesActivity.java | 7 ++---- 5 files changed, 20 insertions(+), 28 deletions(-) diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java index 158273c26..14b9e3811 100644 --- a/src/org/fdroid/fdroid/AppDetails.java +++ b/src/org/fdroid/fdroid/AppDetails.java @@ -243,6 +243,7 @@ public class AppDetails extends ListActivity { private boolean pref_expert; private boolean pref_permissions; + private boolean pref_incompatible; private boolean resetRequired; // The signature of the installed version. @@ -263,6 +264,7 @@ public class AppDetails extends ListActivity { .getDefaultSharedPreferences(getBaseContext()); pref_expert = prefs.getBoolean("expert", false); pref_permissions = prefs.getBoolean("showPermissions", false); + pref_incompatible = prefs.getBoolean("showIncompatible", false); updateViews(); MenuManager.create(this).invalidateOptionsMenu(); @@ -375,7 +377,8 @@ public class AppDetails extends ListActivity { // Populate the list... ApkListAdapter la = (ApkListAdapter) getListAdapter(); for (DB.Apk apk : app.apks) - la.addItem(apk); + if (pref_incompatible || apk.compatible) + la.addItem(apk); la.notifyDataSetChanged(); // Insert the 'infoView' (which contains the summary, various odds and diff --git a/src/org/fdroid/fdroid/AppListManager.java b/src/org/fdroid/fdroid/AppListManager.java index 4b2b5a077..53fe35707 100644 --- a/src/org/fdroid/fdroid/AppListManager.java +++ b/src/org/fdroid/fdroid/AppListManager.java @@ -178,6 +178,9 @@ public class AppListManager { private boolean updateApps() { allApps = ((FDroidApp)fdroidActivity.getApplication()).getApps(); + SharedPreferences prefs = PreferenceManager + .getDefaultSharedPreferences(fdroidActivity.getBaseContext()); + boolean showIncompatible = prefs.getBoolean("showIncompatible", false); if (allApps.isEmpty()) { // If its the first time we've run the app, this should update @@ -197,11 +200,14 @@ public class AppListManager { // Add it to the list(s). Always to installed and updates, but // only to available if it's not filtered. - if (!isFiltered && isInCategory) - availApps.add(app); + if (!isFiltered && isInCategory) { + if (showIncompatible || app.compatible) { + availApps.add(app); + } + } if (app.installedVersion != null) { installedApps.addItem(app); - if (app.hasUpdates) + if (app.hasUpdates && (showIncompatible || app.compatible)) canUpgradeApps.addItem(app); } } diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index de60fe6f1..25560fc4c 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -1153,27 +1153,15 @@ public class DB { if (compatChecker == null) compatChecker = Apk.CompatibilityChecker.getChecker(mContext); - SharedPreferences prefs = PreferenceManager - .getDefaultSharedPreferences(mContext); - boolean prefCompat = prefs.getBoolean("showIncompatible", false); - // See if it's compatible (by which we mean if it has at least one - // compatible apk - if it's not, leave it out) - // Also keep a list of which were compatible, because they're the - // only ones we'll add, unless the showIncompatible preference is set. - List compatibleapks = new ArrayList(); + // compatible apk) + upapp.compatible = false; for (Apk apk : upapp.apks) { if (compatChecker.isCompatible(apk)) { apk.compatible = true; - compatibleapks.add(apk); + upapp.compatible = true; } } - if (compatibleapks.size() > 0) - upapp.compatible = true; - if (prefCompat) - compatibleapks = upapp.apks; - if (compatibleapks.size() == 0) - return false; boolean found = false; for (App app : updateApps) { @@ -1181,7 +1169,7 @@ public class DB { updateApp(app, upapp); app.updated = true; found = true; - for (Apk upapk : compatibleapks) { + for (Apk upapk : upapp.apks) { boolean afound = false; for (Apk apk : app.apks) { if (apk.vercode == upapk.vercode) { @@ -1206,7 +1194,7 @@ public class DB { if (!found) { // It's a brand new application... updateApp(null, upapp); - for (Apk upapk : compatibleapks) { + for (Apk upapk : upapp.apks) { updateApkIfDifferent(null, upapk); upapk.updated = true; } diff --git a/src/org/fdroid/fdroid/FDroid.java b/src/org/fdroid/fdroid/FDroid.java index 52d03fd68..5a115a02f 100644 --- a/src/org/fdroid/fdroid/FDroid.java +++ b/src/org/fdroid/fdroid/FDroid.java @@ -255,8 +255,6 @@ public class FDroid extends FragmentActivity { finish(); overridePendingTransition(0, 0); startActivity(intent); - } else { - repopulateViews(); } break; diff --git a/src/org/fdroid/fdroid/PreferencesActivity.java b/src/org/fdroid/fdroid/PreferencesActivity.java index bdc397fc5..0250fffe0 100644 --- a/src/org/fdroid/fdroid/PreferencesActivity.java +++ b/src/org/fdroid/fdroid/PreferencesActivity.java @@ -35,7 +35,6 @@ public class PreferencesActivity extends PreferenceActivity implements private boolean ignoreTouchscreenChanged = false; - private boolean showIncompatibleChanged = false; private boolean lightThemeChanged = false; Intent ret; @@ -51,7 +50,7 @@ public class PreferencesActivity extends PreferenceActivity implements ActionBarCompat.create(this).setDisplayHomeAsUpEnabled(true); addPreferencesFromResource(R.xml.preferences); for (String prefkey : new String[] { "ignoreTouchscreen", - "showIncompatible", "lightTheme" }) { + "lightTheme" }) { Preference pref = findPreference(prefkey); pref.setOnPreferenceClickListener(this); } @@ -63,14 +62,12 @@ public class PreferencesActivity extends PreferenceActivity implements String key = preference.getKey(); if (key.equals("ignoreTouchscreen")) ignoreTouchscreenChanged ^= true; - else if (key.equals("showIncompatible")) - showIncompatibleChanged ^= true; else lightThemeChanged ^= true; if (lightThemeChanged) ret.putExtra("restart", true); - else if (ignoreTouchscreenChanged || showIncompatibleChanged) + else if (ignoreTouchscreenChanged) ret.putExtra("update", true); setResult(RESULT_OK, ret);