Add option to give Feedback on Google Play

Add button in the 'Launcher' tab in the settings
This commit is contained in:
Finn M Glas 2020-05-21 09:20:18 +02:00
parent 716839e1b9
commit 817fe0d732
No known key found for this signature in database
GPG key ID: 25037A2E81AB459C
3 changed files with 40 additions and 0 deletions

View file

@ -2,6 +2,7 @@ package com.finnmglas.launcher
import android.app.AlertDialog
import android.content.*
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.provider.Settings
@ -81,6 +82,34 @@ class SettingsActivity : AppCompatActivity() {
fun openFinnWebsite(view: View) { openNewTabWindow(getString(R.string.settings_footer_web), this) }
fun openGithubRepo(view: View) { openNewTabWindow(getString(R.string.settings_footer_repo), this) }
// Just copied code from https://stackoverflow.com/q/10816757/12787264
// that is how we write good software ^
fun rateApp(view: View) {
try {
val rateIntent = rateIntentForUrl("market://details")
startActivity(rateIntent)
} catch (e: ActivityNotFoundException) {
val rateIntent = rateIntentForUrl("https://play.google.com/store/apps/details")
startActivity(rateIntent)
}
}
private fun rateIntentForUrl(url: String): Intent {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse(String.format("%s?id=%s", url, packageName))
)
var flags = Intent.FLAG_ACTIVITY_NO_HISTORY or Intent.FLAG_ACTIVITY_MULTIPLE_TASK
flags = if (Build.VERSION.SDK_INT >= 21) {
flags or Intent.FLAG_ACTIVITY_NEW_DOCUMENT
} else {
flags or Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET
}
intent.addFlags(flags)
return intent
}
fun backHome(view: View) { finish() }
fun setLauncher(view: View) {

View file

@ -23,10 +23,19 @@
style="@style/Widget.AppCompat.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="32sp"
android:onClick="resetSettingsClick"
android:text="@string/settings_reset"
android:textAllCaps="false" />
<Button
style="@style/Widget.AppCompat.Button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="rateApp"
android:text="@string/settings_feedback"
android:textAllCaps="false" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View file

@ -22,6 +22,8 @@
<string name="settings_tab_theme" translatable="false">Theme</string>
<string name="settings_tab_launcher" translatable="false">Launcher</string>
<string name="settings_feedback" translatable="false">Give some feedback</string>
<string name="settings_choose_up">Swipe Up</string>
<string name="settings_choose_down">Swipe Down</string>
<string name="settings_choose_left">Swipe Left</string>