diff --git a/app/build.gradle.kts b/app/build.gradle.kts index a1f4663934..90b5b48635 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -31,7 +31,7 @@ android { buildToolsVersion("29.0.2") defaultConfig { - minSdkVersion(21) + minSdkVersion(23) targetSdkVersion(29) applicationId = "eu.kanade.tachiyomi" versionCode = 60 diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt index 3411b4d06c..570121c46a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt @@ -114,9 +114,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor { } // HTTP error codes are only received since M - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && - url == origRequestUrl && !challengeFound - ) { + if (url == origRequestUrl && !challengeFound) { // The first request didn't return the challenge, abort. latch.countDown() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt index 79a6ce86a6..dec5c99bcc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ConductorExtensions.kt @@ -1,7 +1,6 @@ package eu.kanade.tachiyomi.ui.base.controller import android.content.pm.PackageManager.PERMISSION_GRANTED -import android.os.Build import androidx.core.content.ContextCompat import com.bluelinelabs.conductor.Controller import com.bluelinelabs.conductor.Router @@ -19,11 +18,9 @@ fun Router.popControllerWithTag(tag: String): Boolean { fun Controller.requestPermissionsSafe(permissions: Array, requestCode: Int) { val activity = activity ?: return - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - permissions.forEach { permission -> - if (ContextCompat.checkSelfPermission(activity, permission) != PERMISSION_GRANTED) { - requestPermissions(arrayOf(permission), requestCode) - } + permissions.forEach { permission -> + if (ContextCompat.checkSelfPermission(activity, permission) != PERMISSION_GRANTED) { + requestPermissions(arrayOf(permission), requestCode) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/DisplayBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/DisplayBottomSheet.kt index 60ef7399c6..d35346049c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/DisplayBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/DisplayBottomSheet.kt @@ -39,9 +39,7 @@ class DisplayBottomSheet(private val controller: LibraryController) : BottomShee sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup) setEdgeToEdge(activity, bottom_sheet, view, false) - val height = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - activity.window.decorView.rootWindowInsets.systemWindowInsetBottom - } else 0 + val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom sheetBehavior.peekHeight = 220.dpToPx + height sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderItem.kt index 2802da15f5..8104445f0d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHeaderItem.kt @@ -83,10 +83,6 @@ class LibraryHeaderItem(private val categoryF: (Int) -> Category, val catId: Int updateButton.setOnClickListener { addCategoryToUpdate() } sortText.setOnClickListener { it.post { showCatSortOptions() } } checkboxImage.setOnClickListener { selectAll() } - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - sortText.compoundDrawablesRelative[2]?.mutate()?.setTint( - ContextCompat.getColor(contentView.context, R.color.gray_button)) - } updateButton.drawable.mutate() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListController.kt index 12603eb000..84b0d4bae6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListController.kt @@ -390,13 +390,9 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle), if (headerPosition > -1) { val appbar = activity?.appbar recycler.suppressLayout(true) - val appbarOffset = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (appbar?.y ?: 0f > -20) 0 else (appbar?.y?.plus( + val appbarOffset = if (appbar?.y ?: 0f > -20) 0 else (appbar?.y?.plus( view?.rootWindowInsets?.systemWindowInsetTop ?: 0 ) ?: 0f).roundToInt() + 30.dpToPx - } else { - 0 - } (recycler.layoutManager as LinearLayoutManager).scrollToPositionWithOffset( headerPosition, (if (headerPosition == 0) 0 else (-28).dpToPx) + appbarOffset ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index bd3e6da3c5..ad59412727 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -223,7 +223,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener { // if device doesn't support light nav bar window.navigationBarColor = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { // basically if in landscape on a phone - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && (v.rootWindowInsets.systemWindowInsetLeft > 0 || v.rootWindowInsets.systemWindowInsetRight > 0)) + if (v.rootWindowInsets.systemWindowInsetLeft > 0 || v.rootWindowInsets.systemWindowInsetRight > 0)) // For lollipop, draw opaque nav bar Color.BLACK else Color.argb(179, 0, 0, 0) @@ -283,7 +283,7 @@ open class MainActivity : BaseActivity(), DownloadServiceListener { View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR ) } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && currentNightMode == Configuration.UI_MODE_NIGHT_NO) content.systemUiVisibility = + if (currentNightMode == Configuration.UI_MODE_NIGHT_NO) content.systemUiVisibility = content.systemUiVisibility.or( View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR ) @@ -364,13 +364,12 @@ open class MainActivity : BaseActivity(), DownloadServiceListener { } override fun startSupportActionMode(callback: androidx.appcompat.view.ActionMode.Callback): androidx.appcompat.view.ActionMode? { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) window?.statusBarColor = - getResourceColor(R.attr.colorPrimary) + window?.statusBarColor = getResourceColor(R.attr.colorPrimary) return super.startSupportActionMode(callback) } override fun onSupportActionModeFinished(mode: androidx.appcompat.view.ActionMode) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) launchUI { + launchUI { val scale = Settings.Global.getFloat( contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1.0f ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/ChaptersSortBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/ChaptersSortBottomSheet.kt index b6b5e243b3..fcf4a56b8c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/ChaptersSortBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/ChaptersSortBottomSheet.kt @@ -31,9 +31,7 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetD sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup) setEdgeToEdge(activity, bottom_sheet, view, false) - val height = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - activity.window.decorView.rootWindowInsets.systemWindowInsetBottom - } else 0 + val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom sheetBehavior.peekHeight = 380.dpToPx + height sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/TrackingBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/TrackingBottomSheet.kt index 7c18f56195..a12bc96f44 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/TrackingBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/TrackingBottomSheet.kt @@ -48,9 +48,7 @@ class TrackingBottomSheet(private val controller: MangaDetailsController) : Bott sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup) setEdgeToEdge(activity, display_bottom_sheet, view, false) - val height = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - activity.window.decorView.rootWindowInsets.systemWindowInsetBottom - } else 0 + val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom sheetBehavior.peekHeight = 380.dpToPx + height sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationBottomSheetDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationBottomSheetDialog.kt index ae0dd02cae..0c4b52a9ba 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationBottomSheetDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/migration/manga/design/MigrationBottomSheetDialog.kt @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.migration.manga.design import android.app.Activity import android.content.res.Configuration -import android.os.Build import android.os.Bundle import android.view.WindowManager import android.widget.CompoundButton @@ -78,9 +77,7 @@ class MigrationBottomSheetDialog( initPreferences() - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { window?.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS) - } fab.setOnClickListener { preferences.skipPreMigration().set(skip_step.isChecked) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt index 77129cacd2..7a76cb6cbb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt @@ -57,9 +57,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && preferences.readerTheme() .getOrDefault() == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetLeft == 0 ) window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR - val height = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - activity.window.decorView.rootWindowInsets.systemWindowInsetBottom - } else 0 + val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom sheetBehavior.peekHeight = 200.dpToPx + height sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadAdapter.kt index 76109a8a6e..1b3f35df02 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadAdapter.kt @@ -5,10 +5,10 @@ import eu.davidea.flexibleadapter.items.IFlexible import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.source.SourceManager +import uy.kohesive.injekt.injectLazy import java.text.DateFormat import java.text.DecimalFormat import java.text.DecimalFormatSymbols -import uy.kohesive.injekt.injectLazy /** * Adapter of RecentlyReadHolder. @@ -48,6 +48,6 @@ FlexibleAdapter>(null, controller, true) { } interface OnCoverClickListener { - fun onCoverClick(position: Int, lastTouchY: Float) + fun onCoverClick(position: Int) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadController.kt index ae77ecfa9b..6f9a1620fb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadController.kt @@ -181,7 +181,7 @@ class RecentlyReadController(bundle: Bundle? = null) : BaseController(bundle), RemoveHistoryDialog(this, manga, history).showDialog(router) } - override fun onCoverClick(position: Int, lastTouchY: Float) { + override fun onCoverClick(position: Int) { val manga = (adapter?.getItem(position) as? RecentlyReadItem)?.mch?.manga ?: return router.pushController(MangaDetailsController(manga).withFadeTransaction()) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadHolder.kt index d93b7bfeb3..7478d0c272 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recently_read/RecentlyReadHolder.kt @@ -1,6 +1,5 @@ package eu.kanade.tachiyomi.ui.recently_read -import android.os.Build import android.view.MotionEvent import android.view.View import com.bumptech.glide.load.engine.DiskCacheStrategy @@ -9,9 +8,9 @@ import eu.kanade.tachiyomi.data.database.models.MangaChapterHistory import eu.kanade.tachiyomi.data.glide.GlideApp import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder import eu.kanade.tachiyomi.util.lang.toTimestampString +import kotlinx.android.synthetic.main.recently_read_item.* import java.util.Date import kotlin.math.max -import kotlinx.android.synthetic.main.recently_read_item.* /** * Holder that contains recent manga item @@ -27,7 +26,6 @@ class RecentlyReadHolder( val adapter: RecentlyReadAdapter ) : BaseFlexibleViewHolder(view, adapter) { - private var lastTouchUpY = 0f init { remove.setOnClickListener { adapter.removeClickListener.onRemoveClick(adapterPosition) @@ -38,17 +36,7 @@ class RecentlyReadHolder( } cover.setOnClickListener { - adapter.coverClickListener.onCoverClick(adapterPosition, lastTouchUpY) - } - cover.setOnTouchListener { v, event -> - when (event?.action) { - MotionEvent.ACTION_UP -> { - val topH = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) - v.rootWindowInsets.systemWindowInsetTop else 38 - lastTouchUpY = max(topH + 175f, event.rawY - topH - 154f) - } - } - false + adapter.coverClickListener.onCoverClick(adapterPosition) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt index 904926e965..e2c7376c90 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/webview/WebViewActivity.kt @@ -121,8 +121,7 @@ class WebViewActivity : BaseActivity() { if (Build.VERSION.SDK_INT >= 26 && currentNightMode == Configuration.UI_MODE_NIGHT_NO) { content.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && currentNightMode == Configuration - .UI_MODE_NIGHT_NO && preferences.theme() >= 8) + if (currentNightMode == Configuration.UI_MODE_NIGHT_NO && preferences.theme() >= 8) content.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR insets } @@ -215,7 +214,7 @@ class WebViewActivity : BaseActivity() { web_linear_layout.systemUiVisibility = web_linear_layout.systemUiVisibility.or(View .SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR) } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && lightMode && preferences.theme() >= 8) + if (lightMode && preferences.theme() >= 8) web_linear_layout.systemUiVisibility = web_linear_layout.systemUiVisibility .or(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) invalidateOptionsMenu() diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt index 965178e407..1fc621d0e2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/view/ViewExtensions.kt @@ -35,11 +35,11 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.getResourceColor -import kotlin.math.abs -import kotlin.math.min import kotlinx.android.synthetic.main.main_activity.* import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get +import kotlin.math.abs +import kotlin.math.min /** * Returns coordinates of view. @@ -391,13 +391,13 @@ fun BottomSheetDialog.setEdgeToEdge( contentView: View, setTopMargin: Boolean ) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) window?.setBackgroundDrawable(null) + window?.setBackgroundDrawable(null) val currentNightMode = activity.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK if (currentNightMode == Configuration.UI_MODE_NIGHT_NO) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (activity.window.decorView.rootWindowInsets.systemWindowInsetRight == 0 && activity.window.decorView.rootWindowInsets.systemWindowInsetLeft == 0) window?.decorView?.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && layout is ConstraintLayout) { + } else if (layout is ConstraintLayout) { val nView = View(context) val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom val params = ConstraintLayout.LayoutParams( @@ -414,25 +414,19 @@ fun BottomSheetDialog.setEdgeToEdge( ) layout.addView(nView) } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - // window?.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS) - window?.findViewById(com.google.android.material.R.id.container)?.fitsSystemWindows = - false - contentView.updateLayoutParams { - if (setTopMargin) topMargin = - activity.window.decorView.rootWindowInsets.systemWindowInsetTop - leftMargin = activity.window.decorView.rootWindowInsets.systemWindowInsetLeft - rightMargin = activity.window.decorView.rootWindowInsets.systemWindowInsetRight - } + window?.findViewById(com.google.android.material.R.id.container)?.fitsSystemWindows = + false + contentView.updateLayoutParams { + if (setTopMargin) topMargin = + activity.window.decorView.rootWindowInsets.systemWindowInsetTop + leftMargin = activity.window.decorView.rootWindowInsets.systemWindowInsetLeft + rightMargin = activity.window.decorView.rootWindowInsets.systemWindowInsetRight } } fun setBottomEdge(view: View, activity: Activity) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - val marginB = view.marginBottom - view.updateLayoutParams { - bottomMargin = - marginB + activity.window.decorView.rootWindowInsets.systemWindowInsetBottom - } + val marginB = view.marginBottom + view.updateLayoutParams { + bottomMargin = marginB + activity.window.decorView.rootWindowInsets.systemWindowInsetBottom } }