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.os.Bundle;
23 import android.view.WindowManager;
25 import androidx.appcompat.app.ActionBar;
26 import androidx.appcompat.app.AppCompatActivity;
27 import androidx.appcompat.widget.Toolbar;
28 import androidx.fragment.app.Fragment;
29 import androidx.fragment.app.FragmentManager;
30 import androidx.fragment.app.FragmentPagerAdapter;
31 import androidx.viewpager.widget.ViewPager;
33 import com.google.android.material.tabs.TabLayout;
35 import com.stoutner.privacybrowser.fragments.AboutTabFragment;
36 import com.stoutner.privacybrowser.R;
38 public class AboutActivity extends AppCompatActivity {
40 protected void onCreate(Bundle savedInstanceState) {
41 // Disable screenshots if not allowed.
42 if (!MainWebViewActivity.allowScreenshots) {
43 getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
47 if (MainWebViewActivity.darkTheme) {
48 setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
50 setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
53 // Run the default commands.
54 super.onCreate(savedInstanceState);
56 // Set the content view.
57 setContentView(R.layout.about_coordinatorlayout);
59 // `SupportActionBar` from `android.support.v7.app.ActionBar` must be used until the minimum API is >= 21.
60 Toolbar toolbar = findViewById(R.id.about_toolbar);
61 setSupportActionBar(toolbar);
63 // Get a handle for the action bar.
64 final ActionBar actionBar = getSupportActionBar();
66 // Remove the incorrect lint warning that the action bar might be null.
67 assert actionBar != null; //
69 // Display the home arrow on action bar.
70 actionBar.setDisplayHomeAsUpEnabled(true);
72 // Setup the ViewPager.
73 ViewPager aboutViewPager = findViewById(R.id.about_viewpager);
74 aboutViewPager.setAdapter(new aboutPagerAdapter(getSupportFragmentManager()));
76 // Setup the TabLayout and connect it to the ViewPager.
77 TabLayout aboutTabLayout = findViewById(R.id.about_tablayout);
78 aboutTabLayout.setupWithViewPager(aboutViewPager);
81 private class aboutPagerAdapter extends FragmentPagerAdapter {
82 private aboutPagerAdapter(FragmentManager fragmentManager) {
83 // Run the default commands.
84 super(fragmentManager);
88 // Get the count of the number of tabs.
89 public int getCount() {
94 // Get the name of each tab. Tab numbers start at 0.
95 public CharSequence getPageTitle(int tab) {
98 return getString(R.string.version);
101 return getString(R.string.permissions);
104 return getString(R.string.privacy_policy);
107 return getString(R.string.changelog);
110 return getString(R.string.licenses);
113 return getString(R.string.contributors);
116 return getString(R.string.links);
125 public Fragment getItem(int tab) {
126 return AboutTabFragment.createTab(tab);