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.SharedPreferences;
23 import android.os.Bundle;
24 import android.preference.PreferenceManager;
25 import android.view.WindowManager;
27 import androidx.appcompat.app.ActionBar;
28 import androidx.appcompat.app.AppCompatActivity;
29 import androidx.appcompat.widget.Toolbar;
30 import androidx.fragment.app.Fragment;
31 import androidx.fragment.app.FragmentManager;
32 import androidx.fragment.app.FragmentPagerAdapter;
33 import androidx.viewpager.widget.ViewPager;
35 import com.google.android.material.tabs.TabLayout;
37 import com.stoutner.privacybrowser.fragments.AboutTabFragment;
38 import com.stoutner.privacybrowser.R;
40 public class AboutActivity extends AppCompatActivity {
42 protected void onCreate(Bundle savedInstanceState) {
43 // Get a handle for the shared preferences.
44 SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
46 // Get the theme and screenshot preferences.
47 boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
48 boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
50 // Disable screenshots if not allowed.
51 if (!allowScreenshots) {
52 getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
57 setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
59 setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
62 // Run the default commands.
63 super.onCreate(savedInstanceState);
65 // Set the content view.
66 setContentView(R.layout.about_coordinatorlayout);
68 // Get handles for the views.
69 Toolbar toolbar = findViewById(R.id.about_toolbar);
70 TabLayout aboutTabLayout = findViewById(R.id.about_tablayout);
71 ViewPager aboutViewPager = findViewById(R.id.about_viewpager);
73 // Set the action bar. `SupportActionBar` must be used until the minimum API is >= 21.
74 setSupportActionBar(toolbar);
76 // Get a handle for the action bar.
77 final ActionBar actionBar = getSupportActionBar();
79 // Remove the incorrect lint warning that the action bar might be null.
80 assert actionBar != null; //
82 // Display the home arrow on action bar.
83 actionBar.setDisplayHomeAsUpEnabled(true);
85 // Setup the ViewPager.
86 aboutViewPager.setAdapter(new AboutPagerAdapter(getSupportFragmentManager()));
88 // Connect the tab layout to the view pager.
89 aboutTabLayout.setupWithViewPager(aboutViewPager);
92 private class AboutPagerAdapter extends FragmentPagerAdapter {
93 private AboutPagerAdapter(FragmentManager fragmentManager) {
94 // Run the default commands.
95 super(fragmentManager);
99 // Get the count of the number of tabs.
100 public int getCount() {
105 // Get the name of each tab. Tab numbers start at 0.
106 public CharSequence getPageTitle(int tab) {
109 return getString(R.string.version);
112 return getString(R.string.permissions);
115 return getString(R.string.privacy_policy);
118 return getString(R.string.changelog);
121 return getString(R.string.licenses);
124 return getString(R.string.contributors);
127 return getString(R.string.links);
136 public Fragment getItem(int tab) {
137 return AboutTabFragment.createTab(tab);