In-app rate flow
This commit is contained in:
parent
a135f5b312
commit
6efc30b17d
7 changed files with 50 additions and 11 deletions
|
@ -41,9 +41,11 @@ android {
|
||||||
productFlavors {
|
productFlavors {
|
||||||
play {
|
play {
|
||||||
buildConfigField 'boolean', 'FIREBASE_AVAILABLE', 'true'
|
buildConfigField 'boolean', 'FIREBASE_AVAILABLE', 'true'
|
||||||
|
buildConfigField 'boolean', 'RATE_APP_AVAILABLE', 'true'
|
||||||
}
|
}
|
||||||
fdroid {
|
fdroid {
|
||||||
buildConfigField 'boolean', 'FIREBASE_AVAILABLE', 'false'
|
buildConfigField 'boolean', 'FIREBASE_AVAILABLE', 'false'
|
||||||
|
buildConfigField 'boolean', 'RATE_APP_AVAILABLE', 'false'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,4 +98,7 @@ dependencies {
|
||||||
|
|
||||||
// Image viewer
|
// Image viewer
|
||||||
implementation 'com.github.stfalcon-studio:StfalconImageViewer:v1.0.1'
|
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'
|
||||||
}
|
}
|
||||||
|
|
7
app/src/fdroid/java/io/heckel/ntfy/util/RateHelper.kt
Normal file
7
app/src/fdroid/java/io/heckel/ntfy/util/RateHelper.kt
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
package io.heckel.ntfy.util
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
|
||||||
|
fun rateApp(activity: Activity) {
|
||||||
|
// Dummy to keep F-Droid flavor happy
|
||||||
|
}
|
|
@ -17,13 +17,12 @@ import android.widget.Toast
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_NO
|
|
||||||
import androidx.appcompat.app.AppCompatDelegate.MODE_NIGHT_YES
|
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import androidx.work.*
|
import androidx.work.*
|
||||||
|
import io.heckel.ntfy.BuildConfig
|
||||||
import io.heckel.ntfy.R
|
import io.heckel.ntfy.R
|
||||||
import io.heckel.ntfy.app.Application
|
import io.heckel.ntfy.app.Application
|
||||||
import io.heckel.ntfy.db.Repository
|
import io.heckel.ntfy.db.Repository
|
||||||
|
@ -260,6 +259,11 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
|
||||||
}
|
}
|
||||||
val mutedUntilSeconds = repository.getGlobalMutedUntil()
|
val mutedUntilSeconds = repository.getGlobalMutedUntil()
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
|
// Show/hide in-app rate widget
|
||||||
|
val rateAppItem = menu.findItem(R.id.main_menu_rate)
|
||||||
|
rateAppItem.isVisible = BuildConfig.RATE_APP_AVAILABLE
|
||||||
|
|
||||||
|
// Pause notification icons
|
||||||
val notificationsEnabledItem = menu.findItem(R.id.main_menu_notifications_enabled)
|
val notificationsEnabledItem = menu.findItem(R.id.main_menu_notifications_enabled)
|
||||||
val notificationsDisabledUntilItem = menu.findItem(R.id.main_menu_notifications_disabled_until)
|
val notificationsDisabledUntilItem = menu.findItem(R.id.main_menu_notifications_disabled_until)
|
||||||
val notificationsDisabledForeverItem = menu.findItem(R.id.main_menu_notifications_disabled_forever)
|
val notificationsDisabledForeverItem = menu.findItem(R.id.main_menu_notifications_disabled_forever)
|
||||||
|
@ -291,12 +295,16 @@ class MainActivity : AppCompatActivity(), ActionMode.Callback, AddFragment.Subsc
|
||||||
startActivity(Intent(this, SettingsActivity::class.java))
|
startActivity(Intent(this, SettingsActivity::class.java))
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.main_menu_source -> {
|
R.id.main_menu_report_bug -> {
|
||||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.main_menu_source_url))))
|
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.main_menu_report_bug_url))))
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.main_menu_website -> {
|
R.id.main_menu_rate -> {
|
||||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(appBaseUrl)))
|
rateApp(this)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
R.id.main_menu_docs -> {
|
||||||
|
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.main_menu_docs_url))))
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
else -> super.onOptionsItemSelected(item)
|
else -> super.onOptionsItemSelected(item)
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<item android:id="@+id/main_menu_notifications_disabled_forever" android:title="@string/detail_menu_notifications_disabled_forever"
|
<item android:id="@+id/main_menu_notifications_disabled_forever" android:title="@string/detail_menu_notifications_disabled_forever"
|
||||||
app:showAsAction="ifRoom" android:icon="@drawable/ic_notifications_off_white_outline_24dp"/>
|
app:showAsAction="ifRoom" android:icon="@drawable/ic_notifications_off_white_outline_24dp"/>
|
||||||
<item android:id="@+id/main_menu_settings" android:title="@string/main_menu_settings_title"/>
|
<item android:id="@+id/main_menu_settings" android:title="@string/main_menu_settings_title"/>
|
||||||
<item android:id="@+id/main_menu_source" android:title="@string/main_menu_source_title"/>
|
<item android:id="@+id/main_menu_docs" android:title="@string/main_menu_docs_title"/>
|
||||||
<item android:id="@+id/main_menu_website" android:title="@string/main_menu_website_title"/>
|
<item android:id="@+id/main_menu_rate" android:title="@string/main_menu_rate_title"/>
|
||||||
|
<item android:id="@+id/main_menu_report_bug" android:title="@string/main_menu_report_bug_title"/>
|
||||||
</menu>
|
</menu>
|
||||||
|
|
|
@ -38,9 +38,11 @@
|
||||||
<string name="main_menu_notifications_disabled_forever">Notifications disabled</string>
|
<string name="main_menu_notifications_disabled_forever">Notifications disabled</string>
|
||||||
<string name="main_menu_notifications_disabled_until">Notifications disabled until %1$s</string>
|
<string name="main_menu_notifications_disabled_until">Notifications disabled until %1$s</string>
|
||||||
<string name="main_menu_settings_title">Settings</string>
|
<string name="main_menu_settings_title">Settings</string>
|
||||||
<string name="main_menu_source_title">Report a bug</string>
|
<string name="main_menu_report_bug_title">Report a bug</string>
|
||||||
<string name="main_menu_source_url">https://github.com/binwiederhier/ntfy/issues</string>
|
<string name="main_menu_report_bug_url">https://github.com/binwiederhier/ntfy/issues</string>
|
||||||
<string name="main_menu_website_title">Visit ntfy.sh</string>
|
<string name="main_menu_docs_title">Read the docs</string>
|
||||||
|
<string name="main_menu_docs_url">https://ntfy.sh/docs</string>
|
||||||
|
<string name="main_menu_rate_title">Rate this app ⭐</string>
|
||||||
|
|
||||||
<!-- Main activity: Action mode -->
|
<!-- Main activity: Action mode -->
|
||||||
<string name="main_action_mode_menu_unsubscribe">Unsubscribe</string>
|
<string name="main_action_mode_menu_unsubscribe">Unsubscribe</string>
|
||||||
|
|
15
app/src/play/java/io/heckel/ntfy/util/RateHelper.kt
Normal file
15
app/src/play/java/io/heckel/ntfy/util/RateHelper.kt
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
package io.heckel.ntfy.util
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import com.google.android.play.core.review.ReviewManagerFactory
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
New features:
|
New features:
|
||||||
|
* Battery improvements: wakelock disabled by default (#76)
|
||||||
* Dark mode: Allow changing app appearance (#102)
|
* Dark mode: Allow changing app appearance (#102)
|
||||||
* Report logs: Copy/export logs to help troubleshooting (#94)
|
* Report logs: Copy/export logs to help troubleshooting (#94)
|
||||||
* WebSockets (experimental): Use WebSockets to subscribe to topics (#96, #100, #97)
|
* WebSockets (experimental): Use WebSockets to subscribe to topics (#96, #100, #97)
|
||||||
|
|
Loading…
Reference in a new issue