all: cleanup

This commit is contained in:
Alexander Capehart 2024-10-18 15:41:06 -06:00
parent 22ddda4e60
commit 7dfaea3a4b
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
34 changed files with 43 additions and 227 deletions

View file

@ -93,7 +93,8 @@
android:foregroundServiceType="mediaPlayback"
android:icon="@mipmap/ic_launcher"
android:exported="true"
android:roundIcon="@mipmap/ic_launcher">
android:roundIcon="@mipmap/ic_launcher"
tools:ignore="ExportedService">
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService"/>
</intent-filter>

View file

@ -36,7 +36,6 @@ import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import org.oxycblt.auxio.music.service.MusicServiceFragment
import org.oxycblt.auxio.playback.service.PlaybackServiceFragment
import timber.log.Timber as T
@AndroidEntryPoint
class AuxioService :
@ -150,7 +149,6 @@ class AuxioService :
}
override fun invalidateMusic(mediaId: String) {
T.d(mediaId)
notifyChildrenChanged(mediaId)
}

View file

@ -40,7 +40,6 @@ import org.oxycblt.auxio.music.resolveNames
import org.oxycblt.auxio.playback.PlaybackDecision
import org.oxycblt.auxio.util.collect
import org.oxycblt.auxio.util.collectImmediately
import org.oxycblt.auxio.util.context
import org.oxycblt.auxio.util.getPlural
import org.oxycblt.auxio.util.navigateSafe
import org.oxycblt.auxio.util.showToast

View file

@ -38,7 +38,6 @@ import org.oxycblt.auxio.list.recycler.DividerViewHolder
import org.oxycblt.auxio.music.Music
import org.oxycblt.auxio.util.context
import org.oxycblt.auxio.util.inflater
import timber.log.Timber as T
/**
* A [RecyclerView.Adapter] that implements shared behavior between lists of child items in the

View file

@ -19,7 +19,6 @@
package org.oxycblt.auxio.list
import androidx.annotation.StringRes
import timber.log.Timber as T
// TODO: Consider breaking this up into sealed classes for individual adapters
/** A marker for something that is a RecyclerView item. Has no functionality on it's own. */

View file

@ -21,7 +21,6 @@ package org.oxycblt.auxio.list
import androidx.recyclerview.widget.RecyclerView
import androidx.viewbinding.ViewBinding
import org.oxycblt.auxio.music.Music
import timber.log.Timber as T
/**
* A Fragment containing a selectable list.

View file

@ -21,7 +21,6 @@ package org.oxycblt.auxio.list
import android.view.MotionEvent
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import timber.log.Timber as T
/**
* A basic listener for list interactions.

View file

@ -25,7 +25,6 @@ import androidx.recyclerview.widget.AsyncDifferConfig
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import java.util.concurrent.Executor
import timber.log.Timber as T
/**
* A variant of ListDiffer with more flexible updates.

View file

@ -21,7 +21,6 @@ package org.oxycblt.auxio.list.adapter
import android.view.View
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import timber.log.Timber as T
/**
* A [RecyclerView.Adapter] that supports indicating the playback status of a particular item.

View file

@ -22,7 +22,6 @@ import android.view.View
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import org.oxycblt.auxio.music.Music
import timber.log.Timber as T
/**
* A [PlayingIndicatorAdapter] that also supports indicating the selection status of a group of

View file

@ -20,7 +20,6 @@ package org.oxycblt.auxio.list.adapter
import androidx.recyclerview.widget.DiffUtil
import org.oxycblt.auxio.list.Item
import timber.log.Timber as T
/**
* A [DiffUtil.ItemCallback] that automatically implements the [areItemsTheSame] method. Use this

View file

@ -18,6 +18,7 @@
package org.oxycblt.auxio.list.recycler
import android.annotation.SuppressLint
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.divider.MaterialDivider
@ -382,6 +383,7 @@ class DividerViewHolder private constructor(divider: MaterialDivider) :
/** A comparator that can be used with DiffUtil. */
val DIFF_CALLBACK =
object : SimpleDiffCallback<PlainDivider>() {
@SuppressLint("DiffUtilEquals")
override fun areContentsTheSame(oldItem: PlainDivider, newItem: PlainDivider) =
oldItem.anchor == newItem.anchor
}

View file

