add flag to track localized apps for selecting in Latest tab
This commit is contained in:
parent
765bd2892d
commit
dcb1c3accd
@ -98,6 +98,8 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
|||||||
public String preferredSigner;
|
public String preferredSigner;
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
public boolean isApk;
|
public boolean isApk;
|
||||||
|
@JsonIgnore
|
||||||
|
private boolean isLocalized = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is primarily for the purpose of saving app metadata when parsing an index.xml file.
|
* 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<App>, Parcelable {
|
|||||||
case Cols.IS_APK:
|
case Cols.IS_APK:
|
||||||
isApk = cursor.getInt(i) == 1;
|
isApk = cursor.getInt(i) == 1;
|
||||||
break;
|
break;
|
||||||
|
case Cols.IS_LOCALIZED:
|
||||||
|
isLocalized = cursor.getInt(i) == 1;
|
||||||
|
break;
|
||||||
case Cols.InstalledApp.VERSION_CODE:
|
case Cols.InstalledApp.VERSION_CODE:
|
||||||
installedVersionCode = cursor.getInt(i);
|
installedVersionCode = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
@ -468,6 +473,10 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
|||||||
*/
|
*/
|
||||||
@JsonProperty("localized")
|
@JsonProperty("localized")
|
||||||
private void setLocalized(Map<String, Map<String, Object>> localized) { // NOPMD
|
private void setLocalized(Map<String, Map<String, Object>> localized) { // NOPMD
|
||||||
|
if (localized.size() > 1) {
|
||||||
|
isLocalized = true;
|
||||||
|
}
|
||||||
|
|
||||||
Locale defaultLocale = Locale.getDefault();
|
Locale defaultLocale = Locale.getDefault();
|
||||||
String languageTag = defaultLocale.getLanguage();
|
String languageTag = defaultLocale.getLanguage();
|
||||||
String countryTag = defaultLocale.getCountry();
|
String countryTag = defaultLocale.getCountry();
|
||||||
@ -953,6 +962,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
|||||||
values.put(Cols.WEAR_SCREENSHOTS, Utils.serializeCommaSeparatedString(wearScreenshots));
|
values.put(Cols.WEAR_SCREENSHOTS, Utils.serializeCommaSeparatedString(wearScreenshots));
|
||||||
values.put(Cols.IS_COMPATIBLE, compatible ? 1 : 0);
|
values.put(Cols.IS_COMPATIBLE, compatible ? 1 : 0);
|
||||||
values.put(Cols.IS_APK, isApk ? 1 : 0);
|
values.put(Cols.IS_APK, isApk ? 1 : 0);
|
||||||
|
values.put(Cols.IS_LOCALIZED, isLocalized ? 1 : 0);
|
||||||
|
|
||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
@ -1178,6 +1188,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
|||||||
dest.writeStringArray(this.tvScreenshots);
|
dest.writeStringArray(this.tvScreenshots);
|
||||||
dest.writeStringArray(this.wearScreenshots);
|
dest.writeStringArray(this.wearScreenshots);
|
||||||
dest.writeByte(this.isApk ? (byte) 1 : (byte) 0);
|
dest.writeByte(this.isApk ? (byte) 1 : (byte) 0);
|
||||||
|
dest.writeByte(this.isLocalized ? (byte) 1 : (byte) 0);
|
||||||
dest.writeString(this.installedVersionName);
|
dest.writeString(this.installedVersionName);
|
||||||
dest.writeInt(this.installedVersionCode);
|
dest.writeInt(this.installedVersionCode);
|
||||||
dest.writeParcelable(this.installedApk, flags);
|
dest.writeParcelable(this.installedApk, flags);
|
||||||
@ -1229,6 +1240,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
|||||||
this.tvScreenshots = in.createStringArray();
|
this.tvScreenshots = in.createStringArray();
|
||||||
this.wearScreenshots = in.createStringArray();
|
this.wearScreenshots = in.createStringArray();
|
||||||
this.isApk = in.readByte() != 0;
|
this.isApk = in.readByte() != 0;
|
||||||
|
this.isLocalized = in.readByte() != 0;
|
||||||
this.installedVersionName = in.readString();
|
this.installedVersionName = in.readString();
|
||||||
this.installedVersionCode = in.readInt();
|
this.installedVersionCode = in.readInt();
|
||||||
this.installedApk = in.readParcelable(Apk.class.getClassLoader());
|
this.installedApk = in.readParcelable(Apk.class.getClassLoader());
|
||||||
|
@ -169,6 +169,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||||||
+ AppMetadataTable.Cols.TV_SCREENSHOTS + " string,"
|
+ AppMetadataTable.Cols.TV_SCREENSHOTS + " string,"
|
||||||
+ AppMetadataTable.Cols.WEAR_SCREENSHOTS + " string,"
|
+ AppMetadataTable.Cols.WEAR_SCREENSHOTS + " string,"
|
||||||
+ AppMetadataTable.Cols.IS_APK + " boolean,"
|
+ AppMetadataTable.Cols.IS_APK + " boolean,"
|
||||||
|
+ AppMetadataTable.Cols.IS_LOCALIZED + " boolean,"
|
||||||
+ "primary key(" + AppMetadataTable.Cols.PACKAGE_ID + ", " + AppMetadataTable.Cols.REPO_ID + "));";
|
+ "primary key(" + AppMetadataTable.Cols.PACKAGE_ID + ", " + AppMetadataTable.Cols.REPO_ID + "));";
|
||||||
|
|
||||||
private static final String CREATE_TABLE_APP_PREFS = "CREATE TABLE " + AppPrefsTable.NAME
|
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 + ") "
|
+ "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;
|
private final Context context;
|
||||||
|
|
||||||
@ -450,6 +451,19 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||||||
addUserMirrorsFields(db, oldVersion);
|
addUserMirrorsFields(db, oldVersion);
|
||||||
removeNotNullFromVersionName(db, oldVersion);
|
removeNotNullFromVersionName(db, oldVersion);
|
||||||
addDisabledMirrorsFields(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) {
|
private void addDisabledMirrorsFields(SQLiteDatabase db, int oldVersion) {
|
||||||
|
@ -12,11 +12,13 @@ public interface Schema {
|
|||||||
/**
|
/**
|
||||||
* A package is essentially the app that a developer builds and wants you to install on your
|
* A package is essentially the app that a developer builds and wants you to install on your
|
||||||
* device. It differs from entries in:
|
* device. It differs from entries in:
|
||||||
* * {@link ApkTable} because they are specific builds of a particular package. Many different
|
* <ul>
|
||||||
* builds of the same package can exist.
|
* <li>{@link ApkTable} because they are specific builds of a particular package. Many different
|
||||||
* * {@link AppMetadataTable} because this is metdata about a package which is specified by a
|
* builds of the same package can exist.</li>
|
||||||
* given repo. Different repos can provide the same package with different descriptions,
|
* <li>{@link AppMetadataTable} because this is metdata about a package which is specified by a
|
||||||
* categories, etc.
|
* given repo. Different repos can provide the same package with different descriptions,
|
||||||
|
* categories, etc.</li>
|
||||||
|
* </ul>
|
||||||
*/
|
*/
|
||||||
interface PackageTable {
|
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
|
* 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}
|
* 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.
|
* can be in the same category multiple times, if multiple repos think that is the case.
|
||||||
|
*
|
||||||
* @see CategoryTable
|
* @see CategoryTable
|
||||||
* @see AppMetadataTable
|
* @see AppMetadataTable
|
||||||
*/
|
*/
|
||||||
@ -90,12 +93,14 @@ public interface Schema {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Foreign key to {@link AppMetadataTable}.
|
* Foreign key to {@link AppMetadataTable}.
|
||||||
|
*
|
||||||
* @see AppMetadataTable
|
* @see AppMetadataTable
|
||||||
*/
|
*/
|
||||||
String APP_METADATA_ID = "appMetadataId";
|
String APP_METADATA_ID = "appMetadataId";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Foreign key to {@link CategoryTable}.
|
* Foreign key to {@link CategoryTable}.
|
||||||
|
*
|
||||||
* @see CategoryTable
|
* @see CategoryTable
|
||||||
*/
|
*/
|
||||||
String CATEGORY_ID = "categoryId";
|
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.
|
* An entry in this table signifies that an apk has a particular anti feature.
|
||||||
|
*
|
||||||
* @see AntiFeatureTable
|
* @see AntiFeatureTable
|
||||||
* @see ApkTable
|
* @see ApkTable
|
||||||
*/
|
*/
|
||||||
@ -131,12 +137,14 @@ public interface Schema {
|
|||||||
interface Cols {
|
interface Cols {
|
||||||
/**
|
/**
|
||||||
* Foreign key to {@link ApkTable}.
|
* Foreign key to {@link ApkTable}.
|
||||||
|
*
|
||||||
* @see ApkTable
|
* @see ApkTable
|
||||||
*/
|
*/
|
||||||
String APK_ID = "apkId";
|
String APK_ID = "apkId";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Foreign key to {@link AntiFeatureTable}.
|
* Foreign key to {@link AntiFeatureTable}.
|
||||||
|
*
|
||||||
* @see AntiFeatureTable
|
* @see AntiFeatureTable
|
||||||
*/
|
*/
|
||||||
String ANTI_FEATURE_ID = "antiFeatureId";
|
String ANTI_FEATURE_ID = "antiFeatureId";
|
||||||
@ -199,6 +207,7 @@ public interface Schema {
|
|||||||
String TV_SCREENSHOTS = "tvScreenshots";
|
String TV_SCREENSHOTS = "tvScreenshots";
|
||||||
String WEAR_SCREENSHOTS = "wearScreenshots";
|
String WEAR_SCREENSHOTS = "wearScreenshots";
|
||||||
String IS_APK = "isApk";
|
String IS_APK = "isApk";
|
||||||
|
String IS_LOCALIZED = "isLocalized";
|
||||||
|
|
||||||
interface SuggestedApk {
|
interface SuggestedApk {
|
||||||
String VERSION_NAME = "suggestedApkVersion";
|
String VERSION_NAME = "suggestedApkVersion";
|
||||||
@ -238,12 +247,13 @@ public interface Schema {
|
|||||||
ANTI_FEATURES, REQUIREMENTS, ICON_URL,
|
ANTI_FEATURES, REQUIREMENTS, ICON_URL,
|
||||||
FEATURE_GRAPHIC, PROMO_GRAPHIC, TV_BANNER, PHONE_SCREENSHOTS,
|
FEATURE_GRAPHIC, PROMO_GRAPHIC, TV_BANNER, PHONE_SCREENSHOTS,
|
||||||
SEVEN_INCH_SCREENSHOTS, TEN_INCH_SCREENSHOTS, TV_SCREENSHOTS, WEAR_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
|
* Superset of {@link Cols#ALL_COLS} including fields from other tables and also an alias
|
||||||
* to satisfy the Android requirement for an "_ID" field.
|
* to satisfy the Android requirement for an "_ID" field.
|
||||||
|
*
|
||||||
* @see Cols#ALL_COLS
|
* @see Cols#ALL_COLS
|
||||||
*/
|
*/
|
||||||
String[] ALL = {
|
String[] ALL = {
|
||||||
@ -254,7 +264,7 @@ public interface Schema {
|
|||||||
ANTI_FEATURES, REQUIREMENTS, ICON_URL,
|
ANTI_FEATURES, REQUIREMENTS, ICON_URL,
|
||||||
FEATURE_GRAPHIC, PROMO_GRAPHIC, TV_BANNER, PHONE_SCREENSHOTS,
|
FEATURE_GRAPHIC, PROMO_GRAPHIC, TV_BANNER, PHONE_SCREENSHOTS,
|
||||||
SEVEN_INCH_SCREENSHOTS, TEN_INCH_SCREENSHOTS, TV_SCREENSHOTS, WEAR_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.VERSION_CODE, InstalledApp.VERSION_NAME,
|
||||||
InstalledApp.SIGNATURE, Package.PACKAGE_NAME,
|
InstalledApp.SIGNATURE, Package.PACKAGE_NAME,
|
||||||
};
|
};
|
||||||
|
@ -347,6 +347,7 @@ public class IndexV1UpdaterTest extends FDroidProviderTest {
|
|||||||
"installedVersionCode",
|
"installedVersionCode",
|
||||||
"installedVersionName",
|
"installedVersionName",
|
||||||
"isApk",
|
"isApk",
|
||||||
|
"isLocalized",
|
||||||
"preferredSigner",
|
"preferredSigner",
|
||||||
"prefs",
|
"prefs",
|
||||||
"TAG",
|
"TAG",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user