Inline app rating since its only ever used in 1 place

This commit is contained in:
Paul Hawke 2025-07-02 16:05:30 -05:00
parent 544e43a7ef
commit c25b5b0533
2 changed files with 15 additions and 16 deletions

View file

@ -1,8 +1,11 @@
package fr.free.nrw.commons
import android.annotation.SuppressLint
import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.Intent.ACTION_VIEW
import android.net.Uri
import android.net.Uri.parse
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
@ -16,7 +19,9 @@ import fr.free.nrw.commons.theme.BaseActivity
import fr.free.nrw.commons.utils.ConfigUtils.getVersionNameWithSha
import fr.free.nrw.commons.utils.DialogUtil.showAlertDialog
import fr.free.nrw.commons.utils.Utils
import fr.free.nrw.commons.utils.Utils.handleWebUrl
import java.util.Collections
import androidx.core.net.toUri
/**
* Represents about screen of this app
@ -131,7 +136,16 @@ class AboutActivity : BaseActivity() {
}
fun launchRatings(view: View?) {
Utils.rateApp(this)
try {
startActivity(
Intent(
ACTION_VIEW,
(Urls.PLAY_STORE_PREFIX + packageName).toUri()
)
)
} catch (_: ActivityNotFoundException) {
handleWebUrl(this, (Urls.PLAY_STORE_URL_PREFIX + packageName).toUri())
}
}
fun launchCredits(view: View?) {

View file

@ -16,7 +16,6 @@ import androidx.browser.customtabs.CustomTabsIntent;
import androidx.core.content.ContextCompat;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Urls;
import java.util.Calendar;
import java.util.Date;
@ -57,20 +56,6 @@ public class Utils {
return title;
}
/**
* Launches intent to rate app
* @param context
*/
public static void rateApp(Context context) {
final String appPackageName = context.getPackageName();
try {
context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Urls.PLAY_STORE_PREFIX + appPackageName)));
}
catch (android.content.ActivityNotFoundException anfe) {
handleWebUrl(context, Uri.parse(Urls.PLAY_STORE_URL_PREFIX + appPackageName));
}
}
/**
* Opens Custom Tab Activity with in-app browser for the specified URL.
* Launches intent for web URL