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("region") region?.setOnPreferenceChangeListener { _, _ -> val restartDialog = RequireRestartDialog() restartDialog.show(childFragmentManager, "RequireRestartDialog") true } val language = findPreference("language") language?.setOnPreferenceChangeListener { _, _ -> val restartDialog = RequireRestartDialog() restartDialog.show(childFragmentManager, "RequireRestartDialog") true } val autoRotation = findPreference(PreferenceKeys.AUTO_ROTATION) autoRotation?.setOnPreferenceChangeListener { _, _ -> val restartDialog = RequireRestartDialog() restartDialog.show(childFragmentManager, "RequireRestartDialog") true } val hideTrending = findPreference(PreferenceKeys.HIDE_TRENDING_PAGE) hideTrending?.setOnPreferenceChangeListener { _, _ -> val restartDialog = RequireRestartDialog() restartDialog.show(childFragmentManager, "RequireRestartDialog") true } } }