Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -251,10 +250,8 @@ class DownloadFragment : BaseFragment<FragmentDownloadsBinding>(
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) }
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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<AppBarLayout>(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<AppBarLayout>(R.id.search_bar)
?.apply {
if (diff <= 0)
setExpanded(true)
else
setExpanded(false)
}
}

if (diff == 0) return@setOnScrollChangeListener
scrollCallback.invoke(diff > 0)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -85,7 +84,7 @@ class ExtensionsFragment : BaseFragment<FragmentExtensionsBinding>(
nextLeft = R.id.nav_rail_view
)

if (!isLayout(TV))
if (!isLayout(TV)) {
binding.addRepoButton.let { button ->
button.post {
setPadding(
Expand All @@ -96,17 +95,17 @@ class ExtensionsFragment : BaseFragment<FragmentExtensionsBinding>(
)
}
}
}

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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> {
Expand Down Expand Up @@ -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)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/circular_progress_bar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
android:innerRadiusRatio="2.5"
android:shape="ring"
android:thickness="2dp"
android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 -->
android:useLevel="true">

<gradient
android:angle="0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:shape="ring"
android:innerRadius="0dp"
android:thicknessRatio="2.65"
android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 -->
android:useLevel="true">
<solid android:color="?attr/download_fill_color" tools:color="#FFF" />
</shape>
</rotate>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:shape="ring"
android:innerRadius="0dp"
android:thicknessRatio="2.65"
android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 -->
android:useLevel="true">
<solid android:color="?attr/download_fill_color" tools:color="#FFF" />
</shape>
</rotate>
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/circular_progress_bar_filled.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:innerRadiusRatio="100"
android:shape="ring"
android:thickness="11dp"
android:useLevel="true"><!-- this line fixes the issue for lollipop api 21 -->
android:useLevel="true">

<gradient
android:angle="0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
android:shape="ring"
android:innerRadius="0dp"
android:thicknessRatio="2.5"
android:useLevel="false"><!-- this line fixes the issue for lollipop api 21 -->
android:useLevel="false">
<solid
android:color="?attr/download_fill_color"
tools:color="#FFF" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:shape="rectangle"
android:innerRadius="0dp"
android:thicknessRatio="2.5"
android:useLevel="false"><!-- this line fixes the issue for lollipop api 21 -->
android:useLevel="false">
<solid
android:color="?attr/download_fill_color"
tools:color="#FFF" />
Expand All @@ -27,7 +27,7 @@
android:shape="rectangle"
android:innerRadius="0dp"
android:thicknessRatio="2.5"
android:useLevel="false"><!-- this line fixes the issue for lollipop api 21 -->
android:useLevel="false">
<solid
android:color="?attr/download_fill_color"
tools:color="#FFF" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@
<item name="android:windowIsFloating">false</item>
<item name="android:navigationBarColor">?attr/primaryBlackBackground</item>
<item name="android:statusBarColor">?attr/primaryBlackBackground</item>
<item name="android:windowLightStatusBar" tools:targetApi="m">?attr/isLightTheme</item>
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
</style>

<style name="DialogHalfFullscreen" parent="AlertDialogCustom">
Expand Down