2 * Copyright © 2016-2019 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
6 * Privacy Browser is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * Privacy Browser is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Privacy Browser. If not, see <http://www.gnu.org/licenses/>.
20 package com.stoutner.privacybrowser.activities;
22 import android.content.Intent;
23 import android.content.SharedPreferences;
24 import android.os.Bundle;
25 import android.preference.PreferenceManager;
26 import android.view.WindowManager;
28 import androidx.appcompat.app.ActionBar;
29 import androidx.appcompat.app.AppCompatActivity;
30 import androidx.appcompat.widget.Toolbar;
31 import androidx.viewpager.widget.ViewPager;
33 import com.google.android.material.tabs.TabLayout;
35 import com.stoutner.privacybrowser.adapters.AboutPagerAdapter;
36 import com.stoutner.privacybrowser.R;
38 public class AboutActivity extends AppCompatActivity {
40 protected void onCreate(Bundle savedInstanceState) {
41 // Get a handle for the shared preferences.
42 SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
44 // Get the theme and screenshot preferences.
45 boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
46 boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
48 // Disable screenshots if not allowed.
49 if (!allowScreenshots) {
50 getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
55 setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
57 setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
60 // Run the default commands.
61 super.onCreate(savedInstanceState);
63 // Get the intent that launched the activity.
64 Intent launchingIntent = getIntent();
66 // Store the blocklist versions.
67 String[] blocklistVersions = launchingIntent.getStringArrayExtra("blocklist_versions");
69 // Set the content view.
70 setContentView(R.layout.about_coordinatorlayout);
72 // Get handles for the views.
73 Toolbar toolbar = findViewById(R.id.about_toolbar);
74 TabLayout aboutTabLayout = findViewById(R.id.about_tablayout);
75 ViewPager aboutViewPager = findViewById(R.id.about_viewpager);
77 // Set the action bar. `SupportActionBar` must be used until the minimum API is >= 21.
78 setSupportActionBar(toolbar);
80 // Get a handle for the action bar.
81 final ActionBar actionBar = getSupportActionBar();
83 // Remove the incorrect lint warning that the action bar might be null.
84 assert actionBar != null; //
86 // Display the home arrow on action bar.
87 actionBar.setDisplayHomeAsUpEnabled(true);
89 // Setup the ViewPager.
90 aboutViewPager.setAdapter(new AboutPagerAdapter(getSupportFragmentManager(), getApplicationContext(), blocklistVersions));
92 // Connect the tab layout to the view pager.
93 aboutTabLayout.setupWithViewPager(aboutViewPager);