mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
chore: Tackle some compile warnings
This commit is contained in:
parent
bf368e88ed
commit
0e2e1d9ef6
16 changed files with 66 additions and 33 deletions
|
@ -6,7 +6,7 @@ import androidx.compose.foundation.layout.PaddingValues
|
|||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.statusBarsPadding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material3.LargeTopAppBar
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Scaffold
|
||||
|
@ -37,7 +37,7 @@ fun YokaiScaffold(
|
|||
title: String = "",
|
||||
scrollBehavior: TopAppBarScrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(state = rememberTopAppBarState()),
|
||||
fab: @Composable () -> Unit = {},
|
||||
navigationIcon: ImageVector = Icons.Filled.ArrowBack,
|
||||
navigationIcon: ImageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
navigationIconLabel: String = stringResource(id = R.string.back),
|
||||
actions: @Composable RowScope.() -> Unit = {},
|
||||
appBarType: AppBarType = AppBarType.LARGE,
|
||||
|
|
|
@ -3,18 +3,18 @@ package dev.yokai.presentation.extension.repo.component
|
|||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.IconButton
|
||||
import androidx.compose.material.TextField
|
||||
import androidx.compose.material.TextFieldDefaults
|
||||
import androidx.compose.material.TextFieldDefaults.indicatorLine
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.outlined.Label
|
||||
import androidx.compose.material.icons.filled.Add
|
||||
import androidx.compose.material.icons.filled.Check
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.outlined.Label
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextField
|
||||
import androidx.compose.material3.TextFieldDefaults
|
||||
import androidx.compose.material3.TextFieldDefaults.indicatorLine
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Alignment
|
||||
|
@ -45,7 +45,7 @@ fun ExtensionRepoItem(
|
|||
) {
|
||||
Icon(
|
||||
modifier = Modifier.padding(horizontal = 8.dp),
|
||||
imageVector = if (repoUrl != null) Icons.Outlined.Label else Icons.Filled.Add,
|
||||
imageVector = if (repoUrl != null) Icons.AutoMirrored.Outlined.Label else Icons.Filled.Add,
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onBackground,
|
||||
)
|
||||
|
@ -64,10 +64,14 @@ fun ExtensionRepoItem(
|
|||
)
|
||||
}
|
||||
} else {
|
||||
val colors = TextFieldDefaults.textFieldColors(
|
||||
val colors = TextFieldDefaults.colors().copy(
|
||||
cursorColor = MaterialTheme.colorScheme.secondary,
|
||||
placeholderColor = MaterialTheme.colorScheme.textHint,
|
||||
textColor = MaterialTheme.colorScheme.onBackground,
|
||||
focusedPlaceholderColor = MaterialTheme.colorScheme.textHint,
|
||||
unfocusedPlaceholderColor = MaterialTheme.colorScheme.textHint,
|
||||
errorPlaceholderColor = MaterialTheme.colorScheme.textHint,
|
||||
focusedTextColor = MaterialTheme.colorScheme.onBackground,
|
||||
unfocusedTextColor = MaterialTheme.colorScheme.onBackground,
|
||||
errorTextColor = MaterialTheme.colorScheme.onBackground,
|
||||
focusedIndicatorColor = Color.Transparent,
|
||||
unfocusedIndicatorColor = Color.Transparent,
|
||||
errorIndicatorColor = Color.Transparent,
|
||||
|
|
|
@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.source.model.Page
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -242,6 +243,7 @@ class DownloadManager(val context: Context) {
|
|||
* @param manga the manga of the chapters.
|
||||
* @param source the source of the chapters.
|
||||
*/
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
fun deleteChapters(chapters: List<Chapter>, manga: Manga, source: Source, force: Boolean = false) {
|
||||
val filteredChapters = if (force) chapters else getChaptersToDelete(chapters, manga)
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
|||
import eu.kanade.tachiyomi.util.chapter.updateTrackChapterMarkedAsRead
|
||||
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||
import eu.kanade.tachiyomi.util.storage.getUriCompat
|
||||
import eu.kanade.tachiyomi.util.system.getParcelableCompat
|
||||
import eu.kanade.tachiyomi.util.system.notificationManager
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
@ -75,7 +76,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||
ACTION_SHARE_BACKUP ->
|
||||
shareBackup(
|
||||
context,
|
||||
intent.getParcelableExtra(EXTRA_URI)!!,
|
||||
intent.getParcelableCompat(EXTRA_URI, Uri::class.java)!!,
|
||||
intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1),
|
||||
)
|
||||
ACTION_MARK_AS_READ -> {
|
||||
|
@ -96,7 +97,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||
ACTION_SHARE_CRASH_LOG ->
|
||||
shareFile(
|
||||
context,
|
||||
intent.getParcelableExtra(EXTRA_URI)!!,
|
||||
intent.getParcelableCompat(EXTRA_URI, Uri::class.java)!!,
|
||||
"text/plain",
|
||||
intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1),
|
||||
)
|
||||
|
|
|
@ -80,7 +80,7 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept
|
|||
authClient.newCall(GET(url.toString()))
|
||||
.awaitSuccess()
|
||||
.use {
|
||||
var responseBody = it.body?.string().orEmpty()
|
||||
var responseBody = it.body.string().orEmpty()
|
||||
if (responseBody.isEmpty()) {
|
||||
throw Exception("Null Response")
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ class BangumiApi(private val client: OkHttpClient, interceptor: BangumiIntercept
|
|||
|
||||
// TODO: get user readed chapter here
|
||||
var response = authClient.newCall(requestUserRead).awaitSuccess()
|
||||
var responseBody = response.body?.string().orEmpty()
|
||||
var responseBody = response.body.string().orEmpty()
|
||||
if (responseBody.isEmpty()) {
|
||||
throw Exception("Null Response")
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import androidx.core.content.edit
|
|||
import androidx.core.net.toUri
|
||||
import androidx.preference.PreferenceManager
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.system.getParcelableCompat
|
||||
import eu.kanade.tachiyomi.util.system.localeContext
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
|
||||
|
@ -17,7 +18,7 @@ class AppUpdateBroadcast : BroadcastReceiver() {
|
|||
val extras = intent.extras ?: return
|
||||
when (val status = extras.getInt(PackageInstaller.EXTRA_STATUS)) {
|
||||
PackageInstaller.STATUS_PENDING_USER_ACTION -> {
|
||||
val confirmIntent = extras[Intent.EXTRA_INTENT] as? Intent
|
||||
val confirmIntent = extras.getParcelableCompat(Intent.EXTRA_INTENT, Intent::class.java)
|
||||
context.startActivity(confirmIntent?.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK))
|
||||
}
|
||||
PackageInstaller.STATUS_SUCCESS -> {
|
||||
|
|
|
@ -19,6 +19,7 @@ import eu.kanade.tachiyomi.extension.util.ExtensionInstallBroadcast.Companion.EX
|
|||
import eu.kanade.tachiyomi.extension.util.ExtensionInstallBroadcast.Companion.PACKAGE_INSTALLED_ACTION
|
||||
import eu.kanade.tachiyomi.extension.util.ExtensionInstallBroadcast.Companion.packageInstallStep
|
||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||
import eu.kanade.tachiyomi.util.system.getParcelableCompat
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
|
@ -88,7 +89,7 @@ class ExtensionInstallBroadcast : BroadcastReceiver() {
|
|||
val extensionManager: ExtensionManager by injectLazy()
|
||||
when (val status = extras.getInt(PackageInstaller.EXTRA_STATUS)) {
|
||||
PackageInstaller.STATUS_PENDING_USER_ACTION -> {
|
||||
val confirmIntent = extras[Intent.EXTRA_INTENT] as? Intent
|
||||
val confirmIntent = extras.getParcelableCompat(Intent.EXTRA_INTENT, Intent::class.java)
|
||||
if (context is Activity) {
|
||||
context.startActivity(confirmIntent)
|
||||
} else {
|
||||
|
|
|
@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.extension.model.Extension
|
|||
import eu.kanade.tachiyomi.extension.model.LoadResult
|
||||
import eu.kanade.tachiyomi.util.system.launchNow
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.async
|
||||
|
@ -98,6 +99,7 @@ internal class ExtensionInstallReceiver(private val listener: Listener) :
|
|||
* @param context The application context.
|
||||
* @param intent The intent containing the package name of the extension.
|
||||
*/
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
private suspend fun getExtensionFromIntent(context: Context, intent: Intent?): LoadResult {
|
||||
val pkgName = getPackageNameFromIntent(intent)
|
||||
?: return LoadResult.Error
|
||||
|
|
|
@ -255,6 +255,7 @@ internal object ExtensionLoader {
|
|||
return selectExtensionPackage(sharedPkg, privatePkg)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
fun isExtensionInstalledByApp(context: Context, pkgName: String): Boolean {
|
||||
return try {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
|
|
|
@ -46,7 +46,7 @@ class MangaDex : DelegatedHttpSource() {
|
|||
GET("https:///api.mangadex.org/v2$url", delegate!!.headers, CacheControl.FORCE_NETWORK)
|
||||
val response = network.client.newCall(request).await()
|
||||
if (response.code != 200) throw Exception("HTTP error ${response.code}")
|
||||
val body = response.body?.string().orEmpty()
|
||||
val body = response.body.string().orEmpty()
|
||||
if (body.isEmpty()) {
|
||||
throw Exception("Null Response")
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
|
|||
PreferenceManager.OnDisplayPreferenceDialogListener,
|
||||
DialogPreference.TargetFragment {
|
||||
|
||||
private var lastOpenPreferencePosition: Int? = null
|
||||
private var lastOpenPreferencePosition: Int = 0
|
||||
|
||||
private var preferenceScreen: PreferenceScreen? = null
|
||||
|
||||
|
@ -141,13 +141,13 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
|
|||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
lastOpenPreferencePosition?.let { outState.putInt(LASTOPENPREFERENCE_KEY, it) }
|
||||
outState.putInt(LASTOPENPREFERENCE_KEY, lastOpenPreferencePosition)
|
||||
super.onSaveInstanceState(outState)
|
||||
}
|
||||
|
||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||
super.onRestoreInstanceState(savedInstanceState)
|
||||
lastOpenPreferencePosition = savedInstanceState.get(LASTOPENPREFERENCE_KEY) as? Int
|
||||
lastOpenPreferencePosition = savedInstanceState.getInt(LASTOPENPREFERENCE_KEY)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||
|
@ -349,10 +349,10 @@ class ExtensionDetailsController(bundle: Bundle? = null) :
|
|||
private fun Extension.getPreferenceKey(): String = "extension_$pkgName"
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T : Preference> findPreference(key: CharSequence): T? {
|
||||
override fun <T : Preference> findPreference(key: CharSequence): T {
|
||||
// We track [lastOpenPreferencePosition] when displaying the dialog
|
||||
// [key] isn't useful since there may be duplicates
|
||||
return preferenceScreen!!.getPreference(lastOpenPreferencePosition!!) as T
|
||||
return preferenceScreen!!.getPreference(lastOpenPreferencePosition) as T
|
||||
}
|
||||
|
||||
private companion object {
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.os.Build
|
|||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
import android.util.TypedValue
|
||||
import android.view.GestureDetector
|
||||
import android.view.Gravity
|
||||
import android.view.LayoutInflater
|
||||
import android.view.Menu
|
||||
|
@ -29,7 +30,6 @@ import androidx.appcompat.app.AppCompatActivity
|
|||
import androidx.appcompat.view.ActionMode
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.core.animation.doOnEnd
|
||||
import androidx.core.view.GestureDetectorCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsAnimationCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
|
@ -175,7 +175,7 @@ open class LibraryController(
|
|||
var singleCategory: Boolean = false
|
||||
private set
|
||||
var hopperAnimation: ValueAnimator? = null
|
||||
var catGestureDetector: GestureDetectorCompat? = null
|
||||
var catGestureDetector: GestureDetector? = null
|
||||
|
||||
/**
|
||||
* Library search query.
|
||||
|
@ -750,7 +750,7 @@ open class LibraryController(
|
|||
true
|
||||
}.show()
|
||||
}
|
||||
catGestureDetector = GestureDetectorCompat(binding.root.context, LibraryCategoryGestureDetector(this))
|
||||
catGestureDetector = GestureDetector(binding.root.context, LibraryCategoryGestureDetector(this))
|
||||
|
||||
binding.roundedCategoryHopper.categoryButton.setOnLongClickListener {
|
||||
when (preferences.hopperLongPressAction().get()) {
|
||||
|
@ -783,7 +783,7 @@ open class LibraryController(
|
|||
}
|
||||
hopperGravity = gravityPref
|
||||
|
||||
val gestureDetector = GestureDetectorCompat(binding.root.context, LibraryGestureDetector(this))
|
||||
val gestureDetector = GestureDetector(binding.root.context, LibraryGestureDetector(this))
|
||||
with(binding.roundedCategoryHopper) {
|
||||
listOf(categoryHopperLayout, upCategory, downCategory, categoryButton).forEach {
|
||||
it.setOnTouchListener { _, event ->
|
||||
|
|
|
@ -4,12 +4,12 @@ import android.annotation.SuppressLint
|
|||
import android.app.Activity
|
||||
import android.graphics.Color
|
||||
import android.util.TypedValue
|
||||
import android.view.GestureDetector
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.GestureDetectorCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.view.marginTop
|
||||
import androidx.core.view.updateLayoutParams
|
||||
|
@ -82,7 +82,7 @@ class LibraryHeaderHolder(val view: View, val adapter: LibraryCategoryAdapter) :
|
|||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private fun LibraryCategoryHeaderItemBinding.setTouchEvents() {
|
||||
val gestureDetector = GestureDetectorCompat(root.context, headerGestureDetector)
|
||||
val gestureDetector = GestureDetector(root.context, headerGestureDetector)
|
||||
listOf(categoryHeaderLayout, categorySort, categoryTitle, updateButton).forEach {
|
||||
var isCancelling = false
|
||||
it.setOnTouchListener { _, event ->
|
||||
|
|
|
@ -45,7 +45,6 @@ import androidx.core.graphics.ColorUtils
|
|||
import androidx.core.net.toUri
|
||||
import androidx.core.splashscreen.SplashScreen
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import androidx.core.view.GestureDetectorCompat
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
|
@ -162,7 +161,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||
|
||||
protected val searchDrawable by lazy { contextCompatDrawable(R.drawable.ic_search_24dp) }
|
||||
protected val backDrawable by lazy { contextCompatDrawable(R.drawable.ic_arrow_back_24dp) }
|
||||
private var gestureDetector: GestureDetectorCompat? = null
|
||||
private var gestureDetector: GestureDetector? = null
|
||||
|
||||
private var snackBar: Snackbar? = null
|
||||
private var extraViewForUndo: View? = null
|
||||
|
@ -366,7 +365,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||
finish()
|
||||
return
|
||||
}
|
||||
gestureDetector = GestureDetectorCompat(this, GestureListener())
|
||||
gestureDetector = GestureDetector(this, GestureListener())
|
||||
binding = MainActivityBinding.inflate(layoutInflater)
|
||||
|
||||
setContentView(binding.root)
|
||||
|
|
|
@ -5,6 +5,7 @@ import eu.davidea.flexibleadapter.FlexibleAdapter
|
|||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.util.system.getParcelableArrayListCompat
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
@ -36,8 +37,9 @@ class MigrationSourceAdapter(
|
|||
|
||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||
val sourceManager: SourceManager by injectLazy()
|
||||
savedInstanceState.getParcelableArrayList<MigrationSourceItem.ParcelableSI>(
|
||||
savedInstanceState.getParcelableArrayListCompat(
|
||||
SELECTED_SOURCES_KEY,
|
||||
MigrationSourceItem.ParcelableSI::class.java
|
||||
)?.let {
|
||||
updateDataSet(it.map { MigrationSourceItem.fromParcelable(sourceManager, it) })
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package eu.kanade.tachiyomi.util.system
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Parcelable
|
||||
|
||||
fun <T> Intent.getParcelableCompat(name: String, clazz: Class<T>) =
|
||||
extras?.getParcelableCompat(name, clazz)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
fun <T> Bundle.getParcelableCompat(name: String, clazz: Class<T>) =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) getParcelable(name, clazz) else getParcelable(name) as? T
|
||||
|
||||
fun <T : Parcelable?> Intent.getParcelableArrayListCompat(name: String, clazz: Class<T>) =
|
||||
extras?.getParcelableArrayListCompat(name, clazz)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
fun <T : Parcelable?> Bundle.getParcelableArrayListCompat(name: String, clazz: Class<T>) =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) getParcelableArrayList(name, clazz) else getParcelableArrayList<T>(name)
|
Loading…
Add table
Add a link
Reference in a new issue