Skip to content

Commit 744a650

Browse files
committed
feat(ui): use checkbox to indicate reordering station status
1 parent 1238a5f commit 744a650

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

app/src/main/java/com/michatec/radio/collection/CollectionAdapter.kt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,19 @@ package com.michatec.radio.collection
33
import android.annotation.SuppressLint
44
import android.content.Context
55
import android.content.SharedPreferences
6-
import android.content.res.ColorStateList
76
import android.text.Editable
87
import android.text.TextWatcher
98
import android.view.KeyEvent
109
import android.view.LayoutInflater
1110
import android.view.View
1211
import android.view.ViewGroup
1312
import android.view.inputmethod.EditorInfo
13+
import android.widget.CheckBox
1414
import android.widget.ImageView
1515
import android.widget.ProgressBar
1616
import android.widget.TextView
1717
import androidx.appcompat.app.AppCompatActivity
1818
import androidx.constraintlayout.widget.Group
19-
import androidx.core.content.ContextCompat
2019
import androidx.core.net.toUri
2120
import androidx.core.view.isGone
2221
import androidx.core.view.isVisible
@@ -180,7 +179,6 @@ class CollectionAdapter(
180179

181180
// get reference to StationViewHolder
182181
val stationViewHolder: StationViewHolder = holder
183-
184182
// set up station views
185183
setStarredIcon(stationViewHolder, station)
186184
setStationName(stationViewHolder, station)
@@ -190,13 +188,12 @@ class CollectionAdapter(
190188
setPlaybackProgress(stationViewHolder, station)
191189
setDownloadProgress(stationViewHolder, station)
192190

193-
// highlight if reordering
194191
if (reorderStationUuid == station.uuid) {
195-
stationViewHolder.stationCardView.setStrokeColor(
196-
ColorStateList.valueOf(
197-
ContextCompat.getColor(context, R.color.cardview_reordering)
198-
)
199-
)
192+
stationViewHolder.reorderCheckbox.isVisible = true
193+
stationViewHolder.reorderCheckbox.isChecked = true
194+
} else {
195+
stationViewHolder.reorderCheckbox.isGone = true
196+
stationViewHolder.reorderCheckbox.isChecked = false
200197
}
201198

202199
// show / hide edit views
@@ -774,6 +771,7 @@ class CollectionAdapter(
774771
val stationImageView: ImageView = stationCardLayout.findViewById(R.id.station_icon)
775772
val stationNameView: TextView = stationCardLayout.findViewById(R.id.station_name)
776773
val stationStarredView: ImageView = stationCardLayout.findViewById(R.id.starred_icon)
774+
val reorderCheckbox: CheckBox = stationCardLayout.findViewById(R.id.reorder_checkbox)
777775
val bufferingProgress: ProgressBar = stationCardLayout.findViewById(R.id.buffering_progress)
778776
val downloadProgress: ProgressBar = stationCardLayout.findViewById(R.id.download_progress)
779777

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<!-- Focused (TV remote) states -->
34
<item android:color="@color/list_card_stroke_focused" android:state_focused="true" />
5+
<!-- Default state -->
46
<item android:color="@color/list_card_stroke_background" />
57
</selector>

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@
6161
app:shapeAppearanceOverlay="@style/RoundedCorners"
6262
app:srcCompat="@drawable/ic_image_white_36dp" />
6363

64+
<CheckBox
65+
android:id="@+id/reorder_checkbox"
66+
android:layout_width="24dp"
67+
android:layout_height="24dp"
68+
android:foregroundTint="@color/icon_default"
69+
android:visibility="gone"
70+
app:layout_constraintBottom_toBottomOf="@+id/station_icon"
71+
app:layout_constraintStart_toEndOf="@+id/starred_icon"
72+
app:layout_constraintTop_toTopOf="@+id/station_icon" />
73+
6474
<ImageView
6575
android:id="@+id/starred_icon"
6676
android:layout_width="wrap_content"
@@ -86,7 +96,7 @@
8696
android:textColor="@color/text_lightweight"
8797
app:layout_constraintBottom_toBottomOf="@+id/station_icon"
8898
app:layout_constraintEnd_toStartOf="@+id/playback_button"
89-
app:layout_constraintStart_toEndOf="@+id/starred_icon"
99+
app:layout_constraintStart_toEndOf="@+id/reorder_checkbox"
90100
app:layout_constraintTop_toTopOf="@+id/station_icon"
91101
tools:text="@string/sample_text_station_name" />
92102

0 commit comments

Comments
 (0)