forked from hardcoresushi/DroidFS
Fix MainSettingsFragment crash
This commit is contained in:
parent
985be2de59
commit
4608a7a165
@ -6,10 +6,7 @@ import android.os.Bundle
|
|||||||
import android.text.InputType
|
import android.text.InputType
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.preference.ListPreference
|
import androidx.preference.*
|
||||||
import androidx.preference.Preference
|
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
|
||||||
import androidx.preference.SwitchPreference
|
|
||||||
import sushi.hardcore.droidfs.databinding.ActivitySettingsBinding
|
import sushi.hardcore.droidfs.databinding.ActivitySettingsBinding
|
||||||
import sushi.hardcore.droidfs.util.PathUtils
|
import sushi.hardcore.droidfs.util.PathUtils
|
||||||
import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder
|
import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder
|
||||||
@ -26,7 +23,7 @@ class SettingsActivity : BaseActivity() {
|
|||||||
val fragment = if (screen == "UnsafeFeaturesSettingsFragment") {
|
val fragment = if (screen == "UnsafeFeaturesSettingsFragment") {
|
||||||
UnsafeFeaturesSettingsFragment()
|
UnsafeFeaturesSettingsFragment()
|
||||||
} else {
|
} else {
|
||||||
MainSettingsFragment(sharedPrefs)
|
MainSettingsFragment()
|
||||||
}
|
}
|
||||||
supportFragmentManager
|
supportFragmentManager
|
||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
@ -44,7 +41,8 @@ class SettingsActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MainSettingsFragment(private val sharedPrefs: SharedPreferences) : PreferenceFragmentCompat() {
|
class MainSettingsFragment : PreferenceFragmentCompat() {
|
||||||
|
private lateinit var sharedPrefs: SharedPreferences
|
||||||
private lateinit var maxSizePreference: Preference
|
private lateinit var maxSizePreference: Preference
|
||||||
|
|
||||||
private fun setThumbnailMaxSize(input: String) {
|
private fun setThumbnailMaxSize(input: String) {
|
||||||
@ -83,6 +81,7 @@ class SettingsActivity : BaseActivity() {
|
|||||||
|
|
||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.root_preferences, rootKey)
|
setPreferencesFromResource(R.xml.root_preferences, rootKey)
|
||||||
|
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||||
findPreference<ListPreference>("theme")?.setOnPreferenceChangeListener { _, newValue ->
|
findPreference<ListPreference>("theme")?.setOnPreferenceChangeListener { _, newValue ->
|
||||||
(activity as BaseActivity).onThemeChanged(newValue as String)
|
(activity as BaseActivity).onThemeChanged(newValue as String)
|
||||||
true
|
true
|
||||||
|
Loading…
Reference in New Issue
Block a user