X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FSettingsActivity.java;h=7119b0f7958be10c507b322524388ae265ca3620;hp=cb4146da0c8ad243fa032bfe588f2f15f582e9ef;hb=ca7516a7edb9e06d0f9fe9186513986cd82be716;hpb=65eec25c0112c1c5ba2ae0b598ee291572e24a97 diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/SettingsActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/SettingsActivity.java index cb4146da..7119b0f7 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/SettingsActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/SettingsActivity.java @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2018 Soren Stoutner . + * Copyright © 2016-2019 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -19,23 +19,33 @@ package com.stoutner.privacybrowser.activities; +import android.content.SharedPreferences; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; +import android.preference.PreferenceManager; import android.view.WindowManager; +import androidx.appcompat.app.AppCompatActivity; + import com.stoutner.privacybrowser.R; import com.stoutner.privacybrowser.fragments.SettingsFragment; public class SettingsActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { + // Get a handle for the shared preferences. + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); + + // Get the screenshot and theme preferences. + boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false); + boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false); + // Disable screenshots if not allowed. - if (!MainWebViewActivity.allowScreenshots) { + if (!allowScreenshots) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); } // Set the activity theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { setTheme(R.style.PrivacyBrowserSettingsDark); } else { setTheme(R.style.PrivacyBrowserSettingsLight); @@ -45,6 +55,6 @@ public class SettingsActivity extends AppCompatActivity { super.onCreate(savedInstanceState); // Display the settings fragment. - getFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit(); + getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new SettingsFragment()).commit(); } -} +} \ No newline at end of file