Merge pull request #1125 from Bnyro/master

fixes
This commit is contained in:
Bnyro 2022-08-23 09:17:02 +02:00 committed by GitHub
commit 94703c2053
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 20 additions and 20 deletions

View File

@ -39,8 +39,8 @@ class AdvancedSettings : MaterialPreferenceFragment() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.advanced_settings, rootKey) setPreferencesFromResource(R.xml.advanced_settings, rootKey)
val settingsActivity = activity as SettingsActivity val settingsActivity = activity as? SettingsActivity
settingsActivity.changeTopBarText(getString(R.string.advanced)) settingsActivity?.changeTopBarText(getString(R.string.advanced))
val maxImageCache = findPreference<ListPreference>(PreferenceKeys.MAX_IMAGE_CACHE) val maxImageCache = findPreference<ListPreference>(PreferenceKeys.MAX_IMAGE_CACHE)
maxImageCache?.setOnPreferenceChangeListener { _, _ -> maxImageCache?.setOnPreferenceChangeListener { _, _ ->

View File

@ -19,8 +19,8 @@ class AppearanceSettings : MaterialPreferenceFragment() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.appearance_settings, rootKey) setPreferencesFromResource(R.xml.appearance_settings, rootKey)
val settingsActivity = activity as SettingsActivity val settingsActivity = activity as? SettingsActivity
settingsActivity.changeTopBarText(getString(R.string.appearance)) settingsActivity?.changeTopBarText(getString(R.string.appearance))
val themeToggle = findPreference<ListPreference>(PreferenceKeys.THEME_MODE) val themeToggle = findPreference<ListPreference>(PreferenceKeys.THEME_MODE)
themeToggle?.setOnPreferenceChangeListener { _, _ -> themeToggle?.setOnPreferenceChangeListener { _, _ ->

View File

@ -13,8 +13,8 @@ class GeneralSettings : MaterialPreferenceFragment() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.general_settings, rootKey) setPreferencesFromResource(R.xml.general_settings, rootKey)
val settingsActivity = activity as SettingsActivity val settingsActivity = activity as? SettingsActivity
settingsActivity.changeTopBarText(getString(R.string.general)) settingsActivity?.changeTopBarText(getString(R.string.general))
val language = findPreference<ListPreference>("language") val language = findPreference<ListPreference>("language")
language?.setOnPreferenceChangeListener { _, _ -> language?.setOnPreferenceChangeListener { _, _ ->

View File

@ -13,8 +13,8 @@ class HistorySettings : MaterialPreferenceFragment() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.history_settings, rootKey) setPreferencesFromResource(R.xml.history_settings, rootKey)
val settingsActivity = activity as SettingsActivity val settingsActivity = activity as? SettingsActivity
settingsActivity.changeTopBarText(getString(R.string.history)) settingsActivity?.changeTopBarText(getString(R.string.history))
// clear search history // clear search history
val clearHistory = findPreference<Preference>(PreferenceKeys.CLEAR_SEARCH_HISTORY) val clearHistory = findPreference<Preference>(PreferenceKeys.CLEAR_SEARCH_HISTORY)

View File

@ -51,8 +51,8 @@ class InstanceSettings : MaterialPreferenceFragment() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.instance_settings, rootKey) setPreferencesFromResource(R.xml.instance_settings, rootKey)
val settingsActivity = activity as SettingsActivity val settingsActivity = activity as? SettingsActivity
settingsActivity.changeTopBarText(getString(R.string.instance)) settingsActivity?.changeTopBarText(getString(R.string.instance))
val instance = findPreference<ListPreference>(PreferenceKeys.FETCH_INSTANCE) val instance = findPreference<ListPreference>(PreferenceKeys.FETCH_INSTANCE)
// fetchInstance() // fetchInstance()

View File

@ -87,14 +87,14 @@ class MainSettings : MaterialPreferenceFragment() {
update?.setOnPreferenceClickListener { update?.setOnPreferenceClickListener {
CoroutineScope(Dispatchers.IO).launch { CoroutineScope(Dispatchers.IO).launch {
if (!NetworkHelper.isNetworkAvailable(requireContext())) { if (!NetworkHelper.isNetworkAvailable(requireContext())) {
(activity as SettingsActivity).binding.root.getStyledSnackBar(R.string.unknown_error).show() (activity as? SettingsActivity)?.binding?.root?.getStyledSnackBar(R.string.unknown_error)?.show()
return@launch return@launch
} }
// check for update // check for update
val updateInfo = UpdateChecker.getLatestReleaseInfo() val updateInfo = UpdateChecker.getLatestReleaseInfo()
if (updateInfo?.name == null) { if (updateInfo?.name == null) {
// request failed // request failed
(activity as SettingsActivity).binding.root.getStyledSnackBar(R.string.unknown_error).show() (activity as? SettingsActivity)?.binding?.root?.getStyledSnackBar(R.string.unknown_error)?.show()
} else if (BuildConfig.VERSION_NAME != updateInfo.name) { } else if (BuildConfig.VERSION_NAME != updateInfo.name) {
// show the UpdateAvailableDialog if there's an update available // show the UpdateAvailableDialog if there's an update available
val updateAvailableDialog = UpdateDialog(updateInfo) val updateAvailableDialog = UpdateDialog(updateInfo)
@ -104,7 +104,7 @@ class MainSettings : MaterialPreferenceFragment() {
) )
} else { } else {
// otherwise show the no update available snackBar // otherwise show the no update available snackBar
(activity as SettingsActivity).binding.root.getStyledSnackBar(R.string.app_uptodate).show() (activity as? SettingsActivity)?.binding?.root?.getStyledSnackBar(R.string.app_uptodate)?.show()
} }
} }
true true

View File

@ -14,8 +14,8 @@ class NotificationSettings : MaterialPreferenceFragment() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.notification_settings, rootKey) setPreferencesFromResource(R.xml.notification_settings, rootKey)
val settingsActivity = activity as SettingsActivity val settingsActivity = activity as? SettingsActivity
settingsActivity.changeTopBarText(getString(R.string.notifications)) settingsActivity?.changeTopBarText(getString(R.string.notifications))
val notificationsEnabled = val notificationsEnabled =
findPreference<SwitchPreferenceCompat>(PreferenceKeys.NOTIFICATION_ENABLED) findPreference<SwitchPreferenceCompat>(PreferenceKeys.NOTIFICATION_ENABLED)

View File

@ -14,8 +14,8 @@ class PlayerSettings : MaterialPreferenceFragment() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.player_settings, rootKey) setPreferencesFromResource(R.xml.player_settings, rootKey)
val settingsActivity = activity as SettingsActivity val settingsActivity = activity as? SettingsActivity
settingsActivity.changeTopBarText(getString(R.string.audio_video)) settingsActivity?.changeTopBarText(getString(R.string.audio_video))
val playerOrientation = val playerOrientation =
findPreference<ListPreference>(PreferenceKeys.FULLSCREEN_ORIENTATION) findPreference<ListPreference>(PreferenceKeys.FULLSCREEN_ORIENTATION)

View File

@ -10,7 +10,7 @@ class SponsorBlockSettings : MaterialPreferenceFragment() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.sponsorblock_settings, rootKey) setPreferencesFromResource(R.xml.sponsorblock_settings, rootKey)
val settingsActivity = activity as SettingsActivity val settingsActivity = activity as? SettingsActivity
settingsActivity.changeTopBarText(getString(R.string.sponsorblock)) settingsActivity?.changeTopBarText(getString(R.string.sponsorblock))
} }
} }

View File

@ -125,7 +125,7 @@ class BackgroundMode : Service() {
val position = intent.getLongExtra("position", 0L) val position = intent.getLongExtra("position", 0L)
// initialize the playlist autoPlay Helper // initialize the playlist autoPlay Helper
if (playlistId != null) autoPlayHelper = AutoPlayHelper(playlistId!!) autoPlayHelper = AutoPlayHelper(playlistId)
// play the audio in the background // play the audio in the background
playAudio(videoId, position) playAudio(videoId, position)