/* * Copyright © 2021 Soren Stoutner . * * This file is part of Privacy Cell . * * Privacy Cell is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Privacy Cell is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Privacy Cell. If not, see . */ package com.stoutner.privacycell.activities import android.os.Bundle import android.view.MenuItem import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import androidx.preference.PreferenceManager import com.stoutner.privacycell.R import com.stoutner.privacycell.fragments.SettingsFragment class SettingsActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { // Run the default commands. super.onCreate(savedInstanceState) // Get a handle for the shared preferences. val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this) // Get the bottom app bar preference. val bottomAppBar = sharedPreferences.getBoolean(getString(R.string.bottom_app_bar_key), false) // Set the content view. if (bottomAppBar) { setContentView(R.layout.settings_bottom_appbar) } else { setContentView(R.layout.settings_top_appbar) } // Get a handle for the toolbar. val toolbar = findViewById(R.id.toolbar) // Set the support action bar. setSupportActionBar(toolbar) // Get a handle for the action bar. val actionBar = supportActionBar!! // Display the home arrow on the action bar. actionBar.setDisplayHomeAsUpEnabled(true) // Load the preferences fragment. supportFragmentManager.beginTransaction().replace(R.id.preferences_framelayout, SettingsFragment()).commit() } override fun onOptionsItemSelected(item: MenuItem): Boolean { // As there is only one option, go back. onBackPressed() // Consume the event. return true } }