Skip to content

Commit 4fcb8c4

Browse files
msfjarviszx2c4
authored andcommitted
ui: introduce a fresh set of Material3 themes and migrate to them
Signed-off-by: Harsh Shandilya <[email protected]>
1 parent fb05b35 commit 4fcb8c4

File tree

15 files changed

+147
-111
lines changed

15 files changed

+147
-111
lines changed

ui/src/main/java/com/wireguard/android/activity/LogViewerActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import com.wireguard.android.R
4040
import com.wireguard.android.databinding.LogViewerActivityBinding
4141
import com.wireguard.android.util.DownloadsFileSaver
4242
import com.wireguard.android.util.ErrorMessages
43+
import com.wireguard.android.util.resolveAttribute
4344
import com.wireguard.crypto.KeyPair
4445
import kotlinx.coroutines.Dispatchers
4546
import kotlinx.coroutines.launch
@@ -70,7 +71,7 @@ class LogViewerActivity : AppCompatActivity() {
7071
yearFormatter.format(Date())
7172
}
7273

73-
private val defaultColor by lazy { ResourcesCompat.getColor(resources, R.color.primary_text_color, theme) }
74+
private val defaultColor by lazy { ResourcesCompat.getColor(resources, resolveAttribute(com.google.android.material.R.attr.colorOnSurface), theme) }
7475

7576
private val debugColor by lazy { ResourcesCompat.getColor(resources, R.color.debug_tag_color, theme) }
7677

ui/src/main/java/com/wireguard/android/fragment/AddTunnelsSheet.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ class AddTunnelsSheet : BottomSheetDialogFragment() {
3434
}
3535
}
3636

37-
override fun getTheme(): Int {
38-
return R.style.BottomSheetDialogTheme
39-
}
40-
4137
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
4238
if (savedInstanceState != null) dismiss()
4339
val view = inflater.inflate(R.layout.add_tunnels_bottom_sheet, container, false)
@@ -76,7 +72,7 @@ class AddTunnelsSheet : BottomSheetDialogFragment() {
7672
}
7773
})
7874
val gradientDrawable = GradientDrawable().apply {
79-
setColor(requireContext().resolveAttribute(R.attr.colorBackground))
75+
setColor(requireContext().resolveAttribute(com.google.android.material.R.attr.colorSurface))
8076
}
8177
view.background = gradientDrawable
8278
}

ui/src/main/res/layout/tunnel_detail_fragment.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<ScrollView
2626
android:layout_width="match_parent"
2727
android:layout_height="match_parent"
28-
android:background="?attr/colorBackground"
28+
android:background="?attr/colorSurface"
2929
android:clickable="true"
3030
android:focusable="true">
3131

ui/src/main/res/layout/tunnel_editor_fragment.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
android:id="@+id/main_container"
2929
android:layout_width="match_parent"
3030
android:layout_height="wrap_content"
31-
android:background="?attr/colorBackground">
31+
android:background="?attr/colorSurface">
3232

3333
<ScrollView
3434
android:layout_width="match_parent"

ui/src/main/res/layout/tunnel_list_fragment.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
android:id="@+id/main_container"
2525
android:layout_width="match_parent"
2626
android:layout_height="match_parent"
27-
android:background="?attr/colorBackground"
27+
android:background="?attr/colorSurface"
2828
android:clipChildren="false">
2929

3030
<androidx.recyclerview.widget.RecyclerView

ui/src/main/res/layout/tv_tunnel_list_item.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
android:layout_margin="8dp"
3535
android:layout_marginTop="4dp"
3636
android:layout_marginBottom="0dp"
37-
android:backgroundTint="@{(item.state == State.UP &amp;&amp; !isDeleting) ? @color/secondary_dark_color : (isDeleting &amp;&amp; isFocused) ? @color/tv_card_delete_background : @color/tv_card_background}"
3837
android:checkable="true"
3938
android:focusable="true"
40-
app:contentPadding="8dp">
39+
app:contentPadding="8dp"
40+
android:backgroundTint="@{(item.state == State.UP &amp;&amp; !isDeleting) ? @color/tv_secondary_dark_color : (isDeleting &amp;&amp; isFocused) ? @color/tv_card_delete_background : @color/tv_card_background}">
4141

4242
<androidx.constraintlayout.widget.ConstraintLayout
4343
android:layout_width="match_parent"

ui/src/main/res/values-night/colors.xml

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
<resources>
3+
<style name="WireGuardTheme" parent="Theme.Material3.Dark">
4+
<item name="colorPrimary">@color/md_theme_dark_primary</item>
5+
<item name="colorOnPrimary">@color/md_theme_dark_onPrimary</item>
6+
<item name="colorPrimaryContainer">@color/md_theme_dark_primaryContainer</item>
7+
<item name="colorOnPrimaryContainer">@color/md_theme_dark_onPrimaryContainer</item>
8+
<item name="colorSecondary">@color/md_theme_dark_secondary</item>
9+
<item name="colorOnSecondary">@color/md_theme_dark_onSecondary</item>
10+
<item name="colorSecondaryContainer">@color/md_theme_dark_secondaryContainer</item>
11+
<item name="colorOnSecondaryContainer">@color/md_theme_dark_onSecondaryContainer</item>
12+
<item name="colorTertiary">@color/md_theme_dark_tertiary</item>
13+
<item name="colorOnTertiary">@color/md_theme_dark_onTertiary</item>
14+
<item name="colorTertiaryContainer">@color/md_theme_dark_tertiaryContainer</item>
15+
<item name="colorOnTertiaryContainer">@color/md_theme_dark_onTertiaryContainer</item>
16+
<item name="colorError">@color/md_theme_dark_error</item>
17+
<item name="colorErrorContainer">@color/md_theme_dark_errorContainer</item>
18+
<item name="colorOnError">@color/md_theme_dark_onError</item>
19+
<item name="colorOnErrorContainer">@color/md_theme_dark_onErrorContainer</item>
20+
<item name="android:colorBackground">@color/md_theme_dark_background</item>
21+
<item name="colorOnBackground">@color/md_theme_dark_onBackground</item>
22+
<item name="colorSurface">@color/md_theme_dark_surface</item>
23+
<item name="colorOnSurface">@color/md_theme_dark_onSurface</item>
24+
<item name="colorSurfaceVariant">@color/md_theme_dark_surfaceVariant</item>
25+
<item name="colorOnSurfaceVariant">@color/md_theme_dark_onSurfaceVariant</item>
26+
<item name="colorOutline">@color/md_theme_dark_outline</item>
27+
<item name="colorOnSurfaceInverse">@color/md_theme_dark_inverseOnSurface</item>
28+
<item name="colorSurfaceInverse">@color/md_theme_dark_inverseSurface</item>
29+
<item name="colorPrimaryInverse">@color/md_theme_dark_inversePrimary</item>
30+
</style>
31+
</resources>

ui/src/main/res/values-v27/styles.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

ui/src/main/res/values/attrs.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,4 @@
44
<attr name="state_multiselected" format="boolean" />
55
<attr name="colorMultiselectActiveBackground" format="reference|color" />
66
</declare-styleable>
7-
8-
<declare-styleable name="custom_color">
9-
<attr name="colorBackground" format="reference|color" />
10-
</declare-styleable>
117
</resources>

0 commit comments

Comments
 (0)