2020-10-20 17:07:27 +03:00
|
|
|
package com.illusionware.npsbrowser.fragments
|
|
|
|
|
|
|
|
|
|
import android.os.Bundle
|
2020-11-02 19:24:26 +02:00
|
|
|
import android.view.*
|
2020-10-20 17:07:27 +03:00
|
|
|
import androidx.fragment.app.Fragment
|
|
|
|
|
import androidx.fragment.app.FragmentTransaction.TRANSIT_FRAGMENT_OPEN
|
|
|
|
|
import androidx.preference.PreferenceFragmentCompat
|
|
|
|
|
import androidx.preference.PreferenceManager
|
|
|
|
|
import com.illusionware.npsbrowser.R
|
|
|
|
|
|
|
|
|
|
class SettingsFragment : Fragment() {
|
|
|
|
|
|
|
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
|
PreferenceManager.setDefaultValues(context, R.xml.root_preferences, false);
|
|
|
|
|
activity?.supportFragmentManager
|
|
|
|
|
?.beginTransaction()
|
|
|
|
|
?.replace(
|
|
|
|
|
R.id.prefs,
|
2020-11-02 19:24:26 +02:00
|
|
|
PrefsFragment()
|
2020-10-20 17:07:27 +03:00
|
|
|
)
|
|
|
|
|
?.setTransition(TRANSIT_FRAGMENT_OPEN)
|
|
|
|
|
?.commit()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onCreateView(
|
|
|
|
|
inflater: LayoutInflater,
|
|
|
|
|
container: ViewGroup?,
|
|
|
|
|
savedInstanceState: Bundle?
|
|
|
|
|
): View? {
|
|
|
|
|
activity?.title = resources.getString(R.string.title_activity_settings)
|
|
|
|
|
return inflater.inflate(R.layout.settings_fragment, container, false)
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-02 19:24:26 +02:00
|
|
|
class PrefsFragment : PreferenceFragmentCompat() {
|
2020-10-20 17:07:27 +03:00
|
|
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
|
|
|
|
setPreferencesFromResource(R.xml.root_preferences, rootKey)
|
|
|
|
|
PreferenceManager.setDefaultValues(context, R.xml.root_preferences, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|