android/lib/build.gradle | 2 android/lib/libSettings.gradle.in | 1 android/lib/src/main/java/org/libreoffice/androidlib/RateAppController.java | 36 +++++----- android/lib/src/main/res/layout/rate_app_layout.xml | 22 +++--- android/lib/src/main/res/values/strings.xml | 3 5 files changed, 38 insertions(+), 26 deletions(-)
New commits: commit b5e599f3c92c45b19e706c987d6b72b8263559b8 Author: Jan Holesovsky <[email protected]> AuthorDate: Wed Mar 18 00:31:43 2020 +0100 Commit: Jan Holesovsky <[email protected]> CommitDate: Wed Mar 18 00:37:03 2020 +0100 android: Beautify the rating dialog. Change-Id: I2114b42cf0f21526ab4035c1ad69ba25dee4aa7b Reviewed-on: https://gerrit.libreoffice.org/c/online/+/90678 Tested-by: Jan Holesovsky <[email protected]> Reviewed-by: Jan Holesovsky <[email protected]> diff --git a/android/lib/build.gradle b/android/lib/build.gradle index ceac6b811..812a8a7aa 100644 --- a/android/lib/build.gradle +++ b/android/lib/build.gradle @@ -24,6 +24,7 @@ android { buildTypes { debug { + resValue "string", "app_name", "${liboAppName} Debug" buildConfigField "String", "GIT_COMMIT", "\"${liboGitFullCommit}\"" buildConfigField "boolean", "GOOGLE_PLAY_ENABLED", "${liboGooglePlay}" ndk { @@ -33,6 +34,7 @@ android { debuggable true } release { + resValue "string", "app_name", "${liboAppName}" buildConfigField "String", "GIT_COMMIT", "\"${liboGitFullCommit}\"" buildConfigField "boolean", "GOOGLE_PLAY_ENABLED", "${liboGooglePlay}" ndk { diff --git a/android/lib/libSettings.gradle.in b/android/lib/libSettings.gradle.in index 3b6208fb7..9bcd1b58b 100644 --- a/android/lib/libSettings.gradle.in +++ b/android/lib/libSettings.gradle.in @@ -1,4 +1,5 @@ ext { + liboAppName = '@APP_NAME@' liboSrcRoot = '@LOBUILDDIR@' liboInstdir = '@LOBUILDDIR@/instdir' liboEtcFolder = 'program' diff --git a/android/lib/src/main/java/org/libreoffice/androidlib/RateAppController.java b/android/lib/src/main/java/org/libreoffice/androidlib/RateAppController.java index 57a7717f0..1f652d12b 100644 --- a/android/lib/src/main/java/org/libreoffice/androidlib/RateAppController.java +++ b/android/lib/src/main/java/org/libreoffice/androidlib/RateAppController.java @@ -9,9 +9,11 @@ package org.libreoffice.androidlib; +import android.annotation.SuppressLint; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; +import android.view.MotionEvent; import android.view.View; import android.widget.RatingBar; @@ -57,28 +59,32 @@ public class RateAppController { if (!shouldAsk()) return; - AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); final View rateAppLayout = mActivity.getLayoutInflater().inflate(R.layout.rate_app_layout, null); - builder.setView(rateAppLayout); - builder.setPositiveButton(R.string.rate_now, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - // start google play activity for rating - openInGooglePlay(); - } - }); - builder.setNegativeButton(R.string.later, null); + AlertDialog.Builder builder = new AlertDialog.Builder(mActivity); + builder.setView(rateAppLayout) + .setTitle(String.format(mActivity.getString(R.string.rate_our_app_title), mActivity.getString(R.string.app_name))) + .setPositiveButton(R.string.rate_now, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + // start google play activity for rating + openInGooglePlay(); + } + }) + .setNegativeButton(R.string.later, null); final AlertDialog alertDialog = builder.create(); RatingBar ratingBar = rateAppLayout.findViewById(R.id.ratingBar); - ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() { + ratingBar.setOnTouchListener(new View.OnTouchListener() { @Override - public void onRatingChanged(RatingBar ratingBar1, float v, boolean b) { - // start google play activity for rating - openInGooglePlay(); - alertDialog.dismiss(); + public boolean onTouch(View v, MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_UP) { + // start google play activity for rating + openInGooglePlay(); + alertDialog.dismiss(); + } + return true; } }); alertDialog.show(); diff --git a/android/lib/src/main/res/layout/rate_app_layout.xml b/android/lib/src/main/res/layout/rate_app_layout.xml index 21e28be9e..608f7c76e 100644 --- a/android/lib/src/main/res/layout/rate_app_layout.xml +++ b/android/lib/src/main/res/layout/rate_app_layout.xml @@ -1,28 +1,30 @@ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:orientation="vertical" android:layout_width="match_parent" - android:layout_height="wrap_content"> - + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingStart="36dp" + android:paddingTop="24dp" + android:paddingEnd="36dp" + android:paddingBottom="12dp"> <TextView android:id="@+id/textView2" android:layout_width="match_parent" android:layout_height="wrap_content" + android:paddingBottom="24dp" android:text="@string/rate_our_app_text" - android:padding="10dp" - android:textColor="@color/text_color_secondary"/> + android:textAlignment="center" /> <RatingBar android:id="@+id/ratingBar" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_gravity="center" android:indeterminate="false" android:isIndicator="false" android:max="5" android:numStars="5" - android:rating="0" - android:stepSize="1" - android:layout_gravity="center" - android:layout_margin="12dp" - /> + android:rating="5" + android:stepSize="1" /> </LinearLayout> \ No newline at end of file diff --git a/android/lib/src/main/res/values/strings.xml b/android/lib/src/main/res/values/strings.xml index 674c3b62e..176a41790 100644 --- a/android/lib/src/main/res/values/strings.xml +++ b/android/lib/src/main/res/values/strings.xml @@ -8,7 +8,8 @@ <string name="preparing_for_the_first_start_after_an_update">Preparing for the first start after an update.</string> <string name="rate_now">Rate now</string> <string name="later">Later</string> - <string name="rate_our_app_text">Thank you for using our app! If you enjoy using it, please give us a 5-stars review in Google Play.</string> + <string name="rate_our_app_title">Thank you for using %1$s!</string> + <string name="rate_our_app_text">If you like it, please give us 5 stars in Google Play. Your good reviews are our best motivation.</string> <!-- Loading SlideShow Dialog Strings --> <string name="loading">Loading...</string> _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
