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 e8a7bc5ea..ee0d0d5a7 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/App.java +++ b/app/src/main/java/org/fdroid/fdroid/data/App.java @@ -163,7 +163,7 @@ public class App extends ValueObject implements Comparable, Parcelable { public String flattrID; - public String liberapayID; + public String liberapay; public String openCollective; @@ -311,8 +311,8 @@ public class App extends ValueObject implements Comparable, Parcelable { case Cols.FLATTR_ID: flattrID = cursor.getString(i); break; - case Cols.LIBERAPAY_ID: - liberapayID = cursor.getString(i); + case Cols.LIBERAPAY: + liberapay = cursor.getString(i); break; case Cols.OPEN_COLLECTIVE: openCollective = cursor.getString(i); @@ -450,6 +450,25 @@ public class App extends ValueObject implements Comparable, Parcelable { } } + /** + * {@link #liberapay} was originally included using a numeric ID, now it is a + * username. This should not override {@link #liberapay} if that is already set. + */ + @JsonProperty("liberapayID") + void setLiberapayID(String liberapayId) { // NOPMD + if (TextUtils.isEmpty(liberapayId) || !TextUtils.isEmpty(liberapay)) { + return; + } + try { + int id = Integer.parseInt(liberapayId); + if (id > 0) { + liberapay = "~" + liberapayId; + } + } catch (NumberFormatException e) { + // ignored + } + } + /** * Parses the {@code localized} block in the incoming index metadata, * choosing the best match in terms of locale/language while filling as @@ -672,10 +691,10 @@ public class App extends ValueObject implements Comparable, Parcelable { public String getIconUrl(Context context) { Repo repo = RepoProvider.Helper.findById(context, repoId); if (TextUtils.isEmpty(iconUrl)) { - if (TextUtils.isEmpty(iconFromApk)){ + if (TextUtils.isEmpty(iconFromApk)) { return null; } - if (iconFromApk.endsWith(".xml")){ + if (iconFromApk.endsWith(".xml")) { // We cannot use xml ressources as icons. F-Droid server should not include them // https://gitlab.com/fdroid/fdroidserver/issues/344 return null; @@ -995,7 +1014,7 @@ public class App extends ValueObject implements Comparable, Parcelable { values.put(Cols.BITCOIN, bitcoin); values.put(Cols.LITECOIN, litecoin); values.put(Cols.FLATTR_ID, flattrID); - values.put(Cols.LIBERAPAY_ID, liberapayID); + values.put(Cols.LIBERAPAY, liberapay); values.put(Cols.OPEN_COLLECTIVE, openCollective); values.put(Cols.ADDED, Utils.formatDate(added, "")); values.put(Cols.LAST_UPDATED, Utils.formatDate(lastUpdated, "")); @@ -1123,7 +1142,7 @@ public class App extends ValueObject implements Comparable, Parcelable { @Nullable public String getLiberapayUri() { - return TextUtils.isEmpty(liberapayID) ? null : "https://liberapay.com/~" + liberapayID; + return TextUtils.isEmpty(liberapay) ? null : "https://liberapay.com/" + liberapay; } @@ -1231,7 +1250,7 @@ public class App extends ValueObject implements Comparable, Parcelable { dest.writeString(this.bitcoin); dest.writeString(this.litecoin); dest.writeString(this.flattrID); - dest.writeString(this.liberapayID); + dest.writeString(this.liberapay); dest.writeString(this.openCollective); dest.writeString(this.preferredSigner); dest.writeString(this.suggestedVersionName); @@ -1283,7 +1302,7 @@ public class App extends ValueObject implements Comparable, Parcelable { this.bitcoin = in.readString(); this.litecoin = in.readString(); this.flattrID = in.readString(); - this.liberapayID = in.readString(); + this.liberapay = in.readString(); this.openCollective = in.readString(); this.preferredSigner = in.readString(); this.suggestedVersionName = in.readString(); 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 6c27dfd73..c5c4dce03 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/DBHelper.java +++ b/app/src/main/java/org/fdroid/fdroid/data/DBHelper.java @@ -156,7 +156,7 @@ public class DBHelper extends SQLiteOpenHelper { + AppMetadataTable.Cols.BITCOIN + " string," + AppMetadataTable.Cols.LITECOIN + " string," + AppMetadataTable.Cols.FLATTR_ID + " string," - + AppMetadataTable.Cols.LIBERAPAY_ID + " string," + + AppMetadataTable.Cols.LIBERAPAY + " string," + AppMetadataTable.Cols.OPEN_COLLECTIVE + " string," + AppMetadataTable.Cols.REQUIREMENTS + " string," + AppMetadataTable.Cols.ADDED + " string," @@ -573,11 +573,11 @@ public class DBHelper extends SQLiteOpenHelper { return; } - if (!columnExists(db, AppMetadataTable.NAME, AppMetadataTable.Cols.LIBERAPAY_ID)) { - Utils.debugLog(TAG, "Adding " + AppMetadataTable.Cols.LIBERAPAY_ID + " field to " + if (!columnExists(db, AppMetadataTable.NAME, AppMetadataTable.Cols.LIBERAPAY)) { + Utils.debugLog(TAG, "Adding " + AppMetadataTable.Cols.LIBERAPAY + " field to " + AppMetadataTable.NAME + " table in db."); db.execSQL("alter table " + AppMetadataTable.NAME + " add column " - + AppMetadataTable.Cols.LIBERAPAY_ID + " string;"); + + AppMetadataTable.Cols.LIBERAPAY + " string;"); } } diff --git a/app/src/main/java/org/fdroid/fdroid/data/RepoXMLHandler.java b/app/src/main/java/org/fdroid/fdroid/data/RepoXMLHandler.java index 1110a2412..1a04961f9 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/RepoXMLHandler.java +++ b/app/src/main/java/org/fdroid/fdroid/data/RepoXMLHandler.java @@ -257,7 +257,7 @@ public class RepoXMLHandler extends DefaultHandler { curapp.flattrID = str; break; case "liberapay": - curapp.liberapayID = str; + curapp.liberapay = str; break; case "web": curapp.webSite = str; 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 297cffed4..e3a6d3e0b 100644 --- a/app/src/main/java/org/fdroid/fdroid/data/Schema.java +++ b/app/src/main/java/org/fdroid/fdroid/data/Schema.java @@ -189,7 +189,7 @@ public interface Schema { String BITCOIN = "bitcoinAddr"; String LITECOIN = "litecoinAddr"; String FLATTR_ID = "flattrID"; - String LIBERAPAY_ID = "liberapayID"; + String LIBERAPAY = "liberapayID"; String OPEN_COLLECTIVE = "openCollective"; String PREFERRED_SIGNER = "preferredSigner"; String AUTO_INSTALL_VERSION_CODE = "suggestedVercode"; // name mismatch from issue #1063 @@ -244,7 +244,7 @@ public interface Schema { String[] ALL_COLS = { ROW_ID, PACKAGE_ID, REPO_ID, IS_COMPATIBLE, NAME, SUMMARY, ICON, DESCRIPTION, WHATSNEW, LICENSE, AUTHOR_NAME, AUTHOR_EMAIL, WEBSITE, ISSUE_TRACKER, SOURCE_CODE, - TRANSLATION, VIDEO, CHANGELOG, DONATE, BITCOIN, LITECOIN, FLATTR_ID, LIBERAPAY_ID, + TRANSLATION, VIDEO, CHANGELOG, DONATE, BITCOIN, LITECOIN, FLATTR_ID, LIBERAPAY, OPEN_COLLECTIVE, SUGGESTED_VERSION_NAME, SUGGESTED_VERSION_CODE, ADDED, LAST_UPDATED, ANTI_FEATURES, REQUIREMENTS, ICON_URL, FEATURE_GRAPHIC, PROMO_GRAPHIC, TV_BANNER, PHONE_SCREENSHOTS, @@ -261,7 +261,7 @@ public interface Schema { String[] ALL = { _ID, ROW_ID, REPO_ID, IS_COMPATIBLE, NAME, SUMMARY, ICON, DESCRIPTION, WHATSNEW, LICENSE, AUTHOR_NAME, AUTHOR_EMAIL, WEBSITE, ISSUE_TRACKER, SOURCE_CODE, - TRANSLATION, VIDEO, CHANGELOG, DONATE, BITCOIN, LITECOIN, FLATTR_ID, LIBERAPAY_ID, + TRANSLATION, VIDEO, CHANGELOG, DONATE, BITCOIN, LITECOIN, FLATTR_ID, LIBERAPAY, OPEN_COLLECTIVE, SUGGESTED_VERSION_NAME, SUGGESTED_VERSION_CODE, ADDED, LAST_UPDATED, ANTI_FEATURES, REQUIREMENTS, ICON_URL, FEATURE_GRAPHIC, PROMO_GRAPHIC, TV_BANNER, PHONE_SCREENSHOTS, 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 1c9a469c0..b7a29f4c2 100644 --- a/app/src/test/java/org/fdroid/fdroid/updater/IndexV1UpdaterTest.java +++ b/app/src/test/java/org/fdroid/fdroid/updater/IndexV1UpdaterTest.java @@ -151,7 +151,7 @@ public class IndexV1UpdaterTest extends FDroidProviderTest { Schema.AppMetadataTable.Cols.REPO_ID, Schema.AppMetadataTable.Cols.Package.PACKAGE_NAME}); assertEquals("localized icon takes precedence", TESTY_CANONICAL_URL + "/" - + app.packageName + "/en-US/icon.png", app.getIconUrl(context)); + + app.packageName + "/en-US/icon.png", app.getIconUrl(context)); } @Test(expected = IndexUpdater.SigningException.class) @@ -266,6 +266,17 @@ public class IndexV1UpdaterTest extends FDroidProviderTest { } parser.close(); // ensure resources get cleaned up timely and properly + // test LiberapayID: -> Liberapay: migration + for (App app : apps) { + if ("org.witness.informacam.app".equals(app.packageName)) { + assertEquals("GuardianProject", app.liberapay); + } else if ("info.guardianproject.cacert".equals(app.packageName)) { + assertEquals("~1337", app.liberapay); + } else { + assertNull(app.liberapay); + } + } + RepoDetails indexV0Details = getFromFile("guardianproject_index.xml", Repo.PUSH_REQUEST_ACCEPT_ALWAYS); indexV0Details.apps.size(); @@ -325,7 +336,7 @@ public class IndexV1UpdaterTest extends FDroidProviderTest { "iconUrl", "issueTracker", "lastUpdated", - "liberapayID", + "liberapay", "license", "litecoin", "name", diff --git a/app/src/test/resources/guardianproject_index-v1.json b/app/src/test/resources/guardianproject_index-v1.json index 42a42d5f3..d3b92825e 100644 --- a/app/src/test/resources/guardianproject_index-v1.json +++ b/app/src/test/resources/guardianproject_index-v1.json @@ -28,6 +28,7 @@ "suggestedVersionCode": "999999999", "description": "

Android 4+ allows you to disable certificates from the system Settings and root isn't required, so try that first if you want to manually mess with the certificates. The app won't work with Android 4+ anyway.

An app to manage security certificates on your phone also containing a version of the Android CACert keystore derived from Mozilla. If a certificate has recently become untrusted you can either install an update to this app or you can backup and remove certificates by yourself.

Requires root: Yes, it writes to the system partition. You will need a device that has the \u2018grep\u2019 command on it (via busybox: present on most custom ROMs). If the \u2018save\u2019 doesn\u2019t work, then you will need to make your /system partition read-write by using a file explorer like Ghost Commander or via a command in Terminal Emulator.

", "issueTracker": "https://github.com/guardianproject/cacert/issues", + "liberapayID": "1337", "license": "GPLv3", "name": "CACertMan", "sourceCode": "https://github.com/guardianproject/cacert", @@ -47,6 +48,8 @@ "suggestedVersionCode": "9999999", "description": "

An InformaCam app to generate verifiable media.

", "issueTracker": "https://dev.guardianproject.info/projects/informacam/issues", + "liberapay": "GuardianProject", + "liberapayID": "27859", "license": "GPLv3", "name": "CameraV", "openCollective": "GuardianProject",