Theme riotx_positive_accent

This commit is contained in:
SpiritCroc 2020-07-19 11:55:01 +02:00
parent 311244508d
commit e1cbd8c764
13 changed files with 35 additions and 12 deletions

View File

@ -29,9 +29,12 @@ class ColorProvider @Inject constructor(private val context: Context) {
@ColorInt
fun getColor(@ColorRes colorRes: Int): Int {
if (colorRes == R.color.riotx_accent)
return getColorFromAttribute(R.attr.colorAccent)
return ContextCompat.getColor(context, colorRes)
return when(colorRes) {
R.color.riotx_accent -> getColorFromAttribute(R.attr.colorAccent)
R.color.riotx_positive_accent -> getColorFromAttribute(R.attr.riotx_positive_accent)
R.color.riotx_positive_accent_alpha12 -> getColorFromAttribute(R.attr.riotx_positive_accent_alpha12)
else -> ContextCompat.getColor(context, colorRes)
}
}
/**

View File

@ -40,6 +40,7 @@ import im.vector.riotx.core.extensions.replaceFragment
import im.vector.riotx.core.platform.ToolbarConfigurable
import im.vector.riotx.core.platform.VectorBaseActivity
import im.vector.riotx.core.pushers.PushersManager
import im.vector.riotx.core.resources.ColorProvider
import im.vector.riotx.features.disclaimer.showDisclaimerDialog
import im.vector.riotx.features.notifications.NotificationDrawerManager
import im.vector.riotx.features.popup.PopupAlertManager
@ -202,7 +203,7 @@ class HomeActivity : VectorBaseActivity(), ToolbarConfigurable, UnknownDeviceDet
iconId = R.drawable.ic_shield_warning
).apply {
matrixItem = userItem
colorInt = ContextCompat.getColor(this@HomeActivity, R.color.riotx_positive_accent)
colorInt = ColorProvider(this@HomeActivity).getColor(R.color.riotx_positive_accent)
contentAction = Runnable {
(weakCurrentActivity?.get() as? VectorBaseActivity)?.let {
action(it)

View File

@ -28,7 +28,6 @@ import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.preference.PreferenceManager
import im.vector.riotx.R
import im.vector.riotx.features.configuration.VectorConfiguration
import timber.log.Timber
/**
@ -232,8 +231,16 @@ object ThemeUtils {
c.theme.resolveAttribute(colorAttribute, color, true)
color.data
} catch (e: Exception) {
Timber.e(e, "Unable to get color")
ContextCompat.getColor(c, android.R.color.holo_red_dark)
when (colorAttribute) {
android.R.attr.colorAccent -> ContextCompat.getColor(c, R.color.riotx_accent)
R.attr.colorAccent -> ContextCompat.getColor(c, R.color.riotx_accent)
R.attr.riotx_positive_accent -> ContextCompat.getColor(c, R.color.riotx_positive_accent)
R.attr.riotx_positive_accent_alpha12 -> ContextCompat.getColor(c, R.color.riotx_positive_accent_alpha12)
else -> {
Timber.e(e, "Unable to get color")
ContextCompat.getColor(c, android.R.color.holo_red_dark)
}
}
}
}
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/riotx_button_disabled_alpha12" android:state_enabled="false" />
<item android:color="@color/riotx_positive_accent_alpha12" android:state_enabled="true" />
<item android:color="?riotx_positive_accent_alpha12" android:state_enabled="true" />
</selector>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/riotx_disabled_accent" android:state_enabled="false" />
<item android:color="@color/riotx_positive_accent" />
<item android:color="?riotx_positive_accent" />
</selector>

View File

@ -6,6 +6,6 @@
android:width="40dp"
android:height="40dp" />
<solid android:color="@color/riotx_positive_accent" />
<solid android:color="?riotx_positive_accent" />
</shape>
</shape>

View File

@ -37,7 +37,7 @@
android:textColor="?riotx_text_primary"
android:layout_marginStart="8dp"
android:layout_marginEnd="0dp"
tools:textColor="@color/riotx_positive_accent"
tools:textColor="?riotx_positive_accent"
tools:text="Value" />

View File

@ -6,6 +6,9 @@
<attr name="sc_message_bg_incoming" format="color" />
<attr name="sc_message_bg_outgoing" format="color" />
<attr name="riotx_positive_accent" format="color" />
<attr name="riotx_positive_accent_alpha12" format="color" />
</declare-styleable>
</resources>

View File

@ -3,6 +3,7 @@
<color name="accent_sc">#8BC34A</color>
<color name="accent_sc_alpha25">#3F8BC34A</color>
<color name="accent_sc_alpha12">#1E8BC34A</color>
<color name="direct_chat_ring_color_sc">#689F38</color>
<color name="avatar_fill_sc_1">@color/accent_sc</color>

View File

@ -225,6 +225,8 @@
<item name="sc_message_bg_incoming">#FF465561</item>
<item name="sc_message_bg_outgoing">#ff343b47</item>
<item name="riotx_positive_accent">@color/riotx_positive_accent</item>
<item name="riotx_positive_accent_alpha12">@color/riotx_positive_accent_alpha12</item>
</style>
<style name="AppTheme.Dark" parent="AppTheme.Base.Dark" />

View File

@ -225,6 +225,8 @@
<item name="sc_message_bg_incoming">#FFEEEEEE</item>
<item name="sc_message_bg_outgoing">#FFDDDDDD</item>
<item name="riotx_positive_accent">@color/riotx_positive_accent</item>
<item name="riotx_positive_accent_alpha12">@color/riotx_positive_accent_alpha12</item>
</style>
<style name="AppTheme.Light" parent="AppTheme.Base.Light" />

View File

@ -208,6 +208,8 @@
<item name="sc_message_bg_incoming">@color/background_floating_sc</item>
<item name="sc_message_bg_outgoing">@color/background_sc</item>
<item name="riotx_positive_accent">@color/accent_sc</item>
<item name="riotx_positive_accent_alpha12">@color/accent_sc_alpha12</item>
</style>
<style name="AppTheme.Base.SC.Dark">

View File

@ -154,6 +154,8 @@
<item name="sc_message_bg_incoming">#FFFFFFFF</item>
<item name="sc_message_bg_outgoing">#FFE4E8ED</item>
<item name="riotx_positive_accent">@color/riotx_positive_accent</item>
<item name="riotx_positive_accent_alpha12">@color/riotx_positive_accent_alpha12</item>
</style>
<style name="AppTheme.Status" parent="AppTheme.Base.Status" />