]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blob - app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.java
Display memory usage information in About > Version. https://redmine.stoutner.com...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / AboutActivity.java
1 /*
2  * Copyright © 2016-2020 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 screenshot preference.
45         boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
46
47         // Disable screenshots if not allowed.
48         if (!allowScreenshots) {
49             getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
50         }
51
52         // Set the theme.
53         setTheme(R.style.PrivacyBrowser);
54
55         // Run the default commands.
56         super.onCreate(savedInstanceState);
57
58         // Get the intent that launched the activity.
59         Intent launchingIntent = getIntent();
60
61         // Store the blocklist versions.
62         String[] blocklistVersions = launchingIntent.getStringArrayExtra("blocklist_versions");
63
64         // Set the content view.
65         setContentView(R.layout.about_coordinatorlayout);
66
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);
71
72         // Set the action bar.  `SupportActionBar` must be used until the minimum API is >= 21.
73         setSupportActionBar(toolbar);
74
75         // Get a handle for the action bar.
76         final ActionBar actionBar = getSupportActionBar();
77
78         // Remove the incorrect lint warning that the action bar might be null.
79         assert actionBar != null;  //
80
81         // Display the home arrow on action bar.
82         actionBar.setDisplayHomeAsUpEnabled(true);
83
84         //  Setup the ViewPager.
85         aboutViewPager.setAdapter(new AboutPagerAdapter(getSupportFragmentManager(), getApplicationContext(), blocklistVersions));
86
87         // Keep all the tabs in memory.  This prevents the memory usage updater from running multiple times.
88         aboutViewPager.setOffscreenPageLimit(10);
89
90         // Connect the tab layout to the view pager.
91         aboutTabLayout.setupWithViewPager(aboutViewPager);
92     }
93 }