diff --git a/vector/src/main/java/im/vector/riotx/core/utils/UserColor.kt b/vector/src/main/java/im/vector/riotx/core/utils/UserColor.kt index 15c4ce8a15..dbfc414793 100644 --- a/vector/src/main/java/im/vector/riotx/core/utils/UserColor.kt +++ b/vector/src/main/java/im/vector/riotx/core/utils/UserColor.kt @@ -16,14 +16,18 @@ package im.vector.riotx.core.utils +import android.content.Context import androidx.annotation.ColorRes import im.vector.riotx.R import im.vector.riotx.core.resources.ColorProvider +import im.vector.riotx.features.themes.ThemeUtils import org.billcarsonfr.jsonviewer.JSonViewerStyleProvider import kotlin.math.abs @ColorRes -fun getColorFromUserId(userId: String?): Int { +fun getColorFromUserId(userId: String?, context: Context? = null): Int { + if (ThemeUtils.isScTheme(context)) return R.color.username_sc_1; + var hash = 0 userId?.toList()?.map { chr -> hash = (hash shl 5) - hash + chr.toInt() } diff --git a/vector/src/main/java/im/vector/riotx/features/home/AvatarRenderer.kt b/vector/src/main/java/im/vector/riotx/features/home/AvatarRenderer.kt index 6d85dd8a3e..25dd0db4bc 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/AvatarRenderer.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/AvatarRenderer.kt @@ -83,8 +83,8 @@ class AvatarRenderer @Inject constructor(private val activeSessionHolder: Active @AnyThread fun getPlaceholderDrawable(context: Context, matrixItem: MatrixItem): Drawable { val avatarColor = when (matrixItem) { - is MatrixItem.UserItem -> ContextCompat.getColor(context, getColorFromUserId(matrixItem.id)) - else -> ContextCompat.getColor(context, getColorFromRoomId(matrixItem.id)) + is MatrixItem.UserItem -> ContextCompat.getColor(context, getColorFromUserId(matrixItem.id, context)) + else -> ContextCompat.getColor(context, getColorFromRoomId(matrixItem.id, context)) } return TextDrawable.builder() .beginConfig() diff --git a/vector/src/main/java/im/vector/riotx/features/home/RoomColor.kt b/vector/src/main/java/im/vector/riotx/features/home/RoomColor.kt index 0b3fd5396f..b7c5ad8d6d 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/RoomColor.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/RoomColor.kt @@ -16,11 +16,14 @@ package im.vector.riotx.features.home +import android.content.Context import androidx.annotation.ColorRes import im.vector.riotx.R +import im.vector.riotx.features.themes.ThemeUtils @ColorRes -fun getColorFromRoomId(roomId: String?): Int { +fun getColorFromRoomId(roomId: String?, context: Context? = null): Int { + if (ThemeUtils.isScTheme(context)) return R.color.avatar_fill_sc_1; return when ((roomId?.toList()?.sumBy { it.toInt() } ?: 0) % 3) { 1 -> R.color.riotx_avatar_fill_2 2 -> R.color.riotx_avatar_fill_3 diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt index f348e0612a..f147072060 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt @@ -464,7 +464,7 @@ class RoomDetailFragment @Inject constructor( // switch to expanded bar composerLayout.composerRelatedMessageTitle.apply { text = event.getDisambiguatedDisplayName() - setTextColor(ContextCompat.getColor(requireContext(), getColorFromUserId(event.root.senderId))) + setTextColor(ContextCompat.getColor(requireContext(), getColorFromUserId(event.root.senderId, context))) } val messageContent: MessageContent? = event.getLastMessageContent() diff --git a/vector/src/main/java/im/vector/riotx/features/themes/ActivityOtherThemes.kt b/vector/src/main/java/im/vector/riotx/features/themes/ActivityOtherThemes.kt index b37c1a4818..31e9f1cf02 100644 --- a/vector/src/main/java/im/vector/riotx/features/themes/ActivityOtherThemes.kt +++ b/vector/src/main/java/im/vector/riotx/features/themes/ActivityOtherThemes.kt @@ -25,15 +25,18 @@ import im.vector.riotx.R */ sealed class ActivityOtherThemes(@StyleRes val dark: Int, @StyleRes val black: Int, - @StyleRes val status: Int) { + @StyleRes val status: Int, + @StyleRes val sc: Int) { object Default : ActivityOtherThemes( R.style.AppTheme_Dark, R.style.AppTheme_Black, - R.style.AppTheme_Status + R.style.AppTheme_Status, + R.style.AppTheme_SC ) object AttachmentsPreview : ActivityOtherThemes( + R.style.AppTheme_AttachmentsPreview, R.style.AppTheme_AttachmentsPreview, R.style.AppTheme_AttachmentsPreview, R.style.AppTheme_AttachmentsPreview diff --git a/vector/src/main/java/im/vector/riotx/features/themes/ThemeUtils.kt b/vector/src/main/java/im/vector/riotx/features/themes/ThemeUtils.kt index 1f835164db..f9a92c3e7f 100644 --- a/vector/src/main/java/im/vector/riotx/features/themes/ThemeUtils.kt +++ b/vector/src/main/java/im/vector/riotx/features/themes/ThemeUtils.kt @@ -41,9 +41,12 @@ object ThemeUtils { private const val THEME_LIGHT_VALUE = "light" private const val THEME_BLACK_VALUE = "black" private const val THEME_STATUS_VALUE = "status" + private const val THEME_SC_VALUE = "sc" private val mColorByAttr = HashMap() + private var mIsScTheme = false; + /** * Provides the selected application theme * @@ -55,6 +58,19 @@ object ThemeUtils { .getString(APPLICATION_THEME_KEY, THEME_LIGHT_VALUE)!! } + /** + * Whether this is SC theme. + * + * @param context the context + * @return true if SC theme is active, false otherwise + */ + fun isScTheme(context: Context?): Boolean { + if (context != null) { + mIsScTheme = THEME_SC_VALUE.equals(getApplicationTheme(context)); + } + return mIsScTheme; + } + /** * Update the application theme * @@ -65,6 +81,7 @@ object ThemeUtils { THEME_DARK_VALUE -> context.setTheme(R.style.AppTheme_Dark) THEME_BLACK_VALUE -> context.setTheme(R.style.AppTheme_Black) THEME_STATUS_VALUE -> context.setTheme(R.style.AppTheme_Status) + THEME_SC_VALUE -> context.setTheme(R.style.AppTheme_SC) else -> context.setTheme(R.style.AppTheme_Light) } @@ -82,6 +99,7 @@ object ThemeUtils { THEME_DARK_VALUE -> activity.setTheme(otherThemes.dark) THEME_BLACK_VALUE -> activity.setTheme(otherThemes.black) THEME_STATUS_VALUE -> activity.setTheme(otherThemes.status) + THEME_SC_VALUE -> activity.setTheme(otherThemes.sc) } mColorByAttr.clear() @@ -189,6 +207,18 @@ object ThemeUtils { } } } + THEME_SC_VALUE -> { + return when (resourceId) { + R.drawable.bg_search_edit_text_light -> R.drawable.bg_search_edit_text_sc + R.drawable.bg_unread_notification_light -> R.drawable.bg_unread_notification_sc + R.drawable.vector_label_background_light -> R.drawable.vector_label_background_sc + R.drawable.divider_horizontal_light -> R.drawable.divider_horizontal_sc + else -> { + Timber.w("Warning, missing case for wanted drawable in sc theme") + resourceId + } + } + } else -> { Timber.w("Warning, missing theme: $theme") resourceId diff --git a/vector/src/main/res/color/button_background_tint_selector_sc.xml b/vector/src/main/res/color/button_background_tint_selector_sc.xml new file mode 100644 index 0000000000..88d99bc59e --- /dev/null +++ b/vector/src/main/res/color/button_background_tint_selector_sc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_camera.xml b/vector/src/main/res/drawable-anydpi-v24/ic_camera.xml new file mode 100644 index 0000000000..d703e2ff6d --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_camera.xml @@ -0,0 +1,22 @@ + + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_check_on.xml b/vector/src/main/res/drawable-anydpi-v24/ic_check_on.xml new file mode 100644 index 0000000000..08d0cb7779 --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_check_on.xml @@ -0,0 +1,13 @@ + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_filter.xml b/vector/src/main/res/drawable-anydpi-v24/ic_filter.xml new file mode 100644 index 0000000000..ef37e877cc --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_filter.xml @@ -0,0 +1,20 @@ + + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_material_share.xml b/vector/src/main/res/drawable-anydpi-v24/ic_material_share.xml new file mode 100644 index 0000000000..1ea9471f07 --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_material_share.xml @@ -0,0 +1,24 @@ + + + + + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_plus_circle.xml b/vector/src/main/res/drawable-anydpi-v24/ic_plus_circle.xml new file mode 100644 index 0000000000..ea99cb1e02 --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_plus_circle.xml @@ -0,0 +1,22 @@ + + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_search.xml b/vector/src/main/res/drawable-anydpi-v24/ic_search.xml new file mode 100644 index 0000000000..9fa99042d0 --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_search.xml @@ -0,0 +1,22 @@ + + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_send.xml b/vector/src/main/res/drawable-anydpi-v24/ic_send.xml new file mode 100644 index 0000000000..8d16753fca --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_send.xml @@ -0,0 +1,14 @@ + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_call.xml b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_call.xml new file mode 100644 index 0000000000..2baa9e057d --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_call.xml @@ -0,0 +1,14 @@ + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_flair.xml b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_flair.xml new file mode 100644 index 0000000000..67c7124a00 --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_flair.xml @@ -0,0 +1,22 @@ + + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_general.xml b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_general.xml new file mode 100644 index 0000000000..b79e913a0c --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_general.xml @@ -0,0 +1,22 @@ + + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_help_about.xml b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_help_about.xml new file mode 100644 index 0000000000..01ce849a36 --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_help_about.xml @@ -0,0 +1,30 @@ + + + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_ignored_users.xml b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_ignored_users.xml new file mode 100644 index 0000000000..8d2143de8d --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_ignored_users.xml @@ -0,0 +1,30 @@ + + + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_labs.xml b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_labs.xml new file mode 100644 index 0000000000..ed47a63860 --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_labs.xml @@ -0,0 +1,14 @@ + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_legacy.xml b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_legacy.xml new file mode 100644 index 0000000000..2c6da3c3b5 --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_legacy.xml @@ -0,0 +1,14 @@ + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_notification.xml b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_notification.xml new file mode 100644 index 0000000000..a115f04b4e --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_notification.xml @@ -0,0 +1,14 @@ + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_preferences.xml b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_preferences.xml new file mode 100644 index 0000000000..7a2cfdebca --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_preferences.xml @@ -0,0 +1,14 @@ + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_security_privacy.xml b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_security_privacy.xml new file mode 100644 index 0000000000..3b85f05134 --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_settings_root_security_privacy.xml @@ -0,0 +1,22 @@ + + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_shield_custom.xml b/vector/src/main/res/drawable-anydpi-v24/ic_shield_custom.xml new file mode 100644 index 0000000000..e258223d04 --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_shield_custom.xml @@ -0,0 +1,14 @@ + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_shield_trusted.xml b/vector/src/main/res/drawable-anydpi-v24/ic_shield_trusted.xml new file mode 100644 index 0000000000..3d0aa44df4 --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_shield_trusted.xml @@ -0,0 +1,18 @@ + + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_x_18dp.xml b/vector/src/main/res/drawable-anydpi-v24/ic_x_18dp.xml new file mode 100644 index 0000000000..5ab24486cb --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_x_18dp.xml @@ -0,0 +1,14 @@ + + + diff --git a/vector/src/main/res/drawable-anydpi-v24/ic_x_green.xml b/vector/src/main/res/drawable-anydpi-v24/ic_x_green.xml new file mode 100644 index 0000000000..e77a8d4272 --- /dev/null +++ b/vector/src/main/res/drawable-anydpi-v24/ic_x_green.xml @@ -0,0 +1,14 @@ + + + diff --git a/vector/src/main/res/drawable/bg_search_edit_text_sc.xml b/vector/src/main/res/drawable/bg_search_edit_text_sc.xml new file mode 100644 index 0000000000..54dc7e0bd2 --- /dev/null +++ b/vector/src/main/res/drawable/bg_search_edit_text_sc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/bg_unread_notification_sc.xml b/vector/src/main/res/drawable/bg_unread_notification_sc.xml new file mode 100644 index 0000000000..bec8481572 --- /dev/null +++ b/vector/src/main/res/drawable/bg_unread_notification_sc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/direct_chat_circle_sc.xml b/vector/src/main/res/drawable/direct_chat_circle_sc.xml new file mode 100644 index 0000000000..7ce5c5a875 --- /dev/null +++ b/vector/src/main/res/drawable/direct_chat_circle_sc.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/divider_horizontal_sc.xml b/vector/src/main/res/drawable/divider_horizontal_sc.xml new file mode 100644 index 0000000000..5fa91ca508 --- /dev/null +++ b/vector/src/main/res/drawable/divider_horizontal_sc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/highlighted_message_background_sc.xml b/vector/src/main/res/drawable/highlighted_message_background_sc.xml new file mode 100644 index 0000000000..6832ba01d3 --- /dev/null +++ b/vector/src/main/res/drawable/highlighted_message_background_sc.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/line_divider_sc.xml b/vector/src/main/res/drawable/line_divider_sc.xml new file mode 100644 index 0000000000..7c37b022e3 --- /dev/null +++ b/vector/src/main/res/drawable/line_divider_sc.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/pill_background_room_alias_sc.xml b/vector/src/main/res/drawable/pill_background_room_alias_sc.xml new file mode 100644 index 0000000000..41265cf720 --- /dev/null +++ b/vector/src/main/res/drawable/pill_background_room_alias_sc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/pill_background_user_id_sc.xml b/vector/src/main/res/drawable/pill_background_user_id_sc.xml new file mode 100644 index 0000000000..41265cf720 --- /dev/null +++ b/vector/src/main/res/drawable/pill_background_user_id_sc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/pill_receipt_sc.xml b/vector/src/main/res/drawable/pill_receipt_sc.xml new file mode 100644 index 0000000000..54e2df6d0c --- /dev/null +++ b/vector/src/main/res/drawable/pill_receipt_sc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/vector_label_background_sc.xml b/vector/src/main/res/drawable/vector_label_background_sc.xml new file mode 100644 index 0000000000..aecd01d7b5 --- /dev/null +++ b/vector/src/main/res/drawable/vector_label_background_sc.xml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/vector_tabbar_background_sc.xml b/vector/src/main/res/drawable/vector_tabbar_background_sc.xml new file mode 100644 index 0000000000..e0f94aeda3 --- /dev/null +++ b/vector/src/main/res/drawable/vector_tabbar_background_sc.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/vector_tabbar_selected_background_sc.xml b/vector/src/main/res/drawable/vector_tabbar_selected_background_sc.xml new file mode 100644 index 0000000000..9d07d2fd29 --- /dev/null +++ b/vector/src/main/res/drawable/vector_tabbar_selected_background_sc.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/vector_tabbar_unselected_background_sc.xml b/vector/src/main/res/drawable/vector_tabbar_unselected_background_sc.xml new file mode 100644 index 0000000000..5aaa571074 --- /dev/null +++ b/vector/src/main/res/drawable/vector_tabbar_unselected_background_sc.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/vector/src/main/res/layout/fragment_home_drawer.xml b/vector/src/main/res/layout/fragment_home_drawer.xml index 4e257eabd4..d835528aef 100644 --- a/vector/src/main/res/layout/fragment_home_drawer.xml +++ b/vector/src/main/res/layout/fragment_home_drawer.xml @@ -23,7 +23,7 @@ android:layout_height="@dimen/layout_touch_size" android:scaleType="center" android:src="@drawable/ic_settings_x" - android:tint="@color/riotx_accent" + android:tint="?colorAccent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> diff --git a/vector/src/main/res/values-v21/theme_sc.xml b/vector/src/main/res/values-v21/theme_sc.xml new file mode 100644 index 0000000000..b4bc288b03 --- /dev/null +++ b/vector/src/main/res/values-v21/theme_sc.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + + + + + + + +