Update mode selector button style
This commit is contained in:
@@ -164,13 +164,15 @@ class OverviewFragment : Fragment() {
|
|||||||
) :
|
) :
|
||||||
RecyclerView.Adapter<ClashModeItemView>() {
|
RecyclerView.Adapter<ClashModeItemView>() {
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ClashModeItemView {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ClashModeItemView {
|
||||||
return ClashModeItemView(
|
val view = ClashModeItemView(
|
||||||
ViewClashModeButtonBinding.inflate(
|
ViewClashModeButtonBinding.inflate(
|
||||||
LayoutInflater.from(parent.context),
|
LayoutInflater.from(parent.context),
|
||||||
parent,
|
parent,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
view.binding.clashModeButton.clipToOutline = true
|
||||||
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
@@ -186,11 +188,12 @@ class OverviewFragment : Fragment() {
|
|||||||
RecyclerView.ViewHolder(binding.root) {
|
RecyclerView.ViewHolder(binding.root) {
|
||||||
|
|
||||||
fun bind(item: String, selected: String) {
|
fun bind(item: String, selected: String) {
|
||||||
binding.clashModeButton.text = item
|
binding.clashModeButtonText.text = item
|
||||||
if (item != selected) {
|
if (item != selected) {
|
||||||
binding.clashModeButton.setBackgroundColor(
|
binding.clashModeButtonText.setTextColor(
|
||||||
binding.root.context.getAttrColor(com.google.android.material.R.attr.colorButtonNormal)
|
binding.root.context.getAttrColor(com.google.android.material.R.attr.colorOnPrimaryContainer)
|
||||||
)
|
)
|
||||||
|
binding.clashModeButton.setBackgroundResource(R.drawable.bg_rounded_rectangle)
|
||||||
binding.clashModeButton.setOnClickListener {
|
binding.clashModeButton.setOnClickListener {
|
||||||
runCatching {
|
runCatching {
|
||||||
Libbox.newStandaloneCommandClient().setClashMode(item)
|
Libbox.newStandaloneCommandClient().setClashMode(item)
|
||||||
@@ -202,9 +205,10 @@ class OverviewFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
binding.clashModeButton.setBackgroundColor(
|
binding.clashModeButtonText.setTextColor(
|
||||||
binding.root.context.getAttrColor(com.google.android.material.R.attr.colorAccent)
|
binding.root.context.getAttrColor(com.google.android.material.R.attr.colorOnPrimary)
|
||||||
)
|
)
|
||||||
|
binding.clashModeButton.setBackgroundResource(R.drawable.bg_rounded_rectangle_active)
|
||||||
binding.clashModeButton.isClickable = false
|
binding.clashModeButton.isClickable = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
app/src/main/res/drawable/bg_rounded_rectangle.xml
Normal file
9
app/src/main/res/drawable/bg_rounded_rectangle.xml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="@android:color/transparent" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="?colorOnPrimaryContainer" />
|
||||||
|
<corners android:radius="4dp" />
|
||||||
|
</shape>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<solid android:color="?colorPrimary" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="?colorPrimary" />
|
||||||
|
<corners android:radius="4dp" />
|
||||||
|
</shape>
|
||||||
@@ -424,13 +424,14 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Mode"
|
android:text="Mode"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingHorizontal="16dp"
|
||||||
android:textAppearance="?attr/textAppearanceTitleSmall">
|
android:textAppearance="?attr/textAppearanceTitleSmall">
|
||||||
|
|
||||||
</TextView>
|
</TextView>
|
||||||
@@ -440,7 +441,7 @@
|
|||||||
android:id="@+id/clashModeList"
|
android:id="@+id/clashModeList"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="16dp"
|
android:padding="8dp"
|
||||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||||
app:spanCount="3"
|
app:spanCount="3"
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/clashModeButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_margin="8dp"
|
||||||
android:gravity="center">
|
android:background="@drawable/bg_rounded_rectangle_active">
|
||||||
|
|
||||||
<Button
|
<TextView
|
||||||
android:id="@+id/clashModeButton"
|
android:id="@+id/clashModeButtonText"
|
||||||
style="@style/Widget.MaterialComponents.Button"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:background="?selectableItemBackground"
|
||||||
android:textColor="?colorSurfaceContainer"
|
android:gravity="center"
|
||||||
|
android:paddingVertical="8dp"
|
||||||
|
android:textColor="?android:textColorPrimaryInverse"
|
||||||
tools:text="Direct" />
|
tools:text="Direct" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user