forked from recloudstream/cloudstream
* Issue #376: Added new feature for separate watch quality on mobile data.
This commit is contained in:
parent
f722785a37
commit
2926dc6c8e
6 changed files with 42 additions and 6 deletions
|
@ -35,6 +35,7 @@ import com.lagradost.cloudstream3.mvvm.logError
|
||||||
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
|
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
|
||||||
import com.lagradost.cloudstream3.ui.subtitles.SaveCaptionStyle
|
import com.lagradost.cloudstream3.ui.subtitles.SaveCaptionStyle
|
||||||
import com.lagradost.cloudstream3.utils.EpisodeSkip
|
import com.lagradost.cloudstream3.utils.EpisodeSkip
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.isUsingMobileData
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLinkPlayList
|
import com.lagradost.cloudstream3.utils.ExtractorLinkPlayList
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorUri
|
import com.lagradost.cloudstream3.utils.ExtractorUri
|
||||||
|
@ -849,7 +850,7 @@ class CS3IPlayer : IPlayer {
|
||||||
Log.i(TAG, "loadExo")
|
Log.i(TAG, "loadExo")
|
||||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
|
val settingsManager = PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
val maxVideoHeight = settingsManager.getInt(
|
val maxVideoHeight = settingsManager.getInt(
|
||||||
context.getString(com.lagradost.cloudstream3.R.string.quality_pref_key),
|
context.getString(if (context.isUsingMobileData()) com.lagradost.cloudstream3.R.string.quality_pref_mobile_data_key else com.lagradost.cloudstream3.R.string.quality_pref_key),
|
||||||
Int.MAX_VALUE
|
Int.MAX_VALUE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.cloudstream3.mvvm.logError
|
import com.lagradost.cloudstream3.mvvm.logError
|
||||||
import com.lagradost.cloudstream3.ui.player.GeneratorPlayer.Companion.subsProvidersIsActive
|
import com.lagradost.cloudstream3.ui.player.GeneratorPlayer.Companion.subsProvidersIsActive
|
||||||
import com.lagradost.cloudstream3.utils.Qualities
|
import com.lagradost.cloudstream3.utils.Qualities
|
||||||
|
import com.lagradost.cloudstream3.utils.AppUtils.isUsingMobileData
|
||||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog
|
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||||
|
@ -1246,9 +1247,8 @@ open class FullScreenPlayer : AbstractPlayerFragment() {
|
||||||
ctx.getString(R.string.double_tap_pause_enabled_key),
|
ctx.getString(R.string.double_tap_pause_enabled_key),
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
currentPrefQuality = settingsManager.getInt(
|
currentPrefQuality = settingsManager.getInt(
|
||||||
ctx.getString(R.string.quality_pref_key),
|
ctx.getString(if (ctx.isUsingMobileData()) R.string.quality_pref_mobile_data_key else R.string.quality_pref_key),
|
||||||
currentPrefQuality
|
currentPrefQuality
|
||||||
)
|
)
|
||||||
// useSystemBrightness =
|
// useSystemBrightness =
|
||||||
|
|
|
@ -113,6 +113,30 @@ class SettingsPlayer : PreferenceFragmentCompat() {
|
||||||
return@setOnPreferenceClickListener true
|
return@setOnPreferenceClickListener true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPref(R.string.quality_pref_mobile_data_key)?.setOnPreferenceClickListener {
|
||||||
|
val prefValues = Qualities.values().map { it.value }.reversed().toMutableList()
|
||||||
|
prefValues.remove(Qualities.Unknown.value)
|
||||||
|
|
||||||
|
val prefNames = prefValues.map { Qualities.getStringByInt(it) }
|
||||||
|
|
||||||
|
val currentQuality =
|
||||||
|
settingsManager.getInt(
|
||||||
|
getString(R.string.quality_pref_mobile_data_key),
|
||||||
|
Qualities.values().last().value
|
||||||
|
)
|
||||||
|
|
||||||
|
activity?.showBottomDialog(
|
||||||
|
prefNames.toList(),
|
||||||
|
prefValues.indexOf(currentQuality),
|
||||||
|
getString(R.string.watch_quality_pref_data),
|
||||||
|
true,
|
||||||
|
{}) {
|
||||||
|
settingsManager.edit().putInt(getString(R.string.quality_pref_mobile_data_key), prefValues[it])
|
||||||
|
.apply()
|
||||||
|
}
|
||||||
|
return@setOnPreferenceClickListener true
|
||||||
|
}
|
||||||
|
|
||||||
getPref(R.string.player_pref_key)?.setOnPreferenceClickListener {
|
getPref(R.string.player_pref_key)?.setOnPreferenceClickListener {
|
||||||
val prefNames = resources.getStringArray(R.array.player_pref_names)
|
val prefNames = resources.getStringArray(R.array.player_pref_names)
|
||||||
val prefValues = resources.getIntArray(R.array.player_pref_values)
|
val prefValues = resources.getIntArray(R.array.player_pref_values)
|
||||||
|
|
|
@ -776,8 +776,13 @@ object AppUtils {
|
||||||
return networkInfo.any {
|
return networkInfo.any {
|
||||||
conManager.getNetworkCapabilities(it)
|
conManager.getNetworkCapabilities(it)
|
||||||
?.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) == true
|
?.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) == true
|
||||||
|
} &&
|
||||||
|
!networkInfo.any {
|
||||||
|
conManager.getNetworkCapabilities(it)
|
||||||
|
?.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) == true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun Activity?.cacheClass(clazz: String?) {
|
private fun Activity?.cacheClass(clazz: String?) {
|
||||||
clazz?.let { c ->
|
clazz?.let { c ->
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
<string name="test_providers_key" translatable="false">test_providers_key</string>
|
<string name="test_providers_key" translatable="false">test_providers_key</string>
|
||||||
<string name="subtitle_settings_chromecast_key" translatable="false">subtitle_settings_chromecast_key</string>
|
<string name="subtitle_settings_chromecast_key" translatable="false">subtitle_settings_chromecast_key</string>
|
||||||
<string name="quality_pref_key" translatable="false">quality_pref_key</string>
|
<string name="quality_pref_key" translatable="false">quality_pref_key</string>
|
||||||
|
<string name="quality_pref_mobile_data_key" translatable="false">quality_pref_mobile_data_key</string>
|
||||||
<string name="player_pref_key" translatable="false">player_pref_key</string>
|
<string name="player_pref_key" translatable="false">player_pref_key</string>
|
||||||
<string name="prefer_limit_title_key" translatable="false">prefer_limit_title_key</string>
|
<string name="prefer_limit_title_key" translatable="false">prefer_limit_title_key</string>
|
||||||
<string name="prefer_limit_title_rez_key" translatable="false">prefer_limit_title_rez_key</string>
|
<string name="prefer_limit_title_rez_key" translatable="false">prefer_limit_title_rez_key</string>
|
||||||
|
@ -364,7 +365,8 @@
|
||||||
<string name="dont_show_again">Don\'t show again</string>
|
<string name="dont_show_again">Don\'t show again</string>
|
||||||
<string name="skip_update">Skip this Update</string>
|
<string name="skip_update">Skip this Update</string>
|
||||||
<string name="update">Update</string>
|
<string name="update">Update</string>
|
||||||
<string name="watch_quality_pref">Preferred watch quality</string>
|
<string name="watch_quality_pref">Preferred watch quality (WiFi)</string>
|
||||||
|
<string name="watch_quality_pref_data">Preferred watch quality (Mobile Data)</string>
|
||||||
<string name="limit_title">Video player title max chars</string>
|
<string name="limit_title">Video player title max chars</string>
|
||||||
<string name="limit_title_rez">Video player resolution</string>
|
<string name="limit_title_rez">Video player resolution</string>
|
||||||
<string name="video_buffer_size_settings">Video buffer size</string>
|
<string name="video_buffer_size_settings">Video buffer size</string>
|
||||||
|
@ -655,4 +657,4 @@
|
||||||
<string name="subscription_new">Subscribed to %s</string>
|
<string name="subscription_new">Subscribed to %s</string>
|
||||||
<string name="subscription_deleted">Unsubscribed from %s</string>
|
<string name="subscription_deleted">Unsubscribed from %s</string>
|
||||||
<string name="subscription_episode_released">Episode %d released!</string>
|
<string name="subscription_episode_released">Episode %d released!</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -15,6 +15,10 @@
|
||||||
android:icon="@drawable/ic_baseline_hd_24"
|
android:icon="@drawable/ic_baseline_hd_24"
|
||||||
android:key="@string/quality_pref_key"
|
android:key="@string/quality_pref_key"
|
||||||
android:title="@string/watch_quality_pref" />
|
android:title="@string/watch_quality_pref" />
|
||||||
|
<Preference
|
||||||
|
android:icon="@drawable/ic_baseline_hd_24"
|
||||||
|
android:key="@string/quality_pref_mobile_data_key"
|
||||||
|
android:title="@string/watch_quality_pref_data" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:icon="@drawable/netflix_play"
|
android:icon="@drawable/netflix_play"
|
||||||
|
|
Loading…
Reference in a new issue