support "What's New" and "Video" fields from index-v1
fdroidserver currently only supports a single WhatsNew field that comes from the CurrentVersionCode of the app. Google Play and fastlane supply support a WhatsNew field per-release, but we don't use that data anywhere, and implementing that in the data structures would add a lot of complexity since Apk would then need to have its own "localized" section like App does. The "Video" field is just a URL pointing to a video. closes #910
This commit is contained in:
parent
656b3185b2
commit
97fd3f0bad
@ -110,7 +110,10 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
||||
|
||||
public String description;
|
||||
|
||||
public String video;
|
||||
/**
|
||||
* A descriptive text for what has changed in this version.
|
||||
*/
|
||||
public String whatsNew;
|
||||
|
||||
public String featureGraphic;
|
||||
public String promoGraphic;
|
||||
@ -133,6 +136,8 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
||||
|
||||
public String sourceCode;
|
||||
|
||||
public String video;
|
||||
|
||||
public String changelog;
|
||||
|
||||
public String donate;
|
||||
@ -230,6 +235,9 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
||||
case Cols.DESCRIPTION:
|
||||
description = cursor.getString(i);
|
||||
break;
|
||||
case Cols.WHATSNEW:
|
||||
whatsNew = cursor.getString(i);
|
||||
break;
|
||||
case Cols.LICENSE:
|
||||
license = cursor.getString(i);
|
||||
break;
|
||||
@ -248,6 +256,9 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
||||
case Cols.SOURCE_CODE:
|
||||
sourceCode = cursor.getString(i);
|
||||
break;
|
||||
case Cols.VIDEO:
|
||||
video = cursor.getString(i);
|
||||
break;
|
||||
case Cols.CHANGELOG:
|
||||
changelog = cursor.getString(i);
|
||||
break;
|
||||
@ -387,8 +398,10 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
||||
}
|
||||
}
|
||||
// if key starts with Upper case, its set by humans
|
||||
// Name, Summary, Description existed before localization so their values can be set directly
|
||||
video = getLocalizedEntry(localized, localesToUse, "Video");
|
||||
whatsNew = getLocalizedEntry(localized, localesToUse, "WhatsNew");
|
||||
// Name, Summary, Description existed before localization so they shouldn't replace
|
||||
// non-localized old data format with a null or blank string
|
||||
String value = getLocalizedEntry(localized, localesToUse, "Name");
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
name = value;
|
||||
@ -733,12 +746,14 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
||||
values.put(Cols.ICON_URL, iconUrl);
|
||||
values.put(Cols.ICON_URL_LARGE, iconUrlLarge);
|
||||
values.put(Cols.DESCRIPTION, description);
|
||||
values.put(Cols.WHATSNEW, whatsNew);
|
||||
values.put(Cols.LICENSE, license);
|
||||
values.put(Cols.AUTHOR_NAME, authorName);
|
||||
values.put(Cols.AUTHOR_EMAIL, authorEmail);
|
||||
values.put(Cols.WEBSITE, webSite);
|
||||
values.put(Cols.ISSUE_TRACKER, issueTracker);
|
||||
values.put(Cols.SOURCE_CODE, sourceCode);
|
||||
values.put(Cols.VIDEO, video);
|
||||
values.put(Cols.CHANGELOG, changelog);
|
||||
values.put(Cols.DONATE, donate);
|
||||
values.put(Cols.BITCOIN, bitcoin);
|
||||
@ -887,12 +902,14 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
||||
dest.writeString(this.summary);
|
||||
dest.writeString(this.icon);
|
||||
dest.writeString(this.description);
|
||||
dest.writeString(this.whatsNew);
|
||||
dest.writeString(this.license);
|
||||
dest.writeString(this.authorName);
|
||||
dest.writeString(this.authorEmail);
|
||||
dest.writeString(this.webSite);
|
||||
dest.writeString(this.issueTracker);
|
||||
dest.writeString(this.sourceCode);
|
||||
dest.writeString(this.video);
|
||||
dest.writeString(this.changelog);
|
||||
dest.writeString(this.donate);
|
||||
dest.writeString(this.bitcoin);
|
||||
@ -932,12 +949,14 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
|
||||
this.summary = in.readString();
|
||||
this.icon = in.readString();
|
||||
this.description = in.readString();
|
||||
this.whatsNew = in.readString();
|
||||
this.license = in.readString();
|
||||
this.authorName = in.readString();
|
||||
this.authorEmail = in.readString();
|
||||
this.webSite = in.readString();
|
||||
this.issueTracker = in.readString();
|
||||
this.sourceCode = in.readString();
|
||||
this.video = in.readString();
|
||||
this.changelog = in.readString();
|
||||
this.donate = in.readString();
|
||||
this.bitcoin = in.readString();
|
||||
|
@ -119,12 +119,14 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
+ AppMetadataTable.Cols.SUMMARY + " text not null, "
|
||||
+ AppMetadataTable.Cols.ICON + " text, "
|
||||
+ AppMetadataTable.Cols.DESCRIPTION + " text not null, "
|
||||
+ AppMetadataTable.Cols.WHATSNEW + " text, "
|
||||
+ AppMetadataTable.Cols.LICENSE + " text not null, "
|
||||
+ AppMetadataTable.Cols.AUTHOR_NAME + " text, "
|
||||
+ AppMetadataTable.Cols.AUTHOR_EMAIL + " text, "
|
||||
+ AppMetadataTable.Cols.WEBSITE + " text, "
|
||||
+ AppMetadataTable.Cols.ISSUE_TRACKER + " text, "
|
||||
+ AppMetadataTable.Cols.SOURCE_CODE + " text, "
|
||||
+ AppMetadataTable.Cols.VIDEO + " string, "
|
||||
+ AppMetadataTable.Cols.CHANGELOG + " text, "
|
||||
+ AppMetadataTable.Cols.SUGGESTED_VERSION_CODE + " text,"
|
||||
+ AppMetadataTable.Cols.UPSTREAM_VERSION_NAME + " text,"
|
||||
@ -190,7 +192,7 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
+ InstalledAppTable.Cols.HASH + " TEXT NOT NULL"
|
||||
+ " );";
|
||||
|
||||
protected static final int DB_VERSION = 68;
|
||||
protected static final int DB_VERSION = 69;
|
||||
|
||||
private final Context context;
|
||||
|
||||
@ -273,6 +275,21 @@ class DBHelper extends SQLiteOpenHelper {
|
||||
addIndexV1Fields(db, oldVersion);
|
||||
addIndexV1AppFields(db, oldVersion);
|
||||
recalculatePreferredMetadata(db, oldVersion);
|
||||
addWhatsNewAndVideo(db, oldVersion);
|
||||
}
|
||||
|
||||
private void addWhatsNewAndVideo(SQLiteDatabase db, int oldVersion) {
|
||||
if (oldVersion >= 69) {
|
||||
return;
|
||||
}
|
||||
if (!columnExists(db, AppMetadataTable.NAME, AppMetadataTable.Cols.WHATSNEW)) {
|
||||
Utils.debugLog(TAG, "Adding " + AppMetadataTable.Cols.WHATSNEW + " field to " + AppMetadataTable.NAME + " table in db.");
|
||||
db.execSQL("alter table " + AppMetadataTable.NAME + " add column " + AppMetadataTable.Cols.WHATSNEW + " text;");
|
||||
}
|
||||
if (!columnExists(db, AppMetadataTable.NAME, AppMetadataTable.Cols.VIDEO)) {
|
||||
Utils.debugLog(TAG, "Adding " + AppMetadataTable.Cols.VIDEO + " field to " + AppMetadataTable.NAME + " table in db.");
|
||||
db.execSQL("alter table " + AppMetadataTable.NAME + " add column " + AppMetadataTable.Cols.VIDEO + " string;");
|
||||
}
|
||||
}
|
||||
|
||||
private void recalculatePreferredMetadata(SQLiteDatabase db, int oldVersion) {
|
||||
|
@ -123,12 +123,14 @@ public interface Schema {
|
||||
String SUMMARY = "summary";
|
||||
String ICON = "icon";
|
||||
String DESCRIPTION = "description";
|
||||
String WHATSNEW = "whatsNew";
|
||||
String LICENSE = "license";
|
||||
String AUTHOR_NAME = "author";
|
||||
String AUTHOR_EMAIL = "email";
|
||||
String WEBSITE = "webURL";
|
||||
String ISSUE_TRACKER = "trackerURL";
|
||||
String SOURCE_CODE = "sourceURL";
|
||||
String VIDEO = "video";
|
||||
String CHANGELOG = "changelogURL";
|
||||
String DONATE = "donateURL";
|
||||
String BITCOIN = "bitcoinAddr";
|
||||
@ -184,8 +186,8 @@ public interface Schema {
|
||||
*/
|
||||
String[] ALL_COLS = {
|
||||
ROW_ID, PACKAGE_ID, REPO_ID, IS_COMPATIBLE, NAME, SUMMARY, ICON, DESCRIPTION,
|
||||
LICENSE, AUTHOR_NAME, AUTHOR_EMAIL, WEBSITE, ISSUE_TRACKER, SOURCE_CODE,
|
||||
CHANGELOG, DONATE, BITCOIN, LITECOIN, FLATTR_ID,
|
||||
WHATSNEW, LICENSE, AUTHOR_NAME, AUTHOR_EMAIL, WEBSITE, ISSUE_TRACKER, SOURCE_CODE,
|
||||
VIDEO, CHANGELOG, DONATE, BITCOIN, LITECOIN, FLATTR_ID,
|
||||
UPSTREAM_VERSION_NAME, UPSTREAM_VERSION_CODE, ADDED, LAST_UPDATED,
|
||||
ANTI_FEATURES, REQUIREMENTS, ICON_URL, ICON_URL_LARGE,
|
||||
FEATURE_GRAPHIC, PROMO_GRAPHIC, TV_BANNER, PHONE_SCREENSHOTS,
|
||||
@ -200,8 +202,8 @@ public interface Schema {
|
||||
*/
|
||||
String[] ALL = {
|
||||
_ID, ROW_ID, REPO_ID, IS_COMPATIBLE, NAME, SUMMARY, ICON, DESCRIPTION,
|
||||
LICENSE, AUTHOR_NAME, AUTHOR_EMAIL, WEBSITE, ISSUE_TRACKER, SOURCE_CODE,
|
||||
CHANGELOG, DONATE, BITCOIN, LITECOIN, FLATTR_ID,
|
||||
WHATSNEW, LICENSE, AUTHOR_NAME, AUTHOR_EMAIL, WEBSITE, ISSUE_TRACKER, SOURCE_CODE,
|
||||
VIDEO, CHANGELOG, DONATE, BITCOIN, LITECOIN, FLATTR_ID,
|
||||
UPSTREAM_VERSION_NAME, UPSTREAM_VERSION_CODE, ADDED, LAST_UPDATED,
|
||||
ANTI_FEATURES, REQUIREMENTS, ICON_URL, ICON_URL_LARGE,
|
||||
FEATURE_GRAPHIC, PROMO_GRAPHIC, TV_BANNER, PHONE_SCREENSHOTS,
|
||||
|
@ -410,21 +410,17 @@ public class AppDetailsRecyclerViewAdapter
|
||||
lastUpdateView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
Apk suggestedApk = getSuggestedApk();
|
||||
|
||||
// TODO populate whatsNew with suggestedApk.whatsNew once that exists
|
||||
String whatsNew = null;
|
||||
//noinspection ConstantConditions
|
||||
if (suggestedApk == null || TextUtils.isEmpty(whatsNew)) {
|
||||
if (TextUtils.isEmpty(app.whatsNew)) {
|
||||
whatsNewView.setVisibility(View.GONE);
|
||||
} else {
|
||||
//noinspection deprecation Ignore deprecation because the suggested way is only available in API 24.
|
||||
Locale locale = context.getResources().getConfiguration().locale;
|
||||
|
||||
StringBuilder sbWhatsNew = new StringBuilder();
|
||||
sbWhatsNew.append(whatsNewView.getContext().getString(R.string.details_new_in_version, suggestedApk.versionName).toUpperCase(locale));
|
||||
sbWhatsNew.append(whatsNewView.getContext().getString(R.string.details_new_in_version,
|
||||
getSuggestedApk().versionName).toUpperCase(locale));
|
||||
sbWhatsNew.append("\n\n");
|
||||
sbWhatsNew.append(whatsNew);
|
||||
sbWhatsNew.append(app.whatsNew);
|
||||
whatsNewView.setText(sbWhatsNew);
|
||||
whatsNewView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -251,6 +251,7 @@ public class IndexV1UpdaterTest extends FDroidProviderTest {
|
||||
"upstreamVersionCode",
|
||||
"upstreamVersionName",
|
||||
"video",
|
||||
"whatsNew",
|
||||
"wearScreenshots",
|
||||
"webSite",
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user