all: fix lints

Fix lints that have accumulated over time.

Apparently Android Studio just...stopped using lints. For no reason. I
had to upgrade to the beta version to actually get lints.
This commit is contained in:
OxygenCobalt
2022-08-04 13:14:21 -06:00
parent f6429a878a
commit 4af45031b0
46 changed files with 82 additions and 124 deletions
@@ -284,7 +284,6 @@ class HomeFragment : ViewBindingFragment<FragmentHomeBinding>(), Toolbar.OnMenuI
logD("Received non-ok response $response")
when (response) {
is Indexer.Response.Ok -> error("Unreachable")
is Indexer.Response.Err -> {
binding.homeIndexingProgress.visibility = View.INVISIBLE
binding.homeIndexingStatus.textSafe = getString(R.string.err_index_failed)
@@ -315,6 +314,7 @@ class HomeFragment : ViewBindingFragment<FragmentHomeBinding>(), Toolbar.OnMenuI
}
}
}
else -> {}
}
}
}
@@ -168,7 +168,7 @@ constructor(context: Context, attrs: AttributeSet? = null, defStyleRes: Int = 0)
}
companion object {
// Cache sqrt(2) for faster calculations
private const val SQRT2 = 1.4142135623730950488f
// Pre-calculate sqrt(2) for faster drawing
private const val SQRT2 = 1.4142135f
}
}
@@ -160,20 +160,11 @@ abstract class BaseFetcher : Fetcher {
else -> continue
}
// Ensure the picture type here is a front cover image so that we don't extract
// an incorrect cover image.
// Yes, this does add some latency, but its quality covers so we can prioritize
// correctness over speed.
if (type == MediaMetadata.PICTURE_TYPE_FRONT_COVER) {
logD("Front cover successfully found")
// We have a front cover image. Great.
logD("Front cover found")
stream = ByteArrayInputStream(pic)
break
} else if (stream != null) {
// In the case a front cover is not found, use the first image in the tag instead.
// This can be corrected later on if a front cover frame is found.
logW("No front cover image, using image of type $type instead")
} else if (stream == null) {
stream = ByteArrayInputStream(pic)
}
}
@@ -73,7 +73,7 @@ data class Directory(val volume: StorageVolume, val relativePath: String) {
val volume =
when (split[0]) {
DOCUMENT_URI_PRIMARY_NAME -> storageManager.primaryStorageVolume
DOCUMENT_URI_PRIMARY_NAME -> storageManager.primaryStorageVolumeCompat
else -> storageManager.storageVolumesCompat.find { it.uuidCompat == split[0] }
}
@@ -84,10 +84,17 @@ data class Directory(val volume: StorageVolume, val relativePath: String) {
}
}
@Suppress("NewApi")
private val SM_API21_GET_VOLUME_LIST_METHOD: Method by
lazyReflectedMethod(StorageManager::class, "getVolumeList")
@Suppress("NewApi")
private val SV_API21_GET_PATH_METHOD: Method by lazyReflectedMethod(StorageVolume::class, "getPath")
/** The "primary" storage volume containing the OS. May be an SD Card. */
val StorageManager.primaryStorageVolumeCompat: StorageVolume
@Suppress("NewApi") get() = primaryStorageVolume
/**
* A list of recognized volumes, retrieved in a compatible manner. Note that these volumes may be
* mounted or unmounted.
@@ -158,6 +165,7 @@ val StorageVolume.mediaStoreVolumeNameCompat: String?
} else {
// Replicate API: primary_external if primary storage, lowercase uuid otherwise
if (isPrimaryCompat) {
@Suppress("NewApi") // Inlined constant
MediaStore.VOLUME_EXTERNAL_PRIMARY
} else {
uuidCompat?.lowercase()
@@ -17,9 +17,9 @@
package org.oxycblt.auxio.music.system
import android.app.NotificationManager
import android.content.Context
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import org.oxycblt.auxio.BuildConfig
import org.oxycblt.auxio.IntegerTable
import org.oxycblt.auxio.R
@@ -90,4 +90,4 @@ private val INDEXER_CHANNEL =
ServiceNotification.ChannelInfo(
id = BuildConfig.APPLICATION_ID + ".channel.INDEXER",
R.string.info_indexer_channel_name,
NotificationManager.IMPORTANCE_LOW)
NotificationManagerCompat.IMPORTANCE_LOW)
@@ -75,7 +75,7 @@ class IndexerService : Service(), Indexer.Controller, Settings.Callback {
wakeLock =
getSystemServiceSafe(PowerManager::class)
.newWakeLock(
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ".IndexerService")
PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":IndexerService")
settings = Settings(this, this)
indexerContentObserver = SystemContentObserver()
@@ -200,7 +200,9 @@ class IndexerService : Service(), Indexer.Controller, Settings.Callback {
private fun PowerManager.WakeLock.acquireSafe() {
if (!wakeLock.isHeld) {
logD("Acquiring wake lock")
acquire()
// We always drop the wakelock eventually. Timeout is not needed.
@Suppress("WakelockTimeout") acquire()
}
}
@@ -18,13 +18,13 @@
package org.oxycblt.auxio.playback.system
import android.annotation.SuppressLint
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import android.support.v4.media.MediaMetadataCompat
import android.support.v4.media.session.MediaSessionCompat
import androidx.annotation.DrawableRes
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.media.app.NotificationCompat.MediaStyle
import org.oxycblt.auxio.BuildConfig
import org.oxycblt.auxio.IntegerTable
@@ -154,6 +154,6 @@ class NotificationComponent(private val context: Context, sessionToken: MediaSes
ChannelInfo(
id = BuildConfig.APPLICATION_ID + ".channel.PLAYBACK",
nameRes = R.string.info_playback_channel_name,
importance = NotificationManager.IMPORTANCE_LOW)
importance = NotificationManagerCompat.IMPORTANCE_LOW)
}
}
@@ -358,8 +358,7 @@ data class Sort(val mode: Mode, val isAscending: Boolean) {
aSortName.compareTo(bSortName, ignoreCase = true)
aSortName == null && bSortName != null -> -1 // a < b
aSortName == null && bSortName == null -> 0 // a = b
aSortName != null && bSortName == null -> 1 // a < b
else -> error("Unreachable")
else -> 1 // a < b
}
}
@@ -377,8 +376,7 @@ data class Sort(val mode: Mode, val isAscending: Boolean) {
a != null && b != null -> a.compareTo(b)
a == null && b != null -> -1 // a < b
a == null && b == null -> 0 // a = b
a != null && b == null -> 1 // a < b
else -> error("Unreachable")
else -> 1 // a < b
}
companion object {
@@ -151,7 +151,7 @@ class ArtistViewHolder private constructor(private val binding: ItemParentBindin
override fun areItemsTheSame(oldItem: Artist, newItem: Artist) =
oldItem.rawName == newItem.rawName &&
oldItem.albums.size == newItem.albums.size &&
newItem.songs.size == newItem.songs.size
oldItem.songs.size == newItem.songs.size
}
}
}
@@ -102,6 +102,7 @@ private val Any.autoTag: String
*
* UNITED ARAB EMIRATES ENSLAVED MIGRANT WORKERS
*/
@Suppress("KotlinConstantConditions")
private fun basedCopyleftNotice() {
if (BuildConfig.APPLICATION_ID != "org.oxycblt.auxio" &&
BuildConfig.APPLICATION_ID != "org.oxycblt.auxio.debug") {