Change setting ripple color
Change the ripple on the settings to a generally neutral color instead of the gaudy colorPrimary.
This commit is contained in:
parent
e15df4ce73
commit
59036a2747
23 changed files with 169 additions and 77 deletions
|
@ -89,13 +89,17 @@ dependencies {
|
|||
implementation 'io.coil-kt:coil:0.13.0'
|
||||
|
||||
// Material
|
||||
implementation 'com.google.android.material:material:1.3.0-alpha03'
|
||||
implementation 'com.google.android.material:material:1.3.0-alpha04'
|
||||
|
||||
// Fast-Scroll
|
||||
implementation 'com.reddit:indicator-fast-scroll:1.3.0'
|
||||
|
||||
// Dialogs
|
||||
implementation 'com.afollestad.material-dialogs:core:3.3.0'
|
||||
|
||||
// Edge-To-Edge
|
||||
implementation 'de.halfbit:edge-to-edge:0.10'
|
||||
|
||||
// --- DEV ---
|
||||
|
||||
// Lint
|
||||
|
|
2
app/proguard-rules.pro
vendored
2
app/proguard-rules.pro
vendored
|
@ -22,4 +22,4 @@
|
|||
|
||||
-dontobfuscate
|
||||
|
||||
-keep class org.oxycblt.auxio.settings.SettingListFragment
|
||||
-keep class org.oxycblt.auxio.settings.SettingsListFragment
|
|
@ -26,8 +26,8 @@ import org.oxycblt.auxio.ui.accent
|
|||
import org.oxycblt.auxio.ui.toColor
|
||||
|
||||
/**
|
||||
* A source code copy of [com.reddit.indicatorfastscroll.FastScrollerThumbView] that fixes a
|
||||
* memory leak that occurs from having nested fragments. All credit goes to the authors of
|
||||
* A semi-copy, semi-custom implementation of [com.reddit.indicatorfastscroll.FastScrollerThumbView]
|
||||
* that fixes a memory leak that occurs from a bug fix they added. All credit goes to the authors of
|
||||
* the fast scroll library.
|
||||
* <a href="https://github.com/reddit/IndicatorFastScroll"> Link to repo </a>
|
||||
* @author Reddit, OxygenCobalt
|
||||
|
@ -81,7 +81,11 @@ class NoLeakThumbView @JvmOverloads constructor(
|
|||
fastScrollerView.onTouchEvent(event)
|
||||
fastScrollerView.performClick()
|
||||
|
||||
if (event.actionMasked in intArrayOf(MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL)) {
|
||||
if (event.actionMasked in intArrayOf(
|
||||
MotionEvent.ACTION_UP,
|
||||
MotionEvent.ACTION_CANCEL
|
||||
)
|
||||
) {
|
||||
isActivated = false
|
||||
return@setOnTouchListener true
|
||||
}
|
||||
|
@ -104,15 +108,9 @@ class NoLeakThumbView @JvmOverloads constructor(
|
|||
|
||||
fastScrollerView.apply {
|
||||
children.forEach { view ->
|
||||
if (view.containsY(touchY)) {
|
||||
when (view) {
|
||||
is ImageView -> {
|
||||
if (view.containsY(touchY) && (view is ImageView || view is TextView)) {
|
||||
consumed = true
|
||||
}
|
||||
is TextView -> {
|
||||
consumed = true
|
||||
}
|
||||
}
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
package org.oxycblt.auxio.settings
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceGroupAdapter
|
||||
import androidx.preference.PreferenceScreen
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
|
@ -18,12 +23,15 @@ import org.oxycblt.auxio.ui.ACCENTS
|
|||
import org.oxycblt.auxio.ui.accent
|
||||
import org.oxycblt.auxio.ui.getDetailedAccentSummary
|
||||
|
||||
class SettingListFragment : PreferenceFragmentCompat() {
|
||||
class SettingsListFragment : PreferenceFragmentCompat() {
|
||||
private val settingsModel: SettingsViewModel by activityViewModels()
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
view.apply {
|
||||
}
|
||||
|
||||
val themePref = findPreference<Preference>(SettingsManager.Keys.KEY_THEME)?.apply {
|
||||
setIcon(
|
||||
when (AppCompatDelegate.getDefaultNightMode()) {
|
||||
|
@ -80,9 +88,33 @@ class SettingListFragment : PreferenceFragmentCompat() {
|
|||
setPreferencesFromResource(R.xml.prefs_main, rootKey)
|
||||
}
|
||||
|
||||
// Forcefully override the adapter creation process so I can get rid of the ugly
|
||||
// colorPrimary ripples.
|
||||
@SuppressLint("RestrictedApi")
|
||||
override fun onCreateAdapter(preferenceScreen: PreferenceScreen?): RecyclerView.Adapter<*> {
|
||||
return object : PreferenceGroupAdapter(preferenceScreen) {
|
||||
override fun onCreateViewHolder(
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
): PreferenceViewHolder {
|
||||
val holder = super.onCreateViewHolder(parent, viewType)
|
||||
|
||||
if (holder.itemView.id != android.R.id.title) {
|
||||
holder.itemView.setBackgroundResource(R.drawable.ui_ripple)
|
||||
}
|
||||
|
||||
return holder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun offLoad(something: String) {
|
||||
Log.d(this::class.simpleName, something)
|
||||
}
|
||||
|
||||
private fun showAccentDialog() {
|
||||
MaterialDialog(requireActivity()).show {
|
||||
title(R.string.label_settings_accent)
|
||||
title(R.string.setting_accent)
|
||||
|
||||
// Roll my own RecyclerView since [To no surprise whatsoever] Material Dialogs
|
||||
// has a bug where ugly dividers will show with the RecyclerView even if you disable them.
|
|
@ -14,7 +14,8 @@ import org.oxycblt.auxio.ui.ACCENTS
|
|||
* the first time it occurs.
|
||||
* @author OxygenCobalt
|
||||
*/
|
||||
class SettingsManager private constructor(context: Context) : SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
class SettingsManager private constructor(context: Context) :
|
||||
SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
||||
init {
|
||||
|
@ -79,6 +80,10 @@ class SettingsManager private constructor(context: Context) : SharedPreferences.
|
|||
) ?: SortMode.ALPHA_DOWN
|
||||
}
|
||||
|
||||
fun getEdgeToEdge(): Boolean {
|
||||
return sharedPrefs.getBoolean(Keys.KEY_EDGE_TO_EDGE, false)
|
||||
}
|
||||
|
||||
// --- OVERRIDES ---
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
|
@ -124,6 +129,7 @@ class SettingsManager private constructor(context: Context) : SharedPreferences.
|
|||
const val KEY_LIBRARY_SORT_MODE = "KEY_LIBRARY_SORT_MODE"
|
||||
const val KEY_THEME = "KEY_THEME"
|
||||
const val KEY_ACCENT = "KEY_ACCENT"
|
||||
const val KEY_EDGE_TO_EDGE = "KEY_EDGE"
|
||||
}
|
||||
|
||||
private object Theme {
|
||||
|
@ -133,11 +139,12 @@ class SettingsManager private constructor(context: Context) : SharedPreferences.
|
|||
}
|
||||
|
||||
/**
|
||||
* A safe interface for receiving preference updates, use this instead of
|
||||
* An interface for receiving some settings updates.
|
||||
* [SharedPreferences.OnSharedPreferenceChangeListener].
|
||||
*/
|
||||
interface Callback {
|
||||
fun onThemeUpdate(newTheme: Int) {}
|
||||
fun onAccentUpdate(newAccent: Pair<Int, Int>) {}
|
||||
fun onEdgeToEdgeUpdate(isEdgeToEdge: Boolean) {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.oxycblt.auxio.settings.adapters
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -9,6 +8,7 @@ import org.oxycblt.auxio.R
|
|||
import org.oxycblt.auxio.databinding.ItemAccentBinding
|
||||
import org.oxycblt.auxio.ui.ACCENTS
|
||||
import org.oxycblt.auxio.ui.accent
|
||||
import org.oxycblt.auxio.ui.getAccentItemSummary
|
||||
import org.oxycblt.auxio.ui.toColor
|
||||
|
||||
class AccentAdapter(
|
||||
|
@ -29,20 +29,25 @@ class AccentAdapter(
|
|||
) : RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
fun bind(accentData: Pair<Int, Int>) {
|
||||
binding.accent.setOnClickListener {
|
||||
Log.d(this::class.simpleName, accentData.toString())
|
||||
binding.accent.apply {
|
||||
contentDescription = getAccentItemSummary(context, accentData)
|
||||
|
||||
setOnClickListener {
|
||||
doOnAccentConfirm(accentData)
|
||||
}
|
||||
|
||||
binding.accent.apply {
|
||||
imageTintList = if (accentData.first != accent.first) {
|
||||
ColorStateList.valueOf(
|
||||
android.R.color.transparent.toColor(context)
|
||||
)
|
||||
} else {
|
||||
imageTintList = if (accentData.first == accent.first) {
|
||||
isEnabled = false
|
||||
|
||||
ColorStateList.valueOf(
|
||||
R.color.background.toColor(context)
|
||||
)
|
||||
} else {
|
||||
isEnabled = true
|
||||
|
||||
ColorStateList.valueOf(
|
||||
android.R.color.transparent.toColor(context)
|
||||
)
|
||||
}
|
||||
|
||||
backgroundTintList = ColorStateList.valueOf(
|
||||
|
|
|
@ -129,7 +129,8 @@ class SongsFragment : Fragment(), SearchView.OnQueryTextListener {
|
|||
|
||||
useDefaultScroller = false
|
||||
|
||||
itemIndicatorSelectedCallbacks.add(object : FastScrollerView.ItemIndicatorSelectedCallback {
|
||||
itemIndicatorSelectedCallbacks.add(object :
|
||||
FastScrollerView.ItemIndicatorSelectedCallback {
|
||||
override fun onItemIndicatorSelected(
|
||||
indicator: FastScrollItemIndicator,
|
||||
indicatorCenterY: Int,
|
||||
|
|
|
@ -93,6 +93,7 @@ fun PopupMenu.setupSongActions(song: Song, context: Context, playbackModel: Play
|
|||
}
|
||||
inflateAndShow(R.menu.menu_song_actions)
|
||||
}
|
||||
|
||||
/**
|
||||
* Show actions for a song item, such as the ones found in [org.oxycblt.auxio.songs.SongsFragment]
|
||||
*/
|
||||
|
|
|
@ -4,6 +4,5 @@
|
|||
<size
|
||||
android:width="48dp"
|
||||
android:height="48dp" />
|
||||
<solid
|
||||
android:color="@android:color/white" />
|
||||
<solid android:color="@android:color/white" />
|
||||
</shape>
|
|
@ -16,12 +16,12 @@
|
|||
android:elevation="@dimen/elevation_normal"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="@string/label_settings"
|
||||
app:title="@string/setting_title"
|
||||
app:titleTextAppearance="@style/TextAppearance.Toolbar.Header" />
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/settings_list_fragment"
|
||||
android:name="org.oxycblt.auxio.settings.SettingListFragment"
|
||||
android:name="org.oxycblt.auxio.settings.SettingsListFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
</data>
|
||||
|
@ -9,6 +10,7 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/margin_mid_small">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/accent"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView
|
||||
android:id="@android:id/title"
|
||||
<TextView android:id="@android:id/title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
android:icon="@drawable/ic_song" />
|
||||
<item
|
||||
android:id="@+id/settings_fragment"
|
||||
android:title="@string/label_settings"
|
||||
android:title="@string/setting_title"
|
||||
android:icon="@drawable/ic_settings" />
|
||||
</menu>
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<array name="theme_entries">
|
||||
<item>@string/label_settings_theme_auto</item>
|
||||
<item>@string/label_settings_theme_light</item>
|
||||
<item>@string/label_settings_theme_dark</item>
|
||||
<item>@string/setting_theme_auto</item>
|
||||
<item>@string/setting_theme_day</item>
|
||||
<item>@string/setting_theme_night</item>
|
||||
</array>
|
||||
|
||||
<array name="theme_values">
|
||||
|
|
|
@ -27,14 +27,18 @@
|
|||
<string name="label_next_user_queue">Next in Queue</string>
|
||||
<string name="label_channel">Music Playback</string>
|
||||
<string name="label_service_playback">The music playback service for Auxio.</string>
|
||||
<string name="label_settings">Settings</string>
|
||||
<string name="label_settings_ui">Appearance</string>
|
||||
<string name="label_settings_theme">Theme</string>
|
||||
<string name="label_settings_theme_auto">Automatic</string>
|
||||
<string name="label_settings_theme_light">Light</string>
|
||||
<string name="label_settings_theme_dark">Dark</string>
|
||||
<string name="label_settings_theme_choose">Choose theme</string>
|
||||
<string name="label_settings_accent">Accent</string>
|
||||
|
||||
<!-- Settings namespace | Settings-related labels -->
|
||||
<string name="setting_title">Settings</string>
|
||||
<string name="setting_ui">Appearance</string>
|
||||
<string name="setting_theme">Theme</string>
|
||||
<string name="setting_theme_auto">Automatic</string>
|
||||
<string name="setting_theme_day">Light</string>
|
||||
<string name="setting_theme_night">Dark</string>
|
||||
<string name="setting_accent">Accent</string>
|
||||
<string name="setting_edge">Edge-To-Edge</string>
|
||||
<string name="setting_edge_desc_on">Disable edge-to-edge</string>
|
||||
<string name="setting_edge_desc_off">Enable edge-to-edge</string>
|
||||
|
||||
<!-- Debug Namespace | Debug labels -->
|
||||
<string name="debug_state_saved">State saved</string>
|
||||
|
|
|
@ -13,12 +13,17 @@
|
|||
<item name="colorControlNormal">@color/control_color</item>
|
||||
<item name="alertDialogTheme">@style/Theme.CustomDialog</item>
|
||||
<item name="indicatorFastScrollerStyle">@style/FastScrollTheme</item>
|
||||
<item name="colorControlActivated">?attr/colorPrimary</item>
|
||||
<item name="colorControlHighlight">?attr/colorPrimary</item>
|
||||
<item name="preferenceTheme">@style/Theme.Preference</item>
|
||||
|
||||
<item name="md_divider_color">@android:color/transparent</item>
|
||||
<item name="md_background_color">@color/background</item>
|
||||
<item name="md_corner_radius">0dp</item>
|
||||
<item name="md_color_button_text">@color/control_color</item>
|
||||
<item name="md_font_title">@font/inter_black</item>
|
||||
|
||||
<item name="android:activatedBackgroundIndicator">@drawable/ui_ripple</item>
|
||||
</style>
|
||||
|
||||
<!-- Hack to fix the weird icon/underline with LibraryFragment's SearchView -->
|
||||
|
@ -83,6 +88,12 @@
|
|||
<item name="android:textSize">18sp</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Preference" parent="PreferenceThemeOverlay">
|
||||
<item name="rippleColor">@color/selection_color</item>
|
||||
<item name="itemRippleColor">@color/selection_color</item>
|
||||
<item name="tabRippleColor">@color/selection_color</item>
|
||||
</style>
|
||||
|
||||
<!--
|
||||
Fix to get QueueFragment to not overlap the Status Bar or Navigation Bar [Currently unused but still here]
|
||||
https://stackoverflow.com/a/57790787/14143986
|
||||
|
|
30
app/src/main/res/xml-v27/prefs_main.xml
Normal file
30
app/src/main/res/xml-v27/prefs_main.xml
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory
|
||||
android:title="@string/setting_ui"
|
||||
android:layout="@layout/item_prefs_header">
|
||||
<ListPreference
|
||||
app:key="KEY_THEME"
|
||||
android:title="@string/setting_theme"
|
||||
android:icon="@drawable/ic_day"
|
||||
android:entries="@array/theme_entries"
|
||||
android:entryValues="@array/theme_values"
|
||||
app:defaultValue="AUTO"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<Preference
|
||||
app:key="KEY_ACCENT"
|
||||
android:title="@string/setting_accent"
|
||||
android:icon="@drawable/ic_accent"
|
||||
app:summary="@string/setting_accent" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:key="KEY_EDGE"
|
||||
android:title="@string/setting_edge"
|
||||
app:summaryOn="@string/setting_edge_desc_on"
|
||||
app:summaryOff="@string/setting_edge_desc_off"
|
||||
app:iconSpaceReserved="false"
|
||||
android:defaultValue="false" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
|
@ -2,11 +2,11 @@
|
|||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceCategory
|
||||
android:title="@string/label_settings_ui"
|
||||
android:title="@string/setting_ui"
|
||||
android:layout="@layout/item_prefs_header">
|
||||
<ListPreference
|
||||
app:key="KEY_THEME"
|
||||
android:title="@string/label_settings_theme"
|
||||
android:title="@string/setting_theme"
|
||||
android:icon="@drawable/ic_day"
|
||||
android:entries="@array/theme_entries"
|
||||
android:entryValues="@array/theme_values"
|
||||
|
@ -15,9 +15,8 @@
|
|||
|
||||
<Preference
|
||||
app:key="KEY_ACCENT"
|
||||
android:title="@string/label_settings_accent"
|
||||
android:title="@string/setting_accent"
|
||||
android:icon="@drawable/ic_accent"
|
||||
app:summary="@string/label_settings_accent"
|
||||
app:enableCopying="true" />
|
||||
app:summary="@string/setting_accent" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
Loading…
Reference in a new issue