diff --git a/app/src/debug/kotlin/org/koitharu/kotatsu/KotatsuApp.kt b/app/src/debug/kotlin/org/koitharu/kotatsu/KotatsuApp.kt index 5c5718522..b84593846 100644 --- a/app/src/debug/kotlin/org/koitharu/kotatsu/KotatsuApp.kt +++ b/app/src/debug/kotlin/org/koitharu/kotatsu/KotatsuApp.kt @@ -41,8 +41,8 @@ class KotatsuApp : BaseApp() { detectNetwork() detectDiskWrites() detectCustomSlowCalls() + detectResourceMismatches() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) detectUnbufferedIo() - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) detectResourceMismatches() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) detectExplicitGc() penaltyLog() if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && notifier != null) { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/os/NetworkState.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/os/NetworkState.kt index 8c70c8be0..6bef33c71 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/os/NetworkState.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/os/NetworkState.kt @@ -80,12 +80,7 @@ class NetworkState( if (settings.isOfflineCheckDisabled) { return true } - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - activeNetwork?.let { isOnline(it) } == true - } else { - @Suppress("DEPRECATION") - activeNetworkInfo?.isConnected == true - } + return activeNetwork?.let { isOnline(it) } == true } private fun ConnectivityManager.isOnline(network: Network): Boolean { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/OnContextClickListenerCompat.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/OnContextClickListenerCompat.kt deleted file mode 100644 index c53d0f71a..000000000 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/OnContextClickListenerCompat.kt +++ /dev/null @@ -1,8 +0,0 @@ -package org.koitharu.kotatsu.core.ui - -import android.view.View - -fun interface OnContextClickListenerCompat { - - fun onContextClick(v: View): Boolean -} diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/list/AdapterDelegateClickListenerAdapter.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/list/AdapterDelegateClickListenerAdapter.kt index 4239c14c4..aed17b6dd 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/list/AdapterDelegateClickListenerAdapter.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/list/AdapterDelegateClickListenerAdapter.kt @@ -2,17 +2,16 @@ package org.koitharu.kotatsu.core.ui.list import android.view.View import android.view.View.OnClickListener +import android.view.View.OnContextClickListener import android.view.View.OnLongClickListener import androidx.core.util.Function import com.hannesdorfmann.adapterdelegates4.dsl.AdapterDelegateViewBindingViewHolder -import org.koitharu.kotatsu.core.ui.OnContextClickListenerCompat -import org.koitharu.kotatsu.core.util.ext.setOnContextClickListenerCompat class AdapterDelegateClickListenerAdapter( private val adapterDelegate: AdapterDelegateViewBindingViewHolder, private val clickListener: OnListItemClickListener, private val itemMapper: Function, -) : OnClickListener, OnLongClickListener, OnContextClickListenerCompat { +) : OnClickListener, OnLongClickListener, OnContextClickListener { override fun onClick(v: View) { clickListener.onItemClick(mappedItem(), v) @@ -33,7 +32,7 @@ class AdapterDelegateClickListenerAdapter( fun attach(itemView: View) { itemView.setOnClickListener(this) itemView.setOnLongClickListener(this) - itemView.setOnContextClickListenerCompat(this) + itemView.setOnContextClickListener(this) } companion object { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/ActionModeDelegate.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/ActionModeDelegate.kt index 1412f7281..9979b93a1 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/ActionModeDelegate.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/ActionModeDelegate.kt @@ -1,7 +1,6 @@ package org.koitharu.kotatsu.core.ui.util import android.graphics.Color -import android.os.Build import android.view.ViewGroup import android.view.Window import androidx.activity.OnBackPressedCallback @@ -14,7 +13,6 @@ import androidx.core.view.WindowInsetsCompat import androidx.core.view.updateLayoutParams import androidx.lifecycle.DefaultLifecycleObserver import androidx.lifecycle.LifecycleOwner -import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.util.ext.getThemeColor import com.google.android.material.R as materialR @@ -37,14 +35,10 @@ class ActionModeDelegate : OnBackPressedCallback(false) { listeners?.forEach { it.onActionModeStarted(mode) } if (window != null) { val ctx = window.context - val actionModeColor = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - ColorUtils.compositeColors( - ContextCompat.getColor(ctx, materialR.color.m3_appbar_overlay_color), - ctx.getThemeColor(materialR.attr.colorSurface), - ) - } else { - ContextCompat.getColor(ctx, R.color.kotatsu_surface) - } + val actionModeColor = ColorUtils.compositeColors( + ContextCompat.getColor(ctx, materialR.color.m3_appbar_overlay_color), + ctx.getThemeColor(materialR.attr.colorSurface), + ) defaultStatusBarColor = window.statusBarColor window.statusBarColor = actionModeColor val insets = ViewCompat.getRootWindowInsets(window.decorView) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/PopupMenuMediator.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/PopupMenuMediator.kt index 22bbdac14..08a6735d9 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/PopupMenuMediator.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/ui/util/PopupMenuMediator.kt @@ -4,12 +4,10 @@ import android.view.MenuItem import android.view.View import androidx.appcompat.widget.PopupMenu import androidx.core.view.MenuProvider -import org.koitharu.kotatsu.core.ui.OnContextClickListenerCompat -import org.koitharu.kotatsu.core.util.ext.setOnContextClickListenerCompat class PopupMenuMediator( private val provider: MenuProvider, -) : View.OnLongClickListener, OnContextClickListenerCompat, PopupMenu.OnMenuItemClickListener, +) : View.OnLongClickListener, View.OnContextClickListener, PopupMenu.OnMenuItemClickListener, PopupMenu.OnDismissListener { override fun onContextClick(v: View): Boolean = onLongClick(v) @@ -37,6 +35,6 @@ class PopupMenuMediator( fun attach(view: View) { view.setOnLongClickListener(this) - view.setOnContextClickListenerCompat(this) + view.setOnContextClickListener(this) } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/View.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/View.kt index be4d63880..22455915c 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/View.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/View.kt @@ -28,7 +28,6 @@ import com.google.android.material.progressindicator.BaseProgressIndicator import com.google.android.material.slider.RangeSlider import com.google.android.material.slider.Slider import com.google.android.material.tabs.TabLayout -import org.koitharu.kotatsu.core.ui.OnContextClickListenerCompat import kotlin.math.roundToInt fun View.hasGlobalPoint(x: Int, y: Int): Boolean { @@ -169,12 +168,6 @@ fun BaseProgressIndicator<*>.showOrHide(value: Boolean) { } } -fun View.setOnContextClickListenerCompat(listener: OnContextClickListenerCompat) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - setOnContextClickListener(listener::onContextClick) - } -} - fun View.setTooltipCompat(tooltip: CharSequence?) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { tooltipText = tooltip diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt index de2f7b556..1ee1087d6 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt @@ -209,9 +209,7 @@ class DetailsActivity : override fun onProvideAssistContent(outContent: AssistContent) { super.onProvideAssistContent(outContent) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - viewModel.getMangaOrNull()?.publicUrl?.toUriOrNull()?.let { outContent.webUri = it } - } + viewModel.getMangaOrNull()?.publicUrl?.toUriOrNull()?.let { outContent.webUri = it } } override fun isNsfwContent(): Flow = viewModel.manga.map { it?.contentRating == ContentRating.ADULT } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/filter/ui/sheet/FilterSheetFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/filter/ui/sheet/FilterSheetFragment.kt index 921f7c593..420dc4060 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/filter/ui/sheet/FilterSheetFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/filter/ui/sheet/FilterSheetFragment.kt @@ -51,9 +51,7 @@ class FilterSheetFragment : BaseAdaptiveSheet(), super.onViewBindingCreated(binding, savedInstanceState) if (dialog == null) { binding.layoutBody.updatePadding(top = binding.layoutBody.paddingBottom) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - binding.scrollView.scrollIndicators = 0 - } + binding.scrollView.scrollIndicators = 0 } val filter = FilterCoordinator.require(this) filter.sortOrder.observe(viewLifecycleOwner, this::onSortOrderChanged) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/image/ui/CoverImageView.kt b/app/src/main/kotlin/org/koitharu/kotatsu/image/ui/CoverImageView.kt index 056bd40d9..0b6560e76 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/image/ui/CoverImageView.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/image/ui/CoverImageView.kt @@ -83,9 +83,7 @@ class CoverImageView @JvmOverloads constructor( if (fallbackDrawable == null) { fallbackDrawable = context.getThemeColor(materialR.attr.colorSurfaceContainer).toDrawable() } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - addImageRequestListener(ErrorForegroundListener()) - } + addImageRequestListener(ErrorForegroundListener()) } override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { @@ -169,7 +167,6 @@ class CoverImageView @JvmOverloads constructor( } } - @RequiresApi(Build.VERSION_CODES.M) private inner class ErrorForegroundListener : ImageRequest.Listener { override fun onSuccess(request: ImageRequest, result: SuccessResult) { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderActivity.kt index a536bab7e..acf48cf9a 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderActivity.kt @@ -215,9 +215,7 @@ class ReaderActivity : override fun onProvideAssistContent(outContent: AssistContent) { super.onProvideAssistContent(outContent) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - viewModel.getMangaOrNull()?.publicUrl?.toUriOrNull()?.let { outContent.webUri = it } - } + viewModel.getMangaOrNull()?.publicUrl?.toUriOrNull()?.let { outContent.webUri = it } } override fun isNsfwContent(): Flow = viewModel.isMangaNsfw diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/settings/protect/ProtectSetupActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/settings/protect/ProtectSetupActivity.kt index 1addb5ff3..407832e27 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/settings/protect/ProtectSetupActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/settings/protect/ProtectSetupActivity.kt @@ -1,7 +1,6 @@ package org.koitharu.kotatsu.settings.protect import android.content.pm.PackageManager -import android.os.Build import android.os.Bundle import android.text.Editable import android.view.KeyEvent @@ -115,7 +114,6 @@ class ProtectSetupActivity : } private fun isBiometricAvailable(): Boolean { - return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && - packageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT) + return packageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT) } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/settings/utils/DozeHelper.kt b/app/src/main/kotlin/org/koitharu/kotatsu/settings/utils/DozeHelper.kt index 35d0dc359..77b03e250 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/settings/utils/DozeHelper.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/settings/utils/DozeHelper.kt @@ -4,7 +4,6 @@ import android.annotation.SuppressLint import android.content.ActivityNotFoundException import android.content.Context import android.content.Intent -import android.os.Build import android.os.PowerManager import android.provider.Settings import androidx.activity.result.contract.ActivityResultContracts @@ -33,10 +32,6 @@ class DozeHelper( } fun startIgnoreDoseActivity(): Boolean { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - Snackbar.make(fragment.listView ?: return false, R.string.operation_not_supported, Snackbar.LENGTH_SHORT).show() - return false - } val context = fragment.context ?: return false val packageName = context.packageName val powerManager = context.powerManager ?: return false @@ -58,9 +53,6 @@ class DozeHelper( } private fun isDozeIgnoreAvailable(): Boolean { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - return false - } val context = fragment.context ?: return false val packageName = context.packageName val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager