Remove in-app rating; replace with Google Play link

This commit is contained in:
Philipp Heckel 2022-01-21 09:40:09 -05:00
parent 04c4bc2d5b
commit 0e2899c419
4 changed files with 8 additions and 29 deletions

View file

@ -12,8 +12,8 @@ android {
minSdkVersion 21
targetSdkVersion 30
versionCode 17
versionName "1.7.0"
versionCode 18
versionName "1.7.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@ -98,7 +98,4 @@ dependencies {
// Image viewer
implementation 'com.github.stfalcon-studio:StfalconImageViewer:v1.0.1'
// For "Rate this app" menu item (Google Play only)
playImplementation 'com.google.android.play:core-ktx:1.8.1'
}

View file

@ -1,7 +0,0 @@
package io.heckel.ntfy.util
import android.app.Activity
fun rateApp(activity: Activity) {
// Dummy to keep F-Droid flavor happy
}

View file

@ -3,6 +3,7 @@ package io.heckel.ntfy.ui
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.app.AlertDialog
import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Build
@ -300,7 +301,11 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
true
}
R.id.main_menu_rate -> {
rateApp(this)
try {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$packageName")))
} catch (e: ActivityNotFoundException) {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=$packageName")))
}
true
}
R.id.main_menu_docs -> {

View file

@ -1,16 +0,0 @@
package io.heckel.ntfy.util
import android.app.Activity
import com.google.android.play.core.review.ReviewManagerFactory
import io.heckel.ntfy.log.Log
// Open the in-app rate dialog, see https://developer.android.com/guide/playcore/in-app-review/kotlin-java
fun rateApp(activity: Activity) {
val manager = ReviewManagerFactory.create(activity)
val request = manager.requestReviewFlow()
request.addOnCompleteListener { task ->
if (task.isSuccessful) {
manager.launchReviewFlow(activity, task.result)
}
}
}