Updating to min sdk 23

This commit is contained in:
Jay 2020-03-15 23:09:40 -07:00
parent 4734cc1668
commit 1d5163163d
16 changed files with 35 additions and 79 deletions

View File

@ -31,7 +31,7 @@ android {
buildToolsVersion("29.0.2")
defaultConfig {
minSdkVersion(21)
minSdkVersion(23)
targetSdkVersion(29)
applicationId = "eu.kanade.tachiyomi"
versionCode = 60

View File

@ -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()
}

View File

@ -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,13 +18,11 @@ fun Router.popControllerWithTag(tag: String): Boolean {
fun Controller.requestPermissionsSafe(permissions: Array<String>, 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)
}
}
}
}
fun Controller.withFadeTransaction(): RouterTransaction {

View File

@ -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() {

View File

@ -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()
}

View File

@ -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
)

View File

@ -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
)

View File

@ -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() {

View File

@ -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() {

View File

@ -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)

View File

@ -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() {

View File

@ -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<IFlexible<*>>(null, controller, true) {
}
interface OnCoverClickListener {
fun onCoverClick(position: Int, lastTouchY: Float)
fun onCoverClick(position: Int)
}
}

View File

@ -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())
}

View File

@ -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)
}
}

View File

@ -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()

View File

@ -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,8 +414,6 @@ 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<View>(com.google.android.material.R.id.container)?.fitsSystemWindows =
false
contentView.updateLayoutParams<ViewGroup.MarginLayoutParams> {
@ -424,15 +422,11 @@ fun BottomSheetDialog.setEdgeToEdge(
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<ViewGroup.MarginLayoutParams> {
bottomMargin =
marginB + activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
}
bottomMargin = marginB + activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
}
}