mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-01 11:46:57 +01:00
Add checkbox preference, remove PushRulePreference, Split adavanced fragment to new 3 new fragments and inherit common function
This commit is contained in:
parent
d6f1f276c2
commit
7e156d372f
@ -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)
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -27,19 +27,19 @@
|
||||
android:title="@string/settings_notification_global"
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsGlobalNotificationPreferenceFragment" />
|
||||
|
||||
<!-- <im.vector.app.core.preference.VectorPreference-->
|
||||
<!-- android:dependency="SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY"-->
|
||||
<!-- android:key="SETTINGS_NOTIFICATION_KEYWORD_AND_MENTIONS_PREFERENCE_KEY"-->
|
||||
<!-- android:persistent="false"-->
|
||||
<!-- android:title="@string/settings_notification_mentions_and_keywords"-->
|
||||
<!-- app:fragment="im.vector.app.features.settings.VectorSettingsKeywordAndMentionsNotificationPreferenceFragment" />-->
|
||||
<im.vector.app.core.preference.VectorPreference
|
||||
android:dependency="SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY"
|
||||
android:key="SETTINGS_NOTIFICATION_KEYWORD_AND_MENTIONS_PREFERENCE_KEY"
|
||||
android:persistent="false"
|
||||
android:title="@string/settings_notification_mentions_and_keywords"
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsKeywordAndMentionsNotificationPreferenceFragment" />
|
||||
|
||||
<!-- <im.vector.app.core.preference.VectorPreference-->
|
||||
<!-- android:dependency="SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY"-->
|
||||
<!-- android:key="SETTINGS_NOTIFICATION_OTHER_PREFERENCE_KEY"-->
|
||||
<!-- android:persistent="false"-->
|
||||
<!-- android:title="@string/settings_notification_other"-->
|
||||
<!-- app:fragment="im.vector.app.features.settings.VectorSettingsOtherNotificationPreferenceFragment" />-->
|
||||
<im.vector.app.core.preference.VectorPreference
|
||||
android:dependency="SETTINGS_ENABLE_THIS_DEVICE_PREFERENCE_KEY"
|
||||
android:key="SETTINGS_NOTIFICATION_OTHER_PREFERENCE_KEY"
|
||||
android:persistent="false"
|
||||
android:title="@string/settings_notification_other"
|
||||
app:fragment="im.vector.app.features.settings.VectorSettingsOtherNotificationPreferenceFragment" />
|
||||
|
||||
</im.vector.app.core.preference.VectorPreferenceCategory>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user