diff --git a/app/src/main/java/org/fdroid/fdroid/data/App.java b/app/src/main/java/org/fdroid/fdroid/data/App.java index b2ea39190..c3ae71fa7 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/App.java +++ b/app/src/main/java/org/fdroid/fdroid/data/App.java @@ -98,6 +98,8 @@ public class App extends ValueObject implements Comparable, Parcelable { public String preferredSigner; @JsonIgnore public boolean isApk; + @JsonIgnore + private boolean isLocalized = false; /** * This is primarily for the purpose of saving app metadata when parsing an index.xml file. @@ -349,6 +351,9 @@ public class App extends ValueObject implements Comparable, Parcelable { case Cols.IS_APK: isApk = cursor.getInt(i) == 1; break; + case Cols.IS_LOCALIZED: + isLocalized = cursor.getInt(i) == 1; + break; case Cols.InstalledApp.VERSION_CODE: installedVersionCode = cursor.getInt(i); break; @@ -468,6 +473,10 @@ public class App extends ValueObject implements Comparable, Parcelable { */ @JsonProperty("localized") private void setLocalized(Map> localized) { // NOPMD + if (localized.size() > 1) { + isLocalized = true; + } + Locale defaultLocale = Locale.getDefault(); String languageTag = defaultLocale.getLanguage(); String countryTag = defaultLocale.getCountry(); @@ -953,6 +962,7 @@ public class App extends ValueObject implements Comparable, Parcelable { values.put(Cols.WEAR_SCREENSHOTS, Utils.serializeCommaSeparatedString(wearScreenshots)); values.put(Cols.IS_COMPATIBLE, compatible ? 1 : 0); values.put(Cols.IS_APK, isApk ? 1 : 0); + values.put(Cols.IS_LOCALIZED, isLocalized ? 1 : 0); return values; } @@ -1178,6 +1188,7 @@ public class App extends ValueObject implements Comparable, Parcelable { dest.writeStringArray(this.tvScreenshots); dest.writeStringArray(this.wearScreenshots); dest.writeByte(this.isApk ? (byte) 1 : (byte) 0); + dest.writeByte(this.isLocalized ? (byte) 1 : (byte) 0); dest.writeString(this.installedVersionName); dest.writeInt(this.installedVersionCode); dest.writeParcelable(this.installedApk, flags); @@ -1229,6 +1240,7 @@ public class App extends ValueObject implements Comparable, Parcelable { this.tvScreenshots = in.createStringArray(); this.wearScreenshots = in.createStringArray(); this.isApk = in.readByte() != 0; + this.isLocalized = in.readByte() != 0; this.installedVersionName = in.readString(); this.installedVersionCode = in.readInt(); this.installedApk = in.readParcelable(Apk.class.getClassLoader()); diff --git a/app/src/main/java/org/fdroid/fdroid/data/DBHelper.java b/app/src/main/java/org/fdroid/fdroid/data/DBHelper.java index 4444c88f3..43f85276d 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/DBHelper.java +++ b/app/src/main/java/org/fdroid/fdroid/data/DBHelper.java @@ -169,6 +169,7 @@ public class DBHelper extends SQLiteOpenHelper { + AppMetadataTable.Cols.TV_SCREENSHOTS + " string," + AppMetadataTable.Cols.WEAR_SCREENSHOTS + " string," + AppMetadataTable.Cols.IS_APK + " boolean," + + AppMetadataTable.Cols.IS_LOCALIZED + " boolean," + "primary key(" + AppMetadataTable.Cols.PACKAGE_ID + ", " + AppMetadataTable.Cols.REPO_ID + "));"; private static final String CREATE_TABLE_APP_PREFS = "CREATE TABLE " + AppPrefsTable.NAME @@ -224,7 +225,7 @@ public class DBHelper extends SQLiteOpenHelper { + "primary key(" + ApkAntiFeatureJoinTable.Cols.APK_ID + ", " + ApkAntiFeatureJoinTable.Cols.ANTI_FEATURE_ID + ") " + " );"; - protected static final int DB_VERSION = 80; + protected static final int DB_VERSION = 81; private final Context context; @@ -450,6 +451,19 @@ public class DBHelper extends SQLiteOpenHelper { addUserMirrorsFields(db, oldVersion); removeNotNullFromVersionName(db, oldVersion); addDisabledMirrorsFields(db, oldVersion); + addIsLocalized(db, oldVersion); + } + + private void addIsLocalized(SQLiteDatabase db, int oldVersion) { + if (oldVersion >= 81) { + return; + } + if (!columnExists(db, AppMetadataTable.NAME, AppMetadataTable.Cols.IS_LOCALIZED)) { + Utils.debugLog(TAG, "Adding " + AppMetadataTable.Cols.IS_LOCALIZED + " field to " + + AppMetadataTable.NAME + " table in db."); + db.execSQL("alter table " + AppMetadataTable.NAME + " add column " + + AppMetadataTable.Cols.IS_LOCALIZED + " boolean;"); + } } private void addDisabledMirrorsFields(SQLiteDatabase db, int oldVersion) { diff --git a/app/src/main/java/org/fdroid/fdroid/data/Schema.java b/app/src/main/java/org/fdroid/fdroid/data/Schema.java index bdb8c01d8..d6bba529e 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/Schema.java +++ b/app/src/main/java/org/fdroid/fdroid/data/Schema.java @@ -12,11 +12,13 @@ public interface Schema { /** * A package is essentially the app that a developer builds and wants you to install on your * device. It differs from entries in: - * * {@link ApkTable} because they are specific builds of a particular package. Many different - * builds of the same package can exist. - * * {@link AppMetadataTable} because this is metdata about a package which is specified by a - * given repo. Different repos can provide the same package with different descriptions, - * categories, etc. + *
    + *
  • {@link ApkTable} because they are specific builds of a particular package. Many different + * builds of the same package can exist.
  • + *
  • {@link AppMetadataTable} because this is metdata about a package which is specified by a + * given repo. Different repos can provide the same package with different descriptions, + * categories, etc.
  • + *
*/ interface PackageTable { @@ -78,6 +80,7 @@ public interface Schema { * An entry in this table signifies that an app is in a particular category. Each repo can * classify its apps in separate categories, and so the same record in {@link PackageTable} * can be in the same category multiple times, if multiple repos think that is the case. + * * @see CategoryTable * @see AppMetadataTable */ @@ -90,12 +93,14 @@ public interface Schema { /** * Foreign key to {@link AppMetadataTable}. + * * @see AppMetadataTable */ String APP_METADATA_ID = "appMetadataId"; /** * Foreign key to {@link CategoryTable}. + * * @see CategoryTable */ String CATEGORY_ID = "categoryId"; @@ -121,6 +126,7 @@ public interface Schema { /** * An entry in this table signifies that an apk has a particular anti feature. + * * @see AntiFeatureTable * @see ApkTable */ @@ -131,12 +137,14 @@ public interface Schema { interface Cols { /** * Foreign key to {@link ApkTable}. + * * @see ApkTable */ String APK_ID = "apkId"; /** * Foreign key to {@link AntiFeatureTable}. + * * @see AntiFeatureTable */ String ANTI_FEATURE_ID = "antiFeatureId"; @@ -199,6 +207,7 @@ public interface Schema { String TV_SCREENSHOTS = "tvScreenshots"; String WEAR_SCREENSHOTS = "wearScreenshots"; String IS_APK = "isApk"; + String IS_LOCALIZED = "isLocalized"; interface SuggestedApk { String VERSION_NAME = "suggestedApkVersion"; @@ -238,12 +247,13 @@ public interface Schema { ANTI_FEATURES, REQUIREMENTS, ICON_URL, FEATURE_GRAPHIC, PROMO_GRAPHIC, TV_BANNER, PHONE_SCREENSHOTS, SEVEN_INCH_SCREENSHOTS, TEN_INCH_SCREENSHOTS, TV_SCREENSHOTS, WEAR_SCREENSHOTS, - PREFERRED_SIGNER, SUGGESTED_VERSION_CODE, IS_APK, + PREFERRED_SIGNER, SUGGESTED_VERSION_CODE, IS_APK, IS_LOCALIZED, }; /** * Superset of {@link Cols#ALL_COLS} including fields from other tables and also an alias * to satisfy the Android requirement for an "_ID" field. + * * @see Cols#ALL_COLS */ String[] ALL = { @@ -254,7 +264,7 @@ public interface Schema { ANTI_FEATURES, REQUIREMENTS, ICON_URL, FEATURE_GRAPHIC, PROMO_GRAPHIC, TV_BANNER, PHONE_SCREENSHOTS, SEVEN_INCH_SCREENSHOTS, TEN_INCH_SCREENSHOTS, TV_SCREENSHOTS, WEAR_SCREENSHOTS, - PREFERRED_SIGNER, SUGGESTED_VERSION_CODE, IS_APK, SuggestedApk.VERSION_NAME, + PREFERRED_SIGNER, SUGGESTED_VERSION_CODE, IS_APK, IS_LOCALIZED, SuggestedApk.VERSION_NAME, InstalledApp.VERSION_CODE, InstalledApp.VERSION_NAME, InstalledApp.SIGNATURE, Package.PACKAGE_NAME, }; diff --git a/app/src/test/java/org/fdroid/fdroid/updater/IndexV1UpdaterTest.java b/app/src/test/java/org/fdroid/fdroid/updater/IndexV1UpdaterTest.java index 986e74285..22bc9efcc 100644 --- a/app/src/test/java/org/fdroid/fdroid/updater/IndexV1UpdaterTest.java +++ b/app/src/test/java/org/fdroid/fdroid/updater/IndexV1UpdaterTest.java @@ -347,6 +347,7 @@ public class IndexV1UpdaterTest extends FDroidProviderTest { "installedVersionCode", "installedVersionName", "isApk", + "isLocalized", "preferredSigner", "prefs", "TAG",