X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyCell.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacycell%2Factivities%2FSettingsActivity.kt;h=279d836cfd82d7c3fa5fa92b18e24fc643225f5d;hp=098f45f8c54d8940429dc739e85a1ccb563aa844;hb=HEAD;hpb=ff2f3992b7ecddb804a96322789bd35010529f43 diff --git a/app/src/main/java/com/stoutner/privacycell/activities/SettingsActivity.kt b/app/src/main/java/com/stoutner/privacycell/activities/SettingsActivity.kt index 098f45f..3ead325 100644 --- a/app/src/main/java/com/stoutner/privacycell/activities/SettingsActivity.kt +++ b/app/src/main/java/com/stoutner/privacycell/activities/SettingsActivity.kt @@ -1,20 +1,20 @@ -/* - * Copyright 2021-2022 Soren Stoutner . +/* SPDX-License-Identifier: GPL-3.0-or-later + * SPDX-FileCopyrightText: 2021-2022 Soren Stoutner * - * This file is part of Privacy Cell . + * 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. + * This program 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. + * This program 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 . + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . */ package com.stoutner.privacycell.activities @@ -24,7 +24,6 @@ import android.content.Intent import android.content.pm.PackageManager import android.os.Build import android.os.Bundle -import android.view.MenuItem import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar @@ -37,6 +36,9 @@ import com.stoutner.privacycell.fragments.SettingsFragment import com.stoutner.privacycell.services.RealtimeMonitoringService class SettingsActivity : AppCompatActivity(), NotificationPermissionDialogListener { + // Declare the class variables. + private lateinit var settingsFragment: SettingsFragment + override fun onCreate(savedInstanceState: Bundle?) { // Run the default commands. super.onCreate(savedInstanceState) @@ -66,8 +68,11 @@ class SettingsActivity : AppCompatActivity(), NotificationPermissionDialogListen // Display the home arrow on the action bar. actionBar.setDisplayHomeAsUpEnabled(true) - // Load the preferences fragment. - supportFragmentManager.beginTransaction().replace(R.id.preferences_framelayout, SettingsFragment()).commit() + // Instantiate the settings fragment. + settingsFragment = SettingsFragment() + + // Load the settings fragment. + supportFragmentManager.beginTransaction().replace(R.id.preferences_framelayout, settingsFragment).commitNow() } override fun onCloseNotificationPermissionDialog() { @@ -77,14 +82,6 @@ class SettingsActivity : AppCompatActivity(), NotificationPermissionDialogListen } } - override fun onOptionsItemSelected(item: MenuItem): Boolean { - // As there is only one option, go back. - onBackPressed() - - // Consume the event. - return true - } - override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) { // Run the default commands. super.onRequestPermissionsResult(requestCode, permissions, grantResults) @@ -96,6 +93,9 @@ class SettingsActivity : AppCompatActivity(), NotificationPermissionDialogListen if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { // The notification permission was granted. // Start the realtime monitoring service. startService(Intent(this, RealtimeMonitoringService::class.java)) + + // Update the realtime monitoring preference summary. + settingsFragment.updateRealtimeMonitoringSummary() } } }