X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyCell.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Factivities%2FSettingsActivity.kt;fp=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Factivities%2FSettingsActivity.kt;h=279d836cfd82d7c3fa5fa92b18e24fc643225f5d;hp=0000000000000000000000000000000000000000;hb=031b4a8ea78fdbb776a1c5991f246b4f2a3e7ed1;hpb=1b722c3d327fa2d571abee745a115a1f54ab2a27 diff --git a/app/src/main/java/com/stoutner/privacycell/activities/SettingsActivity.kt b/app/src/main/java/com/stoutner/privacycell/activities/SettingsActivity.kt new file mode 100644 index 0000000..279d836 --- /dev/null +++ b/app/src/main/java/com/stoutner/privacycell/activities/SettingsActivity.kt @@ -0,0 +1,73 @@ +/* + * 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 + } +} \ No newline at end of file