all: cleanup
This commit is contained in:
@@ -133,7 +133,4 @@ object IntegerTable {
|
||||
const val PLAY_SONG_FROM_PLAYLIST = 0xA123
|
||||
/** PlaySong.ByItself */
|
||||
const val PLAY_SONG_BY_ITSELF = 0xA124
|
||||
const val PLAYER_COMMAND_INC_REPEAT_MODE = 0xA125
|
||||
const val PLAYER_COMMAND_TOGGLE_SHUFFLE = 0xA126
|
||||
const val PLAYER_COMMAND_EXIT = 0xA127
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ class MainFragment :
|
||||
DetailBackPressedCallback(detailModel).also { detailBackCallback = it }
|
||||
val selectionBackCallback =
|
||||
SelectionBackPressedCallback(listModel).also { selectionBackCallback = it }
|
||||
speedDialBackCallback = SpeedDialBackPressedCallback(homeModel)
|
||||
speedDialBackCallback = SpeedDialBackPressedCallback()
|
||||
|
||||
navigationListener = DialogAwareNavigationListener(::onExploreNavigate)
|
||||
|
||||
@@ -236,10 +236,12 @@ class MainFragment :
|
||||
// Stock bottom sheet overlay won't work with our nested UI setup, have to replicate
|
||||
// it ourselves.
|
||||
requireBinding().root.rootView.apply {
|
||||
findViewById<View>(R.id.main_scrim).setOnTouchListener { _, event ->
|
||||
findViewById<View>(R.id.main_scrim).setOnTouchListener { v, event ->
|
||||
v.performClick()
|
||||
handleSpeedDialBoundaryTouch(event)
|
||||
}
|
||||
findViewById<View>(R.id.sheet_scrim).setOnTouchListener { _, event ->
|
||||
findViewById<View>(R.id.sheet_scrim).setOnTouchListener { v, event ->
|
||||
v.performClick()
|
||||
handleSpeedDialBoundaryTouch(event)
|
||||
}
|
||||
}
|
||||
@@ -791,8 +793,7 @@ class MainFragment :
|
||||
}
|
||||
}
|
||||
|
||||
private inner class SpeedDialBackPressedCallback(private val homeModel: HomeViewModel) :
|
||||
OnBackPressedCallback(false) {
|
||||
private inner class SpeedDialBackPressedCallback() : OnBackPressedCallback(false) {
|
||||
override fun handleOnBackPressed() {
|
||||
val binding = requireBinding()
|
||||
if (binding.homeNewPlaylistFab.isOpen) {
|
||||
|
||||
@@ -90,7 +90,7 @@ class AlbumDetailFragment : DetailFragment<Album, Song>() {
|
||||
}
|
||||
|
||||
override fun onOpenParentMenu() {
|
||||
listModel.openMenu(R.menu.album, unlikelyToBeNull(detailModel.currentAlbum.value))
|
||||
listModel.openMenu(R.menu.detail_album, unlikelyToBeNull(detailModel.currentAlbum.value))
|
||||
}
|
||||
|
||||
override fun onOpenMenu(item: Song) {
|
||||
|
||||
@@ -170,7 +170,8 @@ class PlaylistDetailFragment :
|
||||
}
|
||||
|
||||
override fun onOpenParentMenu() {
|
||||
listModel.openMenu(R.menu.playlist, unlikelyToBeNull(detailModel.currentPlaylist.value))
|
||||
listModel.openMenu(
|
||||
R.menu.detail_playlist, unlikelyToBeNull(detailModel.currentPlaylist.value))
|
||||
}
|
||||
|
||||
override fun onOpenMenu(item: Song) {
|
||||
|
||||
@@ -300,7 +300,7 @@ class ThemedSpeedDialView : SpeedDialView {
|
||||
|
||||
private val DRAWABLE_PROPERTY_LEVEL =
|
||||
object : Property<Drawable, Int>(Int::class.java, "level") {
|
||||
override fun get(drawable: Drawable): Int? = drawable.level
|
||||
override fun get(drawable: Drawable): Int = drawable.level
|
||||
|
||||
override fun set(drawable: Drawable, value: Int?) {
|
||||
drawable.level = value!!
|
||||
|
||||
@@ -73,10 +73,6 @@ constructor(
|
||||
private var currentRequest: Request? = null
|
||||
private var currentHandle = 0L
|
||||
|
||||
/** If this provider is currently attempting to load something. */
|
||||
val isBusy: Boolean
|
||||
get() = currentRequest?.run { !disposable.isDisposed } ?: false
|
||||
|
||||
/**
|
||||
* Load the Album cover [Bitmap] from a [Song].
|
||||
*
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package org.oxycblt.auxio.image.extractor
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.BitmapFactory
|
||||
@@ -72,8 +73,8 @@ constructor(
|
||||
* @param covers The [Cover]s to load.
|
||||
* @param size The [Size] of the image to load.
|
||||
* @return If four distinct album covers could be extracted from the [Song]s, a [DrawableResult]
|
||||
* will be returned of a mosaic composed of four album covers ordered by
|
||||
* [computeCoverOrdering]. Otherwise, a [SourceResult] of one album cover will be returned.
|
||||
* will be returned of a mosaic composed of the first four loaded album covers. Otherwise, a
|
||||
* [SourceResult] of one album cover will be returned.
|
||||
*/
|
||||
suspend fun extract(covers: Collection<Cover>, size: Size): FetchResult? {
|
||||
val streams = mutableListOf<InputStream>()
|
||||
@@ -190,9 +191,11 @@ constructor(
|
||||
return findCoverDataInMetadata(metadata)
|
||||
}
|
||||
|
||||
@SuppressLint("Recycle")
|
||||
private suspend fun extractMediaStoreCover(cover: Cover) =
|
||||
// Eliminate any chance that this blocking call might mess up the loading process
|
||||
withContext(Dispatchers.IO) {
|
||||
// Coil will recycle this InputStream, so we don't need to worry about it.
|
||||
context.contentResolver.openInputStream(cover.mediaStoreCoverUri)
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class MenuItemViewHolder private constructor(private val binding: ItemMenuOption
|
||||
oldItem == newItem
|
||||
|
||||
override fun areContentsTheSame(oldItem: MenuItem, newItem: MenuItem) =
|
||||
oldItem.title == newItem.title
|
||||
oldItem.title.toString() == newItem.title.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package org.oxycblt.auxio.music
|
||||
|
||||
import android.content.Context
|
||||
import android.os.storage.StorageManager
|
||||
import androidx.core.content.edit
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import javax.inject.Inject
|
||||
@@ -27,7 +26,6 @@ import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.music.dirs.MusicDirectories
|
||||
import org.oxycblt.auxio.music.fs.DocumentPathFactory
|
||||
import org.oxycblt.auxio.settings.Settings
|
||||
import org.oxycblt.auxio.util.getSystemServiceCompat
|
||||
import org.oxycblt.auxio.util.logD
|
||||
|
||||
/**
|
||||
@@ -61,8 +59,6 @@ constructor(
|
||||
@ApplicationContext context: Context,
|
||||
private val documentPathFactory: DocumentPathFactory
|
||||
) : Settings.Impl<MusicSettings.Listener>(context), MusicSettings {
|
||||
private val storageManager = context.getSystemServiceCompat(StorageManager::class)
|
||||
|
||||
override var musicDirs: MusicDirectories
|
||||
get() {
|
||||
val dirs =
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Auxio Project
|
||||
* DirectoryModule.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.music.dirs
|
||||
|
||||
import dagger.Module
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
|
||||
@Module @InstallIn(SingletonComponent::class) interface DirectoryModule {}
|
||||
@@ -179,18 +179,6 @@ value class Components private constructor(val components: List<String>) {
|
||||
fun parseWindows(path: String) =
|
||||
Components(path.trimSlashes().split('\\').filter { it.isNotEmpty() })
|
||||
|
||||
/**
|
||||
* Parses a path string into a [Components] instance by any path separator, either unix or
|
||||
* windows. This is useful for parsing paths when you can't determine the separators any
|
||||
* other way, however also risks mangling the paths if they use unix-style escapes.
|
||||
*
|
||||
* @param path The path string to parse.
|
||||
* @return The [Components] instance.
|
||||
*/
|
||||
fun parseAny(path: String) =
|
||||
Components(
|
||||
path.trimSlashes().split(File.separatorChar, '\\').filter { it.isNotEmpty() })
|
||||
|
||||
private fun String.trimSlashes() = trimStart(File.separatorChar).trimEnd(File.separatorChar)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,16 +123,6 @@ fun Long.toAlbumCoverUri(): Uri = ContentUris.withAppendedId(externalCoversUri,
|
||||
@Suppress("NewApi")
|
||||
private val svApi21GetPathMethod: Method by lazyReflectedMethod(StorageVolume::class, "getPath")
|
||||
|
||||
/**
|
||||
* The [StorageVolume] considered the "primary" volume by the system, obtained in a
|
||||
* version-compatible manner.
|
||||
*
|
||||
* @see StorageManager.getPrimaryStorageVolume
|
||||
* @see StorageVolume.isPrimary
|
||||
*/
|
||||
val StorageManager.primaryStorageVolumeCompat: StorageVolume
|
||||
@Suppress("NewApi") get() = primaryStorageVolume
|
||||
|
||||
/**
|
||||
* The list of [StorageVolume]s currently recognized by [StorageManager], in a version-compatible
|
||||
* manner.
|
||||
|
||||
@@ -109,7 +109,7 @@ private class MetadataWorker(
|
||||
var mediaSource: MediaSource?,
|
||||
var mediaPeriod: MediaPeriod?,
|
||||
var mediaSourceCaller: MediaSourceCaller?
|
||||
) {}
|
||||
)
|
||||
|
||||
init {
|
||||
mediaSourceThread.start()
|
||||
|
||||
@@ -336,7 +336,7 @@ class TagInterpreterImpl @Inject constructor(private val coverExtractor: CoverEx
|
||||
first().replace(REPLAYGAIN_ADJUSTMENT_FILTER_REGEX, "").toFloatOrNull()?.nonZeroOrNull()
|
||||
|
||||
private companion object {
|
||||
val COVER_KEY_SAMPLE = 32
|
||||
const val COVER_KEY_SAMPLE = 32
|
||||
|
||||
val COMPILATION_ALBUM_ARTISTS = listOf("Various Artists")
|
||||
val COMPILATION_RELEASE_TYPES = listOf("compilation")
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.oxycblt.auxio.util.logD
|
||||
/**
|
||||
* A [ContentObserver] that observes the [MediaStore] music database for changes, a behavior known
|
||||
* to the user as automatic rescanning. The active (and not passive) nature of observing the
|
||||
* database is what requires [IndexerService] to stay foreground when this is enabled.
|
||||
* database is what requires [IndexerServiceFragment] to stay foreground when this is enabled.
|
||||
*/
|
||||
class SystemContentObserver
|
||||
@Inject
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.oxycblt.auxio.music.Genre
|
||||
import org.oxycblt.auxio.music.MusicParent
|
||||
import org.oxycblt.auxio.music.Playlist
|
||||
import org.oxycblt.auxio.music.Song
|
||||
import org.oxycblt.auxio.playback.persist.PersistenceRepository
|
||||
import org.oxycblt.auxio.playback.state.DeferredPlayback
|
||||
import org.oxycblt.auxio.playback.state.PlaybackCommand
|
||||
import org.oxycblt.auxio.playback.state.PlaybackStateManager
|
||||
@@ -59,7 +58,6 @@ class PlaybackViewModel
|
||||
constructor(
|
||||
private val playbackManager: PlaybackStateManager,
|
||||
private val playbackSettings: PlaybackSettings,
|
||||
private val persistenceRepository: PersistenceRepository,
|
||||
private val commandFactory: PlaybackCommand.Factory,
|
||||
private val listSettings: ListSettings,
|
||||
) : ViewModel(), PlaybackStateManager.Listener, PlaybackSettings.Listener {
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.oxycblt.auxio.util.logD
|
||||
|
||||
/**
|
||||
* A [BroadcastReceiver] that forwards [Intent.ACTION_MEDIA_BUTTON] [Intent]s to
|
||||
* [PlaybackServiceFragment].
|
||||
* [MediaSessionServiceFragment].
|
||||
*
|
||||
* @author Alexander Capehart (OxygenCobalt)
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package org.oxycblt.auxio.playback.service
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@@ -60,6 +61,7 @@ constructor(
|
||||
SystemPlaybackReceiver(playbackManager, playbackSettings, widgetComponent)
|
||||
private var callback: Callback? = null
|
||||
|
||||
@SuppressLint("WrongConstant")
|
||||
fun attach(callback: Callback) {
|
||||
this.callback = callback
|
||||
playbackManager.addListener(this)
|
||||
|
||||
@@ -31,16 +31,21 @@ import org.oxycblt.auxio.music.Song
|
||||
import org.oxycblt.auxio.playback.PlaybackSettings
|
||||
|
||||
/**
|
||||
* @param song A particular [Song] to play, or null to play the first [Song] in the new queue.
|
||||
* @param queue The queue of [Song]s to play from.
|
||||
* @param parent The [MusicParent] to play from, or null if to play from an non-specific collection
|
||||
* of "All [Song]s".
|
||||
* @param shuffled Whether to shuffle or not.
|
||||
* A playback command that can be passed to [PlaybackStateManager] to start new playback.
|
||||
*
|
||||
* @author Alexander Capehart (OxygenCobalt)
|
||||
*/
|
||||
interface PlaybackCommand {
|
||||
/** A particular [Song] to play, or null to play the first [Song] in the new queue. * */
|
||||
val song: Song?
|
||||
/**
|
||||
* The [MusicParent] to play from, or null if to play from an non-specific collection of "All
|
||||
* [Song]s". *
|
||||
*/
|
||||
val parent: MusicParent?
|
||||
/** The queue of [Song]s to play from. * */
|
||||
val queue: List<Song>
|
||||
/** Whether to shuffle or not. * */
|
||||
val shuffled: Boolean
|
||||
|
||||
interface Factory {
|
||||
|
||||
@@ -20,7 +20,6 @@ package org.oxycblt.auxio.playback.state
|
||||
|
||||
import android.net.Uri
|
||||
import android.os.SystemClock
|
||||
import android.support.v4.media.session.PlaybackStateCompat
|
||||
import org.oxycblt.auxio.list.adapter.UpdateInstructions
|
||||
import org.oxycblt.auxio.music.MusicParent
|
||||
import org.oxycblt.auxio.music.Song
|
||||
@@ -324,30 +323,6 @@ private constructor(
|
||||
initPositionMs
|
||||
}
|
||||
|
||||
/**
|
||||
* Load this instance into a [PlaybackStateCompat].
|
||||
*
|
||||
* @param builder The [PlaybackStateCompat.Builder] to mutate.
|
||||
* @return The same [PlaybackStateCompat.Builder] for easy chaining.
|
||||
*/
|
||||
fun intoPlaybackState(builder: PlaybackStateCompat.Builder): PlaybackStateCompat.Builder =
|
||||
builder.setState(
|
||||
// State represents the user's preference, not the actual player state.
|
||||
// Doing this produces a better experience in the media control UI.
|
||||
if (isPlaying) {
|
||||
PlaybackStateCompat.STATE_PLAYING
|
||||
} else {
|
||||
PlaybackStateCompat.STATE_PAUSED
|
||||
},
|
||||
initPositionMs,
|
||||
if (isAdvancing) {
|
||||
1f
|
||||
} else {
|
||||
// Not advancing, so don't move the position.
|
||||
0f
|
||||
},
|
||||
creationTime)
|
||||
|
||||
// Equality ignores the creation time to prevent functionally identical states
|
||||
// from being non-equal.
|
||||
|
||||
|
||||
@@ -346,7 +346,7 @@ class PlaybackStateManagerImpl @Inject constructor() : PlaybackStateManager {
|
||||
val rawQueue: RawQueue
|
||||
)
|
||||
|
||||
private val listeners = mutableListOf<PlaybackStateManager.Listener>()
|
||||
private val listeners = mutableListOf<Listener>()
|
||||
|
||||
@Volatile
|
||||
private var stateMirror =
|
||||
@@ -387,7 +387,7 @@ class PlaybackStateManagerImpl @Inject constructor() : PlaybackStateManager {
|
||||
get() = stateHolder?.audioSessionId
|
||||
|
||||
@Synchronized
|
||||
override fun addListener(listener: PlaybackStateManager.Listener) {
|
||||
override fun addListener(listener: Listener) {
|
||||
logD("Adding $listener to listeners")
|
||||
listeners.add(listener)
|
||||
|
||||
@@ -401,7 +401,7 @@ class PlaybackStateManagerImpl @Inject constructor() : PlaybackStateManager {
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun removeListener(listener: PlaybackStateManager.Listener) {
|
||||
override fun removeListener(listener: Listener) {
|
||||
logD("Removing $listener from listeners")
|
||||
if (!listeners.remove(listener)) {
|
||||
logW("Listener $listener was not added prior, cannot remove")
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.google.android.material.transition.MaterialSharedAxis
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import org.oxycblt.auxio.R
|
||||
import org.oxycblt.auxio.music.MusicViewModel
|
||||
import org.oxycblt.auxio.playback.PlaybackViewModel
|
||||
import org.oxycblt.auxio.settings.ui.WrappedDialogPreference
|
||||
import org.oxycblt.auxio.util.logD
|
||||
import org.oxycblt.auxio.util.navigateSafe
|
||||
@@ -40,7 +39,6 @@ import org.oxycblt.auxio.util.navigateSafe
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
class RootPreferenceFragment : BasePreferenceFragment(R.xml.preferences_root) {
|
||||
private val playbackModel: PlaybackViewModel by activityViewModels()
|
||||
private val musicModel: MusicViewModel by activityViewModels()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
||||
@@ -41,7 +41,6 @@ import androidx.core.view.children
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavDirections
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.google.android.material.appbar.MaterialToolbar
|
||||
import java.lang.IllegalArgumentException
|
||||
@@ -134,12 +133,6 @@ fun Toolbar.overrideOnOverflowMenuClick(block: (View) -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute if this [RecyclerView] can scroll through their items, or if the items can all fit on one
|
||||
* screen.
|
||||
*/
|
||||
fun RecyclerView.canScroll() = computeVerticalScrollRange() > height
|
||||
|
||||
/**
|
||||
* Shortcut to easily set up a [GridLayoutManager.SpanSizeLookup].
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user