Skip to content

Commit 93ab899

Browse files
authored
Merge pull request #105 from winstonsung/dev-104
Add "selected" background color to in-app language picker
2 parents b1a4ee1 + 402b6a2 commit 93ab899

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

app/src/main/java/app/opass/ccip/ui/LanguagePreferenceFragment.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.view.LayoutInflater
66
import android.view.View
77
import android.view.ViewGroup
88
import android.widget.ImageView
9+
import android.widget.LinearLayout
910
import android.widget.TextView
1011
import androidx.appcompat.app.AppCompatDelegate
1112
import androidx.core.os.LocaleListCompat
@@ -141,11 +142,14 @@ class LanguagePreferenceAdapter(
141142

142143
if (!isSelected) {
143144
holder.selectedIcon.setImageDrawable(null)
145+
} else {
146+
holder.optionItem.setBackgroundResource(R.color.secondaryContainer)
144147
}
145148
}
146149
}
147150

148151
class LanguagePreferenceViewHolder(view: View) : RecyclerView.ViewHolder(view) {
152+
val optionItem: LinearLayout = view.findViewById(R.id.option_language_item)
149153
val localName: TextView = view.findViewById(R.id.option_local_name)
150154
val translatedName: TextView = view.findViewById(R.id.option_translated_name)
151155
val selectedIcon: ImageView = view.findViewById(R.id.icon_selected)

app/src/main/res/layout/item_option_language.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
34
xmlns:app="http://schemas.android.com/apk/res-auto"
45
xmlns:tools="http://schemas.android.com/tools"
6+
android:id="@+id/option_language_item"
57
android:layout_width="match_parent"
68
android:layout_height="wrap_content"
79
android:background="?attr/selectableItemBackground"
@@ -41,6 +43,5 @@
4143
android:layout_height="fill_parent"
4244
android:padding="5dp"
4345
android:src="@drawable/ic_baseline_done_24"
44-
app:tint="@color/colorWhite"
45-
tools:tint="@color/colorAccent"/>
46+
app:tint="@color/textColorPrimary" />
4647
</LinearLayout>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
<color name="textColorPrimary">@android:color/white</color>
1212
<color name="textColorSecondary">@color/colorAccent</color>
1313
<color name="backgroundColorPrimary">@color/background_material_dark</color>
14+
<color name="secondaryContainer">#4A4458</color>
1415
</resources>

app/src/main/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@
1111
<color name="textColorPrimary">@android:color/black</color>
1212
<color name="textColorSecondary">@color/colorPrimary</color>
1313
<color name="backgroundColorPrimary">@color/background_material_light</color>
14+
<color name="secondaryContainer">#E8DEF8</color>
1415
</resources>

0 commit comments

Comments
 (0)