diff --git a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt index 122ec8d5f0..a7e15ea2fa 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt @@ -50,7 +50,6 @@ import info.nightscout.androidaps.plugins.source.EversensePlugin import info.nightscout.androidaps.plugins.source.GlimpPlugin import info.nightscout.androidaps.plugins.source.PoctechPlugin import info.nightscout.androidaps.plugins.source.TomatoPlugin -import info.nightscout.androidaps.utils.CryptoUtil import info.nightscout.androidaps.utils.OKDialog.show import info.nightscout.androidaps.utils.SafeParse import info.nightscout.androidaps.utils.protection.PasswordCheck @@ -189,7 +188,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang addPreferencesFromResource(R.xml.pref_datachoices, rootKey) addPreferencesFromResourceIfEnabled(maintenancePlugin, rootKey) } - initSummary(preferenceScreen) + initSummary(preferenceScreen, pluginId != -1) for (plugin in pluginStore.plugins) { plugin.preprocessPreferences(this) } @@ -287,22 +286,27 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang } if (pref is Preference) { - if ((pref.getKey() != null) && (pref.getKey().contains("_password"))) { - if (sp.getString(pref.getKey(), "").startsWith("hmac:")) { - pref.setSummary("******") + if ((pref.key != null) && (pref.key.contains("_password"))) { + if (sp.getString(pref.key, "").startsWith("hmac:")) { + pref.summary = "******" } else { - pref.setSummary(resourceHelper.gs(R.string.password_not_set)) + pref.summary = resourceHelper.gs(R.string.password_not_set) } } } pref?.let { adjustUnitDependentPrefs(it) } } - private fun initSummary(p: Preference) { + private fun initSummary(p: Preference, isSinglePreference: Boolean) { p.isIconSpaceReserved = false // remove extra spacing on left after migration to androidx + // expand single plugin preference by default + if (p is PreferenceScreen && isSinglePreference) { + if (p.size > 0 && p.getPreference(0) is PreferenceCategory) + (p.getPreference(0) as PreferenceCategory).initialExpandedChildrenCount = Int.MAX_VALUE + } if (p is PreferenceGroup) { for (i in 0 until p.preferenceCount) { - initSummary(p.getPreference(i)) + initSummary(p.getPreference(i), isSinglePreference) } } else { updatePrefSummary(p) @@ -313,22 +317,24 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang // to hash password while it is saved and never have to show it, even hashed override fun onPreferenceTreeClick(preference: Preference?): Boolean { - if (preference != null) { - if (preference.key == resourceHelper.gs(R.string.key_master_password)) { - passwordCheck.setPassword(this.context!!, R.string.master_password, R.string.key_master_password) - return true; - } - if (preference.key == resourceHelper.gs(R.string.key_settings_password)) { - passwordCheck.setPassword(this.context!!, R.string.settings_password, R.string.key_settings_password) - return true; - } - if (preference.key == resourceHelper.gs(R.string.key_bolus_password)) { - passwordCheck.setPassword(this.context!!, R.string.bolus_password, R.string.key_bolus_password) - return true; - } - if (preference.key == resourceHelper.gs(R.string.key_application_password)) { - passwordCheck.setPassword(this.context!!, R.string.application_password, R.string.key_application_password) - return true; + context?.let { context -> + if (preference != null) { + if (preference.key == resourceHelper.gs(R.string.key_master_password)) { + passwordCheck.setPassword(context, R.string.master_password, R.string.key_master_password) + return true + } + if (preference.key == resourceHelper.gs(R.string.key_settings_password)) { + passwordCheck.setPassword(context, R.string.settings_password, R.string.key_settings_password) + return true + } + if (preference.key == resourceHelper.gs(R.string.key_bolus_password)) { + passwordCheck.setPassword(context, R.string.bolus_password, R.string.key_bolus_password) + return true + } + if (preference.key == resourceHelper.gs(R.string.key_application_password)) { + passwordCheck.setPassword(context, R.string.application_password, R.string.key_application_password) + return true + } } } return super.onPreferenceTreeClick(preference) diff --git a/app/src/main/res/xml/pref_wear.xml b/app/src/main/res/xml/pref_wear.xml index a18d77061b..855ae4a9af 100644 --- a/app/src/main/res/xml/pref_wear.xml +++ b/app/src/main/res/xml/pref_wear.xml @@ -15,8 +15,7 @@ + android:title="@string/wear_wizard_settings"> + android:title="@string/wear_display_settings"> + android:title="@string/wear_general_settings">