From 8dc0be4a5248e2ca320242d5e168667cc01ac3ce Mon Sep 17 00:00:00 2001 From: Alexander Capehart Date: Sun, 21 Jan 2024 20:01:26 -0700 Subject: [PATCH] all: cleanup --- app/build.gradle | 4 ++-- app/src/main/java/org/oxycblt/auxio/MainActivity.kt | 8 ++++---- .../java/org/oxycblt/auxio/home/ThemedSpeedDialView.kt | 4 ++-- .../main/java/org/oxycblt/auxio/music/MusicSettings.kt | 6 ++++-- .../main/java/org/oxycblt/auxio/music/MusicViewModel.kt | 3 ++- .../auxio/music/decision/PlaylistPickerViewModel.kt | 2 +- .../org/oxycblt/auxio/music/dirs/DirectoryAdapter.kt | 8 +++----- .../org/oxycblt/auxio/music/dirs/MusicDirectories.kt | 7 ++++--- .../org/oxycblt/auxio/music/fs/MediaStoreExtractor.kt | 2 +- .../java/org/oxycblt/auxio/playback/PlaybackViewModel.kt | 9 ++++----- .../oxycblt/auxio/playback/state/PlaybackStateHolder.kt | 7 ++++++- .../oxycblt/auxio/playback/state/PlaybackStateManager.kt | 8 ++++---- .../oxycblt/auxio/playback/system/BetterShuffleOrder.kt | 3 ++- .../org/oxycblt/auxio/playback/system/PlaybackService.kt | 2 +- .../java/org/oxycblt/auxio/widgets/WidgetComponent.kt | 6 +++--- app/src/main/res/layout/fragment_home.xml | 2 ++ app/src/main/res/layout/widget_stick_thin.xml | 1 - app/src/main/res/layout/widget_stick_wide.xml | 1 - app/src/main/res/values-lt/strings.xml | 1 + app/src/main/res/values-pt-rPT/strings.xml | 2 +- 20 files changed, 47 insertions(+), 39 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 915f58a3e..af0bf21bb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -21,8 +21,8 @@ android { defaultConfig { applicationId namespace - versionName "3.3.3" - versionCode 40 + versionName "3.4.0" + versionCode 41 minSdk 24 targetSdk 34 diff --git a/app/src/main/java/org/oxycblt/auxio/MainActivity.kt b/app/src/main/java/org/oxycblt/auxio/MainActivity.kt index 18af927b5..3fa2ad852 100644 --- a/app/src/main/java/org/oxycblt/auxio/MainActivity.kt +++ b/app/src/main/java/org/oxycblt/auxio/MainActivity.kt @@ -111,12 +111,12 @@ class MainActivity : AppCompatActivity() { } /** - * Transform an [Intent] given to [MainActivity] into a [InternalPlayer.Action] that can be used - * in the playback system. + * Transform an [Intent] given to [MainActivity] into a [DeferredPlayback] that can be used in + * the playback system. * * @param intent The (new) [Intent] given to this [MainActivity], or null if there is no intent. - * @return true If the analogous [InternalPlayer.Action] to the given [Intent] was started, - * false otherwise. + * @return true If the analogous [DeferredPlayback] to the given [Intent] was started, false + * otherwise. */ private fun startIntentAction(intent: Intent?): Boolean { if (intent == null) { diff --git a/app/src/main/java/org/oxycblt/auxio/home/ThemedSpeedDialView.kt b/app/src/main/java/org/oxycblt/auxio/home/ThemedSpeedDialView.kt index 1a9b5174d..0db750c1a 100644 --- a/app/src/main/java/org/oxycblt/auxio/home/ThemedSpeedDialView.kt +++ b/app/src/main/java/org/oxycblt/auxio/home/ThemedSpeedDialView.kt @@ -244,7 +244,7 @@ class ThemedSpeedDialView : SpeedDialView { companion object { private val VIEW_PROPERTY_BACKGROUND_TINT = object : Property(Int::class.java, "backgroundTint") { - override fun get(view: View): Int? = view.backgroundTintList!!.defaultColor + override fun get(view: View): Int = view.backgroundTintList!!.defaultColor override fun set(view: View, value: Int?) { view.backgroundTintList = ColorStateList.valueOf(value!!) @@ -253,7 +253,7 @@ class ThemedSpeedDialView : SpeedDialView { private val IMAGE_VIEW_PROPERTY_IMAGE_TINT = object : Property(Int::class.java, "imageTint") { - override fun get(view: ImageView): Int? = view.imageTintList!!.defaultColor + override fun get(view: ImageView): Int = view.imageTintList!!.defaultColor override fun set(view: ImageView, value: Int?) { view.imageTintList = ColorStateList.valueOf(value!!) diff --git a/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt b/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt index e50b0c448..67b46e9ce 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt @@ -57,8 +57,10 @@ interface MusicSettings : Settings { class MusicSettingsImpl @Inject -constructor(@ApplicationContext context: Context, val documentPathFactory: DocumentPathFactory) : - Settings.Impl(context), MusicSettings { +constructor( + @ApplicationContext context: Context, + private val documentPathFactory: DocumentPathFactory +) : Settings.Impl(context), MusicSettings { private val storageManager = context.getSystemServiceCompat(StorageManager::class) override var musicDirs: MusicDirectories diff --git a/app/src/main/java/org/oxycblt/auxio/music/MusicViewModel.kt b/app/src/main/java/org/oxycblt/auxio/music/MusicViewModel.kt index 6140261a9..4c45dfc84 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/MusicViewModel.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/MusicViewModel.kt @@ -368,7 +368,8 @@ sealed interface PlaylistDecision { * @param songs The [Song]s to contain in the new [Playlist]. * @param template An existing playlist name that should be editable in the opened dialog. If * null, a placeholder should be created and shown as a hint instead. - * @param context The context in which this decision is being fulfilled. + * @param reason The reason why a new playlist is being created. For all intensive purposes, you + * do not need to specify this. */ data class New(val songs: List, val template: String?, val reason: Reason) : PlaylistDecision { diff --git a/app/src/main/java/org/oxycblt/auxio/music/decision/PlaylistPickerViewModel.kt b/app/src/main/java/org/oxycblt/auxio/music/decision/PlaylistPickerViewModel.kt index 3e487437a..c9a5d293a 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/decision/PlaylistPickerViewModel.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/decision/PlaylistPickerViewModel.kt @@ -210,7 +210,7 @@ class PlaylistPickerViewModel @Inject constructor(private val musicRepository: M } /** - * Set a new [currentPlaylisttoExport] from a [Playlist] [Music.UID]. + * Set a new [currentPlaylistToExport] from a [Playlist] [Music.UID]. * * @param playlistUid The [Music.UID] of the [Playlist] to export. */ diff --git a/app/src/main/java/org/oxycblt/auxio/music/dirs/DirectoryAdapter.kt b/app/src/main/java/org/oxycblt/auxio/music/dirs/DirectoryAdapter.kt index 9beedd79f..949d9282c 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/dirs/DirectoryAdapter.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/dirs/DirectoryAdapter.kt @@ -29,7 +29,7 @@ import org.oxycblt.auxio.util.inflater import org.oxycblt.auxio.util.logD /** - * [RecyclerView.Adapter] that manages a list of [Directory] instances. + * [RecyclerView.Adapter] that manages a list of [Path] music directory instances. * * @param listener A [DirectoryAdapter.Listener] to bind interactions to. * @author Alexander Capehart (OxygenCobalt) @@ -37,9 +37,7 @@ import org.oxycblt.auxio.util.logD class DirectoryAdapter(private val listener: Listener) : RecyclerView.Adapter() { private val _dirs = mutableListOf() - /** - * The current list of [SystemPath]s, may not line up with [MusicDirectories] due to removals. - */ + /** The current list of [Path]s, may not line up with [MusicDirectories] due to removals. */ val dirs: List = _dirs override fun getItemCount() = dirs.size @@ -94,7 +92,7 @@ class DirectoryAdapter(private val listener: Listener) : } /** - * A [RecyclerView.Recycler] that displays a [Directory]. Use [from] to create an instance. + * A [RecyclerView.Recycler] that displays a [Path]. Use [from] to create an instance. * * @author Alexander Capehart (OxygenCobalt) */ diff --git a/app/src/main/java/org/oxycblt/auxio/music/dirs/MusicDirectories.kt b/app/src/main/java/org/oxycblt/auxio/music/dirs/MusicDirectories.kt index c85b21ad5..a4082cbf7 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/dirs/MusicDirectories.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/dirs/MusicDirectories.kt @@ -23,9 +23,10 @@ import org.oxycblt.auxio.music.fs.Path /** * Represents the configuration for specific directories to filter to/from when loading music. * - * @param dirs A list of [Directory] instances. How these are interpreted depends on [shouldInclude] - * @param shouldInclude True if the library should only load from the [Directory] instances, false - * if the library should not load from the [Directory] instances. + * @param dirs A list of directory [Path] instances. How these are interpreted depends on + * [shouldInclude] + * @param shouldInclude True if the library should only load from the [Path] instances, false if the + * library should not load from the [Path] instances. * @author Alexander Capehart (OxygenCobalt) */ data class MusicDirectories(val dirs: List, val shouldInclude: Boolean) diff --git a/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStoreExtractor.kt b/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStoreExtractor.kt index 90b5e2051..e0e989133 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStoreExtractor.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/fs/MediaStoreExtractor.kt @@ -90,7 +90,7 @@ interface MediaStoreExtractor { * Create a framework-backed instance. * * @param context [Context] required. - * @param volumeManager [VolumeManager] required. + * @param pathInterpreterFactory A [MediaStorePathInterpreter.Factory] to use. * @return A new [MediaStoreExtractor] that will work best on the device's API level. */ fun from( diff --git a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackViewModel.kt b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackViewModel.kt index 73f7d1258..483a36d99 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/PlaybackViewModel.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/PlaybackViewModel.kt @@ -114,8 +114,7 @@ constructor( get() = _playbackDecision /** - * The current audio session ID of the internal player. Null if no [InternalPlayer] is - * available. + * The current audio session ID of the internal player. Null if no audio player is available. */ val currentAudioSessionId: Int? get() = playbackManager.currentAudioSessionId @@ -416,10 +415,10 @@ constructor( } /** - * Start the given [InternalPlayer.Action] to be completed eventually. This can be used to - * enqueue a playback action at startup to then occur when the music library is fully loaded. + * Start the given [DeferredPlayback] to be completed eventually. This can be used to enqueue a + * playback action at startup to then occur when the music library is fully loaded. * - * @param action The [InternalPlayer.Action] to perform eventually. + * @param action The [DeferredPlayback] to perform eventually. */ fun playDeferred(action: DeferredPlayback) { logD("Starting action $action") diff --git a/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateHolder.kt b/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateHolder.kt index 7de33f20c..2374a421f 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateHolder.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateHolder.kt @@ -374,6 +374,11 @@ private constructor( positionMs, SystemClock.elapsedRealtime()) - fun nil() = Progression(false, false, 0, SystemClock.elapsedRealtime()) + fun nil() = + Progression( + isPlaying = false, + isAdvancing = false, + initPositionMs = 0, + creationTime = SystemClock.elapsedRealtime()) } } diff --git a/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt b/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt index aa9ca0078..fd8477913 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/state/PlaybackStateManager.kt @@ -207,7 +207,7 @@ interface PlaybackStateManager { fun playDeferred(action: DeferredPlayback) /** - * Request that the pending [PlaybackStateHolder.Action] (if any) be passed to the given + * Request that the pending [DeferredPlayback] (if any) be passed to the given * [PlaybackStateHolder]. * * @param stateHolder The [PlaybackStateHolder] to synchronize with. Must be the current @@ -271,7 +271,7 @@ interface PlaybackStateManager { fun onIndexMoved(index: Int) {} /** - * Called when the queue changed in a manner outlined by the given [Queue.Change]. + * Called when the queue changed in a manner outlined by the given [DeferredPlayback]. * * @param queue The songs of the new queue. * @param index The new index of the currently playing [Song]. @@ -305,9 +305,9 @@ interface PlaybackStateManager { ) {} /** - * Called when the state of the [InternalPlayer] changes. + * Called when the state of the audio player changes. * - * @param progression The new state of the [InternalPlayer]. + * @param progression The new state of the audio player. */ fun onProgressionChanged(progression: Progression) {} diff --git a/app/src/main/java/org/oxycblt/auxio/playback/system/BetterShuffleOrder.kt b/app/src/main/java/org/oxycblt/auxio/playback/system/BetterShuffleOrder.kt index 099931baf..e09d9ba2a 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/system/BetterShuffleOrder.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/system/BetterShuffleOrder.kt @@ -29,7 +29,7 @@ import java.util.* * * @author media3 team, Alexander Capehart (OxygenCobalt) */ -class BetterShuffleOrder constructor(private val shuffled: IntArray) : ShuffleOrder { +class BetterShuffleOrder(private val shuffled: IntArray) : ShuffleOrder { private val indexInShuffled: IntArray = IntArray(shuffled.size) constructor(length: Int, startIndex: Int) : this(createShuffledList(length, startIndex)) @@ -62,6 +62,7 @@ class BetterShuffleOrder constructor(private val shuffled: IntArray) : ShuffleOr return if (shuffled.isNotEmpty()) shuffled[0] else C.INDEX_UNSET } + @Suppress("KotlinConstantConditions") // Bugged for this function override fun cloneAndInsert(insertionIndex: Int, insertionCount: Int): ShuffleOrder { if (shuffled.isEmpty()) { return BetterShuffleOrder(insertionCount, -1) diff --git a/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackService.kt b/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackService.kt index 6530bca91..a84b5775c 100644 --- a/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackService.kt +++ b/app/src/main/java/org/oxycblt/auxio/playback/system/PlaybackService.kt @@ -593,7 +593,7 @@ class PlaybackService : private fun ExoPlayer.unscrambleQueueIndices(): List { val timeline = currentTimeline - if (timeline.isEmpty()) { + if (timeline.isEmpty) { return emptyList() } val queue = mutableListOf() diff --git a/app/src/main/java/org/oxycblt/auxio/widgets/WidgetComponent.kt b/app/src/main/java/org/oxycblt/auxio/widgets/WidgetComponent.kt index 9280d2ea2..09ac5e8f1 100644 --- a/app/src/main/java/org/oxycblt/auxio/widgets/WidgetComponent.kt +++ b/app/src/main/java/org/oxycblt/auxio/widgets/WidgetComponent.kt @@ -165,12 +165,12 @@ constructor( /** * A condensed form of the playback state that is safe to use in AppWidgets. * - * @param song [Queue.currentSong] + * @param song [PlaybackStateManager.currentSong] * @param cover A pre-loaded album cover [Bitmap] for [song]. * @param cover A pre-loaded album cover [Bitmap] for [song], with rounded corners. - * @param isPlaying [PlaybackStateManager.playerState] + * @param isPlaying [PlaybackStateManager.progression] * @param repeatMode [PlaybackStateManager.repeatMode] - * @param isShuffled [Queue.isShuffled] + * @param isShuffled [PlaybackStateManager.isShuffled] */ data class PlaybackState( val song: Song, diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 2ff9e9757..c92bab632 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -164,6 +164,7 @@ android:clickable="true" android:focusable="true" android:gravity="bottom|end" + android:contentDescription="@string/lbl_new_playlist" app:sdMainFabAnimationRotateAngle="135" app:sdMainFabClosedIconColor="@android:color/white" app:sdMainFabClosedSrc="@drawable/ic_add_24" /> @@ -172,6 +173,7 @@ android:id="@+id/home_shuffle_fab" android:layout_width="match_parent" android:layout_height="wrap_content" + android:contentDescription="@string/lbl_shuffle" android:layout_gravity="bottom|end" android:layout_margin="@dimen/spacing_medium" android:src="@drawable/ic_shuffle_off_24" /> diff --git a/app/src/main/res/layout/widget_stick_thin.xml b/app/src/main/res/layout/widget_stick_thin.xml index 776d26525..f4651eaf1 100644 --- a/app/src/main/res/layout/widget_stick_thin.xml +++ b/app/src/main/res/layout/widget_stick_thin.xml @@ -1,6 +1,5 @@ %d atlikėjas %d atlikėjai + %d atlikėjų %d atlikėjų Perskenuoti muziką diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 1011bf65d..d6d307c19 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -37,7 +37,7 @@ Esquema de cores Áudio Personalizar - Memorizar musica misturada + Memorizar música misturada Nenhuma música encontrada