From 1bcf3cd52080df0a135ec86d8c1aa5c3e01bc664 Mon Sep 17 00:00:00 2001 From: Luna712 <142361265+Luna712@users.noreply.github.com> Date: Fri, 3 Apr 2026 11:46:16 -0600 Subject: [PATCH] Remove checking unsupported SDK versions --- .../cloudstream3/ui/account/AccountAdapter.kt | 21 ++++------ .../ui/download/DownloadFragment.kt | 7 +--- .../ui/library/ViewpagerAdapter.kt | 40 +++++++------------ .../ui/player/FullScreenPlayer.kt | 6 +-- .../cloudstream3/ui/player/GeneratorPlayer.kt | 5 +-- .../ui/player/RoundedBackgroundColorSpan.kt | 26 +++--------- .../settings/extensions/ExtensionsFragment.kt | 19 +++++---- .../cloudstream3/utils/AppContextUtils.kt | 26 ++++-------- .../cloudstream3/utils/PowerManagerAPI.kt | 11 ++--- .../res/drawable/circular_progress_bar.xml | 2 +- .../circular_progress_bar_clockwise.xml | 2 +- ...ircular_progress_bar_counter_clockwise.xml | 2 +- .../drawable/circular_progress_bar_filled.xml | 2 +- .../circular_progress_bar_small_to_large.xml | 2 +- .../circular_progress_bar_top_to_bottom.xml | 4 +- app/src/main/res/values/styles.xml | 2 +- 16 files changed, 62 insertions(+), 115 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/account/AccountAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/account/AccountAdapter.kt index 92d33d0f349..ddd59a38ad8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/account/AccountAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/account/AccountAdapter.kt @@ -1,6 +1,5 @@ package com.lagradost.cloudstream3.ui.account -import android.os.Build import android.view.LayoutInflater import android.view.ViewGroup import androidx.core.content.ContextCompat @@ -62,12 +61,10 @@ class AccountAdapter( root.requestFocus() } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - root.foreground = ContextCompat.getDrawable( - root.context, - R.drawable.outline_drawable - ) - } + root.foreground = ContextCompat.getDrawable( + root.context, + R.drawable.outline_drawable + ) } else { root.setOnLongClickListener { showAccountEditDialog( @@ -114,12 +111,10 @@ class AccountAdapter( root.requestFocus() } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - root.foreground = ContextCompat.getDrawable( - root.context, - R.drawable.outline_drawable - ) - } + root.foreground = ContextCompat.getDrawable( + root.context, + R.drawable.outline_drawable + ) } root.setOnClickListener { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt index be9f768a829..05ed03606b4 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt @@ -6,7 +6,6 @@ import android.content.ClipboardManager import android.content.Context import android.content.Intent import android.content.Intent.FLAG_GRANT_READ_URI_PERMISSION -import android.os.Build import android.text.format.Formatter.formatShortFileSize import android.view.View import android.widget.LinearLayout @@ -251,10 +250,8 @@ class DownloadFragment : BaseFragment( steamImageviewHolder.isVisible = isLayout(TV) } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - binding.downloadList.setOnScrollChangeListener { _, _, scrollY, _, oldScrollY -> - handleScroll(scrollY - oldScrollY) - } + binding.downloadList.setOnScrollChangeListener { _, _, scrollY, _, oldScrollY -> + handleScroll(scrollY - oldScrollY) } context?.let { downloadViewModel.updateHeaderList(it) } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/library/ViewpagerAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/library/ViewpagerAdapter.kt index 68b6eb2735a..f3ebb73dbd0 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/library/ViewpagerAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/library/ViewpagerAdapter.kt @@ -1,13 +1,11 @@ package com.lagradost.cloudstream3.ui.library -import android.os.Build import android.os.Bundle import android.os.Parcelable import android.view.LayoutInflater import android.view.ViewGroup import androidx.core.view.doOnAttach import androidx.fragment.app.Fragment -import androidx.recyclerview.widget.RecyclerView.OnFlingListener import com.google.android.material.appbar.AppBarLayout import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.databinding.LibraryViewpagerPageBinding @@ -94,31 +92,21 @@ class ViewpagerAdapter( // scrollToPosition(0) } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - setOnScrollChangeListener { _, _, scrollY, _, oldScrollY -> - val diff = scrollY - oldScrollY - - //Expand the top Appbar based on scroll direction up/down, simulate phone behavior - if (isLayout(TV or EMULATOR)) { - binding.root.rootView.findViewById(R.id.search_bar) - ?.apply { - if (diff <= 0) - setExpanded(true) - else - setExpanded(false) - } - } - if (diff == 0) return@setOnScrollChangeListener - - scrollCallback.invoke(diff > 0) - } - } else { - onFlingListener = object : OnFlingListener() { - override fun onFling(velocityX: Int, velocityY: Int): Boolean { - scrollCallback.invoke(velocityY > 0) - return false - } + setOnScrollChangeListener { _, _, scrollY, _, oldScrollY -> + val diff = scrollY - oldScrollY + // Expand the top Appbar based on scroll direction up/down, simulate phone behavior + if (isLayout(TV or EMULATOR)) { + binding.root.rootView.findViewById(R.id.search_bar) + ?.apply { + if (diff <= 0) + setExpanded(true) + else + setExpanded(false) + } } + + if (diff == 0) return@setOnScrollChangeListener + scrollCallback.invoke(diff > 0) } } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt index fad4a53e1bb..c1075bfa8f8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt @@ -2642,10 +2642,8 @@ open class FullScreenPlayer : AbstractPlayerFragment() { return@setOnTouchListener handleMotionEvent(callView, event) } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - playerControlsScroll.setOnScrollChangeListener { _, _, _, _, _ -> - autoHide() - } + playerControlsScroll.setOnScrollChangeListener { _, _, _, _, _ -> + autoHide() } exoProgress.setOnTouchListener { _, event -> diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt index ad7c8915f4b..5cf0145d25b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt @@ -263,9 +263,8 @@ class GeneratorPlayer : FullScreenPlayer() { ): PendingIntent { val intent: Intent = Intent(action).setPackage(context.packageName) intent.putExtra(EXTRA_INSTANCE_ID, instanceId) - val pendingFlags = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE - } else PendingIntent.FLAG_UPDATE_CURRENT + val pendingFlags = PendingIntent.FLAG_UPDATE_CURRENT or + PendingIntent.FLAG_IMMUTABLE return PendingIntent.getBroadcast(context, instanceId, intent, pendingFlags) } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/RoundedBackgroundColorSpan.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/RoundedBackgroundColorSpan.kt index 824b5d1a2f3..753666233ec 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/RoundedBackgroundColorSpan.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/RoundedBackgroundColorSpan.kt @@ -23,7 +23,6 @@ package com.lagradost.cloudstream3.ui.player import android.graphics.Canvas import android.graphics.Color import android.graphics.Paint -import android.os.Build import android.text.Layout.Alignment import android.text.StaticLayout import android.text.TextPaint @@ -60,25 +59,12 @@ class RoundedBackgroundColorSpan( } val width = p.measureText(text, start, end) - val textLayout: StaticLayout = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - StaticLayout.Builder - .obtain(text, 0, text.length, TextPaint(p), width.toInt()) - .setAlignment(alignment) - .setLineSpacing(0.0f, 1.0f) - .setIncludePad(true) - .build() - } else { - @Suppress("DEPRECATION") - StaticLayout( - text, - TextPaint(p), - width.toInt(), - alignment, - 1.0f, - 0.0f, - true - ) - } + val textLayout: StaticLayout = StaticLayout.Builder + .obtain(text, 0, text.length, TextPaint(p), width.toInt()) + .setAlignment(alignment) + .setLineSpacing(0.0f, 1.0f) + .setIncludePad(true) + .build() val center = (left + right).toFloat() * 0.5f diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt index bc85cc4782c..e7c6a97be7c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt @@ -3,7 +3,6 @@ package com.lagradost.cloudstream3.ui.settings.extensions import android.content.ClipboardManager import android.content.Context import android.content.DialogInterface -import android.os.Build import android.view.LayoutInflater import android.view.View import android.widget.LinearLayout @@ -85,7 +84,7 @@ class ExtensionsFragment : BaseFragment( nextLeft = R.id.nav_rail_view ) - if (!isLayout(TV)) + if (!isLayout(TV)) { binding.addRepoButton.let { button -> button.post { setPadding( @@ -96,17 +95,17 @@ class ExtensionsFragment : BaseFragment( ) } } + } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - setOnScrollChangeListener { _, _, scrollY, _, oldScrollY -> - val dy = scrollY - oldScrollY - if (dy > 0) { // check for scroll down - binding.addRepoButton.shrink() // hide - } else if (dy < -5) { - binding.addRepoButton.extend() // show - } + setOnScrollChangeListener { _, _, scrollY, _, oldScrollY -> + val dy = scrollY - oldScrollY + if (dy > 0) { // check for scroll down + binding.addRepoButton.shrink() // hide + } else if (dy < -5) { + binding.addRepoButton.extend() // show } } + adapter = RepoAdapter(false, { findNavController().navigate( R.id.navigation_settings_extensions_to_navigation_settings_plugins, diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/AppContextUtils.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/AppContextUtils.kt index 1377ccd08ad..ce93ec8773a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/AppContextUtils.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/AppContextUtils.kt @@ -639,15 +639,10 @@ object AppContextUtils { fun Context.isNetworkAvailable(): Boolean { val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - val network = connectivityManager.activeNetwork ?: return false - val networkCapabilities = - connectivityManager.getNetworkCapabilities(network) ?: return false - networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) - } else { - @Suppress("DEPRECATION") - connectivityManager.activeNetworkInfo?.isConnected == true - } + val network = connectivityManager.activeNetwork ?: return false + val networkCapabilities = + connectivityManager.getNetworkCapabilities(network) ?: return false + return networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) } fun splitQuery(url: URL): Map { @@ -864,15 +859,10 @@ object AppContextUtils { fun Context.isUsingMobileData(): Boolean { val connectionManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - val activeNetwork: Network? = connectionManager.activeNetwork - val networkCapabilities = connectionManager.getNetworkCapabilities(activeNetwork) - networkCapabilities?.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) == true && - !networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) - } else { - @Suppress("DEPRECATION") - connectionManager.activeNetworkInfo?.type == ConnectivityManager.TYPE_MOBILE - } + val activeNetwork: Network? = connectionManager.activeNetwork + val networkCapabilities = connectionManager.getNetworkCapabilities(activeNetwork) + return networkCapabilities?.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) == true && + !networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) } diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/PowerManagerAPI.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/PowerManagerAPI.kt index e3c7d68dffd..2e7bc6d26a8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/PowerManagerAPI.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/PowerManagerAPI.kt @@ -3,7 +3,6 @@ package com.lagradost.cloudstream3.utils import android.content.ActivityNotFoundException import android.content.Context import android.content.Intent -import android.os.Build.VERSION.SDK_INT import android.os.PowerManager import android.provider.Settings import android.util.Log @@ -22,13 +21,9 @@ private const val TAG = "PowerManagerAPI" object BatteryOptimizationChecker { - fun isAppRestricted(context: Context?): Boolean { - if (SDK_INT >= 23 && context != null) { - val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager - return !powerManager.isIgnoringBatteryOptimizations(context.packageName) - } - - return false // below Marshmallow, it's always unrestricted when app is in background + fun isAppRestricted(context: Context): Boolean { + val powerManager = context.getSystemService(Context.POWER_SERVICE) as PowerManager + return !powerManager.isIgnoringBatteryOptimizations(context.packageName) } fun openBatteryOptimizationSettings(context: Context) { diff --git a/app/src/main/res/drawable/circular_progress_bar.xml b/app/src/main/res/drawable/circular_progress_bar.xml index 7496129d647..17b79e7ab8d 100644 --- a/app/src/main/res/drawable/circular_progress_bar.xml +++ b/app/src/main/res/drawable/circular_progress_bar.xml @@ -6,7 +6,7 @@ android:innerRadiusRatio="2.5" android:shape="ring" android:thickness="2dp" - android:useLevel="true"> + android:useLevel="true"> + android:useLevel="true"> \ No newline at end of file diff --git a/app/src/main/res/drawable/circular_progress_bar_counter_clockwise.xml b/app/src/main/res/drawable/circular_progress_bar_counter_clockwise.xml index 477e8db1f2e..a08e4426c9a 100644 --- a/app/src/main/res/drawable/circular_progress_bar_counter_clockwise.xml +++ b/app/src/main/res/drawable/circular_progress_bar_counter_clockwise.xml @@ -8,7 +8,7 @@ android:shape="ring" android:innerRadius="0dp" android:thicknessRatio="2.65" - android:useLevel="true"> + android:useLevel="true"> \ No newline at end of file diff --git a/app/src/main/res/drawable/circular_progress_bar_filled.xml b/app/src/main/res/drawable/circular_progress_bar_filled.xml index 50fa60aa802..03b43c13458 100644 --- a/app/src/main/res/drawable/circular_progress_bar_filled.xml +++ b/app/src/main/res/drawable/circular_progress_bar_filled.xml @@ -7,7 +7,7 @@ android:innerRadiusRatio="100" android:shape="ring" android:thickness="11dp" - android:useLevel="true"> + android:useLevel="true"> + android:useLevel="false"> diff --git a/app/src/main/res/drawable/circular_progress_bar_top_to_bottom.xml b/app/src/main/res/drawable/circular_progress_bar_top_to_bottom.xml index f41eea84a27..e252f1ee185 100644 --- a/app/src/main/res/drawable/circular_progress_bar_top_to_bottom.xml +++ b/app/src/main/res/drawable/circular_progress_bar_top_to_bottom.xml @@ -10,7 +10,7 @@ android:shape="rectangle" android:innerRadius="0dp" android:thicknessRatio="2.5" - android:useLevel="false"> + android:useLevel="false"> @@ -27,7 +27,7 @@ android:shape="rectangle" android:innerRadius="0dp" android:thicknessRatio="2.5" - android:useLevel="false"> + android:useLevel="false"> diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index f386bb62eff..ad8e206705d 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -593,7 +593,7 @@ false ?attr/primaryBlackBackground ?attr/primaryBlackBackground - ?attr/isLightTheme + ?attr/isLightTheme