From 2226d5a23abf45e5e4dc32e5c0f85e9897c3fbca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 2 Jan 2014 13:46:29 +0100 Subject: [PATCH 01/16] Remove obsolete bits from .gitignore --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 023b57957..4b35a9282 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,9 @@ /local.properties -/build.properties .classpath /bin/ /gen/ /build /.gradle -/proguard.cfg /build.xml *~ .idea From 9c61ccebdb4c96532355200a215c879aa73f8642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 01:16:24 +0100 Subject: [PATCH 02/16] Place the update repos button in the Action Bar --- src/org/fdroid/fdroid/FDroid.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/org/fdroid/fdroid/FDroid.java b/src/org/fdroid/fdroid/FDroid.java index 11b46c555..c79749d5b 100644 --- a/src/org/fdroid/fdroid/FDroid.java +++ b/src/org/fdroid/fdroid/FDroid.java @@ -132,8 +132,9 @@ public class FDroid extends FragmentActivity { public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); - menu.add(Menu.NONE, UPDATE_REPO, 1, R.string.menu_update_repo).setIcon( + MenuItem update = menu.add(Menu.NONE, UPDATE_REPO, 1, R.string.menu_update_repo).setIcon( android.R.drawable.ic_menu_rotate); + MenuItemCompat.setShowAsAction(update, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); menu.add(Menu.NONE, MANAGE_REPO, 2, R.string.menu_manage).setIcon( android.R.drawable.ic_menu_agenda); MenuItem search = menu.add(Menu.NONE, SEARCH, 3, R.string.menu_search).setIcon( From ab6f41ec6884822c9720b926fda465ed2287656a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 02:17:32 +0100 Subject: [PATCH 03/16] More layout tweaks, fix landscape --- res/layout-land/appdetails.xml | 71 ++++++++++++++++++++-------------- res/layout/apklistitem.xml | 18 ++++++--- res/layout/appdetails.xml | 11 +++--- res/layout/applistitem.xml | 8 ++-- 4 files changed, 65 insertions(+), 43 deletions(-) diff --git a/res/layout-land/appdetails.xml b/res/layout-land/appdetails.xml index 592971970..53c06af43 100644 --- a/res/layout-land/appdetails.xml +++ b/res/layout-land/appdetails.xml @@ -18,6 +18,14 @@ android:layout_marginRight="4dp" android:orientation="vertical" > + + - - - + + + + + + + + + - + + + @@ -41,7 +41,7 @@ android:ellipsize="end" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="8dp" + android:layout_marginLeft="8sp" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" /> From 50f68d34b9b3a5c9db97bb4778c0f5877daa5a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 02:44:24 +0100 Subject: [PATCH 04/16] Support minSdk info in version list views --- res/layout/apklistitem.xml | 2 +- res/values/strings.xml | 1 + src/org/fdroid/fdroid/AppDetails.java | 37 +++++++++++---------------- src/org/fdroid/fdroid/Utils.java | 25 ++++++++++++++++++ 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/res/layout/apklistitem.xml b/res/layout/apklistitem.xml index d92e92bb7..d9dfdb756 100644 --- a/res/layout/apklistitem.xml +++ b/res/layout/apklistitem.xml @@ -47,7 +47,7 @@ android:textSize="13sp" android:layout_below="@id/buildtype" android:layout_toLeftOf="@id/size" - android:layout_alignParentRight="true" + android:layout_marginRight="12sp" android:layout_height="wrap_content" android:layout_width="wrap_content" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index bc666cb08..60ee632ec 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -163,5 +163,6 @@ Show icons at a smaller size Show icons at regular size Theme + %s or later diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java index f5a056e7e..0082c0783 100644 --- a/src/org/fdroid/fdroid/AppDetails.java +++ b/src/org/fdroid/fdroid/AppDetails.java @@ -140,10 +140,11 @@ public class AppDetails extends ListActivity { tv = (TextView) v.findViewById(R.id.status); if (apk.vercode == app.installedVerCode - && apk.sig.equals(mInstalledSigID)) + && apk.sig.equals(mInstalledSigID)) { tv.setText(getString(R.string.inst)); - else + } else { tv.setText(getString(R.string.not_inst)); + } tv.setEnabled(apk.compatible); tv = (TextView) v.findViewById(R.id.size); @@ -153,6 +154,16 @@ public class AppDetails extends ListActivity { tv.setText(Utils.getFriendlySize(apk.detail_size)); tv.setEnabled(apk.compatible); } + + tv = (TextView) v.findViewById(R.id.api); + if (apk.minSdkVersion == 0) { + tv.setText(""); + } else { + tv.setText(getString(R.string.minsdk_or_later, + Utils.getAndroidVersionName(apk.minSdkVersion))); + tv.setEnabled(apk.compatible); + } + tv = (TextView) v.findViewById(R.id.buildtype); if (apk.srcname != null) { tv.setText("source"); @@ -160,6 +171,7 @@ public class AppDetails extends ListActivity { tv.setText("bin"); } tv.setEnabled(apk.compatible); + tv = (TextView) v.findViewById(R.id.added); if (apk.added != null) { tv.setVisibility(View.VISIBLE); @@ -168,6 +180,7 @@ public class AppDetails extends ListActivity { } else { tv.setVisibility(View.GONE); } + tv = (TextView) v.findViewById(R.id.nativecode); if (pref_expert && apk.nativecode != null) { tv.setVisibility(View.VISIBLE); @@ -457,26 +470,6 @@ public class AppDetails extends ListActivity { tv = (TextView) infoView.findViewById(R.id.description); - /* - The following is a quick solution to enable both text selection and - links. Causes glitches and crashes: - java.lang.IndexOutOfBoundsException: setSpan (-1 ... -1) starts before 0 - - class CustomMovementMethod extends LinkMovementMethod { - @Override - public boolean canSelectArbitrarily () { - return true; - } - } - - if (Utils.hasApi(11)) { - tv.setTextIsSelectable(true); - tv.setMovementMethod(new CustomMovementMethod()); - } else { - tv.setMovementMethod(LinkMovementMethod.getInstance()); - } - */ - tv.setMovementMethod(LinkMovementMethod.getInstance()); // Need this to add the unimplemented support for ordered and unordered diff --git a/src/org/fdroid/fdroid/Utils.java b/src/org/fdroid/fdroid/Utils.java index 4726e2f32..ba271ceaf 100644 --- a/src/org/fdroid/fdroid/Utils.java +++ b/src/org/fdroid/fdroid/Utils.java @@ -81,6 +81,31 @@ public final class Utils { return String.format(FRIENDLY_SIZE_FORMAT[i], s); } + public static String getAndroidVersionName(int sdkLevel) { + switch (sdkLevel) { + case 19: return "4.4"; + case 18: return "4.3"; + case 17: return "4.2"; + case 16: return "4.1"; + case 15: return "4.0.3"; + case 14: return "4.0"; + case 13: return "3.2"; + case 12: return "3.1"; + case 11: return "3.0"; + case 10: return "2.3.3"; + case 9: return "2.3"; + case 8: return "2.2"; + case 7: return "2.1"; + case 6: return "2.0.1"; + case 5: return "2.0"; + case 4: return "1.6"; + case 3: return "1.5"; + case 2: return "1.1"; + case 1: return "1.0"; + } + return "Unknown"; + } + public static int countSubstringOccurrence(File file, String substring) throws IOException { int count = 0; BufferedReader reader = null; From aee57c448bfd70feb40da04a4edde680c046cc0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 02:52:12 +0100 Subject: [PATCH 05/16] Sightly more margins in app list views --- res/layout/applistitem.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/layout/applistitem.xml b/res/layout/applistitem.xml index 58d95cd6c..5711f5fdd 100644 --- a/res/layout/applistitem.xml +++ b/res/layout/applistitem.xml @@ -31,7 +31,7 @@ android:paddingBottom="3sp" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="8sp" + android:layout_marginLeft="10sp" android:layout_alignParentTop="true" android:layout_alignParentRight="true" /> @@ -41,7 +41,7 @@ android:ellipsize="end" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginLeft="8sp" + android:layout_marginLeft="10sp" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" /> From 5cde91ef238c4beb405220185bb5cc1406f1c559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 02:56:25 +0100 Subject: [PATCH 06/16] Show text in the update AB icon --- src/org/fdroid/fdroid/FDroid.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/org/fdroid/fdroid/FDroid.java b/src/org/fdroid/fdroid/FDroid.java index c79749d5b..e9c2ae038 100644 --- a/src/org/fdroid/fdroid/FDroid.java +++ b/src/org/fdroid/fdroid/FDroid.java @@ -134,7 +134,9 @@ public class FDroid extends FragmentActivity { super.onCreateOptionsMenu(menu); MenuItem update = menu.add(Menu.NONE, UPDATE_REPO, 1, R.string.menu_update_repo).setIcon( android.R.drawable.ic_menu_rotate); - MenuItemCompat.setShowAsAction(update, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); + MenuItemCompat.setShowAsAction(update, + MenuItemCompat.SHOW_AS_ACTION_ALWAYS | + MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); menu.add(Menu.NONE, MANAGE_REPO, 2, R.string.menu_manage).setIcon( android.R.drawable.ic_menu_agenda); MenuItem search = menu.add(Menu.NONE, SEARCH, 3, R.string.menu_search).setIcon( From 8a906878675f7b9c4e3533dc3b43f31e2f349e6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 04:30:01 +0100 Subject: [PATCH 07/16] Slightly larger margin separating minsdk --- res/layout/apklistitem.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/layout/apklistitem.xml b/res/layout/apklistitem.xml index d9dfdb756..33f287673 100644 --- a/res/layout/apklistitem.xml +++ b/res/layout/apklistitem.xml @@ -47,7 +47,7 @@ android:textSize="13sp" android:layout_below="@id/buildtype" android:layout_toLeftOf="@id/size" - android:layout_marginRight="12sp" + android:layout_marginRight="16sp" android:layout_height="wrap_content" android:layout_width="wrap_content" /> From 4d942958646ad8501c48c9d3784e24246e8d684f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 06:55:28 +0100 Subject: [PATCH 08/16] Switch to "apks" apk cache dir, use internal cache when external is not available --- src/org/fdroid/fdroid/AppDetails.java | 9 ++++++--- src/org/fdroid/fdroid/DB.java | 8 -------- src/org/fdroid/fdroid/FDroidApp.java | 17 ++++++++++------- src/org/fdroid/fdroid/Utils.java | 13 +++++++++++++ src/org/fdroid/fdroid/compat/ContextCompat.java | 2 +- 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java index 0082c0783..b09f724c1 100644 --- a/src/org/fdroid/fdroid/AppDetails.java +++ b/src/org/fdroid/fdroid/AppDetails.java @@ -76,6 +76,9 @@ import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.assist.ImageScaleType; +import com.nostra13.universalimageloader.utils.StorageUtils; + +import android.os.Environment; public class AppDetails extends ListActivity { @@ -841,8 +844,8 @@ public class AppDetails extends ListActivity { public void onClick(DialogInterface dialog, int whichButton) { downloadHandler = new DownloadHandler(app.curApk, - repoaddress, DB - .getDataPath(getBaseContext())); + repoaddress, Utils + .getApkCacheDir(getBaseContext())); } }); ask_alrt.setNegativeButton(getString(R.string.no), @@ -872,7 +875,7 @@ public class AppDetails extends ListActivity { return; } downloadHandler = new DownloadHandler(app.curApk, repoaddress, - DB.getDataPath(this)); + Utils.getApkCacheDir(getBaseContext())); } private void removeApk(String id) { diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index 2c5e8cbaf..712a964be 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -619,14 +619,6 @@ public class DB { } - /** - * Get the local storage (cache) path. This will also create it if - * it doesn't exist. It can return null if it's currently unavailable. - */ - public static File getDataPath(Context ctx) { - return ContextCompat.create(ctx).getExternalCacheDir(); - } - private Context mContext; private Apk.CompatibilityChecker compatChecker = null; diff --git a/src/org/fdroid/fdroid/FDroidApp.java b/src/org/fdroid/fdroid/FDroidApp.java index f2949ae88..7523c5245 100644 --- a/src/org/fdroid/fdroid/FDroidApp.java +++ b/src/org/fdroid/fdroid/FDroidApp.java @@ -31,11 +31,13 @@ import android.util.Log; import android.content.Context; import android.content.SharedPreferences; -import com.nostra13.universalimageloader.utils.StorageUtils; +import org.fdroid.fdroid.Utils; + import com.nostra13.universalimageloader.cache.disc.impl.LimitedAgeDiscCache; import com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator; import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; +import com.nostra13.universalimageloader.utils.StorageUtils; public class FDroidApp extends Application { @@ -78,14 +80,14 @@ public class FDroidApp extends Application { curTheme = Theme.valueOf(prefs.getString("theme", "dark")); if (!prefs.getBoolean("cacheDownloaded", false)) { - File local_path = DB.getDataPath(this); + File local_path = Utils.getApkCacheDir(this); // Things can be null if the SD card is not ready - we'll just // ignore that and do it next time. - if(local_path != null) { + if (local_path != null) { File[] files = local_path.listFiles(); - if(files != null) { - for(File f : files) { - if(f.getName().endsWith(".apk")) { + if (files != null) { + for (File f : files) { + if (f.getName().endsWith(".apk")) { f.delete(); } } @@ -101,7 +103,8 @@ public class FDroidApp extends Application { ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(ctx) .discCache(new LimitedAgeDiscCache( - new File(StorageUtils.getCacheDirectory(ctx), "icons"), + new File(StorageUtils.getCacheDirectory(ctx, true), + "icons"), new FileNameGenerator() { @Override public String generate(String imageUri) { diff --git a/src/org/fdroid/fdroid/Utils.java b/src/org/fdroid/fdroid/Utils.java index ba271ceaf..be13a98cd 100644 --- a/src/org/fdroid/fdroid/Utils.java +++ b/src/org/fdroid/fdroid/Utils.java @@ -26,6 +26,10 @@ import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; +import android.content.Context; + +import com.nostra13.universalimageloader.utils.StorageUtils; + public final class Utils { public static final int BUFFER_SIZE = 4096; @@ -143,4 +147,13 @@ public final class Utils { return count; } + public static File getApkCacheDir(Context context) { + File apkCacheDir = new File( + StorageUtils.getCacheDirectory(context, true), "apks"); + if (!apkCacheDir.exists()) { + apkCacheDir.mkdir(); + } + return apkCacheDir; + } + } diff --git a/src/org/fdroid/fdroid/compat/ContextCompat.java b/src/org/fdroid/fdroid/compat/ContextCompat.java index dde5c5ca3..0daeabf5d 100644 --- a/src/org/fdroid/fdroid/compat/ContextCompat.java +++ b/src/org/fdroid/fdroid/compat/ContextCompat.java @@ -39,7 +39,7 @@ class OldContextCompatImpl extends ContextCompat { public File getExternalCacheDir() { File file = new File(Environment.getExternalStorageDirectory(), "Android/data/org.fdroid.fdroid/cache"); - if(!file.exists()) + if (!file.exists()) file.mkdirs(); return file; } From 105390fa882dd803428d7def2063b179041f03a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 07:40:42 +0100 Subject: [PATCH 09/16] Revert "Add very basic support for " This reverts commit bc74d97195417814193ce9ccfa838f0730310821. Conflicts: src/org/fdroid/fdroid/DB.java --- src/org/fdroid/fdroid/DB.java | 19 ++++--------------- src/org/fdroid/fdroid/RepoXMLHandler.java | 2 -- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index 712a964be..058c1aea1 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -105,7 +105,7 @@ public class DB { + "lastUpdated string," + "compatible int not null," + "ignoreAllUpdates int not null," + "ignoreThisUpdate int not null," - + "provides string," + "primary key(id));"; + + "primary key(id));"; public static class App implements Comparable { @@ -123,7 +123,6 @@ public class DB { detail_dogecoinAddr = null; detail_webURL = null; categories = null; - provides = null; antiFeatures = null; requirements = null; hasUpdates = false; @@ -198,9 +197,6 @@ public class DB { public int installedVerCode; public boolean userInstalled; - // List of app IDs that this app provides or null if there aren't any. - public CommaSeparatedList provides; - // List of categories (as defined in the metadata // documentation) or null if there aren't any. public CommaSeparatedList categories; @@ -442,7 +438,7 @@ public class DB { public String lastetag; // last etag we updated from, null forces update } - private final int DBVersion = 32; + private final int DBVersion = 33; private static void createAppApk(SQLiteDatabase db) { db.execSQL(CREATE_TABLE_APP); @@ -814,8 +810,7 @@ public class DB { String cols[] = new String[] { "antiFeatures", "requirements", "categories", "id", "name", "summary", "icon", "license", "curVersion", "curVercode", "added", "lastUpdated", - "compatible", "ignoreAllUpdates", "ignoreThisUpdate", - "provides" }; + "compatible", "ignoreAllUpdates", "ignoreThisUpdate" }; c = db.query(TABLE_APP, cols, null, null, null, null, null); c.moveToFirst(); while (!c.isAfterLast()) { @@ -841,7 +836,6 @@ public class DB { app.compatible = c.getInt(12) == 1; app.ignoreAllUpdates = c.getInt(13) == 1; app.ignoreThisUpdate = c.getInt(14); - app.provides = DB.CommaSeparatedList.make(c.getString(15)); app.hasUpdates = false; if (getinstalledinfo && systemApks.containsKey(app.id)) { @@ -861,11 +855,6 @@ public class DB { } apps.put(app.id, app); - if (app.provides != null) { - for (String id : app.provides) { - apps.put(id, app); - } - } c.moveToNext(); } @@ -1023,7 +1012,7 @@ public class DB { try { String filter = "%" + query + "%"; c = db.query(TABLE_APP, new String[] { "id" }, - "id like ? or provides like ? or name like ? or summary like ? or description like ?", + "id like ? or name like ? or summary like ? or description like ?", new String[] { filter, filter, filter, filter }, null, null, null); c.moveToFirst(); while (!c.isAfterLast()) { diff --git a/src/org/fdroid/fdroid/RepoXMLHandler.java b/src/org/fdroid/fdroid/RepoXMLHandler.java index 30a07d87e..5b0c91b38 100644 --- a/src/org/fdroid/fdroid/RepoXMLHandler.java +++ b/src/org/fdroid/fdroid/RepoXMLHandler.java @@ -242,8 +242,6 @@ public class RepoXMLHandler extends DefaultHandler { } catch (NumberFormatException ex) { curapp.curVercode = -1; } - } else if (curel.equals("provides")) { - curapp.provides = DB.CommaSeparatedList.make(str); } else if (curel.equals("categories")) { curapp.categories = DB.CommaSeparatedList.make(str); } else if (curel.equals("antifeatures")) { From aff6a03fa2c2ea84cee6597a44dcfb32fa7006f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 17:55:23 +0100 Subject: [PATCH 10/16] Specify that the version is for Android --- res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 60ee632ec..a466bd9a4 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -163,6 +163,6 @@ Show icons at a smaller size Show icons at regular size Theme - %s or later + Android %s or later From 066f67bcd419b622355f7d5e2d9421c731f1451e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 17:55:33 +0100 Subject: [PATCH 11/16] Default to minSdk version "1.0" --- src/org/fdroid/fdroid/Utils.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/org/fdroid/fdroid/Utils.java b/src/org/fdroid/fdroid/Utils.java index be13a98cd..5a2b1b8f3 100644 --- a/src/org/fdroid/fdroid/Utils.java +++ b/src/org/fdroid/fdroid/Utils.java @@ -105,9 +105,8 @@ public final class Utils { case 4: return "1.6"; case 3: return "1.5"; case 2: return "1.1"; - case 1: return "1.0"; + default: return "1.0"; } - return "Unknown"; } public static int countSubstringOccurrence(File file, String substring) throws IOException { From eeeace080f92b4bd79b335bd3813ce118b944ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 20:29:02 +0100 Subject: [PATCH 12/16] Start cpuAbis at length 2, place secondary abi at second position --- src/org/fdroid/fdroid/DB.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index 058c1aea1..40cbb8626 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -370,10 +370,11 @@ public class DB { } } - cpuAbis = new ArrayList(); - if (hasApi(8)) - cpuAbis.add(android.os.Build.CPU_ABI2); + cpuAbis = new ArrayList(2); cpuAbis.add(android.os.Build.CPU_ABI); + if (hasApi(8)) { + cpuAbis.add(android.os.Build.CPU_ABI2); + } Log.d("FDroid", logMsg.toString()); } @@ -406,8 +407,7 @@ public class DB { } if (!compatibleApi(apk.nativecode)) { Log.d("FDroid", apk.id + " vercode " + apk.vercode - + " makes use of incompatible native code: " - + CommaSeparatedList.str(apk.nativecode) + + " only supports " + CommaSeparatedList.str(apk.nativecode) + " while your architecture is " + cpuAbis.get(0)); return false; } From e9abbfa743b00f66131e6df4fafce6bc18fa51d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 20:47:08 +0100 Subject: [PATCH 13/16] Add 'repo.version' integer --- src/org/fdroid/fdroid/DB.java | 49 ++++++++++++++--------- src/org/fdroid/fdroid/ManageRepo.java | 2 +- src/org/fdroid/fdroid/RepoXMLHandler.java | 37 +++++++++++++---- 3 files changed, 61 insertions(+), 27 deletions(-) diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index 40cbb8626..127b784ec 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -430,6 +430,7 @@ public class DB { public String address; public String name; public String description; + public int version; // index version, i.e. what fdroidserver built it - 0 if not specified public boolean inuse; public int priority; public String pubkey; // null for an unsigned repo @@ -438,7 +439,7 @@ public class DB { public String lastetag; // last etag we updated from, null forces update } - private final int DBVersion = 33; + private final int DBVersion = 34; private static void createAppApk(SQLiteDatabase db) { db.execSQL(CREATE_TABLE_APP); @@ -504,6 +505,7 @@ public class DB { mContext.getString(R.string.default_repo_name)); values.put("description", mContext.getString(R.string.default_repo_description)); + values.put("version", 0); String pubkey = mContext.getString(R.string.default_repo_pubkey); String fingerprint = DB.calcFingerprint(pubkey); values.put("pubkey", pubkey); @@ -521,9 +523,11 @@ public class DB { mContext.getString(R.string.default_repo_name2)); values.put("description", mContext.getString(R.string.default_repo_description2)); + values.put("version", 0); // default #2 is /archive which has the same key as /repo values.put("pubkey", pubkey); values.put("fingerprint", fingerprint); + values.put("maxage", 0); values.put("inuse", 0); values.put("priority", 20); values.put("lastetag", (String) null); @@ -611,6 +615,10 @@ public class DB { if (oldVersion < 30) { db.execSQL("alter table " + TABLE_REPO + " add column maxage integer not null default 0"); } + + if (oldVersion < 34) { + db.execSQL("alter table " + TABLE_REPO + " add column version integer not null default 0"); + } } } @@ -1283,8 +1291,8 @@ public class DB { Cursor c = null; try { c = db.query(TABLE_REPO, new String[] { "address", "name", - "description", "inuse", "priority", "pubkey", "fingerprint", - "maxage", "lastetag" }, + "description", "version", "inuse", "priority", "pubkey", + "fingerprint", "maxage", "lastetag" }, "id = ?", new String[] { Integer.toString(id) }, null, null, null); if (!c.moveToFirst()) return null; @@ -1293,12 +1301,13 @@ public class DB { repo.address = c.getString(0); repo.name = c.getString(1); repo.description = c.getString(2); - repo.inuse = (c.getInt(3) == 1); - repo.priority = c.getInt(4); - repo.pubkey = c.getString(5); - repo.fingerprint = c.getString(6); - repo.maxage = c.getInt(7); - repo.lastetag = c.getString(8); + repo.version = c.getInt(3); + repo.inuse = (c.getInt(4) == 1); + repo.priority = c.getInt(5); + repo.pubkey = c.getString(6); + repo.fingerprint = c.getString(7); + repo.maxage = c.getInt(8); + repo.lastetag = c.getString(9); return repo; } finally { if (c != null) @@ -1312,8 +1321,8 @@ public class DB { Cursor c = null; try { c = db.query(TABLE_REPO, new String[] { "id", "address", "name", - "description", "inuse", "priority", "pubkey", "fingerprint", - "maxage", "lastetag" }, + "description", "version", "inuse", "priority", "pubkey", + "fingerprint", "maxage", "lastetag" }, null, null, null, null, "priority"); c.moveToFirst(); while (!c.isAfterLast()) { @@ -1322,12 +1331,13 @@ public class DB { repo.address = c.getString(1); repo.name = c.getString(2); repo.description = c.getString(3); - repo.inuse = (c.getInt(4) == 1); - repo.priority = c.getInt(5); - repo.pubkey = c.getString(6); - repo.fingerprint = c.getString(7); - repo.maxage = c.getInt(8); - repo.lastetag = c.getString(9); + repo.version = c.getInt(4); + repo.inuse = (c.getInt(5) == 1); + repo.priority = c.getInt(6); + repo.pubkey = c.getString(7); + repo.fingerprint = c.getString(8); + repo.maxage = c.getInt(9); + repo.lastetag = c.getString(10); repos.add(repo); c.moveToNext(); } @@ -1357,6 +1367,7 @@ public class DB { ContentValues values = new ContentValues(); values.put("name", repo.name); values.put("description", repo.description); + values.put("version", repo.version); values.put("inuse", repo.inuse); values.put("priority", repo.priority); values.put("pubkey", repo.pubkey); @@ -1380,12 +1391,14 @@ public class DB { } public void addRepo(String address, String name, String description, - int priority, String pubkey, String fingerprint, int maxage, boolean inuse) + int version, int priority, String pubkey, String fingerprint, + int maxage, boolean inuse) throws SecurityException { ContentValues values = new ContentValues(); values.put("address", address); values.put("name", name); values.put("description", description); + values.put("version", version); values.put("inuse", inuse ? 1 : 0); values.put("priority", priority); values.put("pubkey", pubkey); diff --git a/src/org/fdroid/fdroid/ManageRepo.java b/src/org/fdroid/fdroid/ManageRepo.java index 6e4db92bd..bf6414ed8 100644 --- a/src/org/fdroid/fdroid/ManageRepo.java +++ b/src/org/fdroid/fdroid/ManageRepo.java @@ -218,7 +218,7 @@ public class ManageRepo extends ListActivity { protected void addRepo(String repoUri, String fingerprint) { try { DB db = DB.getDB(); - db.addRepo(repoUri, null, null, 10, null, fingerprint, 0, true); + db.addRepo(repoUri, null, null, 0, 10, null, fingerprint, 0, true); } finally { DB.releaseDB(); } diff --git a/src/org/fdroid/fdroid/RepoXMLHandler.java b/src/org/fdroid/fdroid/RepoXMLHandler.java index 5b0c91b38..f12d004ea 100644 --- a/src/org/fdroid/fdroid/RepoXMLHandler.java +++ b/src/org/fdroid/fdroid/RepoXMLHandler.java @@ -64,8 +64,9 @@ public class RepoXMLHandler extends DefaultHandler { private DB.Apk curapk = null; private StringBuilder curchars = new StringBuilder(); - // After processing the XML, this will be null if the index didn't specify - // a maximum age - otherwise it will be the value specified. + // After processing the XML, these will be null if the index didn't specify + // them - otherwise it will be the value specified. + private String version; private String maxage; // After processing the XML, this will be null if the index specified a @@ -262,10 +263,12 @@ public class RepoXMLHandler extends DefaultHandler { public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { super.startElement(uri, localName, qName, attributes); + if (localName.equals("repo")) { String pk = attributes.getValue("", "pubkey"); if (pk != null) pubkey = pk; + version = attributes.getValue("", "version"); maxage = attributes.getValue("", "maxage"); String nm = attributes.getValue("", "name"); if (nm != null) @@ -273,6 +276,7 @@ public class RepoXMLHandler extends DefaultHandler { String dc = attributes.getValue("", "description"); if (dc != null) description = dc; + } else if (localName.equals("application") && curapp == null) { curapp = new DB.App(); curapp.detail_Populated = true; @@ -283,11 +287,13 @@ public class RepoXMLHandler extends DefaultHandler { new ProgressListener.Event( RepoXMLHandler.PROGRESS_TYPE_PROCESS_XML, progressCounter, totalAppCount, progressData)); + } else if (localName.equals("package") && curapp != null && curapk == null) { curapk = new DB.Apk(); curapk.id = curapp.id; curapk.repo = repo.id; hashType = null; + } else if (localName.equals("hash") && curapk != null) { hashType = attributes.getValue("", "type"); } @@ -469,6 +475,17 @@ public class RepoXMLHandler extends DefaultHandler { DB.releaseDB(); } } + boolean updateRepo = false; + + if (handler.version != null) { + int version = Integer.parseInt(handler.version); + if (version != repo.version) { + Log.d("FDroid", "Repo specified a new version: from " + + repo.version + " to " + version); + repo.version = version; + updateRepo = true; + } + } if (handler.maxage != null) { int maxage = Integer.parseInt(handler.maxage); @@ -476,12 +493,16 @@ public class RepoXMLHandler extends DefaultHandler { Log.d("FDroid", "Repo specified a new maximum age - updated"); repo.maxage = maxage; - try { - DB db = DB.getDB(); - db.updateRepoByAddress(repo); - } finally { - DB.releaseDB(); - } + updateRepo = true; + } + } + + if (updateRepo) { + try { + DB db = DB.getDB(); + db.updateRepoByAddress(repo); + } finally { + DB.releaseDB(); } } From bd2e379073b6db86495ca48a2478df578a4d43e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 22:05:34 +0100 Subject: [PATCH 14/16] Keep the same inflater in the AppListAdapter --- src/org/fdroid/fdroid/views/AppListAdapter.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/org/fdroid/fdroid/views/AppListAdapter.java b/src/org/fdroid/fdroid/views/AppListAdapter.java index 78d60e8f7..c4326e822 100644 --- a/src/org/fdroid/fdroid/views/AppListAdapter.java +++ b/src/org/fdroid/fdroid/views/AppListAdapter.java @@ -27,10 +27,13 @@ abstract public class AppListAdapter extends BaseAdapter { private List items = new ArrayList(); private Context mContext; + private LayoutInflater mInflater; private DisplayImageOptions displayImageOptions; public AppListAdapter(Context context) { mContext = context; + mInflater = (LayoutInflater) mContext.getSystemService( + Context.LAYOUT_INFLATER_SERVICE); displayImageOptions = new DisplayImageOptions.Builder() .cacheInMemory(true) @@ -83,8 +86,7 @@ abstract public class AppListAdapter extends BaseAdapter { DB.App app = items.get(position); if (convertView == null) { - convertView = ((LayoutInflater) mContext.getSystemService( - Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.applistitem, null); + convertView = mInflater.inflate(R.layout.applistitem, null); } TextView name = (TextView) convertView.findViewById(R.id.name); From 463561d97191325190d5841c510a73b1f156908c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 22:17:29 +0100 Subject: [PATCH 15/16] Use a ViewHolder static class to avoid most findViewById calls --- .../fdroid/fdroid/views/AppListAdapter.java | 50 +++++++++++++------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/src/org/fdroid/fdroid/views/AppListAdapter.java b/src/org/fdroid/fdroid/views/AppListAdapter.java index c4326e822..9783ab843 100644 --- a/src/org/fdroid/fdroid/views/AppListAdapter.java +++ b/src/org/fdroid/fdroid/views/AppListAdapter.java @@ -79,37 +79,55 @@ abstract public class AppListAdapter extends BaseAdapter { return position; } + static class ViewHolder { + TextView name; + TextView summary; + TextView status; + TextView license; + ImageView icon; + } + @Override public View getView(int position, View convertView, ViewGroup parent) { boolean compact = Preferences.get().hasCompactLayout(); DB.App app = items.get(position); + ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.applistitem, null); + + holder = new ViewHolder(); + holder.name = (TextView) convertView.findViewById(R.id.name); + holder.summary = (TextView) convertView.findViewById(R.id.summary); + holder.status = (TextView) convertView.findViewById(R.id.status); + holder.license = (TextView) convertView.findViewById(R.id.license); + holder.icon = (ImageView) convertView.findViewById(R.id.icon); + + convertView.setTag(holder); + } else { + holder = (ViewHolder) convertView.getTag(); } - TextView name = (TextView) convertView.findViewById(R.id.name); - TextView summary = (TextView) convertView.findViewById(R.id.summary); - TextView status = (TextView) convertView.findViewById(R.id.status); - TextView license = (TextView) convertView.findViewById(R.id.license); - ImageView icon = (ImageView) convertView.findViewById(R.id.icon); + holder.name.setText(app.name); + holder.summary.setText(app.summary); - name.setText(app.name); - summary.setText(app.summary); - - int visibleOnCompact = compact ? View.VISIBLE : View.GONE; - int notVisibleOnCompact = compact ? View.GONE : View.VISIBLE; - - layoutIcon(icon, compact); - ImageLoader.getInstance().displayImage(app.iconUrl, icon, + layoutIcon(holder.icon, compact); + ImageLoader.getInstance().displayImage(app.iconUrl, holder.icon, displayImageOptions); - status.setText(getVersionInfo(app)); - license.setText(app.license); + holder.status.setText(getVersionInfo(app)); + holder.license.setText(app.license); // Disable it all if it isn't compatible... - View[] views = { convertView, status, summary, license, name }; + View[] views = { + convertView, + holder.status, + holder.summary, + holder.license, + holder.name + }; + for (View view : views) { view.setEnabled(app.compatible && !app.filtered); } From 21747dcf408bef108187588c5ba8b8d72c4b34dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 3 Jan 2014 22:45:21 +0100 Subject: [PATCH 16/16] getApps(): Start Map size with the number of apps we have --- src/org/fdroid/fdroid/DB.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index 127b784ec..158d5ea4f 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -810,8 +810,16 @@ public class DB { } } - Map apps = new HashMap(); - Cursor c = null; + // Start the map at the actual number of apps we will have + Cursor c = db.rawQuery("select count(*) from "+TABLE_APP, null); + c.moveToFirst(); + int count = c.getInt(0); + c.close(); + c = null; + + Log.d("FDroid", "Will be fetching " + count + " apps, and this took us "); + + Map apps = new HashMap(count); long startTime = System.currentTimeMillis(); try { @@ -869,7 +877,7 @@ public class DB { c.close(); c = null; - Log.d("FDroid", "Read app data from database " + " (took " + Log.d("FDroid", "Read app data from database (took " + (System.currentTimeMillis() - startTime) + " ms)"); List repos = getRepos(); @@ -928,7 +936,7 @@ public class DB { c.close(); } - Log.d("FDroid", "Read app and apk data from database " + " (took " + Log.d("FDroid", "Read app and apk data from database (took " + (System.currentTimeMillis() - startTime) + " ms)"); }