X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FAboutActivity.java;h=e15bfe79a0bb77b38617dbc496ea3e639d3b6711;hb=f0393ca22075be3e5fe9199c7db87381256236fa;hp=8244774e30240a27b87a90865be1b6f278350915;hpb=e3ed631a52f5e8eac2d5c938b2d475ed6c9362bb;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.java index 8244774e..e15bfe79 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.java @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2017 Soren Stoutner . + * Copyright © 2016-2019 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -19,15 +19,20 @@ package com.stoutner.privacybrowser.activities; +import android.content.SharedPreferences; import android.os.Bundle; -import android.support.design.widget.TabLayout; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.view.ViewPager; -import android.support.v7.app.ActionBar; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.Toolbar; +import android.preference.PreferenceManager; +import android.view.WindowManager; + +import androidx.appcompat.app.ActionBar; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.Toolbar; +import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentPagerAdapter; +import androidx.viewpager.widget.ViewPager; + +import com.google.android.material.tabs.TabLayout; import com.stoutner.privacybrowser.fragments.AboutTabFragment; import com.stoutner.privacybrowser.R; @@ -35,8 +40,20 @@ import com.stoutner.privacybrowser.R; public class AboutActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { + // Get a handle for the shared preferences. + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); + + // Get the theme and screenshot preferences. + boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false); + boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false); + + // Disable screenshots if not allowed. + if (!allowScreenshots) { + getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE); + } + // Set the theme. - if (MainWebViewActivity.darkTheme) { + if (darkTheme) { setTheme(R.style.PrivacyBrowserDark_SecondaryActivity); } else { setTheme(R.style.PrivacyBrowserLight_SecondaryActivity); @@ -45,34 +62,37 @@ public class AboutActivity extends AppCompatActivity { // Run the default commands. super.onCreate(savedInstanceState); - // Set the content view according to the theme. - if (MainWebViewActivity.darkTheme) { - setContentView(R.layout.about_coordinatorlayout_dark); - } else { - setContentView(R.layout.about_coordinatorlayout_light); - } + // Set the content view. + setContentView(R.layout.about_coordinatorlayout); + + // Get handles for the views. + Toolbar toolbar = findViewById(R.id.about_toolbar); + TabLayout aboutTabLayout = findViewById(R.id.about_tablayout); + ViewPager aboutViewPager = findViewById(R.id.about_viewpager); + + // Set the action bar. `SupportActionBar` must be used until the minimum API is >= 21. + setSupportActionBar(toolbar); + + // Get a handle for the action bar. + final ActionBar actionBar = getSupportActionBar(); - // We need to use the SupportActionBar from android.support.v7.app.ActionBar until the minimum API is >= 21. - Toolbar aboutAppBar = (Toolbar) findViewById(R.id.about_toolbar); - setSupportActionBar(aboutAppBar); + // Remove the incorrect lint warning that the action bar might be null. + assert actionBar != null; // - // Display the home arrow on supportAppBar. - final ActionBar appBar = getSupportActionBar(); - assert appBar != null;// This assert removes the incorrect warning in Android Studio on the following line that appBar might be null. - appBar.setDisplayHomeAsUpEnabled(true); + // Display the home arrow on action bar. + actionBar.setDisplayHomeAsUpEnabled(true); // Setup the ViewPager. - ViewPager aboutViewPager = (ViewPager) findViewById(R.id.about_viewpager); - aboutViewPager.setAdapter(new aboutPagerAdapter(getSupportFragmentManager())); + aboutViewPager.setAdapter(new AboutPagerAdapter(getSupportFragmentManager())); - // Setup the TabLayout and connect it to the ViewPager. - TabLayout aboutTabLayout = (TabLayout) findViewById(R.id.about_tablayout); + // Connect the tab layout to the view pager. aboutTabLayout.setupWithViewPager(aboutViewPager); } - private class aboutPagerAdapter extends FragmentPagerAdapter { - private aboutPagerAdapter(FragmentManager fm) { - super(fm); + private class AboutPagerAdapter extends FragmentPagerAdapter { + private AboutPagerAdapter(FragmentManager fragmentManager) { + // Run the default commands. + super(fragmentManager); } @Override