mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
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
This commit is contained in:
@@ -22,6 +22,7 @@ import android.app.backup.BackupManager
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.util.Log
|
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.AndroidNotificationTray.Companion.createAndroidNotificationChannel
|
||||||
import org.isoron.uhabits.notifications.RingtoneManager
|
import org.isoron.uhabits.notifications.RingtoneManager
|
||||||
import org.isoron.uhabits.utils.StyledResources
|
import org.isoron.uhabits.utils.StyledResources
|
||||||
|
import org.isoron.uhabits.utils.startActivitySafely
|
||||||
import org.isoron.uhabits.widgets.WidgetUpdater
|
import org.isoron.uhabits.widgets.WidgetUpdater
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
|
|
||||||
@@ -92,10 +94,12 @@ class SettingsFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeLis
|
|||||||
|
|
||||||
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||||
val key = preference.key ?: return false
|
val key = preference.key ?: return false
|
||||||
if (key == "reminderSound") {
|
when (key) {
|
||||||
|
"reminderSound" -> {
|
||||||
showRingtonePicker()
|
showRingtonePicker()
|
||||||
return true
|
return true
|
||||||
} else if (key == "reminderCustomize") {
|
}
|
||||||
|
"reminderCustomize" -> {
|
||||||
createAndroidNotificationChannel(requireContext())
|
createAndroidNotificationChannel(requireContext())
|
||||||
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
||||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, requireContext().packageName)
|
intent.putExtra(Settings.EXTRA_APP_PACKAGE, requireContext().packageName)
|
||||||
@@ -103,6 +107,12 @@ class SettingsFragment : PreferenceFragmentCompat(), OnSharedPreferenceChangeLis
|
|||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
"rateApp" -> {
|
||||||
|
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(getString(R.string.playStoreURL)))
|
||||||
|
activity?.startActivitySafely(intent)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
return super.onPreferenceTreeClick(preference)
|
return super.onPreferenceTreeClick(preference)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,11 +160,9 @@
|
|||||||
</Preference>
|
</Preference>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
|
android:key="rateApp"
|
||||||
android:title="@string/pref_rate_this_app"
|
android:title="@string/pref_rate_this_app"
|
||||||
app:iconSpaceReserved="false">
|
app:iconSpaceReserved="false">
|
||||||
<intent
|
|
||||||
android:action="android.intent.action.VIEW"
|
|
||||||
android:data="@string/playStoreURL" />
|
|
||||||
</Preference>
|
</Preference>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
|
|||||||
Reference in New Issue
Block a user