2 * Copyright © 2021 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Cell <https://www.stoutner.com/privacy-cell>.
6 * Privacy Cell is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * Privacy Cell is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Privacy Cell. If not, see <http://www.gnu.org/licenses/>.
20 package com.stoutner.privacycell.activities
22 import android.os.Bundle
23 import android.view.MenuItem
25 import androidx.appcompat.app.AppCompatActivity
26 import androidx.appcompat.widget.Toolbar
27 import androidx.preference.PreferenceManager
29 import com.stoutner.privacycell.R
30 import com.stoutner.privacycell.fragments.SettingsFragment
32 class SettingsActivity : AppCompatActivity() {
33 override fun onCreate(savedInstanceState: Bundle?) {
34 // Run the default commands.
35 super.onCreate(savedInstanceState)
37 // Get a handle for the shared preferences.
38 val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
40 // Get the bottom app bar preference.
41 val bottomAppBar = sharedPreferences.getBoolean(getString(R.string.bottom_app_bar_key), false)
43 // Set the content view.
45 setContentView(R.layout.settings_bottom_appbar)
47 setContentView(R.layout.settings_top_appbar)
50 // Get a handle for the toolbar.
51 val toolbar = findViewById<Toolbar>(R.id.toolbar)
53 // Set the support action bar.
54 setSupportActionBar(toolbar)
56 // Get a handle for the action bar.
57 val actionBar = supportActionBar!!
59 // Display the home arrow on the action bar.
60 actionBar.setDisplayHomeAsUpEnabled(true)
62 // Load the preferences fragment.
63 supportFragmentManager.beginTransaction().replace(R.id.preferences_framelayout, SettingsFragment()).commit()
66 override fun onOptionsItemSelected(item: MenuItem): Boolean {
67 // As there is only one option, go back.