diff --git a/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackNotification.kt b/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackNotification.kt index b80cecf79..59091f0e2 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackNotification.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackNotification.kt @@ -89,15 +89,10 @@ class PlaybackNotification private constructor( setSubText(song.album.name) } - if (settingsManager.colorizeNotif) { - // loadBitmap() is concurrent, so only call back to the object calling this function when - // the loading is over. - loadBitmap(context, song) { bitmap -> - setLargeIcon(bitmap) - onDone() - } - } else { - setLargeIcon(null) + // loadBitmap() is concurrent, so only call back to the object calling this function when + // the loading is over. + loadBitmap(context, song) { bitmap -> + setLargeIcon(bitmap) onDone() } } diff --git a/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackSessionConnector.kt b/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackSessionConnector.kt index fa61fa312..d73549756 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackSessionConnector.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackSessionConnector.kt @@ -127,24 +127,6 @@ class PlaybackSessionConnector( .putString(MediaMetadataCompat.METADATA_KEY_ALBUM, song.album.name) .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 // MediaSessionConnector, which AFAIK makes it impossible to load this the way I do // without a bunch of stupid race conditions. diff --git a/app/src/main/java/org/oxycblt/auxio/settings/SettingUtils.kt b/app/src/main/java/org/oxycblt/auxio/settings/SettingUtils.kt deleted file mode 100644 index 8b11f490d..000000000 --- a/app/src/main/java/org/oxycblt/auxio/settings/SettingUtils.kt +++ /dev/null @@ -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 . - */ - -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 SharedPreferences.getData(key: String, convert: (Int) -> T?): T? { - return convert(getInt(key, Int.MIN_VALUE)) -} diff --git a/app/src/main/java/org/oxycblt/auxio/settings/SettingsCompat.kt b/app/src/main/java/org/oxycblt/auxio/settings/SettingsCompat.kt index d508421d6..3c4791f9e 100644 --- a/app/src/main/java/org/oxycblt/auxio/settings/SettingsCompat.kt +++ b/app/src/main/java/org/oxycblt/auxio/settings/SettingsCompat.kt @@ -28,6 +28,9 @@ import org.oxycblt.auxio.playback.state.PlaybackMode // A couple of utils for migrating from old settings values to the new // 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 { if (prefs.contains(OldKeys.KEY_THEME)) { // Before the creation of IntListPreference, I used strings to represent the themes. @@ -103,7 +106,7 @@ fun handleSongPlayModeCompat(prefs: SharedPreferences): PlaybackMode { 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 } diff --git a/app/src/main/java/org/oxycblt/auxio/settings/SettingsListFragment.kt b/app/src/main/java/org/oxycblt/auxio/settings/SettingsListFragment.kt index 223a82c8e..52877126f 100644 --- a/app/src/main/java/org/oxycblt/auxio/settings/SettingsListFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/settings/SettingsListFragment.kt @@ -20,6 +20,7 @@ package org.oxycblt.auxio.settings import android.os.Bundle import android.view.View +import androidx.annotation.DrawableRes import androidx.appcompat.app.AppCompatDelegate import androidx.core.view.updatePadding 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 + } + } } diff --git a/app/src/main/java/org/oxycblt/auxio/settings/SettingsManager.kt b/app/src/main/java/org/oxycblt/auxio/settings/SettingsManager.kt index c99254e71..2fdb8d0ef 100644 --- a/app/src/main/java/org/oxycblt/auxio/settings/SettingsManager.kt +++ b/app/src/main/java/org/oxycblt/auxio/settings/SettingsManager.kt @@ -56,7 +56,6 @@ class SettingsManager private constructor(context: Context) : /** The current accent. */ var accent: Accent get() = handleAccentCompat(sharedPrefs) - set(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. * False if loop, true if shuffle. @@ -115,11 +110,10 @@ class SettingsManager private constructor(context: Context) : /** The current filter mode of the search tab */ 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) { sharedPrefs.edit { - putInt(KEY_SEARCH_FILTER_MODE, DisplayMode.toSearchInt(value)) + putInt(KEY_SEARCH_FILTER_MODE, DisplayMode.toFilterInt(value)) apply() } } @@ -140,10 +134,6 @@ class SettingsManager private constructor(context: Context) : override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) { when (key) { - KEY_COLORIZE_NOTIFICATION -> callbacks.forEach { - it.onColorizeNotifUpdate(colorizeNotif) - } - KEY_USE_ALT_NOTIFICATION_ACTION -> callbacks.forEach { it.onNotifActionUpdate(useAltNotifAction) } @@ -177,7 +167,6 @@ class SettingsManager private constructor(context: Context) : const val KEY_SHOW_COVERS = "KEY_SHOW_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_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_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" @Volatile diff --git a/app/src/main/java/org/oxycblt/auxio/ui/DisplayMode.kt b/app/src/main/java/org/oxycblt/auxio/ui/DisplayMode.kt index 115056fbf..1d789a5f0 100644 --- a/app/src/main/java/org/oxycblt/auxio/ui/DisplayMode.kt +++ b/app/src/main/java/org/oxycblt/auxio/ui/DisplayMode.kt @@ -34,8 +34,8 @@ enum class DisplayMode { private const val CONST_SHOW_ARTISTS = 0xA109 private const val CONST_SHOW_ALBUMS = 0xA10A private const val CONST_SHOW_SONGS = 0xA10B - - fun toSearchInt(value: DisplayMode?): Int { + + fun toFilterInt(value: DisplayMode?): Int { return when (value) { SHOW_SONGS -> CONST_SHOW_SONGS 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) { CONST_SHOW_SONGS -> SHOW_SONGS CONST_SHOW_ALBUMS -> SHOW_ALBUMS diff --git a/app/src/main/res/xml/prefs_main.xml b/app/src/main/res/xml/prefs_main.xml index 594832126..59ff2cf44 100644 --- a/app/src/main/res/xml/prefs_main.xml +++ b/app/src/main/res/xml/prefs_main.xml @@ -49,14 +49,6 @@ app:summary="@string/set_quality_covers_desc" app:title="@string/set_quality_covers" /> - -