Fix issue in theme

This commit is contained in:
Benoit Marty 2019-06-06 14:37:30 +02:00
parent 311d8484a2
commit 75b8932395
28 changed files with 136 additions and 111 deletions

View File

@ -375,7 +375,7 @@ class MessageItemFactory(private val colorProvider: ColorProvider,
val message = messageContent.body.let {
val formattedBody = span {
text = it
textColor = colorProvider.getColor(R.color.slate_grey)
textColor = colorProvider.getColorFromAttribute(R.attr.riotx_text_secondary)
textStyle = "italic"
}
linkifyBody(formattedBody, callback)

View File

@ -36,6 +36,7 @@ abstract class RoomCategoryItem : VectorEpoxyModel<RoomCategoryItem.Holder>() {
@EpoxyAttribute var listener: (() -> Unit)? = null
override fun bind(holder: Holder) {
// TODO Theme get text secondary color instead
val tintColor = ContextCompat.getColor(holder.rootView.context, R.color.bluey_grey_two)
val expandedArrowDrawableRes = if (expanded) R.drawable.ic_expand_more_white else R.drawable.ic_expand_less_white
val expandedArrowDrawable = ContextCompat.getDrawable(holder.rootView.context, expandedArrowDrawableRes)?.also {

View File

@ -32,6 +32,7 @@ import im.vector.riotredesign.core.error.ErrorFormatter
import im.vector.riotredesign.core.extensions.addFragmentToBackstack
import im.vector.riotredesign.core.platform.VectorBaseFragment
import im.vector.riotredesign.features.roomdirectory.picker.RoomDirectoryPickerFragment
import im.vector.riotredesign.features.themes.ThemeUtils
import io.reactivex.rxkotlin.subscribeBy
import kotlinx.android.synthetic.main.fragment_public_rooms.*
import org.koin.android.ext.android.inject
@ -65,6 +66,8 @@ class PublicRoomsFragment : VectorBaseFragment(), PublicRoomsController.Callback
it.setDisplayHomeAsUpEnabled(true)
}
publicRoomsFilter.setBackgroundResource(ThemeUtils.getResourceId(requireContext(), R.drawable.bg_search_edit_text_light))
RxTextView.textChanges(publicRoomsFilter)
.debounce(500, TimeUnit.MILLISECONDS)
.subscribeBy {

View File

@ -20,7 +20,6 @@ package im.vector.riotredesign.features.themes
import android.app.Activity
import android.content.Context
import android.graphics.drawable.Drawable
import android.text.TextUtils
import android.util.TypedValue
import android.view.Menu
import androidx.annotation.AttrRes
@ -89,8 +88,8 @@ object ThemeUtils {
*/
fun setActivityTheme(activity: Activity, otherThemes: ActivityOtherThemes) {
when (getApplicationTheme(activity)) {
THEME_DARK_VALUE -> activity.setTheme(otherThemes.dark)
THEME_BLACK_VALUE -> activity.setTheme(otherThemes.black)
THEME_DARK_VALUE -> activity.setTheme(otherThemes.dark)
THEME_BLACK_VALUE -> activity.setTheme(otherThemes.black)
THEME_STATUS_VALUE -> activity.setTheme(otherThemes.status)
}
@ -164,7 +163,7 @@ object ThemeUtils {
try {
val typedValue = TypedValue()
c.theme.resolveAttribute(attribute, typedValue, true)
return typedValue
return typedValue
} catch (e: Exception) {
Timber.e(e, "Unable to get color")
}
@ -175,19 +174,37 @@ object ThemeUtils {
* Get the resource Id applied to the current theme
*
* @param c the context
* @param resourceId the resource id
* @param resourceId the resource id in the light theme
* @return the resource Id for the current theme
*/
fun getResourceId(c: Context, resourceId: Int): Int {
if (TextUtils.equals(getApplicationTheme(c), THEME_LIGHT_VALUE)
|| TextUtils.equals(getApplicationTheme(c), THEME_STATUS_VALUE)) {
return when (resourceId) {
R.drawable.line_divider_dark -> R.drawable.line_divider_light
R.style.Floating_Actions_Menu -> R.style.Floating_Actions_Menu_Light
else -> resourceId
val theme = getApplicationTheme(c)
return when (theme) {
THEME_LIGHT_VALUE -> resourceId
THEME_DARK_VALUE -> {
return when (resourceId) {
R.drawable.bg_search_edit_text_light -> R.drawable.bg_search_edit_text_dark
else -> {
Timber.w("Warning, missing case for wanted drawable in dark theme")
resourceId
}
}
}
THEME_BLACK_VALUE -> {
return when (resourceId) {
R.drawable.bg_search_edit_text_light -> R.drawable.bg_search_edit_text_black
else -> {
Timber.w("Warning, missing case for wanted drawable in black theme")
resourceId
}
}
}
else -> {
Timber.w("Warning, missing theme: $theme")
resourceId
}
}
return resourceId
}
/**

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/black" android:state_checked="true" />
<item android:color="@color/bluey_grey_two" />
</selector>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/riotx_search_background_mobile_black" />
<corners android:radius="4dp" />
</shape>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/light_blue_grey" />
<solid android:color="@color/riotx_search_background_mobile_dark" />
<corners android:radius="4dp" />
</shape>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/riotx_search_background_mobile_light" />
<corners android:radius="4dp" />
</shape>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<item>
<shape>
<solid android:color="@android:color/white" />
</shape>
</item>
<item android:gravity="top">
<shape android:shape="rectangle">
<size android:height="80dp" />
<!--<solid android:color="?colorPrimary" />-->
<solid android:color="@color/dark" />
</shape>
</item>
</layer-list>

View File

@ -4,5 +4,5 @@
<corners android:radius="40dp" />
<solid android:color="@color/rosy_pink" />
<solid android:color="@color/riotx_notice" />
</shape>

View File

@ -88,10 +88,11 @@
android:layout_height="22dp"
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/ic_close_round"
android:tint="@color/rosy_pink"
android:tint="@color/riotx_notice"
android:visibility="invisible"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintStart_toEndOf="parent" />
app:layout_constraintStart_toEndOf="parent"
tools:visibility="visible" />
<ImageView
android:id="@+id/composer_avatar_view"

View File

@ -96,7 +96,7 @@
android:layout_marginRight="8dp"
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/ic_close_round"
android:tint="@color/rosy_pink"
android:tint="@color/riotx_notice"
app:layout_constraintBottom_toBottomOf="@id/composer_related_message_preview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/composer_related_message_preview" />

View File

@ -35,7 +35,7 @@
android:layout_marginEnd="32dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?vctr_toolbar_primary_text_color"
android:textColor="?riotx_text_primary"
android:textSize="20sp"
android:textStyle="bold"
tools:text="@tools:sample/lorem/random" />
@ -58,8 +58,6 @@
android:layout_height="48dp"
android:background="?riotx_background"
app:itemIconSize="20dp"
app:itemIconTint="@color/home_bottom_nav_view_tint"
app:itemTextColor="@color/home_bottom_nav_view_tint"
app:labelVisibilityMode="unlabeled"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

View File

@ -23,6 +23,7 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_scrollFlags="noScroll">
<!-- Note: Background is modified in the code for other themes -->
<EditText
android:id="@+id/publicRoomsFilter"
android:layout_width="match_parent"
@ -33,11 +34,11 @@
android:layout_marginEnd="@dimen/layout_horizontal_margin"
android:layout_marginRight="@dimen/layout_horizontal_margin"
android:layout_marginBottom="8dp"
android:background="@drawable/bg_search_edit_text"
android:background="@drawable/bg_search_edit_text_light"
android:drawableStart="@drawable/ic_search_white"
android:drawableLeft="@drawable/ic_search_white"
android:drawablePadding="8dp"
android:drawableTint="#9fa9ba"
android:drawableTint="?riotx_text_secondary"
android:hint="@string/home_filter_placeholder_rooms"
android:lines="1"
android:paddingLeft="8dp"
@ -56,6 +57,7 @@
android:text="@string/create_new_room"
app:icon="@drawable/ic_plus_circle"
app:iconPadding="13dp"
app:iconTint="@color/riotx_accent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/publicRoomsToolbar"
app:layout_scrollFlags="scroll|enterAlways|snap" />

View File

@ -5,7 +5,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/pale_grey">
android:background="?riotx_header_panel_background">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"

View File

@ -5,7 +5,7 @@
android:id="@+id/stateView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/pale_grey">
android:background="?riotx_header_panel_background">
<com.airbnb.epoxy.EpoxyRecyclerView
android:id="@+id/epoxyRecyclerView"

View File

@ -6,9 +6,9 @@
android:id="@+id/itemPublicRoomLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?riotx_background"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
android:minHeight="97dp">
<ImageView

View File

@ -5,7 +5,7 @@
android:id="@+id/itemRoomLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:background="?riotx_background"
android:clickable="true"
android:focusable="true">
@ -41,7 +41,7 @@
android:duplicateParentState="true"
android:ellipsize="end"
android:maxLines="1"
android:textColor="@color/black_87"
android:textColor="?riotx_text_primary"
android:textSize="15sp"
app:layout_constrainedWidth="true"
app:layout_constraintEnd_toStartOf="@+id/roomUnreadCounterBadgeView"
@ -77,7 +77,7 @@
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:textColor="@color/black_38"
android:textColor="?riotx_text_secondary"
android:textSize="15sp"
app:layout_constraintBottom_toBottomOf="@+id/roomNameView"
app:layout_constraintEnd_toEndOf="parent"
@ -93,7 +93,7 @@
android:layout_marginRight="8dp"
android:ellipsize="end"
android:maxLines="2"
android:textColor="@color/black_38"
android:textColor="?riotx_text_secondary"
android:textSize="15sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/roomNameView"

View File

@ -14,7 +14,7 @@
android:paddingTop="@dimen/layout_vertical_margin"
android:paddingEnd="@dimen/layout_horizontal_margin"
android:paddingRight="@dimen/layout_horizontal_margin"
tools:background="@color/pale_grey">
tools:background="?riotx_header_panel_background">
<TextView
android:id="@+id/roomCategoryTitleView"
@ -24,7 +24,7 @@
android:layout_marginRight="8dp"
android:drawableStart="@drawable/ic_expand_more_white"
android:drawableLeft="@drawable/ic_expand_more_white"
android:drawableTint="@color/bluey_grey_two"
android:drawableTint="?riotx_text_secondary"
android:ellipsize="end"
android:gravity="center_vertical"
android:maxLines="1"

View File

@ -22,7 +22,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:textColor="@color/slate_grey"
android:textColor="?riotx_text_secondary"
android:textSize="14sp"
android:textStyle="italic"
tools:text="John doe changed their avatar" />

View File

@ -72,7 +72,7 @@
android:layout_height="22dp"
android:background="?android:attr/selectableItemBackground"
android:src="@drawable/ic_close_round"
android:tint="@color/rosy_pink"
android:tint="@color/riotx_notice"
tools:ignore="MissingConstraints" />

View File

@ -14,7 +14,7 @@
tools:layout_gravity="center_horizontal"
tools:text="@string/join" />
<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/buttonStateButtonBig"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -42,14 +42,14 @@
tools:layout_marginTop="300dp"
tools:src="@drawable/ic_tick" />
<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/buttonStateRetry"
style="@style/VectorButtonStyleFlat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/global_retry"
android:textColor="@color/vector_warning_color"
android:textColor="@color/riotx_notice"
tools:layout_gravity="center_horizontal"
tools:layout_marginTop="400dp" />

View File

@ -1,25 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- TODO remove those colors-->
<color name="pale_grey">#f2f5f8</color>
<color name="dark">#2e3649</color>
<color name="pale_teal">#7ac9a1</color>
<color name="deep_sky_blue">#007aff</color>
<color name="rosy_pink">#f56679</color>
<color name="bluey_grey">#a5a5a6</color>
<color name="slate_grey">#5f6268</color>
<color name="sky_blue">#7bb2ea</color>
<color name="bluey_grey_two">#929eb4</color>
<color name="light_blue_grey">#4ac1c9d6</color>
<!-- Now use ?colorOnPrimary or ?vctr_toolbar_primary_text_color -->
<!--color name="dark_grey">#2e2f32</color-->
<color name="light_grey_blue">#9fa9ba</color>
<color name="cool_grey">#a5aab2</color>
<color name="pale_grey_two">#ebedf8</color>
<color name="grey_lynch">#61708B</color>
<color name="black_87">#de000000</color>
<color name="black_38">#61000000</color>
<color name="black_37">#5d000000</color>
<color name="grey_lynch">#61708B</color>
<color name="black">#000000</color>
</resources>

View File

@ -129,7 +129,7 @@
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:background">@null</item>
<item name="android:textColor">?colorAccent</item>
<!--item name="android:textColor">?colorAccent</item-->
<item name="colorControlHighlight">?colorAccent</item>
</style>

View File

@ -20,21 +20,21 @@
<item name="android:textSize">16sp</item>
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:textStyle">normal</item>
<item name="android:textColor">@color/black_87</item>
<item name="android:textColor">?riotx_text_primary</item>
</style>
<style name="TextAppearance.Vector.Subtitle" parent="TextAppearance.AppCompat">
<item name="android:textSize">14sp</item>
<item name="android:fontFamily">sans-serif</item>
<item name="android:textStyle">normal</item>
<item name="android:textColor">@color/black_37</item>
<item name="android:textColor">?riotx_text_primary</item>
</style>
<style name="TextAppearance.Vector.Subtitle2" parent="TextAppearance.AppCompat">
<item name="android:textSize">14sp</item>
<item name="android:fontFamily">sans-serif-medium</item>
<item name="android:textStyle">normal</item>
<item name="android:textColor">@color/black_38</item>
<item name="android:textColor">?riotx_text_primary</item>
</style>
</resources>

View File

@ -6,11 +6,6 @@
<style name="AppTheme.Base.Black" parent="AppTheme.Base.Dark">
<!-- Only setting the items we need to override to get the background to be pure black, otherwise inheriting -->
<item name="colorPrimaryDark">@color/primary_color_dark_black</item>
<item name="colorPrimary">@color/primary_color_black</item>
<item name="android:textColorLink">@color/riotx_links</item>
<!-- Riotx attribute for palette -->
<item name="riotx_background">@color/riotx_background_black</item>
<item name="riotx_base">@color/riotx_base_black</item>
@ -30,6 +25,33 @@
<item name="riotx_android_status_bar">@color/riotx_android_status_bar_black</item>
<item name="riotx_line_break_mobile">@color/riotx_line_break_mobile_black</item>
<!-- Material color: Note: this block should be the same in all theme because it references only common colors and ?riotx attributes -->
<item name="colorPrimary">@color/riotx_accent</item>
<!--item name="colorPrimaryVariant">@color/primary_color_dark_light</item-->
<item name="colorOnPrimary">@color/riotx_text_primary_light</item>
<!-- We do not use color secondary, default will be colorPrimary values: It does not work so declare again the value -->
<item name="colorSecondary">@color/riotx_accent</item>
<item name="colorSecondaryVariant">@color/primary_color_dark_black</item>
<item name="colorOnSecondary">@color/riotx_text_primary_black</item>
<item name="colorError">@color/riotx_notice</item>
<item name="colorOnError">#FFFFFF</item>
<!--item name="colorSurface">#FFFFFF</item>
<item name="colorOnSurface">#212121</item-->
<item name="android:colorBackground">?riotx_background</item>
<item name="colorOnBackground">?riotx_text_primary</item>
<!-- Keep color accent for legacy widget-->
<item name="colorAccent">@color/riotx_accent</item>
<item name="materialButtonStyle">@style/VectorButtonStyle</item>
<item name="toolbarStyle">@style/VectorToolbarStyle</item>
<item name="alertDialogTheme">@style/VectorAlertDialogStyle</item>
<item name="android:textColorLink">@color/riotx_links</item>
<!-- Menu text color -->
<!--item name="android:actionMenuTextColor">#FFFFFFFF</item-->
<!-- list colors -->
<!--Header/Panel Background-->
<item name="vctr_list_header_background_color">#FF090A0C</item>
@ -42,7 +64,6 @@
<!-- color for dividers in settings -->
<item name="vctr_preference_divider_color">@color/list_divider_color_black</item>
<item name="android:colorBackground">@color/riot_primary_background_color_black</item>
<item name="vctr_markdown_block_background_color">#FF4D4D4D</item>
<!-- activities background -->

View File

@ -4,17 +4,6 @@
<!-- DARK THEME COLORS -->
<style name="AppTheme.Base.Dark" parent="Theme.MaterialComponents.NoActionBar.Bridge">
<item name="colorPrimaryDark">@color/primary_color_dark_dark</item>
<item name="colorPrimary">@color/primary_color_dark</item>
<item name="colorAccent">@color/accent_color_dark</item>
<item name="android:textColorPrimary">@color/primary_text_color_selector_dark</item>
<item name="android:textColorSecondary">@color/riot_secondary_text_color_dark</item>
<!-- Default color for text View -->
<item name="android:textColorTertiary">@color/riot_tertiary_text_color_dark</item>
<item name="android:textColorLink">@color/link_color_dark</item>
<!-- Riotx attribute for palette -->
<item name="riotx_background">@color/riotx_background_dark</item>
<item name="riotx_base">@color/riotx_base_dark</item>
@ -34,11 +23,34 @@
<item name="riotx_android_status_bar">@color/riotx_android_status_bar_dark</item>
<item name="riotx_line_break_mobile">@color/riotx_line_break_mobile_dark</item>
<!-- Material color: Note: this block should be the same in all theme because it references only common colors and ?riotx attributes -->
<item name="colorPrimary">@color/riotx_accent</item>
<item name="colorPrimaryVariant">@color/primary_color_dark_light</item>
<item name="colorOnPrimary">@color/riotx_text_primary_light</item>
<!-- We do not use color secondary, default will be colorPrimary values: It does not work so declare again the value -->
<item name="colorSecondary">@color/riotx_accent</item>
<item name="colorSecondaryVariant">@color/primary_color_dark_dark</item>
<item name="colorOnSecondary">@color/riotx_text_primary_dark</item>
<item name="colorError">@color/riotx_notice</item>
<item name="colorOnError">#FFFFFF</item>
<!--item name="colorSurface">#FFFFFF</item>
<item name="colorOnSurface">#212121</item-->
<item name="android:colorBackground">?riotx_background</item>
<item name="colorOnBackground">?riotx_text_primary</item>
<!-- Keep color accent for legacy widget-->
<item name="colorAccent">@color/riotx_accent</item>
<item name="materialButtonStyle">@style/VectorButtonStyle</item>
<item name="toolbarStyle">@style/VectorToolbarStyle</item>
<item name="alertDialogTheme">@style/VectorAlertDialogStyle</item>
<item name="android:textColorLink">@color/riotx_links</item>
<!-- Menu text color -->
<item name="android:actionMenuTextColor">#FFFFFFFF</item>
<!--item name="android:actionMenuTextColor">#FFFFFFFF</item-->
<!-- default background color -->
<item name="android:colorBackground">@color/riot_primary_background_color_dark</item>
<item name="vctr_bottom_nav_background_color">@color/primary_color_dark</item>
<item name="vctr_bottom_nav_background_border_color">#FFE9EDF1</item>

View File

@ -25,33 +25,28 @@
<!-- Material color: Note: this block should be the same in all theme because it references only common colors and ?riotx attributes -->
<item name="colorPrimary">@color/riotx_accent</item>
<item name="colorPrimaryVariant">@color/primary_color_dark_light</item>
<!--item name="colorPrimaryVariant">@color/primary_color_dark_light</item-->
<item name="colorOnPrimary">@color/riotx_text_primary_light</item>
<item name="colorSecondary">@color/accent_color_light</item>
<!-- We do not use color secondary, default will be colorPrimary values-->
<!--item name="colorSecondary">@color/accent_color_light</item>
<item name="colorSecondaryVariant">#0039CB</item>
<item name="colorOnSecondary">@android:color/white</item>
<item name="colorOnSecondary">@android:color/white</item-->
<item name="colorError">@color/riotx_notice</item>
<item name="colorOnError">#FFFFFF</item>
<item name="colorSurface">#FFFFFF</item>
<item name="colorOnSurface">#212121</item>
<!--item name="colorSurface">#FFFFFF</item>
<item name="colorOnSurface">#212121</item-->
<item name="android:colorBackground">?riotx_background</item>
<item name="colorOnBackground">?riotx_text_primary</item>
<!-- TODO is it still required? -->
<item name="colorAccent">@color/accent_color_light</item>
<!-- Keep color accent for legacy widget-->
<item name="colorAccent">@color/riotx_accent</item>
<item name="materialButtonStyle">@style/VectorButtonStyle</item>
<item name="toolbarStyle">@style/VectorToolbarStyle</item>
<item name="alertDialogTheme">@style/VectorAlertDialogStyle</item>
<!--item name="android:textColorPrimary">@color/black_87</item>
<item name="android:textColorSecondary">@color/black_38</item>
<item name="android:textColorTertiary">@color/black_37</item-->
<item name="android:textColorLink">@color/riotx_links</item>
<!-- Menu text color -->
<!--item name="android:actionMenuTextColor">#FFFFFFFF</item-->