From 7e156d372f7c1573e66c41d6a02aa17cbdf6e876 Mon Sep 17 00:00:00 2001 From: langleyd Date: Mon, 12 Jul 2021 14:08:35 +0100 Subject: [PATCH] Add checkbox preference, remove PushRulePreference, Split adavanced fragment to new 3 new fragments and inherit common function --- .../im/vector/app/core/di/FragmentModule.kt | 5 -- .../preference/VectorCheckboxPreference.kt | 47 ------------------- ...ngsGlobalNotificationPreferenceFragment.kt | 3 +- ...dMentionsNotificationPreferenceFragment.kt | 4 +- ...ingsOtherNotificationPreferenceFragment.kt | 3 +- .../res/xml/vector_settings_notifications.xml | 24 +++++----- 6 files changed, 16 insertions(+), 70 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt b/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt index 77e7e7ad72..7d50dbdcb5 100644 --- a/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/FragmentModule.kt @@ -389,11 +389,6 @@ interface FragmentModule { @FragmentKey(VectorSettingsNotificationsTroubleshootFragment::class) fun bindVectorSettingsNotificationsTroubleshootFragment(fragment: VectorSettingsNotificationsTroubleshootFragment): Fragment -// @Binds -// @IntoMap -// @FragmentKey(VectorSettingsAdvancedNotificationPreferenceFragment::class) -// fun bindVectorSettingsAdvancedNotificationPreferenceFragment(fragment: VectorSettingsAdvancedNotificationPreferenceFragment): Fragment - @Binds @IntoMap @FragmentKey(VectorSettingsNotificationPreferenceFragment::class) diff --git a/vector/src/main/java/im/vector/app/core/preference/VectorCheckboxPreference.kt b/vector/src/main/java/im/vector/app/core/preference/VectorCheckboxPreference.kt index fd7a2ef5c5..b66ea77bdd 100644 --- a/vector/src/main/java/im/vector/app/core/preference/VectorCheckboxPreference.kt +++ b/vector/src/main/java/im/vector/app/core/preference/VectorCheckboxPreference.kt @@ -16,18 +16,11 @@ package im.vector.app.core.preference -import android.animation.Animator -import android.animation.ArgbEvaluator -import android.animation.ValueAnimator import android.content.Context -import android.graphics.Color import android.util.AttributeSet import android.widget.TextView -import androidx.core.animation.doOnEnd import androidx.preference.CheckBoxPreference import androidx.preference.PreferenceViewHolder -import im.vector.app.R -import im.vector.app.features.themes.ThemeUtils open class VectorCheckboxPreference : CheckBoxPreference { // Note: @JvmOverload does not work here... @@ -44,49 +37,9 @@ open class VectorCheckboxPreference : CheckBoxPreference { isIconSpaceReserved = true } - var isHighlighted = false - set(value) { - field = value - notifyChanged() - } - - var currentHighlightAnimator: Animator? = null - override fun onBindViewHolder(holder: PreferenceViewHolder) { // display the title in multi-line to avoid ellipsis. (holder.findViewById(android.R.id.title) as? TextView)?.isSingleLine = false - - // cancel existing animation (find a way to resume if happens during anim?) - currentHighlightAnimator?.cancel() - - val itemView = holder.itemView - if (isHighlighted) { - val colorFrom = Color.TRANSPARENT - val colorTo = ThemeUtils.getColor(itemView.context, R.attr.colorControlHighlight) - currentHighlightAnimator = ValueAnimator.ofObject(ArgbEvaluator(), colorFrom, colorTo).apply { - duration = 250 // milliseconds - addUpdateListener { animator -> - itemView.setBackgroundColor(animator.animatedValue as Int) - } - doOnEnd { - currentHighlightAnimator = ValueAnimator.ofObject(ArgbEvaluator(), colorTo, colorFrom).apply { - duration = 250 // milliseconds - addUpdateListener { animator -> - itemView.setBackgroundColor(animator.animatedValue as Int) - } - doOnEnd { - isHighlighted = false - } - start() - } - } - startDelay = 200 - start() - } - } else { - itemView.setBackgroundColor(Color.TRANSPARENT) - } - super.onBindViewHolder(holder) } } diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsGlobalNotificationPreferenceFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsGlobalNotificationPreferenceFragment.kt index a91b3c5ef7..7e6f51f0b6 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsGlobalNotificationPreferenceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsGlobalNotificationPreferenceFragment.kt @@ -18,9 +18,8 @@ package im.vector.app.features.settings import im.vector.app.R import org.matrix.android.sdk.api.pushrules.RuleIds -import javax.inject.Inject -class VectorSettingsGlobalNotificationPreferenceFragment @Inject constructor() +class VectorSettingsGlobalNotificationPreferenceFragment : VectorSettingsPushRuleNotificationPreferenceFragment() { override var titleRes: Int = R.string.settings_notification_global diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsKeywordAndMentionsNotificationPreferenceFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsKeywordAndMentionsNotificationPreferenceFragment.kt index 0c7ed23070..2bf0a7c0ed 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsKeywordAndMentionsNotificationPreferenceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsKeywordAndMentionsNotificationPreferenceFragment.kt @@ -18,9 +18,9 @@ package im.vector.app.features.settings import im.vector.app.R import org.matrix.android.sdk.api.pushrules.RuleIds -import javax.inject.Inject -class VectorSettingsKeywordAndMentionsNotificationPreferenceFragment @Inject constructor() + +class VectorSettingsKeywordAndMentionsNotificationPreferenceFragment : VectorSettingsPushRuleNotificationPreferenceFragment() { override var titleRes: Int = R.string.settings_notification_mentions_and_keywords diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsOtherNotificationPreferenceFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsOtherNotificationPreferenceFragment.kt index bf58ab27a1..64d5cda638 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsOtherNotificationPreferenceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsOtherNotificationPreferenceFragment.kt @@ -18,9 +18,8 @@ package im.vector.app.features.settings import im.vector.app.R import org.matrix.android.sdk.api.pushrules.RuleIds -import javax.inject.Inject -class VectorSettingsOtherNotificationPreferenceFragment @Inject constructor() +class VectorSettingsOtherNotificationPreferenceFragment : VectorSettingsPushRuleNotificationPreferenceFragment() { override var titleRes: Int = R.string.settings_notification_other diff --git a/vector/src/main/res/xml/vector_settings_notifications.xml b/vector/src/main/res/xml/vector_settings_notifications.xml index 35e21ca320..d19945cd46 100644 --- a/vector/src/main/res/xml/vector_settings_notifications.xml +++ b/vector/src/main/res/xml/vector_settings_notifications.xml @@ -27,19 +27,19 @@ android:title="@string/settings_notification_global" app:fragment="im.vector.app.features.settings.VectorSettingsGlobalNotificationPreferenceFragment" /> - - - - - - + - - - - - - +