Skip to content
Merged
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
4 changes: 2 additions & 2 deletions app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
// backup when we update the app, I don't trust myself to not boot lock users, might want to make this a setting?
safe {
val appVer = BuildConfig.VERSION_NAME
val lastAppAutoBackup: String = getKey("VERSION_NAME") ?: ""
val lastAppAutoBackup: String = getKey<String>("VERSION_NAME") ?: ""
if (appVer != lastAppAutoBackup) {
setKey("VERSION_NAME", BuildConfig.VERSION_NAME)
if (lastAppAutoBackup.isEmpty()) return@safe
Expand Down Expand Up @@ -2018,7 +2018,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
}

try {
if (getKey(HAS_DONE_SETUP_KEY, false) != true) {
if (getKey<Boolean>(HAS_DONE_SETUP_KEY, false) != true) {
navController.navigate(R.id.navigation_setup_language)
// If no plugins bring up extensions screen
} else if (PluginManager.getPluginsOnline().isEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ open class VlcPackage: OpenInAppAction(
intent.putExtra("secure_uri", true)
intent.putExtra("title", video.name)

val subsLang = getKey(SUBTITLE_AUTO_SELECT_KEY) ?: "en"
val subsLang = getKey<String>(SUBTITLE_AUTO_SELECT_KEY) ?: "en"
result.subs.firstOrNull {
subsLang == it.languageCode
}?.let {
Expand All @@ -74,4 +74,4 @@ open class VlcPackage: OpenInAppAction(
Log.d("VLC", "Position: $position, Duration: $duration")
updateDurationAndPosition(position, duration)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,11 @@ object PluginManager {


fun getPluginsOnline(): Array<PluginData> {
return getKey(PLUGINS_KEY) ?: emptyArray()
return getKey<Array<PluginData>>(PLUGINS_KEY) ?: emptyArray()
}

fun getPluginsLocal(): Array<PluginData> {
return getKey(PLUGINS_KEY_LOCAL) ?: emptyArray()
return getKey<Array<PluginData>>(PLUGINS_KEY_LOCAL) ?: emptyArray()
}

private val CLOUD_STREAM_FOLDER =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ data class PluginWrapper(
object RepositoryManager {
const val ONLINE_PLUGINS_FOLDER = "Extensions"
val PREBUILT_REPOSITORIES: Array<RepositoryData> by lazy {
getKey("PREBUILT_REPOSITORIES") ?: emptyArray()
getKey<Array<RepositoryData>>("PREBUILT_REPOSITORIES") ?: emptyArray()
}
private val GH_REGEX =
Regex("^https://raw.githubusercontent.com/([A-Za-z0-9-]+)/([A-Za-z0-9_.-]+)/(.*)$")
Expand Down Expand Up @@ -240,7 +240,7 @@ object RepositoryManager {
}

fun getRepositories(): Array<RepositoryData> {
return getKey(REPOSITORIES_KEY) ?: emptyArray()
return getKey<Array<RepositoryData>>(REPOSITORIES_KEY) ?: emptyArray()
}

// Don't want to read before we write in another thread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ class CS3IPlayer : IPlayer {
**/
var preferredAudioTrackLanguage: String? = null
get() {
return field ?: getKey(
return field ?: getKey<String>(
"$currentAccount/$PREFERRED_AUDIO_LANGUAGE_KEY",
field
)?.also {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ object QualityDataHelper {

fun getSourcePriority(profile: Int, name: String?): Int {
if (name == null) return DEFAULT_SOURCE_PRIORITY
return getKey(
return getKey<Int>(
"$currentAccount/$VIDEO_SOURCE_PRIORITY/$profile",
name,
DEFAULT_SOURCE_PRIORITY
Expand Down Expand Up @@ -94,7 +94,7 @@ object QualityDataHelper {
}

fun getQualityPriority(profile: Int, quality: Qualities): Int {
return getKey(
return getKey<Int>(
"$currentAccount/$VIDEO_QUALITY_PRIORITY/$profile",
quality.value.toString(),
quality.defaultPriority
Expand Down Expand Up @@ -223,4 +223,4 @@ object QualityDataHelper {
if (target == null) return Qualities.Unknown
return Qualities.entries.minBy { abs(it.value - target) }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ class SettingsGeneral : BasePreferenceFragmentCompat() {
} ?: emptyList()
}

settingsManager.edit { putBoolean(getString(R.string.jsdelivr_proxy_key), getKey(getString(R.string.jsdelivr_proxy_key), false) ?: false) }
settingsManager.edit { putBoolean(getString(R.string.jsdelivr_proxy_key), getKey<Boolean>(getString(R.string.jsdelivr_proxy_key), false) ?: false) }
getPref(R.string.jsdelivr_proxy_key)?.setOnPreferenceChangeListener { _, newValue ->
setKey(getString(R.string.jsdelivr_proxy_key), newValue)
return@setOnPreferenceChangeListener true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class ChromecastSubtitlesFragment : BaseFragment<ChromecastSubtitleSettingsBindi
}

fun getCurrentSavedStyle(): SaveChromeCaptionStyle {
return getKey(CHROME_SUBTITLE_KEY) ?: defaultState
return getKey<SaveChromeCaptionStyle>(CHROME_SUBTITLE_KEY) ?: defaultState
}

private val defaultState = SaveChromeCaptionStyle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
}

fun getCurrentSavedStyle(): SaveCaptionStyle {
return cachedSubtitleStyle ?: (getKey(SUBTITLE_KEY) ?: SaveCaptionStyle(
return cachedSubtitleStyle ?: (getKey<SaveCaptionStyle>(SUBTITLE_KEY) ?: SaveCaptionStyle(
foregroundColor = getDefColor(0),
backgroundColor = getDefColor(2),
windowColor = getDefColor(3),
Expand Down Expand Up @@ -293,11 +293,11 @@ class SubtitlesFragment : BaseDialogFragment<SubtitleSettingsBinding>(
}

fun getDownloadSubsLanguageTagIETF(): List<String> {
return getKey(SUBTITLE_DOWNLOAD_KEY) ?: listOf("en")
return getKey<List<String>>(SUBTITLE_DOWNLOAD_KEY) ?: listOf("en")
}

fun getAutoSelectLanguageTagIETF(): String {
return getKey(SUBTITLE_AUTO_SELECT_KEY) ?: "en"
return getKey<String>(SUBTITLE_AUTO_SELECT_KEY) ?: "en"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ object DataStoreHelper {
* Setting this does not automatically reload the homepage.
*/
var currentHomePage: String?
get() = getKey("$currentAccount/$USER_SELECTED_HOMEPAGE_API")
get() = getKey<String>("$currentAccount/$USER_SELECTED_HOMEPAGE_API")
set(value) {
val key = "$currentAccount/$USER_SELECTED_HOMEPAGE_API"
if (value == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ const val PROGRAM_ID_LIST_KEY = "persistent_program_ids"

object TvChannelUtils {
fun Context.saveProgramId(programId: Long) {
val existing: List<Long> = getKey(PROGRAM_ID_LIST_KEY) ?: emptyList()
val existing: List<Long> = getKey<List<Long>>(PROGRAM_ID_LIST_KEY) ?: emptyList()
val updated = (existing + programId).distinct()
setKey(PROGRAM_ID_LIST_KEY, updated)
}
fun Context.getStoredProgramIds(): List<Long> {
return getKey(PROGRAM_ID_LIST_KEY) ?: emptyList()
return getKey<List<Long>>(PROGRAM_ID_LIST_KEY) ?: emptyList()
}
fun Context.removeProgramId(programId: Long) {
val existing: List<Long> = getKey(PROGRAM_ID_LIST_KEY) ?: emptyList()
val existing: List<Long> = getKey<List<Long>>(PROGRAM_ID_LIST_KEY) ?: emptyList()
val updated = existing.filter { it != programId }
setKey(PROGRAM_ID_LIST_KEY, updated)
}
Expand Down Expand Up @@ -161,4 +161,4 @@ object TvChannelUtils {
}
}

}
}
Loading