libs update

This commit is contained in:
Milos Kozak 2022-02-24 21:25:06 +01:00
parent 99efbcad6c
commit 21a3069a40
4 changed files with 57 additions and 61 deletions

View file

@ -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)

View file

@ -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))
}
}

View file

@ -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'

View file

@ -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 {