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
This commit is contained in:
Ayushi Negi 2018-03-07 06:44:51 +05:30 committed by Vivek Maskara
parent 51221f69c2
commit cfc1449615
2 changed files with 6 additions and 3 deletions

View file

@ -86,6 +86,10 @@ public class AboutActivity extends NavigationBaseActivity {
} }
} }
@OnClick(R.id.about_rate_us)
public void launchRatings(View view){
Utils.rateApp(this);
}
@OnClick(R.id.about_credits) @OnClick(R.id.about_credits)
public void launchCredits(View view) { public void launchCredits(View view) {

View file

@ -166,14 +166,13 @@ public class Utils {
} }
public static void rateApp(Context context) { public static void rateApp(Context context) {
final String appPackageName = context.getPackageName(); final String appPackageName = BuildConfig.class.getPackage().getName();
try { try {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
} }
catch (android.content.ActivityNotFoundException anfe) { catch (android.content.ActivityNotFoundException anfe) {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName))); 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){ public static void handleWebUrl(Context context,Uri url){