]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blob - app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.java
6ce5b431fa641b21d494a3b0238079bc9ad13235
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / AboutActivity.java
1 /*
2  * Copyright © 2016-2019 Soren Stoutner <soren@stoutner.com>.
3  *
4  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 package com.stoutner.privacybrowser.activities;
21
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;
27
28 import androidx.appcompat.app.ActionBar;
29 import androidx.appcompat.app.AppCompatActivity;
30 import androidx.appcompat.widget.Toolbar;
31 import androidx.viewpager.widget.ViewPager;
32
33 import com.google.android.material.tabs.TabLayout;
34
35 import com.stoutner.privacybrowser.adapters.AboutPagerAdapter;
36 import com.stoutner.privacybrowser.R;
37
38 public class AboutActivity extends AppCompatActivity {
39     @Override
40     protected void onCreate(Bundle savedInstanceState) {
41         // Get a handle for the shared preferences.
42         SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
43
44         // Get the theme and screenshot preferences.
45         boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
46         boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
47
48         // Disable screenshots if not allowed.
49         if (!allowScreenshots) {
50             getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
51         }
52
53         // Set the theme.
54         if (darkTheme) {
55             setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
56         } else {
57             setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
58         }
59
60         // Run the default commands.
61         super.onCreate(savedInstanceState);
62
63         // Get the intent that launched the activity.
64         Intent launchingIntent = getIntent();
65
66         // Store the blocklist versions.
67         String[] blocklistVersions = launchingIntent.getStringArrayExtra("blocklist_versions");
68
69         // Set the content view.
70         setContentView(R.layout.about_coordinatorlayout);
71
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);
76
77         // Set the action bar.  `SupportActionBar` must be used until the minimum API is >= 21.
78         setSupportActionBar(toolbar);
79
80         // Get a handle for the action bar.
81         final ActionBar actionBar = getSupportActionBar();
82
83         // Remove the incorrect lint warning that the action bar might be null.
84         assert actionBar != null;  //
85
86         // Display the home arrow on action bar.
87         actionBar.setDisplayHomeAsUpEnabled(true);
88
89         //  Setup the ViewPager.
90         aboutViewPager.setAdapter(new AboutPagerAdapter(getSupportFragmentManager(), getApplicationContext(), blocklistVersions));
91
92         // Connect the tab layout to the view pager.
93         aboutTabLayout.setupWithViewPager(aboutViewPager);
94     }
95 }