This commit is contained in:
LagradOst 2021-08-31 00:07:39 +02:00
parent bb2f8a3e56
commit 3e3e1b6a9d

View file

@ -35,6 +35,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
}
private fun saveAndUpload() {
if (ScoreManager.privateCode.isNullOrBlank()) return
try {
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
val uuid = usernameUUID
if (uuid != null) {
@ -48,6 +50,9 @@ class SettingsFragment : PreferenceFragmentCompat() {
}
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
override fun onPause() {
@ -61,17 +66,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
}
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
hideKeyboard()
setPreferencesFromResource(R.xml.settings, rootKey)
val updatePrefrence = findPreference<Preference>(getString(R.string.manual_check_update_key))!!
val benenePref = findPreference<Preference>(getString(R.string.benene_count))!!
if (ScoreManager.privateCode.isNullOrBlank()) {
benenePref.isVisible = false
} else {
benenePref.isVisible = true
try {
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
@ -79,10 +79,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
usernameUUID =
settingsManager.getString(getString(R.string.benene_count_uuid), UUID.randomUUID().toString())
if (count > 20) {
if (!ScoreManager.privateCode.isNullOrBlank()) {
thread {
scoreboard = normalSafeApiCall { ScoreManager.getScore() }
}
}
}
benenePref.summary =
if (count <= 0) getString(R.string.benene_count_text_none) else getString(R.string.benene_count_text).format(
count
@ -112,8 +114,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
} catch (e: Exception) {
e.printStackTrace()
}
}
updatePrefrence.setOnPreferenceClickListener {
thread {