From cfc1449615559e8c8326071906d18393d6098d76 Mon Sep 17 00:00:00 2001 From: Ayushi Negi Date: Wed, 7 Mar 2018 06:44:51 +0530 Subject: [PATCH] Launch Rate Us Feature from AboutActivity (#1264) * Launch Rate Us Feature from AboutActivity Rate us feature is added in Utils, But it is never used/launched. * Add LaunchRatings Method in AboutActivity * Fix Package Name to enable rate us feature The rate us feature was not working for the debug build type since getPackageName() was returning the fr.free.nrw.commons.debug. Use of this package name was leading to an error on google play. * Replace getPackageName() with BuildConfig.class.getPackage().getName() in rateApp method of Utils.java --- app/src/main/java/fr/free/nrw/commons/AboutActivity.java | 6 +++++- app/src/main/java/fr/free/nrw/commons/Utils.java | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/AboutActivity.java b/app/src/main/java/fr/free/nrw/commons/AboutActivity.java index 91a4f6eb9..bb7b1fc1e 100644 --- a/app/src/main/java/fr/free/nrw/commons/AboutActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/AboutActivity.java @@ -86,7 +86,11 @@ public class AboutActivity extends NavigationBaseActivity { } } - + @OnClick(R.id.about_rate_us) + public void launchRatings(View view){ + Utils.rateApp(this); + } + @OnClick(R.id.about_credits) public void launchCredits(View view) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/commons-app/apps-android-commons/blob/master/CREDITS/\\")); diff --git a/app/src/main/java/fr/free/nrw/commons/Utils.java b/app/src/main/java/fr/free/nrw/commons/Utils.java index 1044a7c17..2b6ba9907 100644 --- a/app/src/main/java/fr/free/nrw/commons/Utils.java +++ b/app/src/main/java/fr/free/nrw/commons/Utils.java @@ -166,14 +166,13 @@ public class Utils { } public static void rateApp(Context context) { - final String appPackageName = context.getPackageName(); + final String appPackageName = BuildConfig.class.getPackage().getName(); try { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) { context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName))); } - return ; } public static void handleWebUrl(Context context,Uri url){