Remove Status theme and handle migration or current status theme to light theme (#2424)

This commit is contained in:
Benoit Marty 2020-12-01 16:19:50 +01:00
parent 51b86e21f6
commit aa6c7afbbd
12 changed files with 14 additions and 194 deletions

View file

@ -25,7 +25,7 @@ Test:
- -
Other changes: Other changes:
- - Remove "Status.im" theme #2424
Changes in Element 1.0.11 (2020-11-27) Changes in Element 1.0.11 (2020-11-27)
=================================================== ===================================================

View file

@ -4,7 +4,7 @@
android:id="@+id/test_linkify_coordinator" android:id="@+id/test_linkify_coordinator"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/riot_secondary_text_color_status" android:background="#7F70808D"
tools:context=".features.debug.TestLinkifyActivity"> tools:context=".features.debug.TestLinkifyActivity">
<androidx.core.widget.NestedScrollView <androidx.core.widget.NestedScrollView

View file

@ -41,14 +41,4 @@
</FrameLayout> </FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:theme="@style/AppTheme.Status">
<include layout="@layout/demo_theme_sample" />
</FrameLayout>
</LinearLayout> </LinearLayout>

View file

@ -24,23 +24,19 @@ import im.vector.app.R
* Note that style for light theme is default and is declared in the Android Manifest * Note that style for light theme is default and is declared in the Android Manifest
*/ */
sealed class ActivityOtherThemes(@StyleRes val dark: Int, sealed class ActivityOtherThemes(@StyleRes val dark: Int,
@StyleRes val black: Int, @StyleRes val black: Int) {
@StyleRes val status: Int) {
object Default : ActivityOtherThemes( object Default : ActivityOtherThemes(
R.style.AppTheme_Dark, R.style.AppTheme_Dark,
R.style.AppTheme_Black, R.style.AppTheme_Black
R.style.AppTheme_Status
) )
object AttachmentsPreview : ActivityOtherThemes( object AttachmentsPreview : ActivityOtherThemes(
R.style.AppTheme_AttachmentsPreview,
R.style.AppTheme_AttachmentsPreview, R.style.AppTheme_AttachmentsPreview,
R.style.AppTheme_AttachmentsPreview R.style.AppTheme_AttachmentsPreview
) )
object VectorAttachmentsPreview : ActivityOtherThemes( object VectorAttachmentsPreview : ActivityOtherThemes(
R.style.AppTheme_Transparent,
R.style.AppTheme_Transparent, R.style.AppTheme_Transparent,
R.style.AppTheme_Transparent R.style.AppTheme_Transparent
) )

View file

@ -24,6 +24,7 @@ import android.view.Menu
import androidx.annotation.AttrRes import androidx.annotation.AttrRes
import androidx.annotation.ColorInt import androidx.annotation.ColorInt
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.core.content.edit
import androidx.core.graphics.drawable.DrawableCompat import androidx.core.graphics.drawable.DrawableCompat
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.di.DefaultSharedPreferences import im.vector.app.core.di.DefaultSharedPreferences
@ -41,7 +42,6 @@ object ThemeUtils {
private const val THEME_DARK_VALUE = "dark" private const val THEME_DARK_VALUE = "dark"
private const val THEME_LIGHT_VALUE = "light" private const val THEME_LIGHT_VALUE = "light"
private const val THEME_BLACK_VALUE = "black" private const val THEME_BLACK_VALUE = "black"
private const val THEME_STATUS_VALUE = "status"
private var currentTheme = AtomicReference<String>(null) private var currentTheme = AtomicReference<String>(null)
@ -58,8 +58,7 @@ object ThemeUtils {
*/ */
fun isLightTheme(context: Context): Boolean { fun isLightTheme(context: Context): Boolean {
return when (getApplicationTheme(context)) { return when (getApplicationTheme(context)) {
THEME_LIGHT_VALUE, THEME_LIGHT_VALUE -> true
THEME_STATUS_VALUE -> true
else -> false else -> false
} }
} }
@ -73,8 +72,13 @@ object ThemeUtils {
fun getApplicationTheme(context: Context): String { fun getApplicationTheme(context: Context): String {
val currentTheme = this.currentTheme.get() val currentTheme = this.currentTheme.get()
return if (currentTheme == null) { return if (currentTheme == null) {
val themeFromPref = DefaultSharedPreferences.getInstance(context) val prefs = DefaultSharedPreferences.getInstance(context)
.getString(APPLICATION_THEME_KEY, THEME_LIGHT_VALUE) ?: THEME_LIGHT_VALUE var themeFromPref = prefs.getString(APPLICATION_THEME_KEY, THEME_LIGHT_VALUE) ?: THEME_LIGHT_VALUE
if (themeFromPref == "status") {
// Migrate to light theme, which is the closest theme
themeFromPref = THEME_LIGHT_VALUE
prefs.edit { putString(APPLICATION_THEME_KEY, THEME_LIGHT_VALUE) }
}
this.currentTheme.set(themeFromPref) this.currentTheme.set(themeFromPref)
themeFromPref themeFromPref
} else { } else {
@ -92,7 +96,6 @@ object ThemeUtils {
when (aTheme) { when (aTheme) {
THEME_DARK_VALUE -> context.setTheme(R.style.AppTheme_Dark) THEME_DARK_VALUE -> context.setTheme(R.style.AppTheme_Dark)
THEME_BLACK_VALUE -> context.setTheme(R.style.AppTheme_Black) THEME_BLACK_VALUE -> context.setTheme(R.style.AppTheme_Black)
THEME_STATUS_VALUE -> context.setTheme(R.style.AppTheme_Status)
else -> context.setTheme(R.style.AppTheme_Light) else -> context.setTheme(R.style.AppTheme_Light)
} }
@ -109,7 +112,6 @@ object ThemeUtils {
when (getApplicationTheme(activity)) { when (getApplicationTheme(activity)) {
THEME_DARK_VALUE -> activity.setTheme(otherThemes.dark) THEME_DARK_VALUE -> activity.setTheme(otherThemes.dark)
THEME_BLACK_VALUE -> activity.setTheme(otherThemes.black) THEME_BLACK_VALUE -> activity.setTheme(otherThemes.black)
THEME_STATUS_VALUE -> activity.setTheme(otherThemes.status)
} }
mColorByAttr.clear() mColorByAttr.clear()

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme.Status.v23" parent="AppTheme.Base.Status">
<item name="android:statusBarColor">@color/riotx_header_panel_background_light</item>
<item name="android:windowLightStatusBar">true</item>
</style>
<style name="AppTheme.Status" parent="AppTheme.Status.v23"/>
</resources>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme.Status.v27" parent="AppTheme.Status.v23">
<item name="android:navigationBarColor">@color/riotx_header_panel_background_light</item>
<item name="android:windowLightNavigationBar">true</item>
</style>
<style name="AppTheme.Status" parent="AppTheme.Status.v27" />
</resources>

View file

@ -95,14 +95,12 @@
<item>@string/light_theme</item> <item>@string/light_theme</item>
<item>@string/dark_theme</item> <item>@string/dark_theme</item>
<item>@string/black_them</item> <item>@string/black_them</item>
<item>@string/status_theme</item>
</string-array> </string-array>
<string-array name="theme_values"> <string-array name="theme_values">
<item>light</item> <item>light</item>
<item>dark</item> <item>dark</item>
<item>black</item> <item>black</item>
<item>status</item>
</string-array> </string-array>
<!-- Info area --> <!-- Info area -->

View file

@ -20,7 +20,6 @@
<color name="riot_primary_background_color_dark">#FF181B21</color> <color name="riot_primary_background_color_dark">#FF181B21</color>
<!-- Black/Background--> <!-- Black/Background-->
<color name="riot_primary_background_color_black">#F000</color> <color name="riot_primary_background_color_black">#F000</color>
<color name="riot_primary_background_color_status">#FFEEF2F5</color>
<!--Default/Android Status Bar--> <!--Default/Android Status Bar-->
<color name="primary_color_dark_light">#FF1A2027</color> <color name="primary_color_dark_light">#FF1A2027</color>
@ -41,10 +40,6 @@
<!--Black/Base--> <!--Black/Base-->
<color name="primary_color_black">#FF060708</color> <color name="primary_color_black">#FF060708</color>
<color name="primary_color_dark_status">#FF465561</color>
<color name="primary_color_status">#FF586C7B</color>
<color name="accent_color_status">#FF586C7B</color>
<!--Default/Line break mobile--> <!--Default/Line break mobile-->
<attr name="list_divider_color" format="color" /> <attr name="list_divider_color" format="color" />
<color name="list_divider_color_light">#EEEFEF</color> <color name="list_divider_color_light">#EEEFEF</color>
@ -56,12 +51,10 @@
<attr name="tab_bar_selected_background_color" format="color" /> <attr name="tab_bar_selected_background_color" format="color" />
<color name="tab_bar_selected_background_color_light">@color/riotx_android_secondary_light</color> <color name="tab_bar_selected_background_color_light">@color/riotx_android_secondary_light</color>
<color name="tab_bar_selected_background_color_dark">@color/riotx_android_secondary_dark</color> <color name="tab_bar_selected_background_color_dark">@color/riotx_android_secondary_dark</color>
<color name="tab_bar_selected_background_color_status">@color/riotx_android_secondary_black</color>
<attr name="tab_bar_unselected_background_color" format="color" /> <attr name="tab_bar_unselected_background_color" format="color" />
<color name="tab_bar_unselected_background_color_light">@color/riotx_background_light</color> <color name="tab_bar_unselected_background_color_light">@color/riotx_background_light</color>
<color name="tab_bar_unselected_background_color_dark">@color/riotx_background_dark</color> <color name="tab_bar_unselected_background_color_dark">@color/riotx_background_dark</color>
<color name="tab_bar_unselected_background_color_status">@color/riotx_background_black</color>
<!-- Hint Colors --> <!-- Hint Colors -->
<color name="primary_hint_text_color_light">#FFFFFF</color> <color name="primary_hint_text_color_light">#FFFFFF</color>
@ -88,13 +81,6 @@
<color name="riot_secondary_text_color_dark">#FFA1B2D1</color> <color name="riot_secondary_text_color_dark">#FFA1B2D1</color>
<color name="riot_tertiary_text_color_dark">@color/riot_primary_text_color_dark</color> <color name="riot_tertiary_text_color_dark">@color/riot_primary_text_color_dark</color>
<!-- Status/Text Primary-->
<color name="riot_primary_text_color_status">#FF70808D</color>
<color name="riot_primary_text_color_disabled_status">#7F70808D</color>
<!-- Status/Text Secondary-->
<color name="riot_secondary_text_color_status">#7F70808D</color>
<color name="riot_tertiary_text_color_status">@color/riot_primary_text_color_status</color>
<!-- Notification view colors --> <!-- Notification view colors -->
<color name="soft_resource_limit_exceeded">#2f9edb</color> <color name="soft_resource_limit_exceeded">#2f9edb</color>
<color name="hard_resource_limit_exceeded">@color/vector_fuchsia_color</color> <color name="hard_resource_limit_exceeded">@color/vector_fuchsia_color</color>
@ -118,7 +104,6 @@
<!-- Link color --> <!-- Link color -->
<color name="link_color_light">#368BD6</color> <color name="link_color_light">#368BD6</color>
<color name="link_color_dark">#368BD6</color> <color name="link_color_dark">#368BD6</color>
<color name="link_color_status">#368BD6</color>
<!-- Notification (do not depends on theme) --> <!-- Notification (do not depends on theme) -->
<color name="notification_accent_color">#368BD6</color> <color name="notification_accent_color">#368BD6</color>

View file

@ -202,13 +202,11 @@
<color name="riotx_bottom_nav_background_color_light">@color/riot_primary_background_color_light</color> <color name="riotx_bottom_nav_background_color_light">@color/riot_primary_background_color_light</color>
<color name="riotx_bottom_nav_background_color_dark">@color/primary_color_dark</color> <color name="riotx_bottom_nav_background_color_dark">@color/primary_color_dark</color>
<color name="riotx_bottom_nav_background_color_black">@color/primary_color_black</color> <color name="riotx_bottom_nav_background_color_black">@color/primary_color_black</color>
<color name="riotx_bottom_nav_background_color_status">@color/riot_primary_background_color_status</color>
<attr name="riotx_bottom_nav_background_border_color" format="color" /> <attr name="riotx_bottom_nav_background_border_color" format="color" />
<color name="riotx_bottom_nav_background_border_color_light">#E9EDF1</color> <color name="riotx_bottom_nav_background_border_color_light">#E9EDF1</color>
<color name="riotx_bottom_nav_background_border_color_dark">#55555555</color> <color name="riotx_bottom_nav_background_border_color_dark">#55555555</color>
<color name="riotx_bottom_nav_background_border_color_black">#FF15171b</color> <color name="riotx_bottom_nav_background_border_color_black">#FF15171b</color>
<color name="riotx_bottom_nav_background_border_color_status">#FFE9EDF1</color>
<attr name="riotx_bottom_nav_icon_color" format="color" /> <attr name="riotx_bottom_nav_icon_color" format="color" />
<color name="riotx_bottom_nav_icon_color_light">#C1C6CD</color> <color name="riotx_bottom_nav_icon_color_light">#C1C6CD</color>
@ -218,7 +216,6 @@
<attr name="riotx_waiting_background_color" format="color" /> <attr name="riotx_waiting_background_color" format="color" />
<color name="riotx_waiting_background_color_light">#AAAAAAAA</color> <color name="riotx_waiting_background_color_light">#AAAAAAAA</color>
<color name="riotx_waiting_background_color_dark">#55555555</color> <color name="riotx_waiting_background_color_dark">#55555555</color>
<color name="riotx_waiting_background_color_status">#AAAAAAAA</color>
<attr name="riotx_disabled_view_color" format="color" /> <attr name="riotx_disabled_view_color" format="color" />
<color name="riotx_disabled_view_color_light">#EEEEEE</color> <color name="riotx_disabled_view_color_light">#EEEEEE</color>

View file

@ -280,14 +280,6 @@
<item name="android:textColorLink">@color/riotx_links</item> <item name="android:textColorLink">@color/riotx_links</item>
</style> </style>
<style name="Vector.BottomSheet.Status" parent="Theme.Design.Light.BottomSheetDialog">
<item name="android:textColorPrimary">@color/riot_primary_text_color_status</item>
<item name="android:textColorSecondary">@color/riot_secondary_text_color_status</item>
<!-- Default color for text View -->
<item name="android:textColorTertiary">@color/riot_tertiary_text_color_status</item>
<item name="android:textColorLink">@color/link_color_status</item>
</style>
<style name="TimelineContentStubBaseParams"> <style name="TimelineContentStubBaseParams">
<item name="android:layout_width">match_parent</item> <item name="android:layout_width">match_parent</item>

View file

@ -1,118 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- STATUS.IM THEME COLORS -->
<!-- Inherit of Light theme to avoid crash TODO Adapt color (phase 2) -->
<style name="AppTheme.Base.Status" parent="AppTheme.Base.Light">
<item name="colorPrimaryDark">@color/primary_color_dark_status</item>
<item name="colorPrimary">@color/primary_color_status</item>
<item name="colorAccent">@color/accent_color_status</item>
<item name="android:textColorPrimary">@color/primary_text_color_selector</item>
<item name="android:textColorSecondary">@color/riot_secondary_text_color_status</item>
<!-- Default color for text View -->
<item name="android:textColorTertiary">@color/riot_tertiary_text_color_status</item>
<item name="android:textColorLink">@color/link_color_status</item>
<!-- Menu text color -->
<item name="android:actionMenuTextColor">?colorAccent</item>
<!-- default background color -->
<item name="android:colorBackground">@color/riot_primary_background_color_status</item>
<item name="riotx_bottom_nav_background_color">@color/riotx_bottom_nav_background_color_status
</item>
<item name="riotx_bottom_nav_background_border_color">@color/riotx_bottom_nav_background_border_color_status</item>
<!-- waiting view background -->
<item name="riotx_waiting_background_color">@color/riotx_waiting_background_color_status</item>
<!-- application bar text color -->
<item name="vctr_toolbar_primary_text_color">@color/primary_color_status</item>
<item name="vctr_toolbar_secondary_text_color">@color/primary_color_dark_status</item>
<item name="vctr_toolbar_link_text_color">@color/primary_color_dark_status</item>
<!-- room message colors -->
<item name="vctr_notice_secondary">#61708B</item>
<item name="vctr_unsent_message_text_color">#FFFF4444</item>
<item name="vctr_message_text_color">#70879d</item>
<item name="vctr_notice_text_color">#adadbe</item>
<item name="vctr_encrypting_message_text_color">#AECDF9</item>
<item name="vctr_sending_message_text_color">#b3e8d2</item>
<item name="vctr_markdown_block_background_color">#FFEEEEEE</item>
<item name="riot_primary_text_color">@color/riot_primary_text_color_status</item>
<item name="riot_primary_text_color_disabled">@color/riot_primary_text_color_disabled_status</item>
<!-- tab bar colors -->
<item name="vctr_tab_bar_inverted_background_color">#FFF2F2F2</item>
<!-- list colors -->
<item name="vctr_list_header_background_color">#FFF6F6F6</item>
<item name="vctr_list_header_primary_text_color">#7F3C3C3C</item>
<item name="vctr_list_header_secondary_text_color">#4D3C3C3C</item>
<!-- outgoing call background color -->
<item name="vctr_pending_outgoing_view_background_color">#33000000</item>
<!-- room notification text color (typing, unsent...) -->
<item name="vctr_room_notification_text_color">#a0a29f</item>
<!-- icon colors -->
<item name="vctr_settings_icon_tint_color">@color/accent_color_status</item>
<item name="vctr_icon_tint_on_light_action_bar_color">@color/riotx_accent</item>
<!-- ANDROID SUPPORT ATTRIBUTES -->
<!-- disable the overscroll because setOverscrollHeader/Footer don't always work -->
<item name="android:overScrollMode">never</item>
<!-- activities background -->
<item name="android:windowBackground">@color/riot_primary_background_color_status</item>
<!-- fonts -->
<item name="android:typeface">sans</item>
<!-- custom action bar -->
<item name="android:actionBarStyle">@style/Vector.Styled.ActionBar</item>
<item name="actionBarStyle">@style/Vector.Styled.ActionBar</item>
<!-- actionbar icons color -->
<item name="actionBarTheme">@style/Vector.ActionBarTheme</item>
<!-- remove the shadow under the actionbar -->
<item name="android:windowContentOverlay">@null</item>
<item name="android:popupMenuStyle">@style/Vector.PopupMenu</item>
<!-- no divider -->
<item name="android:actionBarDivider">@null</item>
<!-- tabbar text color -->
<item name="android:actionBarTabTextStyle">@style/Vector.TabText</item>
<item name="actionBarTabTextStyle">@style/Vector.TabText</item>
<item name="tab_bar_selected_background_color">@color/tab_bar_selected_background_color_status</item>
<item name="tab_bar_unselected_background_color">@color/tab_bar_unselected_background_color_status</item>
<!-- Preference -->
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
<item name="bottomSheetDialogTheme">@style/Vector.BottomSheet.Status</item>
<!-- Use dark color, to have enough contrast with icons color. windowLightStatusBar is only available in API 23+ -->
<item name="android:statusBarColor">@color/riotx_header_panel_background_dark</item>
<!-- Use dark color, to have enough contrast with icons color. windowLightNavigationBar is only available in API 27+ -->
<item name="android:navigationBarColor">@color/riotx_header_panel_background_dark</item>
<!-- enable window content transitions -->
<item name="android:windowContentTransitions">true</item>
<!-- specify shared element enter and exit transitions -->
<item name="android:windowSharedElementEnterTransition">@transition/image_preview_transition</item>
<item name="android:windowSharedElementExitTransition">@transition/image_preview_transition</item>
</style>
<style name="AppTheme.Status" parent="AppTheme.Base.Status" />
</resources>