diff app/src/main/java/com/bartsent/simpleresizer/SettingsActivity.kt @ 15:20da616dcda0

Add preferences.
author David Barts <n5jrn@me.com>
date Thu, 18 Feb 2021 22:12:19 -0800
parents
children 9231f1a41a59
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/src/main/java/com/bartsent/simpleresizer/SettingsActivity.kt	Thu Feb 18 22:12:19 2021 -0800
@@ -0,0 +1,28 @@
+package com.bartsent.simpleresizer
+
+import android.os.Bundle
+import androidx.appcompat.app.AppCompatActivity
+import androidx.preference.PreferenceFragmentCompat
+import androidx.preference.PreferenceManager
+
+class SettingsActivity : AppCompatActivity() {
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        setContentView(R.layout.settings_activity)
+        if (savedInstanceState == null) {
+            supportFragmentManager
+                    .beginTransaction()
+                    .replace(R.id.settings, SettingsFragment())
+                    .commit()
+        }
+        supportActionBar?.setDisplayHomeAsUpEnabled(true)
+        PreferenceManager.setDefaultValues(applicationContext, R.xml.root_preferences, false)
+    }
+
+    class SettingsFragment : PreferenceFragmentCompat() {
+        override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
+            setPreferencesFromResource(R.xml.root_preferences, rootKey)
+        }
+    }
+}
\ No newline at end of file