From d54c138a1dae7102a2541596842a0b9cb761d114 Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Wed, 21 Dec 2016 22:14:23 +1100 Subject: [PATCH 1/3] Work on the "Donate" styles. Still needs some better assets for the actual donate buttons, but now it includes the relevant text about donating to developers. It also puts the donation options in a grid layout and lets them flow across so that if there is more than three, they will end up on the second line. --- app/build.gradle | 2 + .../views/AppDetailsRecyclerViewAdapter.java | 39 ++++++++--- .../res/drawable/donation_option_bitcoin.xml | 33 ++++++++++ .../res/drawable/donation_option_flattr.xml | 9 +++ .../res/drawable/donation_option_litecoin.xml | 64 +++++++++++++++++++ .../main/res/layout/app_details2_donate.xml | 27 +++++--- .../main/res/layout/app_details_summary.xml | 8 +-- app/src/main/res/layout/donate_bitcoin.xml | 11 ++++ app/src/main/res/layout/donate_flattr.xml | 11 ++++ app/src/main/res/layout/donate_generic.xml | 10 +++ app/src/main/res/layout/donate_litecoin.xml | 7 ++ app/src/main/res/values/strings.xml | 3 + 12 files changed, 202 insertions(+), 22 deletions(-) create mode 100644 app/src/main/res/drawable/donation_option_bitcoin.xml create mode 100644 app/src/main/res/drawable/donation_option_flattr.xml create mode 100644 app/src/main/res/drawable/donation_option_litecoin.xml create mode 100644 app/src/main/res/layout/donate_bitcoin.xml create mode 100644 app/src/main/res/layout/donate_flattr.xml create mode 100644 app/src/main/res/layout/donate_generic.xml create mode 100644 app/src/main/res/layout/donate_litecoin.xml diff --git a/app/build.gradle b/app/build.gradle index 1af92e952..68be1b837 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,6 +20,7 @@ repositories { dependencies { compile 'com.android.support:support-v4:24.2.1' compile 'com.android.support:appcompat-v7:24.2.1' + compile 'com.android.support:gridlayout-v7:24.2.1' compile 'com.android.support:support-annotations:24.2.1' compile 'com.android.support:design:24.2.1' compile 'com.android.support:cardview-v7:24.2.1' @@ -105,6 +106,7 @@ if (!hasProperty('sourceDeps')) { 'com.android.support:support-vector-drawable:6ee37a7f7b93c1df1294e6f6f97df3724ac989fcda0549faf677001085330548', 'com.android.support:design:89842bb1243507fe3079066ea4ea58795effe69cdf9a819e05274d21760adfc2', 'com.android.support:cardview-v7:2303b351686d1db060b5fcf1a9c709c79b4a54a85bfda0fb3c4849e244606ee1', + 'com.android.support:gridlayout-v7:1a31c248d69faa815cc155883ddcb0ccc7ba8e14e69ec58dd18d8017e23d76f5', 'com.android.support:recyclerview-v7:9077766a1a0f4e89528fbf9dcdf6d5880a8686f0266fa852d58d803beeef18fa', 'com.google.zxing:core:b4d82452e7a6bf6ec2698904b332431717ed8f9a850224f295aec89de80f2259', 'com.madgag.spongycastle:core:9b6b7ac856b91bcda2ede694eccd26cefb0bf0b09b89f13cda05b5da5ff68c6b', diff --git a/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java index a14b8602d..19c49418e 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java +++ b/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java @@ -6,10 +6,12 @@ import android.content.Context; import android.content.Intent; import android.graphics.Bitmap; import android.net.Uri; +import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; import android.support.v4.view.ViewCompat; import android.support.v4.widget.TextViewCompat; import android.support.v7.text.AllCapsTransformationMethod; +import android.support.v7.widget.GridLayout; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.text.Html; @@ -503,38 +505,57 @@ public class AppDetailsRecyclerViewAdapter } private class DonateViewHolder extends RecyclerView.ViewHolder { - final TextView textView; - final LinearLayout contentView; + final TextView donateHeading; + final GridLayout donationOptionsLayout; DonateViewHolder(View view) { super(view); - textView = (TextView) view.findViewById(R.id.information); - contentView = (LinearLayout) view.findViewById(R.id.ll_information); + donateHeading = (TextView) view.findViewById(R.id.donate_header); + donationOptionsLayout = (GridLayout) view.findViewById(R.id.donation_options); } public void bindModel() { - contentView.removeAllViews(); + if (TextUtils.isEmpty(app.author)) { + donateHeading.setText(context.getString(R.string.app_details_donate_prompt_unknown_author, app.name)); + } else { + String author = "" + app.author + ""; + donateHeading.setText(Html.fromHtml(context.getString(R.string.app_details_donate_prompt, app.name, author))); + } + + donationOptionsLayout.removeAllViews(); // Donate button if (uriIsSetAndCanBeOpened(app.donateURL)) { - addLinkItemView(contentView, R.string.menu_donate, R.drawable.ic_donate, app.donateURL); + addDonateOption(R.layout.donate_generic, app.donateURL); } // Bitcoin if (uriIsSetAndCanBeOpened(app.getBitcoinUri())) { - addLinkItemView(contentView, R.string.menu_bitcoin, R.drawable.ic_bitcoin, app.getBitcoinUri()); + addDonateOption(R.layout.donate_bitcoin, app.getBitcoinUri()); } // Litecoin if (uriIsSetAndCanBeOpened(app.getLitecoinUri())) { - addLinkItemView(contentView, R.string.menu_litecoin, R.drawable.ic_litecoin, app.getLitecoinUri()); + addDonateOption(R.layout.donate_litecoin, app.getLitecoinUri()); } // Flattr if (uriIsSetAndCanBeOpened(app.getFlattrUri())) { - addLinkItemView(contentView, R.string.menu_flattr, R.drawable.ic_flattr, app.getFlattrUri()); + addDonateOption(R.layout.donate_flattr, app.getFlattrUri()); } } + + private void addDonateOption(@LayoutRes int layout, final String uri) { + LayoutInflater inflater = LayoutInflater.from(context); + View option = inflater.inflate(layout, donationOptionsLayout, false); + option.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + onLinkClicked(uri); + } + }); + donationOptionsLayout.addView(option); + } } private abstract class ExpandableLinearLayoutViewHolder extends RecyclerView.ViewHolder { diff --git a/app/src/main/res/drawable/donation_option_bitcoin.xml b/app/src/main/res/drawable/donation_option_bitcoin.xml new file mode 100644 index 000000000..a4a1aa5ff --- /dev/null +++ b/app/src/main/res/drawable/donation_option_bitcoin.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/donation_option_flattr.xml b/app/src/main/res/drawable/donation_option_flattr.xml new file mode 100644 index 000000000..8fad0face --- /dev/null +++ b/app/src/main/res/drawable/donation_option_flattr.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/app/src/main/res/drawable/donation_option_litecoin.xml b/app/src/main/res/drawable/donation_option_litecoin.xml new file mode 100644 index 000000000..6a7be5275 --- /dev/null +++ b/app/src/main/res/drawable/donation_option_litecoin.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/app_details2_donate.xml b/app/src/main/res/layout/app_details2_donate.xml index b50d20924..b6d8d5204 100644 --- a/app/src/main/res/layout/app_details2_donate.xml +++ b/app/src/main/res/layout/app_details2_donate.xml @@ -1,19 +1,28 @@ - + android:padding="@dimen/details_activity_padding"> + + android:id="@+id/donate_header" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:textSize="15sp" + android:textAlignment="center" + tools:text="F-Droid is created by F-Droid Limited and Contributors. Buy them a coffee!" + android:layout_marginBottom="12dp" /> + + + diff --git a/app/src/main/res/layout/app_details_summary.xml b/app/src/main/res/layout/app_details_summary.xml index 7d4738445..6044c330d 100644 --- a/app/src/main/res/layout/app_details_summary.xml +++ b/app/src/main/res/layout/app_details_summary.xml @@ -184,15 +184,15 @@ Changelog" /> diff --git a/app/src/main/res/layout/donate_bitcoin.xml b/app/src/main/res/layout/donate_bitcoin.xml new file mode 100644 index 000000000..2ba601ee6 --- /dev/null +++ b/app/src/main/res/layout/donate_bitcoin.xml @@ -0,0 +1,11 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/donate_flattr.xml b/app/src/main/res/layout/donate_flattr.xml new file mode 100644 index 000000000..e78df12c6 --- /dev/null +++ b/app/src/main/res/layout/donate_flattr.xml @@ -0,0 +1,11 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/donate_generic.xml b/app/src/main/res/layout/donate_generic.xml new file mode 100644 index 000000000..a683887ef --- /dev/null +++ b/app/src/main/res/layout/donate_generic.xml @@ -0,0 +1,10 @@ + + \ No newline at end of file diff --git a/app/src/main/res/layout/donate_litecoin.xml b/app/src/main/res/layout/donate_litecoin.xml new file mode 100644 index 000000000..beca15e9f --- /dev/null +++ b/app/src/main/res/layout/donate_litecoin.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c6589d552..988bae209 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -48,6 +48,9 @@ App Details No such app found. + Buy the developers of %1$s a coffee! + %1$s is created by %2$s. Buy them a coffee! + About F-Droid Version Website From 6a6cede4dea0a564a95a563e0ab46123694d1053 Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Wed, 21 Dec 2016 22:16:09 +1100 Subject: [PATCH 2/3] More specific paddings round the "collapsable lists" at the bottom of app details. Also tried a more specific naming scheme for dimens to make it clearer where they are to be used. This increased the padding on the left/right of the collapsable lists. It also decreased the padding above/below. --- app/src/main/res/layout/app_details2_links.xml | 11 ++++++++++- app/src/main/res/values/dimens.xml | 7 ++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/layout/app_details2_links.xml b/app/src/main/res/layout/app_details2_links.xml index 830cb42ab..0ff67bbc1 100644 --- a/app/src/main/res/layout/app_details2_links.xml +++ b/app/src/main/res/layout/app_details2_links.xml @@ -5,7 +5,12 @@ android:id="@+id/ll_information" android:layout_width="fill_parent" android:layout_height="wrap_content" - android:layout_margin="@dimen/details_activity_padding" + android:layout_marginStart="@dimen/details_activity_padding" + android:layout_marginLeft="@dimen/details_activity_padding" + android:layout_marginEnd="@dimen/details_activity_padding" + android:layout_marginRight="@dimen/details_activity_padding" + android:layout_marginTop="@dimen/details_activity__collapsable_lists__padding__vertical" + android:layout_marginBottom="@dimen/details_activity__collapsable_lists__padding__vertical" android:clickable="true" android:orientation="vertical" tools:ignore="UnusedAttribute"> @@ -13,6 +18,10 @@ android:id="@+id/information" style="@style/AppDetailsSubheaderText" android:text="@string/links" + android:paddingLeft="@dimen/details_activity__collapsable_lists__padding__horizontal" + android:paddingStart="@dimen/details_activity__collapsable_lists__padding__horizontal" + android:paddingRight="@dimen/details_activity__collapsable_lists__padding__horizontal" + android:paddingEnd="@dimen/details_activity__collapsable_lists__padding__horizontal" android:drawableRight="@drawable/ic_expand_more_grey600" android:drawableEnd="@drawable/ic_expand_more_grey600" android:drawableLeft="@drawable/ic_website" diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index c85219705..20d2d578d 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -4,7 +4,12 @@ 16dp 48dp 180dp - 8dp + 16dp + + 3dp + + 4dp 200dp 200dp From 75eb72c50b45ff6ab68233c470836937057b1816 Mon Sep 17 00:00:00 2001 From: Peter Serwylo Date: Wed, 22 Feb 2017 10:18:09 +1100 Subject: [PATCH 3/3] Show material-design-ripple in background when touching list item. Also ensure it shows this animation correctly when expanding "Versions". This is done by changing from `notifyDataSetChanged()` to the more specific `notifyItemRange(Inserted|Removed)`, which ensures the "Versions" item doesn't get rebuilt midway through an animation. --- .../views/AppDetailsRecyclerViewAdapter.java | 14 +++++++-- .../res/layout/app_details2_link_item.xml | 5 ++-- .../main/res/layout/app_details2_links.xml | 30 +++++++++++-------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java b/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java index 19c49418e..e8ac029af 100644 --- a/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java +++ b/app/src/main/java/org/fdroid/fdroid/views/AppDetailsRecyclerViewAdapter.java @@ -135,11 +135,19 @@ public class AppDetailsRecyclerViewAdapter private void setShowVersions(boolean showVersions) { this.showVersions = showVersions; - items.removeAll(versions); + boolean itemsWereRemoved = items.removeAll(versions); + int startIndex = items.indexOf(VIEWTYPE_VERSIONS) + 1; + + // When adding/removing items, be sure to only notifyItemInserted and notifyItemRemoved + // rather than notifyDatasetChanged(). If we only notify about the entire thing, then + // everything gets rebuilt, including the expandable "Versions" item. By rebuilding that + // item it will interrupt the nice material-design-style-ripple from the background. if (showVersions) { - items.addAll(items.indexOf(VIEWTYPE_VERSIONS) + 1, versions); + items.addAll(startIndex, versions); + notifyItemRangeInserted(startIndex, versions.size()); + } else if (itemsWereRemoved) { + notifyItemRangeRemoved(startIndex, versions.size()); } - notifyDataSetChanged(); } private void addItem(int item) { diff --git a/app/src/main/res/layout/app_details2_link_item.xml b/app/src/main/res/layout/app_details2_link_item.xml index 35bcba867..f157cbf4d 100644 --- a/app/src/main/res/layout/app_details2_link_item.xml +++ b/app/src/main/res/layout/app_details2_link_item.xml @@ -1,9 +1,10 @@ \ No newline at end of file + tools:text="@string/menu_website" /> \ No newline at end of file diff --git a/app/src/main/res/layout/app_details2_links.xml b/app/src/main/res/layout/app_details2_links.xml index 0ff67bbc1..11f50ce9f 100644 --- a/app/src/main/res/layout/app_details2_links.xml +++ b/app/src/main/res/layout/app_details2_links.xml @@ -14,18 +14,24 @@ android:clickable="true" android:orientation="vertical" tools:ignore="UnusedAttribute"> - + + + + + +