mirror of
https://github.com/Michatec/Radio.git
synced 2026-05-31 01:52:39 +02:00
feat(ui): use checkbox to indicate reordering station status
This commit is contained in:
@@ -3,7 +3,6 @@ package com.michatec.radio.collection
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.content.res.ColorStateList
|
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
@@ -11,12 +10,12 @@ import android.view.LayoutInflater
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
|
import android.widget.CheckBox
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.ProgressBar
|
import android.widget.ProgressBar
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.constraintlayout.widget.Group
|
import androidx.constraintlayout.widget.Group
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
@@ -180,7 +179,6 @@ class CollectionAdapter(
|
|||||||
|
|
||||||
// get reference to StationViewHolder
|
// get reference to StationViewHolder
|
||||||
val stationViewHolder: StationViewHolder = holder
|
val stationViewHolder: StationViewHolder = holder
|
||||||
|
|
||||||
// set up station views
|
// set up station views
|
||||||
setStarredIcon(stationViewHolder, station)
|
setStarredIcon(stationViewHolder, station)
|
||||||
setStationName(stationViewHolder, station)
|
setStationName(stationViewHolder, station)
|
||||||
@@ -190,13 +188,12 @@ class CollectionAdapter(
|
|||||||
setPlaybackProgress(stationViewHolder, station)
|
setPlaybackProgress(stationViewHolder, station)
|
||||||
setDownloadProgress(stationViewHolder, station)
|
setDownloadProgress(stationViewHolder, station)
|
||||||
|
|
||||||
// highlight if reordering
|
|
||||||
if (reorderStationUuid == station.uuid) {
|
if (reorderStationUuid == station.uuid) {
|
||||||
stationViewHolder.stationCardView.setStrokeColor(
|
stationViewHolder.reorderCheckbox.isVisible = true
|
||||||
ColorStateList.valueOf(
|
stationViewHolder.reorderCheckbox.isChecked = true
|
||||||
ContextCompat.getColor(context, R.color.cardview_reordering)
|
} else {
|
||||||
)
|
stationViewHolder.reorderCheckbox.isGone = true
|
||||||
)
|
stationViewHolder.reorderCheckbox.isChecked = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// show / hide edit views
|
// show / hide edit views
|
||||||
@@ -774,6 +771,7 @@ class CollectionAdapter(
|
|||||||
val stationImageView: ImageView = stationCardLayout.findViewById(R.id.station_icon)
|
val stationImageView: ImageView = stationCardLayout.findViewById(R.id.station_icon)
|
||||||
val stationNameView: TextView = stationCardLayout.findViewById(R.id.station_name)
|
val stationNameView: TextView = stationCardLayout.findViewById(R.id.station_name)
|
||||||
val stationStarredView: ImageView = stationCardLayout.findViewById(R.id.starred_icon)
|
val stationStarredView: ImageView = stationCardLayout.findViewById(R.id.starred_icon)
|
||||||
|
val reorderCheckbox: CheckBox = stationCardLayout.findViewById(R.id.reorder_checkbox)
|
||||||
val bufferingProgress: ProgressBar = stationCardLayout.findViewById(R.id.buffering_progress)
|
val bufferingProgress: ProgressBar = stationCardLayout.findViewById(R.id.buffering_progress)
|
||||||
val downloadProgress: ProgressBar = stationCardLayout.findViewById(R.id.download_progress)
|
val downloadProgress: ProgressBar = stationCardLayout.findViewById(R.id.download_progress)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<!-- Focused (TV remote) states -->
|
||||||
<item android:color="@color/list_card_stroke_focused" android:state_focused="true" />
|
<item android:color="@color/list_card_stroke_focused" android:state_focused="true" />
|
||||||
|
<!-- Default state -->
|
||||||
<item android:color="@color/list_card_stroke_background" />
|
<item android:color="@color/list_card_stroke_background" />
|
||||||
</selector>
|
</selector>
|
||||||
@@ -61,6 +61,16 @@
|
|||||||
app:shapeAppearanceOverlay="@style/RoundedCorners"
|
app:shapeAppearanceOverlay="@style/RoundedCorners"
|
||||||
app:srcCompat="@drawable/ic_image_white_36dp" />
|
app:srcCompat="@drawable/ic_image_white_36dp" />
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/reorder_checkbox"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:foregroundTint="@color/icon_default"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/station_icon"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/starred_icon"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/station_icon" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/starred_icon"
|
android:id="@+id/starred_icon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -86,7 +96,7 @@
|
|||||||
android:textColor="@color/text_lightweight"
|
android:textColor="@color/text_lightweight"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/station_icon"
|
app:layout_constraintBottom_toBottomOf="@+id/station_icon"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/playback_button"
|
app:layout_constraintEnd_toStartOf="@+id/playback_button"
|
||||||
app:layout_constraintStart_toEndOf="@+id/starred_icon"
|
app:layout_constraintStart_toEndOf="@+id/reorder_checkbox"
|
||||||
app:layout_constraintTop_toTopOf="@+id/station_icon"
|
app:layout_constraintTop_toTopOf="@+id/station_icon"
|
||||||
tools:text="@string/sample_text_station_name" />
|
tools:text="@string/sample_text_station_name" />
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user