From 21a3069a401376fc94440f48293e8f2bf66ba4fc Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 24 Feb 2022 21:25:06 +0100 Subject: [PATCH] libs update --- .../activities/MyPreferenceFragment.kt | 100 +++++++++--------- .../smsCommunicator/SmsCommunicatorPlugin.kt | 2 +- build.gradle | 10 +- .../ValidatingEditTextPreference.kt | 6 +- 4 files changed, 57 insertions(+), 61 deletions(-) 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 62435f5d19..8770925cb5 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt @@ -123,9 +123,11 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang override fun onDestroy() { super.onDestroy() - PreferenceManager - .getDefaultSharedPreferences(context) - .unregisterOnSharedPreferenceChangeListener(this) + context?.let { context -> + PreferenceManager + .getDefaultSharedPreferences(context) + .unregisterOnSharedPreferenceChangeListener(this) + } } private fun addPreferencesFromResourceIfEnabled(p: PluginBase?, rootKey: String?, enabled: Boolean) { @@ -139,9 +141,11 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - PreferenceManager - .getDefaultSharedPreferences(context) - .registerOnSharedPreferenceChangeListener(this) + context?.let { context -> + PreferenceManager + .getDefaultSharedPreferences(context) + .registerOnSharedPreferenceChangeListener(this) + } } override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { @@ -263,19 +267,19 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang @SuppressLint("RestrictedApi") private fun addPreferencesFromResource(@XmlRes preferencesResId: Int, key: String?) { - val xmlRoot = preferenceManager.inflateFromResource(context, - preferencesResId, null) - val root: Preference? - if (key != null) { - root = xmlRoot.findPreference(key) - if (root == null) return - require(root is PreferenceScreen) { - ("Preference object with key " + key - + " is not a PreferenceScreen") + context?.let { context -> + val xmlRoot = preferenceManager.inflateFromResource(context, preferencesResId, null) + val root: Preference? + if (key != null) { + root = xmlRoot.findPreference(key) + if (root == null) return + require(root is PreferenceScreen) { + ("Preference object with key $key is not a PreferenceScreen") + } + preferenceScreen = root + } else { + addPreferencesFromResource(preferencesResId) } - preferenceScreen = root - } else { - addPreferencesFromResource(preferencesResId) } } @@ -305,15 +309,9 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang p.initialExpandedChildrenCount = Int.MAX_VALUE } } else { - if (p.key != null) { - visible = visible || p.key.contains(filter, true) - } - if (p.title != null) { - visible = visible || p.title.contains(filter, true) - } - if (p.summary != null) { - visible = visible || p.summary.contains(filter, true) - } + visible = visible || p.key?.contains(filter, true) == true + visible = visible || p.title?.contains(filter, true) == true + visible = visible || p.summary?.contains(filter, true) == true } p.isVisible = visible @@ -393,32 +391,30 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang // We use Preference and custom editor instead of EditTextPreference // to hash password while it is saved and never have to show it, even hashed - override fun onPreferenceTreeClick(preference: Preference?): Boolean { + override fun onPreferenceTreeClick(preference: Preference): Boolean { context?.let { context -> - if (preference != null) { - if (preference.key == rh.gs(R.string.key_master_password)) { - passwordCheck.queryPassword(context, R.string.current_master_password, R.string.key_master_password, { - passwordCheck.setPassword(context, R.string.master_password, R.string.key_master_password) - }) - return true - } - if (preference.key == rh.gs(R.string.key_settings_password)) { - passwordCheck.setPassword(context, R.string.settings_password, R.string.key_settings_password) - return true - } - if (preference.key == rh.gs(R.string.key_bolus_password)) { - passwordCheck.setPassword(context, R.string.bolus_password, R.string.key_bolus_password) - return true - } - if (preference.key == rh.gs(R.string.key_application_password)) { - passwordCheck.setPassword(context, R.string.application_password, R.string.key_application_password) - return true - } - // NSClient copy settings - if (preference.key == rh.gs(R.string.key_statuslights_copy_ns)) { - nsSettingStatus.copyStatusLightsNsSettings(context) - return true - } + if (preference.key == rh.gs(R.string.key_master_password)) { + passwordCheck.queryPassword(context, R.string.current_master_password, R.string.key_master_password, { + passwordCheck.setPassword(context, R.string.master_password, R.string.key_master_password) + }) + return true + } + if (preference.key == rh.gs(R.string.key_settings_password)) { + passwordCheck.setPassword(context, R.string.settings_password, R.string.key_settings_password) + return true + } + if (preference.key == rh.gs(R.string.key_bolus_password)) { + passwordCheck.setPassword(context, R.string.bolus_password, R.string.key_bolus_password) + return true + } + if (preference.key == rh.gs(R.string.key_application_password)) { + passwordCheck.setPassword(context, R.string.application_password, R.string.key_application_password) + return true + } + // NSClient copy settings + if (preference.key == rh.gs(R.string.key_statuslights_copy_ns)) { + nsSettingStatus.copyStatusLightsNsSettings(context) + return true } } return super.onPreferenceTreeClick(preference) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt index 4f733dded3..d357611a06 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/SmsCommunicatorPlugin.kt @@ -165,7 +165,7 @@ class SmsCommunicatorPlugin @Inject constructor( override fun updatePreferenceSummary(pref: Preference) { super.updatePreferenceSummary(pref) if (pref is EditTextPreference) { - if (pref.getKey().contains("smscommunicator_allowednumbers") && (pref.text == null || TextUtils.isEmpty(pref.text.trim { it <= ' ' }))) { + if (pref.getKey().contains("smscommunicator_allowednumbers") && (TextUtils.isEmpty(pref.text?.trim { it <= ' ' }))) { pref.setSummary(rh.gs(R.string.smscommunicator_allowednumbers_summary)) } } diff --git a/build.gradle b/build.gradle index 6c2a214ee0..70c6a55369 100644 --- a/build.gradle +++ b/build.gradle @@ -3,11 +3,11 @@ buildscript { ext { kotlin_version = '1.6.10' - core_version = '1.6.0' + core_version = '1.7.0' rxjava_version = '2.2.21' rxandroid_version = '2.1.1' rxkotlin_version = '2.4.0' - room_version = '2.3.0' + room_version = '2.4.2' lifecycle_version = '2.3.1' dagger_version = '2.41' coroutines_version = '1.4.1' @@ -15,10 +15,10 @@ buildscript { fragmentktx_version = '1.3.6' ormLite_version = '4.46' nav_version = '2.3.5' - appcompat_version = '1.3.1' + appcompat_version = '1.4.1' material_version = '1.4.0' constraintlayout_version = '2.1.0' - preferencektx_version = '1.1.1' + preferencektx_version = '1.2.0' commonslang3_version = '3.11' commonscodec_version = '1.15' jodatime_version = '2.10.13' @@ -30,7 +30,7 @@ buildscript { dexmaker_version = "1.2" retrofit2_version = '2.9.0' okhttp3_version = '4.9.0' - byteBuddy_version = '1.12.3' + byteBuddy_version = '1.12.8' androidx_junit_version = '1.1.2' androidx_rules_version = '1.4.0' diff --git a/core/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt index 495b71eeac..c9f22c0718 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/textValidator/ValidatingEditTextPreference.kt @@ -27,10 +27,10 @@ class ValidatingEditTextPreference(ctx: Context, attrs: AttributeSet, defStyleAt constructor(ctx: Context, attrs: AttributeSet) : this(ctx, attrs, R.attr.editTextPreferenceStyle) - override fun onBindViewHolder(holder: PreferenceViewHolder?) { + override fun onBindViewHolder(holder: PreferenceViewHolder) { super.onBindViewHolder(holder) - holder?.isDividerAllowedAbove = false - holder?.isDividerAllowedBelow = false + holder.isDividerAllowedAbove = false + holder.isDividerAllowedBelow = false } private fun obtainValidatorParameters(attrs: AttributeSet): DefaultEditTextValidator.Parameters {