mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 23:00:31 +05:30
50 lines
1.9 KiB
Kotlin
50 lines
1.9 KiB
Kotlin
|
package com.github.libretube.preferences
|
||
|
|
||
|
import android.os.Bundle
|
||
|
import androidx.preference.ListPreference
|
||
|
import androidx.preference.Preference
|
||
|
import androidx.preference.PreferenceFragmentCompat
|
||
|
import androidx.preference.SwitchPreferenceCompat
|
||
|
import com.github.libretube.R
|
||
|
import com.github.libretube.activities.SettingsActivity
|
||
|
import com.github.libretube.dialogs.RequireRestartDialog
|
||
|
|
||
|
class GeneralSettings : PreferenceFragmentCompat() {
|
||
|
val TAG = "SettingsFragment"
|
||
|
|
||
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||
|
setPreferencesFromResource(R.xml.general_settings, rootKey)
|
||
|
|
||
|
val settingsActivity = activity as SettingsActivity
|
||
|
settingsActivity.changeTopBarText(getString(R.string.general))
|
||
|
|
||
|
val region = findPreference<Preference>("region")
|
||
|
region?.setOnPreferenceChangeListener { _, _ ->
|
||
|
val restartDialog = RequireRestartDialog()
|
||
|
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
||
|
true
|
||
|
}
|
||
|
|
||
|
val language = findPreference<ListPreference>("language")
|
||
|
language?.setOnPreferenceChangeListener { _, _ ->
|
||
|
val restartDialog = RequireRestartDialog()
|
||
|
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
||
|
true
|
||
|
}
|
||
|
|
||
|
val autoRotation = findPreference<SwitchPreferenceCompat>(PreferenceKeys.AUTO_ROTATION)
|
||
|
autoRotation?.setOnPreferenceChangeListener { _, _ ->
|
||
|
val restartDialog = RequireRestartDialog()
|
||
|
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
||
|
true
|
||
|
}
|
||
|
|
||
|
val hideTrending = findPreference<SwitchPreferenceCompat>(PreferenceKeys.HIDE_TRENDING_PAGE)
|
||
|
hideTrending?.setOnPreferenceChangeListener { _, _ ->
|
||
|
val restartDialog = RequireRestartDialog()
|
||
|
restartDialog.show(childFragmentManager, "RequireRestartDialog")
|
||
|
true
|
||
|
}
|
||
|
}
|
||
|
}
|