]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.java
Move Clear and Exit to the top of the navigation menu. https://redmine.stoutner...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / AboutActivity.java
index 8244774e30240a27b87a90865be1b6f278350915..3508b7521f3de43efec13ac42c3ca111abaabaa8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2016-2017 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2019 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
  *
 package com.stoutner.privacybrowser.activities;
 
 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.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,6 +38,11 @@ import com.stoutner.privacybrowser.R;
 public class AboutActivity extends AppCompatActivity {
     @Override
     protected void onCreate(Bundle savedInstanceState) {
+        // Disable screenshots if not allowed.
+        if (!MainWebViewActivity.allowScreenshots) {
+            getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
+        }
+
         // Set the theme.
         if (MainWebViewActivity.darkTheme) {
             setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
@@ -45,34 +53,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