From 443024cebb06c85e25a87945c95580c05a05913e Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 30 Mar 2021 23:15:17 -0400 Subject: [PATCH] Drop support for Android 5.x It's 5-6 years old, and only accounts for 2% of users in the Firebase analytics. --- .../network/CloudflareInterceptor.kt | 6 +--- .../ui/base/activity/BaseThemedActivity.kt | 4 --- .../ui/base/controller/ConductorExtensions.kt | 9 ++--- .../tachiyomi/ui/manga/MangaController.kt | 24 +++++-------- .../ui/manga/info/MangaInfoHeaderAdapter.kt | 15 -------- .../ui/setting/SettingsAdvancedController.kt | 35 +++++++++---------- .../util/system/WebViewClientCompat.kt | 2 -- .../tachiyomi/widget/ElevationAppBarLayout.kt | 8 +---- .../tachiyomi/widget/RevealAnimationView.kt | 5 +-- app/src/main/res/values-v23/themes.xml | 9 ----- app/src/main/res/values/themes.xml | 3 +- .../tachiyomi/data/backup/BackupTest.kt | 2 +- .../tachiyomi/data/database/CategoryTest.kt | 2 +- .../data/library/LibraryUpdateServiceTest.kt | 2 +- buildSrc/src/main/kotlin/AndroidConfig.kt | 2 +- 15 files changed, 37 insertions(+), 91 deletions(-) delete mode 100644 app/src/main/res/values-v23/themes.xml 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 49ddc16fb7..d26b3a0e22 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/CloudflareInterceptor.kt @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.network import android.annotation.SuppressLint import android.content.Context -import android.os.Build import android.os.Handler import android.os.Looper import android.webkit.WebSettings @@ -114,10 +113,7 @@ class CloudflareInterceptor(private val context: Context) : Interceptor { latch.countDown() } - // 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/activity/BaseThemedActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt index afd4d10285..40d3074cb4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/BaseThemedActivity.kt @@ -32,10 +32,6 @@ abstract class BaseThemedActivity : AppCompatActivity() { R.style.Theme_Tachiyomi_Light_Api27 } // Light status bar + fallback gray navigation bar - Build.VERSION.SDK_INT >= Build.VERSION_CODES.M -> { - R.style.Theme_Tachiyomi_Light_Api23 - } - // Fallback gray status + navigation bar else -> { R.style.Theme_Tachiyomi_Light } 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 ce9fbb586a..a91acb5ea0 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 @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.base.controller import android.content.Intent import android.content.pm.PackageManager.PERMISSION_GRANTED -import android.os.Build import androidx.core.content.ContextCompat import androidx.core.net.toUri import com.bluelinelabs.conductor.Controller @@ -21,11 +20,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/manga/MangaController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt index 597fcfb4e5..272bd4f292 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt @@ -290,23 +290,17 @@ class MangaController : fab.setOnClickListener { val item = presenter.getNextUnreadChapter() if (item != null) { - // Create animation listener - val revealAnimationListener: Animator.AnimatorListener = object : AnimatorListenerAdapter() { - override fun onAnimationStart(animation: Animator?) { - openChapter(item.chapter, true) - } - } - // Get coordinates and start animation actionFab?.getCoordinates()?.let { coordinates -> - if (!binding.revealView.showRevealEffect( - coordinates.x, - coordinates.y, - revealAnimationListener - ) - ) { - openChapter(item.chapter) - } + binding.revealView.showRevealEffect( + coordinates.x, + coordinates.y, + object : AnimatorListenerAdapter() { + override fun onAnimationStart(animation: Animator?) { + openChapter(item.chapter, true) + } + } + ) } } else { view?.context?.toast(R.string.no_next_chapter) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt index ee3e6ddb32..411d56d7c0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt @@ -1,7 +1,5 @@ package eu.kanade.tachiyomi.ui.manga.info -import android.graphics.PorterDuff -import android.os.Build import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -21,7 +19,6 @@ import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.util.system.copyToClipboard -import eu.kanade.tachiyomi.util.system.getResourceColor import eu.kanade.tachiyomi.util.view.setChips import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.merge @@ -304,18 +301,6 @@ class MangaInfoHeaderAdapter( initialLoad = false } } - - // backgroundTint attribute doesn't work properly on Android 5 - if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) { - listOf(binding.backdropOverlay, binding.mangaInfoToggleMoreScrim) - .forEach { - @Suppress("DEPRECATION") - it.background.setColorFilter( - view.context.getResourceColor(android.R.attr.colorBackground), - PorterDuff.Mode.SRC_ATOP - ) - } - } } private fun showMangaInfo(visible: Boolean) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt index 636e3faa60..6f35f9836a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsAdvancedController.kt @@ -4,7 +4,6 @@ import android.annotation.SuppressLint import android.app.Dialog import android.content.ActivityNotFoundException import android.content.Intent -import android.os.Build import android.os.Bundle import android.provider.Settings import androidx.core.net.toUri @@ -64,27 +63,25 @@ class SettingsAdvancedController : SettingsController() { } } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - preference { - key = "pref_disable_battery_optimization" - titleRes = R.string.pref_disable_battery_optimization - summaryRes = R.string.pref_disable_battery_optimization_summary + preference { + key = "pref_disable_battery_optimization" + titleRes = R.string.pref_disable_battery_optimization + summaryRes = R.string.pref_disable_battery_optimization_summary - onClick { - val packageName: String = context.packageName - if (!context.powerManager.isIgnoringBatteryOptimizations(packageName)) { - try { - val intent = Intent().apply { - action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS - data = "package:$packageName".toUri() - } - startActivity(intent) - } catch (e: ActivityNotFoundException) { - context.toast(R.string.battery_optimization_setting_activity_not_found) + onClick { + val packageName: String = context.packageName + if (!context.powerManager.isIgnoringBatteryOptimizations(packageName)) { + try { + val intent = Intent().apply { + action = Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS + data = "package:$packageName".toUri() } - } else { - context.toast(R.string.battery_optimization_disabled) + startActivity(intent) + } catch (e: ActivityNotFoundException) { + context.toast(R.string.battery_optimization_setting_activity_not_found) } + } else { + context.toast(R.string.battery_optimization_disabled) } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewClientCompat.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewClientCompat.kt index 8d2eea7cf0..5ccbb4f7e5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewClientCompat.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/WebViewClientCompat.kt @@ -54,7 +54,6 @@ abstract class WebViewClientCompat : WebViewClient() { return shouldInterceptRequestCompat(view, url) } - @TargetApi(Build.VERSION_CODES.M) final override fun onReceivedError( view: WebView, request: WebResourceRequest, @@ -78,7 +77,6 @@ abstract class WebViewClientCompat : WebViewClient() { onReceivedErrorCompat(view, errorCode, description, failingUrl, failingUrl == view.url) } - @TargetApi(Build.VERSION_CODES.M) final override fun onReceivedHttpError( view: WebView, request: WebResourceRequest, diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/ElevationAppBarLayout.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/ElevationAppBarLayout.kt index 66057589fb..ad0e52e03b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/ElevationAppBarLayout.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/ElevationAppBarLayout.kt @@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.widget import android.animation.ObjectAnimator import android.animation.StateListAnimator import android.content.Context -import android.os.Build import android.util.AttributeSet import com.google.android.material.R import com.google.android.material.appbar.AppBarLayout @@ -20,12 +19,7 @@ class ElevationAppBarLayout @JvmOverloads constructor( } fun enableElevation(liftOnScroll: Boolean) { - if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) { - // Delay to avoid crash - post { setElevation(liftOnScroll) } - } else { - setElevation(liftOnScroll) - } + setElevation(liftOnScroll) } private fun setElevation(liftOnScroll: Boolean) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/RevealAnimationView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/RevealAnimationView.kt index 8201d3b4ac..6bd1546f19 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/RevealAnimationView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/RevealAnimationView.kt @@ -49,10 +49,8 @@ class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: Att * @param centerX x starting point * @param centerY y starting point * @param listener animation listener - * - * @return sdk version lower then 21 */ - fun showRevealEffect(centerX: Int, centerY: Int, listener: Animator.AnimatorListener): Boolean { + fun showRevealEffect(centerX: Int, centerY: Int, listener: Animator.AnimatorListener) { this.isVisible = true val height = this.height @@ -71,6 +69,5 @@ class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: Att anim.addListener(listener) anim.start() - return true } } diff --git a/app/src/main/res/values-v23/themes.xml b/app/src/main/res/values-v23/themes.xml deleted file mode 100644 index bc8372bffa..0000000000 --- a/app/src/main/res/values-v23/themes.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index def145cf50..a90c3308c1 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -88,7 +88,8 @@