From 4fcb8c47923a6ef76d606ca03aebf2a8531136fa Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 27 Mar 2023 16:22:40 +0530 Subject: ui: introduce a fresh set of Material3 themes and migrate to them Signed-off-by: Harsh Shandilya --- .../android/activity/LogViewerActivity.kt | 3 +- .../wireguard/android/fragment/AddTunnelsSheet.kt | 6 +- ui/src/main/res/layout/tunnel_detail_fragment.xml | 2 +- ui/src/main/res/layout/tunnel_editor_fragment.xml | 2 +- ui/src/main/res/layout/tunnel_list_fragment.xml | 2 +- ui/src/main/res/layout/tv_tunnel_list_item.xml | 4 +- ui/src/main/res/values-night/colors.xml | 23 ------ ui/src/main/res/values-night/themes.xml | 31 +++++++++ ui/src/main/res/values-v27/styles.xml | 9 --- ui/src/main/res/values/attrs.xml | 4 -- ui/src/main/res/values/colors.xml | 81 +++++++++++++++++----- ui/src/main/res/values/styles.xml | 51 ++++---------- ui/src/main/res/values/themes.xml | 31 +++++++++ ui/src/main/res/values/tv_colors.xml | 1 + ui/src/main/res/values/tv_styles.xml | 8 +-- 15 files changed, 147 insertions(+), 111 deletions(-) delete mode 100644 ui/src/main/res/values-night/colors.xml create mode 100644 ui/src/main/res/values-night/themes.xml delete mode 100644 ui/src/main/res/values-v27/styles.xml create mode 100644 ui/src/main/res/values/themes.xml (limited to 'ui') diff --git a/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt b/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt index fe75be35..2493d281 100644 --- a/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt +++ b/ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt @@ -40,6 +40,7 @@ import com.wireguard.android.R import com.wireguard.android.databinding.LogViewerActivityBinding import com.wireguard.android.util.DownloadsFileSaver import com.wireguard.android.util.ErrorMessages +import com.wireguard.android.util.resolveAttribute import com.wireguard.crypto.KeyPair import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -70,7 +71,7 @@ class LogViewerActivity : AppCompatActivity() { yearFormatter.format(Date()) } - private val defaultColor by lazy { ResourcesCompat.getColor(resources, R.color.primary_text_color, theme) } + private val defaultColor by lazy { ResourcesCompat.getColor(resources, resolveAttribute(com.google.android.material.R.attr.colorOnSurface), theme) } private val debugColor by lazy { ResourcesCompat.getColor(resources, R.color.debug_tag_color, theme) } diff --git a/ui/src/main/java/com/wireguard/android/fragment/AddTunnelsSheet.kt b/ui/src/main/java/com/wireguard/android/fragment/AddTunnelsSheet.kt index f54f88f2..78b9f3d7 100644 --- a/ui/src/main/java/com/wireguard/android/fragment/AddTunnelsSheet.kt +++ b/ui/src/main/java/com/wireguard/android/fragment/AddTunnelsSheet.kt @@ -34,10 +34,6 @@ class AddTunnelsSheet : BottomSheetDialogFragment() { } } - override fun getTheme(): Int { - return R.style.BottomSheetDialogTheme - } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { if (savedInstanceState != null) dismiss() val view = inflater.inflate(R.layout.add_tunnels_bottom_sheet, container, false) @@ -76,7 +72,7 @@ class AddTunnelsSheet : BottomSheetDialogFragment() { } }) val gradientDrawable = GradientDrawable().apply { - setColor(requireContext().resolveAttribute(R.attr.colorBackground)) + setColor(requireContext().resolveAttribute(com.google.android.material.R.attr.colorSurface)) } view.background = gradientDrawable } diff --git a/ui/src/main/res/layout/tunnel_detail_fragment.xml b/ui/src/main/res/layout/tunnel_detail_fragment.xml index 96829e3c..751088f6 100644 --- a/ui/src/main/res/layout/tunnel_detail_fragment.xml +++ b/ui/src/main/res/layout/tunnel_detail_fragment.xml @@ -25,7 +25,7 @@ diff --git a/ui/src/main/res/layout/tunnel_editor_fragment.xml b/ui/src/main/res/layout/tunnel_editor_fragment.xml index 59572b32..4443c003 100644 --- a/ui/src/main/res/layout/tunnel_editor_fragment.xml +++ b/ui/src/main/res/layout/tunnel_editor_fragment.xml @@ -28,7 +28,7 @@ android:id="@+id/main_container" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="?attr/colorBackground"> + android:background="?attr/colorSurface"> + app:contentPadding="8dp" + android:backgroundTint="@{(item.state == State.UP && !isDeleting) ? @color/tv_secondary_dark_color : (isDeleting && isFocused) ? @color/tv_card_delete_background : @color/tv_card_background}"> - - - #ff212121 - #ff484848 - #ff000000 - #ff4285f4 - #ff80b4ff - #ff0059c1 - #ffffffff - #ffffffff - - - #1aeeeeee - @color/primary_color - #aa212121 - - - #aaaaaa - #ff0000 - #00ff00 - #ffff00 - diff --git a/ui/src/main/res/values-night/themes.xml b/ui/src/main/res/values-night/themes.xml new file mode 100644 index 00000000..9187e48a --- /dev/null +++ b/ui/src/main/res/values-night/themes.xml @@ -0,0 +1,31 @@ + + + + diff --git a/ui/src/main/res/values-v27/styles.xml b/ui/src/main/res/values-v27/styles.xml deleted file mode 100644 index b797e105..00000000 --- a/ui/src/main/res/values-v27/styles.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - diff --git a/ui/src/main/res/values/attrs.xml b/ui/src/main/res/values/attrs.xml index b5b614e9..903ac008 100644 --- a/ui/src/main/res/values/attrs.xml +++ b/ui/src/main/res/values/attrs.xml @@ -4,8 +4,4 @@ - - - - diff --git a/ui/src/main/res/values/colors.xml b/ui/src/main/res/values/colors.xml index 989c6fc1..41dee2fa 100644 --- a/ui/src/main/res/values/colors.xml +++ b/ui/src/main/res/values/colors.xml @@ -1,24 +1,67 @@ - - - - #ffffffff - #ffffffff - #ffcccccc - #ff1a73e8 - #ff1a73e8 - #ff1a73e8 - #ff000000 - #ffffffff + + #1a73e8 + #005BC0 + #FFFFFF + #D8E2FF + #001A41 + #565E71 + #FFFFFF + #DBE2F9 + #131B2C + #715574 + #FFFFFF + #FBD7FC + #29132D + #BA1A1A + #FFDAD6 + #FFFFFF + #410002 + #FEFBFF + #1B1B1F + #FEFBFF + #1B1B1F + #E1E2EC + #44474F + #74777F + #F2F0F4 + #303033 + #ADC7FF + #000000 + #005BC0 + #C4C6D0 + #000000 + #ADC7FF + #002E68 + #004493 + #D8E2FF + #BFC6DC + #283041 + #3F4759 + #DBE2F9 + #DEBCDF + #402843 + #583E5B + #FBD7FC + #FFB4AB + #93000A + #690005 + #FFDAD6 + #1B1B1F + #E3E2E6 + #1B1B1F + #E3E2E6 + #44474F + #C4C6D0 + #8E9099 + #1B1B1F + #E3E2E6 + #005BC0 + #000000 + #ADC7FF + #44474F + #000000 - - @color/primary_text_color - @color/primary_color - #aaffffff #ffeeeeee - - @color/secondary_color - - #ffffffff #444444 diff --git a/ui/src/main/res/values/styles.xml b/ui/src/main/res/values/styles.xml index e9a174cf..019cb300 100644 --- a/ui/src/main/res/values/styles.xml +++ b/ui/src/main/res/values/styles.xml @@ -1,49 +1,28 @@ - - - - - diff --git a/ui/src/main/res/values/themes.xml b/ui/src/main/res/values/themes.xml new file mode 100644 index 00000000..e8d36cdd --- /dev/null +++ b/ui/src/main/res/values/themes.xml @@ -0,0 +1,31 @@ + + + + diff --git a/ui/src/main/res/values/tv_colors.xml b/ui/src/main/res/values/tv_colors.xml index f330bedc..40fb45a0 100644 --- a/ui/src/main/res/values/tv_colors.xml +++ b/ui/src/main/res/values/tv_colors.xml @@ -1,6 +1,7 @@ #ff212121 + #ff0059c1 @color/tv_primary_color #b00020 diff --git a/ui/src/main/res/values/tv_styles.xml b/ui/src/main/res/values/tv_styles.xml index 536ca752..a78f2d63 100644 --- a/ui/src/main/res/values/tv_styles.xml +++ b/ui/src/main/res/values/tv_styles.xml @@ -10,7 +10,6 @@ #ff0059c1 @color/tv_primary_color #fffafafa - @color/tv_primary_color @color/list_multiselect_background #fffafafa false @@ -25,15 +24,10 @@