From 03f286928120074181acd41a69233b9ed4da7090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Wed, 25 Dec 2013 22:48:12 +0100 Subject: [PATCH] Always load incompatible apks on memory --- src/org/fdroid/fdroid/AppDetails.java | 14 +++++++-- src/org/fdroid/fdroid/DB.java | 42 +++++++++++++-------------- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java index c8ed91e24..a2667be35 100644 --- a/src/org/fdroid/fdroid/AppDetails.java +++ b/src/org/fdroid/fdroid/AppDetails.java @@ -87,11 +87,18 @@ public class AppDetails extends ListActivity { private List items; public ApkListAdapter(Context context, List items) { - this.items = (items != null ? items : new ArrayList()); + this.items = new ArrayList(); + if (items != null) { + for (DB.Apk apk : items) { + this.addItem(apk); + } + } } public void addItem(DB.Apk apk) { - items.add(apk); + if (apk.compatible || pref_incompatibleVersions) { + items.add(apk); + } } public List getItems() { @@ -273,6 +280,8 @@ public class AppDetails extends ListActivity { .getDefaultSharedPreferences(getBaseContext()); pref_expert = prefs.getBoolean("expert", false); pref_permissions = prefs.getBoolean("showPermissions", false); + pref_incompatibleVersions = prefs.getBoolean( + "incompatibleVersions", false); startViews(); @@ -280,6 +289,7 @@ public class AppDetails extends ListActivity { private boolean pref_expert; private boolean pref_permissions; + private boolean pref_incompatibleVersions; private boolean resetRequired; // The signature of the installed version. diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index 1f8150545..f3089476f 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -243,7 +243,8 @@ public class DB { int latestcode = -1; Apk latestapk = null; for (Apk apk : apks) { - if (apk.compatible && apk.vercode <= curVercode + if ((!this.compatible || apk.compatible) + && apk.vercode <= curVercode && apk.vercode > latestcode) { latestapk = apk; latestcode = apk.vercode; @@ -257,7 +258,8 @@ public class DB { int latestcode = -1; Apk latestapk = null; for (Apk apk : apks) { - if (apk.compatible && apk.vercode > latestcode) { + if ((!this.compatible || apk.compatible) + && apk.vercode > latestcode) { latestapk = apk; latestcode = apk.vercode; } @@ -891,8 +893,6 @@ public class DB { List repos = getRepos(); SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(mContext); - boolean incompatibleVersions = prefs - .getBoolean("incompatibleVersions", false); cols = new String[] { "id", "version", "vercode", "sig", "srcname", "apkName", "minSdkVersion", "added", "features", "nativecode", "compatible", "repo" }; @@ -908,24 +908,22 @@ public class DB { } boolean compatible = c.getInt(10) == 1; int repoid = c.getInt(11); - if (compatible || incompatibleVersions) { - Apk apk = new Apk(); - apk.id = id; - apk.version = c.getString(1); - apk.vercode = c.getInt(2); - apk.sig = c.getString(3); - apk.srcname = c.getString(4); - apk.apkName = c.getString(5); - apk.minSdkVersion = c.getInt(6); - String sApkAdded = c.getString(7); - apk.added = (sApkAdded == null || sApkAdded.length() == 0) ? null - : mDateFormat.parse(sApkAdded); - apk.features = CommaSeparatedList.make(c.getString(8)); - apk.nativecode = CommaSeparatedList.make(c.getString(9)); - apk.compatible = compatible; - apk.repo = repoid; - app.apks.add(apk); - } + Apk apk = new Apk(); + apk.id = id; + apk.version = c.getString(1); + apk.vercode = c.getInt(2); + apk.sig = c.getString(3); + apk.srcname = c.getString(4); + apk.apkName = c.getString(5); + apk.minSdkVersion = c.getInt(6); + String sApkAdded = c.getString(7); + apk.added = (sApkAdded == null || sApkAdded.length() == 0) ? null + : mDateFormat.parse(sApkAdded); + apk.features = CommaSeparatedList.make(c.getString(8)); + apk.nativecode = CommaSeparatedList.make(c.getString(9)); + apk.compatible = compatible; + apk.repo = repoid; + app.apks.add(apk); if (app.iconUrl == null && app.icon != null) { for (DB.Repo repo : repos) { if (repo.id == repoid) {