/*
- * Copyright © 2016-2017 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2020 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
package com.stoutner.privacybrowser.activities;
+import android.content.Intent;
+import android.content.SharedPreferences;
import android.os.Bundle;
-import android.support.design.widget.TabLayout;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentPagerAdapter;
-import android.support.v4.view.ViewPager;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-
-import com.stoutner.privacybrowser.fragments.AboutTabFragment;
+import android.preference.PreferenceManager;
+import android.view.WindowManager;
+
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.appcompat.widget.Toolbar;
+import androidx.viewpager.widget.ViewPager;
+
+import com.google.android.material.tabs.TabLayout;
+
+import com.stoutner.privacybrowser.adapters.AboutPagerAdapter;
import com.stoutner.privacybrowser.R;
public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
- // Set the theme.
- if (MainWebViewActivity.darkTheme) {
- setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
- } else {
- setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
- }
+ // Get a handle for the shared preferences.
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
- // Run the default commands.
- super.onCreate(savedInstanceState);
+ // Get the screenshot preference.
+ boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
- // Set the content view according to the theme.
- if (MainWebViewActivity.darkTheme) {
- setContentView(R.layout.about_coordinatorlayout_dark);
- } else {
- setContentView(R.layout.about_coordinatorlayout_light);
+ // Disable screenshots if not allowed.
+ if (!allowScreenshots) {
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
- // We need to use the SupportActionBar from android.support.v7.app.ActionBar until the minimum API is >= 21.
- Toolbar aboutAppBar = (Toolbar) findViewById(R.id.about_toolbar);
- setSupportActionBar(aboutAppBar);
-
- // Display the home arrow on supportAppBar.
- final ActionBar appBar = getSupportActionBar();
- assert appBar != null;// This assert removes the incorrect warning in Android Studio on the following line that appBar might be null.
- appBar.setDisplayHomeAsUpEnabled(true);
-
- // Setup the ViewPager.
- ViewPager aboutViewPager = (ViewPager) findViewById(R.id.about_viewpager);
- aboutViewPager.setAdapter(new aboutPagerAdapter(getSupportFragmentManager()));
-
- // Setup the TabLayout and connect it to the ViewPager.
- TabLayout aboutTabLayout = (TabLayout) findViewById(R.id.about_tablayout);
- aboutTabLayout.setupWithViewPager(aboutViewPager);
- }
+ // Set the theme.
+ setTheme(R.style.PrivacyBrowser);
- private class aboutPagerAdapter extends FragmentPagerAdapter {
- private aboutPagerAdapter(FragmentManager fm) {
- super(fm);
- }
+ // Run the default commands.
+ super.onCreate(savedInstanceState);
- @Override
- // Get the count of the number of tabs.
- public int getCount() {
- return 7;
- }
+ // Get the intent that launched the activity.
+ Intent launchingIntent = getIntent();
- @Override
- // Get the name of each tab. Tab numbers start at 0.
- public CharSequence getPageTitle(int tab) {
- switch (tab) {
- case 0:
- return getString(R.string.version);
+ // Store the blocklist versions.
+ String[] blocklistVersions = launchingIntent.getStringArrayExtra("blocklist_versions");
- case 1:
- return getString(R.string.permissions);
+ // Set the content view.
+ setContentView(R.layout.about_coordinatorlayout);
- case 2:
- return getString(R.string.privacy_policy);
+ // Get handles for the views.
+ Toolbar toolbar = findViewById(R.id.about_toolbar);
+ TabLayout aboutTabLayout = findViewById(R.id.about_tablayout);
+ ViewPager aboutViewPager = findViewById(R.id.about_viewpager);
- case 3:
- return getString(R.string.changelog);
+ // Set the action bar. `SupportActionBar` must be used until the minimum API is >= 21.
+ setSupportActionBar(toolbar);
- case 4:
- return getString(R.string.licenses);
+ // Get a handle for the action bar.
+ final ActionBar actionBar = getSupportActionBar();
- case 5:
- return getString(R.string.contributors);
+ // Remove the incorrect lint warning that the action bar might be null.
+ assert actionBar != null; //
- case 6:
- return getString(R.string.links);
+ // Display the home arrow on action bar.
+ actionBar.setDisplayHomeAsUpEnabled(true);
- default:
- return "";
- }
- }
+ // Setup the ViewPager.
+ aboutViewPager.setAdapter(new AboutPagerAdapter(getSupportFragmentManager(), getApplicationContext(), blocklistVersions));
- @Override
- // Setup each tab.
- public Fragment getItem(int tab) {
- return AboutTabFragment.createTab(tab);
- }
+ // Connect the tab layout to the view pager.
+ aboutTabLayout.setupWithViewPager(aboutViewPager);
}
-}
+}
\ No newline at end of file