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