@ -22,9 +22,6 @@ import android.content.Context
import android.net.Uri
import android.os.Parcelable
import androidx.room.TypeConverter
import java.security.MessageDigest
import java.util.UUID
import kotlin.math.max
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import org.oxycblt.auxio.image.extractor.Cover
@ -39,7 +36,9 @@ import org.oxycblt.auxio.music.info.ReleaseType
import org.oxycblt.auxio.playback.replaygain.ReplayGainAdjustment
import org.oxycblt.auxio.util.concatLocalized
import org.oxycblt.auxio.util.toUuidOrNull
import timber.log.Timber as T
import java.security.MessageDigest
import java.util.UUID
import kotlin.math.max
/**
* Abstract music data. This contains universal information about all concrete music

View file

@ -261,7 +261,7 @@ constructor(
}
commonIndex == components.size -> {
// The working directory is deeper in the path, backtrack.
for (i in 0..workingDirectory.components.size - commonIndex - 1) {
for (i in 0..<workingDirectory.components.size - commonIndex) {
relativeComponents = relativeComponents.child("..")
}
}
@ -272,7 +272,7 @@ constructor(
}
else -> {
// The paths are siblings. Backtrack and append as needed.
for (i in 0..workingDirectory.components.size - commonIndex - 1) {
for (i in 0..<workingDirectory.components.size - commonIndex) {
relativeComponents = relativeComponents.child("..")
}
relativeComponents = relativeComponents.child(depth(commonIndex))

View file

@ -38,8 +38,8 @@ import timber.log.Timber as T
*/
class Date private constructor(private val tokens: List<Int>) : Comparable<Date> {
val year = tokens[0]
val month = tokens.getOrNull(1)
val day = tokens.getOrNull(2)
private val month = tokens.getOrNull(1)
private val day = tokens.getOrNull(2)
private val hour = tokens.getOrNull(3)
private val minute = tokens.getOrNull(4)
private val second = tokens.getOrNull(5)

View file

@ -23,7 +23,6 @@ import android.os.Bundle
import android.support.v4.media.MediaBrowserCompat.MediaItem
import androidx.media.MediaBrowserServiceCompat.BrowserRoot
import androidx.media.MediaBrowserServiceCompat.Result
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@ -31,12 +30,12 @@ import kotlinx.coroutines.launch
import org.oxycblt.auxio.ForegroundListener
import org.oxycblt.auxio.ForegroundServiceNotification
import org.oxycblt.auxio.music.MusicRepository
import timber.log.Timber as T
import javax.inject.Inject
class MusicServiceFragment
@Inject
constructor(
private val context: Context,
context: Context,
foregroundListener: ForegroundListener,
private val invalidator: Invalidator,
indexerFactory: Indexer.Factory,

View file

@ -33,7 +33,7 @@ import timber.log.Timber as T
/**
* 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 [IndexerServiceFragment] to stay foreground when this is enabled.
* database is what requires [MusicServiceFragment] to stay foreground when this is enabled.
*/
class SystemContentObserver
@Inject

View file

@ -31,7 +31,7 @@ import timber.log.Timber as T
/**
* A [BroadcastReceiver] that forwards [Intent.ACTION_MEDIA_BUTTON] [Intent]s to
* [MediaSessionServiceFragment].
* [PlaybackServiceFragment].
*
* @author Alexander Capehart (OxygenCobalt)
*/

View file

@ -53,7 +53,7 @@ import timber.log.Timber as T
/**
* A component that mirrors the current playback state into the [MediaSessionCompat] and
* [NotificationComponent].
* [PlaybackNotification].
*
* @author Alexander Capehart (OxygenCobalt)
*/
@ -109,7 +109,7 @@ private constructor(
/**
* Release this instance, closing the [MediaSessionCompat] and preventing any further updates to
* the [NotificationComponent].
* the [PlaybackNotification].
*/
fun release() {
bitmapProvider.release()
@ -202,7 +202,7 @@ private constructor(
/**
* Upload a new [MediaMetadataCompat] based on the current playback state to the
* [MediaSessionCompat] and [NotificationComponent].
* [MediaSessionCompat] and [PlaybackNotification].
*
* @param song The current [Song] to create the [MediaMetadataCompat] from, or null if no [Song]
* is currently playing.

View file

@ -59,25 +59,22 @@ constructor(
) : MediaSessionCompat.Callback() {
private val jaroWinkler = JaroWinklerSimilarity()
override fun onPrepare() {
super.onPrepare()
// STUB, we already automatically prepare playback.
}
// STUBS: We already automatically prepare playback.
// override fun onPrepare() {
// super.onPrepare()
// }
override fun onPrepareFromMediaId(mediaId: String?, extras: Bundle?) {
super.onPrepareFromMediaId(mediaId, extras)
// STUB, can't tell when this is called
}
override fun onPrepareFromUri(uri: Uri?, extras: Bundle?) {
super.onPrepareFromUri(uri, extras)
// STUB, can't tell when this is called
}
override fun onPlayFromUri(uri: Uri?, extras: Bundle?) {
super.onPlayFromUri(uri, extras)
// STUB, can't tell when this is called
}
// override fun onPrepareFromMediaId(mediaId: String?, extras: Bundle?) {
// super.onPrepareFromMediaId(mediaId, extras)
// }
//
// override fun onPrepareFromUri(uri: Uri?, extras: Bundle?) {
// super.onPrepareFromUri(uri, extras)
// }
//
// override fun onPlayFromUri(uri: Uri?, extras: Bundle?) {
// super.onPlayFromUri(uri, extras)
// }
override fun onPlayFromMediaId(mediaId: String?, extras: Bundle?) {
super.onPlayFromMediaId(mediaId, extras)

View file

@ -32,14 +32,14 @@ import timber.log.Timber as T
class PlaybackServiceFragment
private constructor(
private val context: Context,
context: Context,
private val foregroundListener: ForegroundListener,
private val playbackManager: PlaybackStateManager,
exoHolderFactory: ExoPlaybackStateHolder.Factory,
sessionHolderFactory: MediaSessionHolder.Factory,
widgetComponentFactory: WidgetComponent.Factory,
systemReceiverFactory: SystemPlaybackReceiver.Factory,
) : MediaSessionCompat.Callback(), PlaybackStateManager.Listener {
) : PlaybackStateManager.Listener {
class Factory
@Inject
constructor(

View file

@ -54,6 +54,7 @@ private constructor(
SystemPlaybackReceiver(context, playbackManager, playbackSettings, widgetComponent)
}
@Suppress("WrongConstant")
fun attach() {
ContextCompat.registerReceiver(
context, this, INTENT_FILTER, ContextCompat.RECEIVER_EXPORTED)

View file

@ -18,7 +18,6 @@
package org.oxycblt.auxio.playback.state
import javax.inject.Inject
import org.oxycblt.auxio.list.ListSettings
import org.oxycblt.auxio.list.sort.Sort
import org.oxycblt.auxio.music.Album
@ -29,7 +28,7 @@ import org.oxycblt.auxio.music.MusicRepository
import org.oxycblt.auxio.music.Playlist
import org.oxycblt.auxio.music.Song
import org.oxycblt.auxio.playback.PlaybackSettings
import timber.log.Timber as T
import javax.inject.Inject
/**
* A playback command that can be passed to [PlaybackStateManager] to start new playback.

View file

@ -61,7 +61,7 @@ interface SearchEngine {
val artists: Collection<Artist>? = null,
val genres: Collection<Genre>? = null,
val playlists: Collection<Playlist>? = null
) {}
)
}
class SearchEngineImpl @Inject constructor(@ApplicationContext private val context: Context) :

View file

@ -45,7 +45,7 @@ class StartActionHelper(config: TaskerPluginConfig<Unit>) :
}
class ActivityConfigStartAction : Activity(), TaskerPluginConfigNoInput {
override val context
override val context: Context
get() = applicationContext
private val taskerHelper by lazy { StartActionHelper(this) }

View file

@ -40,7 +40,6 @@ import kotlin.reflect.KClass
import org.oxycblt.auxio.IntegerTable
import org.oxycblt.auxio.MainActivity
import org.oxycblt.auxio.R
import timber.log.Timber as T
/**
* Get a [LayoutInflater] instance from this [Context].

View file

@ -3,7 +3,7 @@ package org.oxycblt.auxio.util
import timber.log.Timber
class CopyleftNoticeTree : Timber.DebugTree() {
// Feel free to remove this if you are forking the project in good faith.
// Feel free to remove this logger if you are forking the project in good faith.
//
// However, if you are stealing the source code to repackage it into a new closed-source app,
// I will warn you that the One True, Living, Almighty God HATES thieves and WILL punish you

View file

@ -18,6 +18,7 @@
package org.oxycblt.auxio.util
import android.annotation.SuppressLint
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
@ -117,6 +118,7 @@ val ViewBinding.context: Context
* Override the behavior of a [MaterialToolbar]'s overflow menu to do something else. This is
* extremely dumb, but required to hook overflow menus to bottom sheet menus.
*/
@SuppressLint("RestrictedApi")
fun Toolbar.overrideOnOverflowMenuClick(block: (View) -> Unit) {
for (toolbarChild in children) {
if (toolbarChild is ActionMenuView) {

View file

@ -23,7 +23,6 @@ import java.util.UUID
import kotlin.reflect.KClass
import org.oxycblt.auxio.BuildConfig
import org.oxycblt.auxio.music.info.Date
import timber.log.Timber as T
/**
* Sanitizes a value that is unlikely to be null. On debug builds, this aliases to [requireNotNull],

View file

@ -24,7 +24,7 @@ import coil.size.Size
import coil.transform.Transformation
import kotlin.math.sqrt
class WidgetBitmapTransformation(private val reduce: Float) : Transformation {
class WidgetBitmapTransformation(reduce: Float) : Transformation {
private val metrics = Resources.getSystem().displayMetrics
private val sw = metrics.widthPixels
private val sh = metrics.heightPixels

View file

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:alpha="0.24" android:color="?attr/colorOnSurface" />
</selector>

View file

@ -1,56 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.oxycblt.auxio.image.CoverView
android:id="@+id/playback_cover"
style="@style/Widget.Auxio.Image.Full"
android:layout_margin="@dimen/spacing_medium"
app:enablePlaybackIndicator="false"
app:enableSelectionBadge="false"
app:layout_constraintBottom_toTopOf="@id/playback_song"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/playback_song"
style="@style/Widget.Auxio.TextView.Primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_medium"
app:layout_constraintBottom_toTopOf="@+id/playback_artist"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_chainStyle="packed"
tools:text="Song Name" />
<TextView
android:id="@+id/playback_artist"
style="@style/Widget.Auxio.TextView.Secondary.Marquee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_medium"
app:layout_constraintBottom_toTopOf="@+id/playback_album"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="Artist Name" />
<TextView
android:id="@+id/playback_album"
style="@style/Widget.Auxio.TextView.Secondary.Marquee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_medium"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="Album Name" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -1,56 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.oxycblt.auxio.image.CoverView
android:id="@+id/playback_cover"
style="@style/Widget.Auxio.Image.Full"
android:layout_margin="@dimen/spacing_medium"
app:enablePlaybackIndicator="false"
app:enableSelectionBadge="false"
app:layout_constraintBottom_toTopOf="@id/playback_song"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/playback_song"
style="@style/Widget.Auxio.TextView.Primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_medium"
app:layout_constraintBottom_toTopOf="@+id/playback_artist"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_chainStyle="packed"
tools:text="Song Name" />
<TextView
android:id="@+id/playback_artist"
style="@style/Widget.Auxio.TextView.Secondary.Marquee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_medium"
app:layout_constraintBottom_toTopOf="@+id/playback_album"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="Artist Name" />
<TextView
android:id="@+id/playback_album"
style="@style/Widget.Auxio.TextView.Secondary.Marquee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/spacing_medium"
android:layout_marginEnd="@dimen/spacing_medium"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
tools:text="Album Name" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.oxycblt.auxio.image.CoverView
android:id="@+id/playback_cover"
style="@style/Widget.Auxio.Image.Full"
android:layout_margin="@dimen/spacing_medium"
app:enablePlaybackIndicator="false"
app:enableSelectionBadge="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<!-- Playback information is wrapped in a container so that marquee doesn't break -->
<LinearLayout
android:id="@+id/playback_info_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/spacing_medium"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/playback_cover"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed">
<TextView
android:id="@+id/playback_song"
style="@style/Widget.Auxio.TextView.Primary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Song Name" />
<TextView
android:id="@+id/playback_artist"
style="@style/Widget.Auxio.TextView.Secondary.Marquee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Artist Name" />
<TextView
android:id="@+id/playback_album"
style="@style/Widget.Auxio.TextView.Secondary.Marquee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:text="Album Name" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>