2 * Copyright © 2016-2020 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 screenshot preference.
45 boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
47 // Disable screenshots if not allowed.
48 if (!allowScreenshots) {
49 getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
53 setTheme(R.style.PrivacyBrowser);
55 // Run the default commands.
56 super.onCreate(savedInstanceState);
58 // Get the intent that launched the activity.
59 Intent launchingIntent = getIntent();
61 // Store the blocklist versions.
62 String[] blocklistVersions = launchingIntent.getStringArrayExtra("blocklist_versions");
64 // Set the content view.
65 setContentView(R.layout.about_coordinatorlayout);
67 // Get handles for the views.
68 Toolbar toolbar = findViewById(R.id.about_toolbar);
69 TabLayout aboutTabLayout = findViewById(R.id.about_tablayout);
70 ViewPager aboutViewPager = findViewById(R.id.about_viewpager);
72 // Set the action bar. `SupportActionBar` must be used until the minimum API is >= 21.
73 setSupportActionBar(toolbar);
75 // Get a handle for the action bar.
76 final ActionBar actionBar = getSupportActionBar();
78 // Remove the incorrect lint warning that the action bar might be null.
79 assert actionBar != null; //
81 // Display the home arrow on action bar.
82 actionBar.setDisplayHomeAsUpEnabled(true);
84 // Setup the ViewPager.
85 aboutViewPager.setAdapter(new AboutPagerAdapter(getSupportFragmentManager(), getApplicationContext(), blocklistVersions));
87 // Connect the tab layout to the view pager.
88 aboutTabLayout.setupWithViewPager(aboutViewPager);