settings: remove colorizeNotif option
Remove the notification colorizing option. It's simply causing too many bugs for it to be usable, especially on Android 11 with it's insane behavior regarding album cover loading.
This commit is contained in:
parent
bc6bba56fc
commit
d16c1099bf
8 changed files with 28 additions and 106 deletions
|
@ -89,15 +89,10 @@ class PlaybackNotification private constructor(
|
||||||
setSubText(song.album.name)
|
setSubText(song.album.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settingsManager.colorizeNotif) {
|
// loadBitmap() is concurrent, so only call back to the object calling this function when
|
||||||
// loadBitmap() is concurrent, so only call back to the object calling this function when
|
// the loading is over.
|
||||||
// the loading is over.
|
loadBitmap(context, song) { bitmap ->
|
||||||
loadBitmap(context, song) { bitmap ->
|
setLargeIcon(bitmap)
|
||||||
setLargeIcon(bitmap)
|
|
||||||
onDone()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setLargeIcon(null)
|
|
||||||
onDone()
|
onDone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,24 +127,6 @@ class PlaybackSessionConnector(
|
||||||
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, song.album.name)
|
.putString(MediaMetadataCompat.METADATA_KEY_ALBUM, song.album.name)
|
||||||
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, song.duration)
|
.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, song.duration)
|
||||||
|
|
||||||
// Oh my god. I don't like swearing in my comments, but I have no other way to describe my
|
|
||||||
// attitudes by the insane change Android 11 made to MediaStyle. Basically, they changed
|
|
||||||
// the notification code to FIRST look for a large icon [like previous versions], but THEN
|
|
||||||
// TO LOOK TO THE MEDIA SESSION SECOND. Cue me having to debug this issue for over 3 hours
|
|
||||||
// thinking it was some kind of strange bytecode problem, only to realize that it was this
|
|
||||||
// undocumented behavior change.
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
||||||
logD("Doing colorizeNotif R+ hack")
|
|
||||||
|
|
||||||
val settingsManager = SettingsManager.getInstance()
|
|
||||||
|
|
||||||
if (!settingsManager.colorizeNotif) {
|
|
||||||
mediaSession.setMetadata(builder.build())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the cover asynchronously. This is the entire reason I don't use a plain
|
// Load the cover asynchronously. This is the entire reason I don't use a plain
|
||||||
// MediaSessionConnector, which AFAIK makes it impossible to load this the way I do
|
// MediaSessionConnector, which AFAIK makes it impossible to load this the way I do
|
||||||
// without a bunch of stupid race conditions.
|
// without a bunch of stupid race conditions.
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2021 Auxio Project
|
|
||||||
* SettingUtils.kt is part of Auxio.
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.oxycblt.auxio.settings
|
|
||||||
|
|
||||||
import android.content.SharedPreferences
|
|
||||||
import androidx.annotation.DrawableRes
|
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
|
||||||
import org.oxycblt.auxio.R
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert an theme integer into an icon that can be used.
|
|
||||||
*/
|
|
||||||
@DrawableRes
|
|
||||||
fun Int.toThemeIcon(): Int {
|
|
||||||
return when (this) {
|
|
||||||
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM -> R.drawable.ic_auto
|
|
||||||
AppCompatDelegate.MODE_NIGHT_NO -> R.drawable.ic_day
|
|
||||||
AppCompatDelegate.MODE_NIGHT_YES -> R.drawable.ic_night
|
|
||||||
|
|
||||||
else -> R.drawable.ic_auto
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an int preference under [key] to [T] through a [convert] function.
|
|
||||||
* This is only intended for use for the enums with fromInt functions.
|
|
||||||
*
|
|
||||||
* NOTE: If one of your constant values uses Int.MIN_VALUE, this function may return an
|
|
||||||
* unexpected result.
|
|
||||||
*/
|
|
||||||
fun <T> SharedPreferences.getData(key: String, convert: (Int) -> T?): T? {
|
|
||||||
return convert(getInt(key, Int.MIN_VALUE))
|
|
||||||
}
|
|
|
@ -28,6 +28,9 @@ import org.oxycblt.auxio.playback.state.PlaybackMode
|
||||||
// A couple of utils for migrating from old settings values to the new
|
// A couple of utils for migrating from old settings values to the new
|
||||||
// formats used in 1.3.2 & 1.4.0
|
// formats used in 1.3.2 & 1.4.0
|
||||||
|
|
||||||
|
// TODO: Slate these for removal in 2.0.0. 1.4.0 was Pre-FDroid so it's extremely likely that
|
||||||
|
// everyone has migrated.
|
||||||
|
|
||||||
fun handleThemeCompat(prefs: SharedPreferences): Int {
|
fun handleThemeCompat(prefs: SharedPreferences): Int {
|
||||||
if (prefs.contains(OldKeys.KEY_THEME)) {
|
if (prefs.contains(OldKeys.KEY_THEME)) {
|
||||||
// Before the creation of IntListPreference, I used strings to represent the themes.
|
// Before the creation of IntListPreference, I used strings to represent the themes.
|
||||||
|
@ -103,7 +106,7 @@ fun handleSongPlayModeCompat(prefs: SharedPreferences): PlaybackMode {
|
||||||
return mode
|
return mode
|
||||||
}
|
}
|
||||||
|
|
||||||
return prefs.getData(SettingsManager.KEY_SONG_PLAYBACK_MODE, PlaybackMode::fromInt)
|
return PlaybackMode.fromInt(prefs.getInt(SettingsManager.KEY_SONG_PLAYBACK_MODE, Int.MIN_VALUE))
|
||||||
?: PlaybackMode.ALL_SONGS
|
?: PlaybackMode.ALL_SONGS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.oxycblt.auxio.settings
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.appcompat.app.AppCompatDelegate
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
|
@ -159,4 +160,18 @@ class SettingsListFragment : PreferenceFragmentCompat() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an theme integer into an icon that can be used.
|
||||||
|
*/
|
||||||
|
@DrawableRes
|
||||||
|
private fun Int.toThemeIcon(): Int {
|
||||||
|
return when (this) {
|
||||||
|
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM -> R.drawable.ic_auto
|
||||||
|
AppCompatDelegate.MODE_NIGHT_NO -> R.drawable.ic_day
|
||||||
|
AppCompatDelegate.MODE_NIGHT_YES -> R.drawable.ic_night
|
||||||
|
|
||||||
|
else -> R.drawable.ic_auto
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,6 @@ class SettingsManager private constructor(context: Context) :
|
||||||
/** The current accent. */
|
/** The current accent. */
|
||||||
var accent: Accent
|
var accent: Accent
|
||||||
get() = handleAccentCompat(sharedPrefs)
|
get() = handleAccentCompat(sharedPrefs)
|
||||||
|
|
||||||
set(value) {
|
set(value) {
|
||||||
val accentIndex = ACCENTS.indexOf(value)
|
val accentIndex = ACCENTS.indexOf(value)
|
||||||
|
|
||||||
|
@ -68,10 +67,6 @@ class SettingsManager private constructor(context: Context) :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Whether to colorize the notification */
|
|
||||||
val colorizeNotif: Boolean
|
|
||||||
get() = sharedPrefs.getBoolean(KEY_COLORIZE_NOTIFICATION, true)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether to display the LoopMode or the shuffle status on the notification.
|
* Whether to display the LoopMode or the shuffle status on the notification.
|
||||||
* False if loop, true if shuffle.
|
* False if loop, true if shuffle.
|
||||||
|
@ -115,11 +110,10 @@ class SettingsManager private constructor(context: Context) :
|
||||||
|
|
||||||
/** The current filter mode of the search tab */
|
/** The current filter mode of the search tab */
|
||||||
var searchFilterMode: DisplayMode?
|
var searchFilterMode: DisplayMode?
|
||||||
get() = sharedPrefs.getData(KEY_SEARCH_FILTER_MODE, DisplayMode::fromSearchInt)
|
get() = DisplayMode.fromFilterInt(sharedPrefs.getInt(KEY_SEARCH_FILTER_MODE, Int.MIN_VALUE))
|
||||||
|
|
||||||
set(value) {
|
set(value) {
|
||||||
sharedPrefs.edit {
|
sharedPrefs.edit {
|
||||||
putInt(KEY_SEARCH_FILTER_MODE, DisplayMode.toSearchInt(value))
|
putInt(KEY_SEARCH_FILTER_MODE, DisplayMode.toFilterInt(value))
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,10 +134,6 @@ class SettingsManager private constructor(context: Context) :
|
||||||
|
|
||||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||||
when (key) {
|
when (key) {
|
||||||
KEY_COLORIZE_NOTIFICATION -> callbacks.forEach {
|
|
||||||
it.onColorizeNotifUpdate(colorizeNotif)
|
|
||||||
}
|
|
||||||
|
|
||||||
KEY_USE_ALT_NOTIFICATION_ACTION -> callbacks.forEach {
|
KEY_USE_ALT_NOTIFICATION_ACTION -> callbacks.forEach {
|
||||||
it.onNotifActionUpdate(useAltNotifAction)
|
it.onNotifActionUpdate(useAltNotifAction)
|
||||||
}
|
}
|
||||||
|
@ -177,7 +167,6 @@ class SettingsManager private constructor(context: Context) :
|
||||||
|
|
||||||
const val KEY_SHOW_COVERS = "KEY_SHOW_COVERS"
|
const val KEY_SHOW_COVERS = "KEY_SHOW_COVERS"
|
||||||
const val KEY_QUALITY_COVERS = "KEY_QUALITY_COVERS"
|
const val KEY_QUALITY_COVERS = "KEY_QUALITY_COVERS"
|
||||||
const val KEY_COLORIZE_NOTIFICATION = "KEY_COLOR_NOTIF"
|
|
||||||
const val KEY_USE_ALT_NOTIFICATION_ACTION = "KEY_ALT_NOTIF_ACTION"
|
const val KEY_USE_ALT_NOTIFICATION_ACTION = "KEY_ALT_NOTIF_ACTION"
|
||||||
|
|
||||||
const val KEY_AUDIO_FOCUS = "KEY_AUDIO_FOCUS"
|
const val KEY_AUDIO_FOCUS = "KEY_AUDIO_FOCUS"
|
||||||
|
@ -191,11 +180,6 @@ class SettingsManager private constructor(context: Context) :
|
||||||
const val KEY_SAVE_STATE = "KEY_SAVE_STATE"
|
const val KEY_SAVE_STATE = "KEY_SAVE_STATE"
|
||||||
const val KEY_BLACKLIST = "KEY_BLACKLIST"
|
const val KEY_BLACKLIST = "KEY_BLACKLIST"
|
||||||
|
|
||||||
const val KEY_LIB_SORT_MODE = "KEY_LIBRARY_SORT_MODE"
|
|
||||||
const val KEY_ALBUM_SORT_MODE = "KEY_ALBUM_SORT"
|
|
||||||
const val KEY_ARTIST_SORT_MODE = "KEY_ARTIST_SORT"
|
|
||||||
const val KEY_GENRE_SORT_MODE = "KEY_GENRE_SORT"
|
|
||||||
|
|
||||||
const val KEY_SEARCH_FILTER_MODE = "KEY_SEARCH_FILTER"
|
const val KEY_SEARCH_FILTER_MODE = "KEY_SEARCH_FILTER"
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
|
|
|
@ -35,7 +35,7 @@ enum class DisplayMode {
|
||||||
private const val CONST_SHOW_ALBUMS = 0xA10A
|
private const val CONST_SHOW_ALBUMS = 0xA10A
|
||||||
private const val CONST_SHOW_SONGS = 0xA10B
|
private const val CONST_SHOW_SONGS = 0xA10B
|
||||||
|
|
||||||
fun toSearchInt(value: DisplayMode?): Int {
|
fun toFilterInt(value: DisplayMode?): Int {
|
||||||
return when (value) {
|
return when (value) {
|
||||||
SHOW_SONGS -> CONST_SHOW_SONGS
|
SHOW_SONGS -> CONST_SHOW_SONGS
|
||||||
SHOW_ALBUMS -> CONST_SHOW_ALBUMS
|
SHOW_ALBUMS -> CONST_SHOW_ALBUMS
|
||||||
|
@ -45,7 +45,7 @@ enum class DisplayMode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun fromSearchInt(value: Int): DisplayMode? {
|
fun fromFilterInt(value: Int): DisplayMode? {
|
||||||
return when (value) {
|
return when (value) {
|
||||||
CONST_SHOW_SONGS -> SHOW_SONGS
|
CONST_SHOW_SONGS -> SHOW_SONGS
|
||||||
CONST_SHOW_ALBUMS -> SHOW_ALBUMS
|
CONST_SHOW_ALBUMS -> SHOW_ALBUMS
|
||||||
|
|
|
@ -49,14 +49,6 @@
|
||||||
app:summary="@string/set_quality_covers_desc"
|
app:summary="@string/set_quality_covers_desc"
|
||||||
app:title="@string/set_quality_covers" />
|
app:title="@string/set_quality_covers" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
|
||||||
app:defaultValue="true"
|
|
||||||
app:dependency="KEY_SHOW_COVERS"
|
|
||||||
app:iconSpaceReserved="false"
|
|
||||||
app:key="KEY_COLOR_NOTIF"
|
|
||||||
app:summary="@string/set_color_notif_desc"
|
|
||||||
app:title="@string/set_color_notif" />
|
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
app:allowDividerBelow="false"
|
app:allowDividerBelow="false"
|
||||||
app:defaultValue="false"
|
app:defaultValue="false"
|
||||||
|
|
Loading…
Reference in a new issue