mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
Fix compilation error after bump preference-ktx from 1.1.1 to 1.2.0
This commit is contained in:
parent
48c126515c
commit
5ad2567633
5 changed files with 14 additions and 11 deletions
|
@ -30,6 +30,11 @@ inline fun <T> T.ooi(block: (T) -> Unit): T = also(block)
|
||||||
*/
|
*/
|
||||||
fun CharSequence.isEmail() = Patterns.EMAIL_ADDRESS.matcher(this).matches()
|
fun CharSequence.isEmail() = Patterns.EMAIL_ADDRESS.matcher(this).matches()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return empty CharSequence if the CharSequence is null
|
||||||
|
*/
|
||||||
|
fun CharSequence?.orEmpty() = this ?: ""
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a CharSequence is a phone number
|
* Check if a CharSequence is a phone number
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -33,6 +33,7 @@ import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceViewHolder
|
import androidx.preference.PreferenceViewHolder
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.features.themes.ThemeUtils
|
import im.vector.app.features.themes.ThemeUtils
|
||||||
|
import org.matrix.android.sdk.api.extensions.orFalse
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,16 +153,12 @@ open class VectorPreference : Preference {
|
||||||
*/
|
*/
|
||||||
private fun addClickListeners(view: View) {
|
private fun addClickListeners(view: View) {
|
||||||
view.setOnLongClickListener {
|
view.setOnLongClickListener {
|
||||||
if (null != onPreferenceLongClickListener) {
|
onPreferenceLongClickListener?.onPreferenceLongClick(this@VectorPreference).orFalse()
|
||||||
onPreferenceLongClickListener!!.onPreferenceLongClick(this@VectorPreference)
|
|
||||||
} else false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
view.setOnClickListener {
|
view.setOnClickListener {
|
||||||
// call only the click listener
|
// call only the click listener
|
||||||
if (onPreferenceClickListener != null) {
|
onPreferenceClickListener?.onPreferenceClick(this@VectorPreference)
|
||||||
onPreferenceClickListener.onPreferenceClick(this@VectorPreference)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import android.os.Bundle
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import im.vector.app.BuildConfig
|
import im.vector.app.BuildConfig
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
|
import im.vector.app.core.extensions.orEmpty
|
||||||
import im.vector.app.core.preference.VectorPreference
|
import im.vector.app.core.preference.VectorPreference
|
||||||
import im.vector.app.core.utils.FirstThrottler
|
import im.vector.app.core.utils.FirstThrottler
|
||||||
import im.vector.app.core.utils.copyToClipboard
|
import im.vector.app.core.utils.copyToClipboard
|
||||||
|
@ -72,7 +73,7 @@ class VectorSettingsHelpAboutFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
it.setOnPreferenceClickListener { pref ->
|
it.setOnPreferenceClickListener { pref ->
|
||||||
copyToClipboard(requireContext(), pref.summary)
|
copyToClipboard(requireContext(), pref.summary.orEmpty())
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +83,7 @@ class VectorSettingsHelpAboutFragment @Inject constructor(
|
||||||
it.summary = Matrix.getSdkVersion()
|
it.summary = Matrix.getSdkVersion()
|
||||||
|
|
||||||
it.setOnPreferenceClickListener { pref ->
|
it.setOnPreferenceClickListener { pref ->
|
||||||
copyToClipboard(requireContext(), pref.summary)
|
copyToClipboard(requireContext(), pref.summary.orEmpty())
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
||||||
findPreference<VectorSwitchPreference>("SETTINGS_USER_ANALYTICS_CONSENT_KEY")!!
|
findPreference<VectorSwitchPreference>("SETTINGS_USER_ANALYTICS_CONSENT_KEY")!!
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateRecyclerView(inflater: LayoutInflater?, parent: ViewGroup?, savedInstanceState: Bundle?): RecyclerView {
|
override fun onCreateRecyclerView(inflater: LayoutInflater, parent: ViewGroup, savedInstanceState: Bundle?): RecyclerView {
|
||||||
return super.onCreateRecyclerView(inflater, parent, savedInstanceState).also {
|
return super.onCreateRecyclerView(inflater, parent, savedInstanceState).also {
|
||||||
// Insert animation are really annoying the first time the list is shown
|
// Insert animation are really annoying the first time the list is shown
|
||||||
// due to the way preference fragment is done, it's not trivial to disable it for first appearance only..
|
// due to the way preference fragment is done, it's not trivial to disable it for first appearance only..
|
||||||
|
|
|
@ -352,8 +352,8 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor(
|
||||||
super.onDetach()
|
super.onDetach()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
override fun onPreferenceTreeClick(preference: Preference): Boolean {
|
||||||
return when (preference?.key) {
|
return when (preference.key) {
|
||||||
VectorPreferences.SETTINGS_ENABLE_ALL_NOTIF_PREFERENCE_KEY -> {
|
VectorPreferences.SETTINGS_ENABLE_ALL_NOTIF_PREFERENCE_KEY -> {
|
||||||
updateEnabledForAccount(preference)
|
updateEnabledForAccount(preference)
|
||||||
true
|
true
|
||||||
|
|
Loading…
Reference in a new issue