Merge branch 'liberapay' into 'master'

add liberapay field and donation option

See merge request fdroid/fdroidclient!644
This commit is contained in:
Hans-Christoph Steiner 2018-02-19 22:14:52 +00:00
commit 32601baf5c
9 changed files with 131 additions and 4 deletions

View File

@ -235,6 +235,9 @@ public class RepoXMLHandler extends DefaultHandler {
case "flattr":
curapp.flattrID = str;
break;
case "liberapay":
curapp.liberapayID = str;
break;
case "web":
curapp.webSite = str;
break;

View File

@ -157,6 +157,8 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
public String flattrID;
public String liberapayID;
public String upstreamVersionName;
/**
@ -292,6 +294,9 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
case Cols.FLATTR_ID:
flattrID = cursor.getString(i);
break;
case Cols.LIBERAPAY_ID:
liberapayID = cursor.getString(i);
break;
case Cols.SuggestedApk.VERSION_NAME:
suggestedVersionName = cursor.getString(i);
break;
@ -919,6 +924,7 @@ public class App extends ValueObject implements Comparable<App>, 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.ADDED, Utils.formatDate(added, ""));
values.put(Cols.LAST_UPDATED, Utils.formatDate(lastUpdated, ""));
values.put(Cols.PREFERRED_SIGNER, preferredSigner);
@ -1034,6 +1040,12 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
return TextUtils.isEmpty(flattrID) ? null : "https://flattr.com/thing/" + flattrID;
}
@Nullable
public String getLiberapayUri() {
return TextUtils.isEmpty(liberapayID) ? null : "https://liberapay.com/~" + liberapayID;
}
/**
* @see App#suggestedVersionName for why this uses a getter while other member variables are
* publicly accessible.
@ -1134,6 +1146,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
dest.writeString(this.bitcoin);
dest.writeString(this.litecoin);
dest.writeString(this.flattrID);
dest.writeString(this.liberapayID);
dest.writeString(this.preferredSigner);
dest.writeString(this.upstreamVersionName);
dest.writeInt(this.upstreamVersionCode);
@ -1183,6 +1196,7 @@ public class App extends ValueObject implements Comparable<App>, Parcelable {
this.bitcoin = in.readString();
this.litecoin = in.readString();
this.flattrID = in.readString();
this.liberapayID = in.readString();
this.preferredSigner = in.readString();
this.upstreamVersionName = in.readString();
this.upstreamVersionCode = in.readInt();

View File

@ -144,6 +144,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.REQUIREMENTS + " string,"
+ AppMetadataTable.Cols.ADDED + " string,"
+ AppMetadataTable.Cols.LAST_UPDATED + " string,"
@ -214,7 +215,7 @@ public class DBHelper extends SQLiteOpenHelper {
+ "primary key(" + ApkAntiFeatureJoinTable.Cols.APK_ID + ", " + ApkAntiFeatureJoinTable.Cols.ANTI_FEATURE_ID + ") "
+ " );";
protected static final int DB_VERSION = 76;
protected static final int DB_VERSION = 77;
private final Context context;
@ -322,6 +323,20 @@ public class DBHelper extends SQLiteOpenHelper {
addIsAppToApp(db, oldVersion);
addApkAntiFeatures(db, oldVersion);
addIgnoreVulnPref(db, oldVersion);
addLiberapayID(db, oldVersion);
}
private void addLiberapayID(SQLiteDatabase db, int oldVersion) {
if (oldVersion >= 77) {
return;
}
if (!columnExists(db, AppMetadataTable.NAME, AppMetadataTable.Cols.LIBERAPAY_ID)) {
Utils.debugLog(TAG, "Adding " + AppMetadataTable.Cols.LIBERAPAY_ID + " field to "
+ AppMetadataTable.NAME + " table in db.");
db.execSQL("alter table " + AppMetadataTable.NAME + " add column "
+ AppMetadataTable.Cols.LIBERAPAY_ID + " string;");
}
}
private void addIgnoreVulnPref(SQLiteDatabase db, int oldVersion) {

View File

@ -180,6 +180,7 @@ public interface Schema {
String BITCOIN = "bitcoinAddr";
String LITECOIN = "litecoinAddr";
String FLATTR_ID = "flattrID";
String LIBERAPAY_ID = "liberapayID";
String PREFERRED_SIGNER = "preferredSigner";
String SUGGESTED_VERSION_CODE = "suggestedVercode";
String UPSTREAM_VERSION_NAME = "upstreamVersion";
@ -233,7 +234,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,
VIDEO, CHANGELOG, DONATE, BITCOIN, LITECOIN, FLATTR_ID,
VIDEO, CHANGELOG, DONATE, BITCOIN, LITECOIN, FLATTR_ID, LIBERAPAY_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,
@ -249,7 +250,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,
VIDEO, CHANGELOG, DONATE, BITCOIN, LITECOIN, FLATTR_ID,
VIDEO, CHANGELOG, DONATE, BITCOIN, LITECOIN, FLATTR_ID, LIBERAPAY_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,

View File

@ -202,7 +202,8 @@ public class AppDetailsRecyclerViewAdapter
return uriIsSetAndCanBeOpened(app.donate) ||
uriIsSetAndCanBeOpened(app.getBitcoinUri()) ||
uriIsSetAndCanBeOpened(app.getLitecoinUri()) ||
uriIsSetAndCanBeOpened(app.getFlattrUri());
uriIsSetAndCanBeOpened(app.getFlattrUri()) ||
uriIsSetAndCanBeOpened(app.getLiberapayUri());
}
public void clearProgress() {
@ -649,6 +650,10 @@ public class AppDetailsRecyclerViewAdapter
if (uriIsSetAndCanBeOpened(app.getFlattrUri())) {
addDonateOption(R.layout.donate_flattr, app.getFlattrUri());
}
// LiberaPay
if (uriIsSetAndCanBeOpened(app.getLiberapayUri())) {
addDonateOption(R.layout.donate_liberapay, app.getLiberapayUri());
}
}
private void addDonateOption(@LayoutRes int layout, final String uri) {

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="83dp"
android:height="30dp"
android:viewportWidth="83"
android:viewportHeight="30">
<path
android:fillColor="#f6c915"
android:pathData="M5,0.5 L79,0.5 Q83,0.5,83,4.5 L83,25.5 Q83,29.5,79,29.5 L5,29.5 Q1,29.5,1,25.5
L1,4.5 Q1,0.5,5,0.5 Z" />
<path
android:fillColor="#1a171b"
android:pathData="M35.786,14.89 C35.786,13.322,35.352,11.936,34.54,10.97
C33.854,10.144,32.888,9.794,31.32,9.794 L27.33,9.794 L27.33,20 L31.32,20
C32.874,20,33.84,19.636,34.54,18.81 C35.338,17.858,35.786,16.472,35.786,14.89 Z
M33.686,14.904 C33.686,17.144,32.902,18.25,31.32,18.25 L29.43,18.25
L29.43,11.544 L31.32,11.544 C32.902,11.544,33.686,12.65,33.686,14.904 Z" />
<path
android:fillColor="#1a171b"
android:pathData="M44.3351,16.276 C44.3351,13.714,42.9491,12.314,40.5831,12.314
C38.2731,12.314,36.8591,13.742,36.8591,16.22
C36.8591,18.712,38.2731,20.126,40.5971,20.126
C42.8931,20.126,44.3351,18.698,44.3351,16.276 Z M42.3751,16.248
C42.3751,17.662,41.6471,18.544,40.5971,18.544
C39.5331,18.544,38.8191,17.662,38.8191,16.22
C38.8191,14.778,39.5331,13.896,40.5971,13.896
C41.6751,13.896,42.3751,14.764,42.3751,16.248 Z" />
<path
android:fillColor="#1a171b"
android:pathData="M52.5717,20 L52.5717,14.932 C52.5717,13.266,51.6477,12.314,50.0377,12.314
C49.0157,12.314,48.3297,12.692,47.7697,13.532 L47.7697,12.44 L45.8097,12.44
L45.8097,20 L47.7697,20 L47.7697,15.464
C47.7697,14.568,48.3997,13.98,49.3517,13.98
C50.1917,13.98,50.6117,14.442,50.6117,15.338 L50.6117,20 Z" />
<path
android:fillColor="#1a171b"
android:pathData="M60.8223,20 L60.8223,19.762 C60.4723,19.44,60.3743,19.23,60.3743,18.838
L60.3743,14.638 C60.3743,13.098,59.3243,12.314,57.2803,12.314
C55.2363,12.314,54.1723,13.182,54.0463,14.932 L55.9363,14.932
C56.0343,14.148,56.3563,13.896,57.3223,13.896
C58.0783,13.896,58.4563,14.148,58.4563,14.652
C58.4563,15.45,57.8683,15.366,56.8883,15.534 L56.1043,15.674
C54.6063,15.94,53.8783,16.584,53.8783,17.956
C53.8783,19.426,54.9143,20.126,56.1743,20.126
C57.0143,20.126,57.7843,19.762,58.4703,19.048
C58.4703,19.44,58.5123,19.776,58.6943,20 Z M58.4563,16.766
C58.4563,17.9,57.8963,18.544,56.9023,18.544
C56.2443,18.544,55.8383,18.292,55.8383,17.732
C55.8383,17.158,56.1463,16.948,56.9583,16.794 L57.6303,16.668
C58.1483,16.57,58.2323,16.542,58.4563,16.43 Z" />
<path
android:fillColor="#1a171b"
android:pathData="M65.4933,20 L65.4933,18.628 C65.2973,18.656,65.1853,18.67,65.0453,18.67
C64.5273,18.67,64.4013,18.516,64.4013,17.844 L64.4013,13.896 L65.4933,13.896
L65.4933,12.594 L64.4013,12.594 L64.4013,10.564 L62.4413,10.564 L62.4413,12.594
L61.4753,12.594 L61.4753,13.896 L62.4413,13.896 L62.4413,18.376
C62.4413,19.566,63.0713,20.056,64.3593,20.056
C64.7933,20.056,65.1433,20.014,65.4933,20 Z" />
<path
android:fillColor="#1a171b"
android:pathData="M73.3051,16.5 C73.3051,13.896,71.9891,12.314,69.7631,12.314
C67.5931,12.314,66.2631,13.784,66.2631,16.318
C66.2631,18.74,67.5791,20.126,69.7211,20.126
C71.4151,20.126,72.7871,19.356,73.2211,17.872 L71.2891,17.872
C71.1211,18.418,70.5051,18.628,69.7911,18.628
C68.8671,18.628,68.2791,18.208,68.2231,16.738 L73.2911,16.738 Z M71.2611,15.436
L68.2511,15.436 C68.3771,14.386,68.8671,13.812,69.7351,13.812
C70.5751,13.812,71.1631,14.358,71.2611,15.436 Z" />
<path
android:pathData="M11.18,19.11a4.25,4.25 0,0 1,-1.68 -0.28,1.85 1.85,0 0,1 -0.88,-0.76 2.22,2.22 0,0 1,-0.25 -1.11,6 6,0 0,1 0.17,-1.34l1.92,-8 2.34,-0.36 -2.1,8.69a3.32,3.32 0,0 0,-0.07 0.5,0.87 0.87,0 0,0 0.08,0.4 0.71,0.71 0,0 0,0.31 0.28,1.79 1.79,0 0,0 0.61,0.13l-0.45,1.86"
android:fillColor="#1a171b"/>
<path
android:pathData="M19.63,14.12a5.44,5.44 0,0 1,-0.36 2,5 5,0 0,1 -1,1.58 4.58,4.58 0,0 1,-1.54 1,5 5,0 0,1 -2,0.37 5.86,5.86 0,0 1,-1 -0.09l-0.68,2.73L10.84,21.71l2.5,-10.44a11.85,11.85 0,0 1,1.38 -0.32,8.9 8.9,0 0,1 1.68,-0.15 3.77,3.77 0,0 1,1.46 0.26,2.61 2.61,0 0,1 1,0.7 2.8,2.8 0,0 1,0.58 1,4.09 4.09,0 0,1 0.19,1.28m-5.47,3.09a2.8,2.8 0,0 0,0.63 0.06,2.5 2.5,0 0,0 1.07,-0.22 2.38,2.38 0,0 0,0.82 -0.61,2.87 2.87,0 0,0 0.53,-0.94 3.63,3.63 0,0 0,0.19 -1.22,2 2,0 0,0 -0.29,-1.1 1.08,1.08 0,0 0,-1 -0.45,4.39 4.39,0 0,0 -0.91,0.09l-1.05,4.39"
android:fillColor="#1a171b"/>
</vector>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="80dp"
android:layout_height="28dp"
android:layout_marginEnd="12dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginStart="12dp"
android:contentDescription="@string/menu_liberapay"
android:src="@drawable/donation_option_liberapay" />

View File

@ -170,6 +170,7 @@ This often occurs with apps installed via Google Play or other sources, if they
<string name="menu_bitcoin">Bitcoin</string>
<string name="menu_litecoin">Litecoin</string>
<string name="menu_flattr">Flattr</string>
<string name="menu_liberapay">Liberapay</string>
<string name="main_menu__latest_apps">Latest</string>
<string name="main_menu__categories">Categories</string>

View File

@ -274,6 +274,7 @@ public class IndexV1UpdaterTest extends FDroidProviderTest {
"iconUrlLarge",
"issueTracker",
"lastUpdated",
"liberapayID",
"license",
"litecoin",
"name",