Skip to content

Commit aec2f14

Browse files
authored
ADFA-6371: Make the selected toggle button visible in new-file dialogs (#2102)
Material 3 fills a checked outlined button with colorSecondaryContainer, which the theme sets to #E8E8E8 on a #EDEDED dialog, and keeps the text colour, so selecting Kotlin or a class type showed no change. The theme now points materialButtonOutlinedStyle at a style that fills checked buttons with colorPrimary and draws their text and icon in colorOnPrimary; unchecked and non-toggle buttons keep Material's colours. The Class button also switches to the Kotlin icon when Kotlin is picked.
1 parent bb9efab commit aec2f14

4 files changed

Lines changed: 40 additions & 0 deletions

File tree

‎app/src/main/java/com/itsaky/androidide/actions/filetree/NewFileAction.kt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,15 @@ class NewFileAction(
168168
val builder = DialogUtils.newMaterialDialogBuilder(context)
169169
val binding: LayoutCreateFileJavaBinding =
170170
LayoutCreateFileJavaBinding.inflate(LayoutInflater.from(context))
171+
binding.languageGroup.addOnButtonCheckedListener { _, _, _ ->
172+
binding.typeClass.setIconResource(
173+
if (binding.languageGroup.checkedButtonId == binding.langKotlin.id) {
174+
R.drawable.ic_language_kotlin
175+
} else {
176+
R.drawable.ic_language_java
177+
},
178+
)
179+
}
171180
binding.typeGroup.addOnButtonCheckedListener { _, _, _ ->
172181
binding.createLayout.isVisible = binding.typeGroup.checkedButtonId == binding.typeActivity.id
173182
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item
4+
android:color="?attr/colorPrimary"
5+
android:state_checked="true"
6+
android:state_enabled="true" />
7+
<item android:color="?attr/colorContainer" />
8+
</selector>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item
4+
android:alpha="0.38"
5+
android:color="?attr/colorOnSurface"
6+
android:state_enabled="false" />
7+
<item
8+
android:color="?attr/colorOnContainer"
9+
android:state_checkable="false" />
10+
<item
11+
android:color="?attr/colorOnPrimary"
12+
android:state_checked="true" />
13+
<item android:color="?attr/colorOnSurface" />
14+
</selector>

‎resources/src/main/res/values/styles.xml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@
5555
<item name="shapeAppearanceLargeComponent">@style/AppTheme.ShapeOverlay.Large</item>
5656
<item name="textAppearanceBodySmall">@style/TextAppearance.AndroidIDE.BodySmall</item>
5757
<item name="colorSuccess">@color/green_500</item>
58+
<item name="materialButtonOutlinedStyle">@style/Widget.AndroidIDE.Button.OutlinedButton</item>
59+
</style>
60+
61+
<style
62+
name="Widget.AndroidIDE.Button.OutlinedButton"
63+
parent="Widget.Material3.Button.OutlinedButton">
64+
<item name="backgroundTint">@color/button_outlined_background_selector</item>
65+
<item name="android:textColor">@color/button_outlined_foreground_selector</item>
66+
<item name="iconTint">@color/button_outlined_foreground_selector</item>
5867
</style>
5968

6069
<style

0 commit comments

Comments
 (0)