package com.stoutner.privacybrowser.activities;
+import android.content.SharedPreferences;
import android.os.Bundle;
+import android.preference.PreferenceManager;
import android.view.WindowManager;
import androidx.appcompat.app.ActionBar;
public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
+ // Get a handle for the shared preferences.
+ SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
+
+ // Get the theme and screenshot preferences.
+ boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
+ boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);
+
// Disable screenshots if not allowed.
- if (!MainWebViewActivity.allowScreenshots) {
+ if (!allowScreenshots) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SECURE);
}
// Set the theme.
- if (MainWebViewActivity.darkTheme) {
+ if (darkTheme) {
setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
} else {
setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
// Set the content view.
setContentView(R.layout.about_coordinatorlayout);
- // `SupportActionBar` from `android.support.v7.app.ActionBar` must be used until the minimum API is >= 21.
+ // 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);
+
+ // Set the action bar. `SupportActionBar` must be used until the minimum API is >= 21.
setSupportActionBar(toolbar);
// Get a handle for the action bar.
actionBar.setDisplayHomeAsUpEnabled(true);
// Setup the ViewPager.
- ViewPager aboutViewPager = findViewById(R.id.about_viewpager);
- aboutViewPager.setAdapter(new aboutPagerAdapter(getSupportFragmentManager()));
+ aboutViewPager.setAdapter(new AboutPagerAdapter(getSupportFragmentManager()));
- // Setup the TabLayout and connect it to the ViewPager.
- TabLayout aboutTabLayout = findViewById(R.id.about_tablayout);
+ // Connect the tab layout to the view pager.
aboutTabLayout.setupWithViewPager(aboutViewPager);
}
- private class aboutPagerAdapter extends FragmentPagerAdapter {
- private aboutPagerAdapter(FragmentManager fragmentManager) {
+ private class AboutPagerAdapter extends FragmentPagerAdapter {
+ private AboutPagerAdapter(FragmentManager fragmentManager) {
// Run the default commands.
super(fragmentManager);
}