mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Inline app rating since its only ever used in 1 place
This commit is contained in:
parent
544e43a7ef
commit
c25b5b0533
2 changed files with 15 additions and 16 deletions
|
|
@ -1,8 +1,11 @@
|
||||||
package fr.free.nrw.commons
|
package fr.free.nrw.commons
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.Intent.ACTION_VIEW
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.net.Uri.parse
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
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.ConfigUtils.getVersionNameWithSha
|
||||||
import fr.free.nrw.commons.utils.DialogUtil.showAlertDialog
|
import fr.free.nrw.commons.utils.DialogUtil.showAlertDialog
|
||||||
import fr.free.nrw.commons.utils.Utils
|
import fr.free.nrw.commons.utils.Utils
|
||||||
|
import fr.free.nrw.commons.utils.Utils.handleWebUrl
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
|
import androidx.core.net.toUri
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents about screen of this app
|
* Represents about screen of this app
|
||||||
|
|
@ -131,7 +136,16 @@ class AboutActivity : BaseActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun launchRatings(view: View?) {
|
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?) {
|
fun launchCredits(view: View?) {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ import androidx.browser.customtabs.CustomTabsIntent;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.Urls;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
@ -57,20 +56,6 @@ public class Utils {
|
||||||
return title;
|
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.
|
* Opens Custom Tab Activity with in-app browser for the specified URL.
|
||||||
* Launches intent for web URL
|
* Launches intent for web URL
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue