Issue 1589: Fixed crash after choosing Settings/Rate app when there's no Play Store on the device (#1590)

* Using startActivitySafely when launching Play Store

* Returning true for rateApp click
feature/deps
Jakub Kalinowski 3 years ago committed by GitHub
parent d24dcbf2ca
commit c7d1e92cae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22,6 +22,7 @@ import android.app.backup.BackupManager
import android.content.Intent
import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.net.Uri
import android.os.Bundle
import android.provider.Settings
import android.util.Log
@ -43,6 +44,7 @@ import org.isoron.uhabits.core.utils.DateUtils.Companion.getLongWeekdayNames
import org.isoron.uhabits.notifications.AndroidNotificationTray.Companion.createAndroidNotificationChannel
import org.isoron.uhabits.notifications.RingtoneManager
import org.isoron.uhabits.utils.StyledResources
import org.isoron.uhabits.utils.startActivitySafely
import org.isoron.uhabits.widgets.WidgetUpdater
import java.util.Calendar
@ -92,10 +94,12 @@ class SettingsFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeLis
override fun onPreferenceTreeClick(preference: Preference): Boolean {
val key = preference.key ?: return false
if (key == "reminderSound") {
when (key) {
"reminderSound" -> {
showRingtonePicker()
return true
} else if (key == "reminderCustomize") {
}
"reminderCustomize" -> {
createAndroidNotificationChannel(requireContext())
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
intent.putExtra(Settings.EXTRA_APP_PACKAGE, requireContext().packageName)
@ -103,6 +107,12 @@ class SettingsFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeLis
startActivity(intent)
return true
}
"rateApp" -> {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.playStoreURL)))
activity?.startActivitySafely(intent)
return true
}
}
return super.onPreferenceTreeClick(preference)
}

@ -160,11 +160,9 @@
</Preference>
<Preference
android:key="rateApp"
android:title="@string/pref_rate_this_app"
app:iconSpaceReserved="false">
<intent
android:action="android.intent.action.VIEW"
android:data="@string/playStoreURL" />
</Preference>
<Preference

Loading…
Cancel
Save