From bbac03b4d1bbc38f1035f3dced2ce6529a297014 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 30 Sep 2016 11:00:15 +0200 Subject: [PATCH] use ApkTable column names when parsing XML This makes it easier to track the relationship between the index XML and the database tables where that data is ultimately stored and used. There are a few mismatches between the XML tag and database column names, so those are just marked with a comment. This makes it much easier to find all the spots in the code that need changing when adding new columns/data to the APK table, like the OBB stuff. In Android Studio, just Ctrl-Click on any table constant definition, and then it lists all the places its used. Any new data will need to be added in all of those locations. --- .../org/fdroid/fdroid/RepoXMLHandler.java | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/RepoXMLHandler.java b/app/src/main/java/org/fdroid/fdroid/RepoXMLHandler.java index bb7d53580..ec4cf5dcd 100644 --- a/app/src/main/java/org/fdroid/fdroid/RepoXMLHandler.java +++ b/app/src/main/java/org/fdroid/fdroid/RepoXMLHandler.java @@ -100,16 +100,16 @@ public class RepoXMLHandler extends DefaultHandler { final String str = curchars.toString().trim(); if (curapk != null) { switch (localName) { - case "version": + case ApkTable.Cols.VERSION_NAME: curapk.versionName = str; break; - case "versioncode": + case "versioncode": // ApkTable.Cols.VERSION_CODE curapk.versionCode = Utils.parseInt(str, -1); break; - case "size": + case ApkTable.Cols.SIZE: curapk.size = Utils.parseInt(str, 0); break; - case "hash": + case ApkTable.Cols.HASH: if (currentApkHashType == null || "md5".equals(currentApkHashType)) { if (curapk.hash == null) { curapk.hash = str; @@ -120,22 +120,22 @@ public class RepoXMLHandler extends DefaultHandler { curapk.hashType = "SHA-256"; } break; - case "sig": + case ApkTable.Cols.SIGNATURE: curapk.sig = str; break; - case "srcname": + case ApkTable.Cols.SOURCE_NAME: curapk.srcname = str; break; - case "apkname": + case "apkname": // ApkTable.Cols.NAME curapk.apkName = str; break; - case "sdkver": + case "sdkver": // ApkTable.Cols.MIN_SDK_VERSION curapk.minSdkVersion = Utils.parseInt(str, Apk.SDK_VERSION_MIN_VALUE); break; - case "targetSdkVersion": + case ApkTable.Cols.TARGET_SDK_VERSION: curapk.targetSdkVersion = Utils.parseInt(str, Apk.SDK_VERSION_MIN_VALUE); break; - case "maxsdkver": + case "maxsdkver": // ApkTable.Cols.MAX_SDK_VERSION curapk.maxSdkVersion = Utils.parseInt(str, Apk.SDK_VERSION_MAX_VALUE); if (curapk.maxSdkVersion == 0) { // before fc0df0dcf4dd0d5f13de82d7cd9254b2b48cb62d, this could be 0 @@ -154,16 +154,16 @@ public class RepoXMLHandler extends DefaultHandler { case ApkTable.Cols.OBB_PATCH_FILE_SHA256: curapk.obbPatchFileSha256 = str; break; - case "added": + case ApkTable.Cols.ADDED_DATE: curapk.added = Utils.parseDate(str, null); break; - case "permissions": + case ApkTable.Cols.PERMISSIONS: curapk.permissions = Utils.parseCommaSeparatedString(str); break; - case "features": + case ApkTable.Cols.FEATURES: curapk.features = Utils.parseCommaSeparatedString(str); break; - case "nativecode": + case ApkTable.Cols.NATIVE_CODE: curapk.nativecode = Utils.parseCommaSeparatedString(str); break; }