X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FAboutActivity.java;h=9ce67ad74b3b054367269b68ee2cc59bafdd821a;hb=4196bafc4069857b554ac95addcae92fcabae901;hp=e15bfe79a0bb77b38617dbc496ea3e639d3b6711;hpb=f0393ca22075be3e5fe9199c7db87381256236fa;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.java index e15bfe79..9ce67ad7 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/AboutActivity.java @@ -1,5 +1,5 @@ /* - * Copyright © 2016-2019 Soren Stoutner . + * Copyright © 2016-2020 Soren Stoutner . * * This file is part of Privacy Browser . * @@ -19,6 +19,7 @@ package com.stoutner.privacybrowser.activities; +import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; @@ -27,14 +28,11 @@ import android.view.WindowManager; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentManager; -import androidx.fragment.app.FragmentPagerAdapter; import androidx.viewpager.widget.ViewPager; import com.google.android.material.tabs.TabLayout; -import com.stoutner.privacybrowser.fragments.AboutTabFragment; +import com.stoutner.privacybrowser.adapters.AboutPagerAdapter; import com.stoutner.privacybrowser.R; public class AboutActivity extends AppCompatActivity { @@ -43,8 +41,7 @@ public class AboutActivity extends AppCompatActivity { // 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); + // Get the screenshot preference. boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false); // Disable screenshots if not allowed. @@ -53,15 +50,17 @@ public class AboutActivity extends AppCompatActivity { } // Set the theme. - if (darkTheme) { - setTheme(R.style.PrivacyBrowserDark_SecondaryActivity); - } else { - setTheme(R.style.PrivacyBrowserLight_SecondaryActivity); - } + setTheme(R.style.PrivacyBrowser); // Run the default commands. super.onCreate(savedInstanceState); + // Get the intent that launched the activity. + Intent launchingIntent = getIntent(); + + // Store the blocklist versions. + String[] blocklistVersions = launchingIntent.getStringArrayExtra("blocklist_versions"); + // Set the content view. setContentView(R.layout.about_coordinatorlayout); @@ -83,58 +82,12 @@ public class AboutActivity extends AppCompatActivity { actionBar.setDisplayHomeAsUpEnabled(true); // Setup the ViewPager. - aboutViewPager.setAdapter(new AboutPagerAdapter(getSupportFragmentManager())); + aboutViewPager.setAdapter(new AboutPagerAdapter(getSupportFragmentManager(), getApplicationContext(), blocklistVersions)); + + // Keep all the tabs in memory. This prevents the memory usage updater from running multiple times. + aboutViewPager.setOffscreenPageLimit(10); // Connect the tab layout to the view pager. aboutTabLayout.setupWithViewPager(aboutViewPager); } - - private class AboutPagerAdapter extends FragmentPagerAdapter { - private AboutPagerAdapter(FragmentManager fragmentManager) { - // Run the default commands. - super(fragmentManager); - } - - @Override - // Get the count of the number of tabs. - public int getCount() { - return 7; - } - - @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); - - case 1: - return getString(R.string.permissions); - - case 2: - return getString(R.string.privacy_policy); - - case 3: - return getString(R.string.changelog); - - case 4: - return getString(R.string.licenses); - - case 5: - return getString(R.string.contributors); - - case 6: - return getString(R.string.links); - - default: - return ""; - } - } - - @Override - // Setup each tab. - public Fragment getItem(int tab) { - return AboutTabFragment.createTab(tab); - } - } -} +} \ No newline at end of file