2 * Copyright 2016-2022 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
6 * Privacy Browser Android 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.
11 * Privacy Browser Android 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.
16 * You should have received a copy of the GNU General Public License
17 * along with Privacy Browser Android. If not, see <http://www.gnu.org/licenses/>.
20 package com.stoutner.privacybrowser.activities
22 import android.os.Bundle
23 import android.view.WindowManager
25 import androidx.appcompat.app.AppCompatActivity
26 import androidx.appcompat.widget.Toolbar
27 import androidx.preference.PreferenceManager
28 import androidx.viewpager.widget.ViewPager
30 import com.google.android.material.tabs.TabLayout
32 import com.stoutner.privacybrowser.R
33 import com.stoutner.privacybrowser.adapters.AboutPagerAdapter
35 const val FILTERLIST_VERSIONS = "filterlist_versions"
37 class AboutActivity : AppCompatActivity() {
38 override fun onCreate(savedInstanceState: Bundle?) {
39 // Get a handle for the shared preferences.
40 val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
42 // Get the preferences.
43 val allowScreenshots = sharedPreferences.getBoolean(getString(R.string.allow_screenshots_key), false)
44 val bottomAppBar = sharedPreferences.getBoolean(getString(R.string.bottom_app_bar_key), false)
46 // Disable screenshots if not allowed.
47 if (!allowScreenshots) {
48 window.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
51 // Run the default commands.
52 super.onCreate(savedInstanceState)
54 // Get the intent that launched the activity.
55 val launchingIntent = intent
57 // Get the filter list versions.
58 val filterListVersions = launchingIntent.getStringArrayExtra(FILTERLIST_VERSIONS)!!
60 // Set the content view.
62 setContentView(R.layout.about_bottom_appbar)
64 setContentView(R.layout.about_top_appbar)
66 // Get handles for the views.
67 val toolbar = findViewById<Toolbar>(R.id.about_toolbar)
68 val aboutTabLayout = findViewById<TabLayout>(R.id.about_tablayout)
69 val aboutViewPager = findViewById<ViewPager>(R.id.about_viewpager)
71 // Set the support action bar.
72 setSupportActionBar(toolbar)
74 // Get a handle for the action bar.
75 val actionBar = supportActionBar!!
77 // Display the home arrow on the action bar.
78 actionBar.setDisplayHomeAsUpEnabled(true)
80 // Initialize the about pager adapter.
81 val aboutPagerAdapter = AboutPagerAdapter(supportFragmentManager, applicationContext, filterListVersions)
83 // Set the view pager adapter.
84 aboutViewPager.adapter = aboutPagerAdapter
86 // Keep all the tabs in memory. This prevents the memory usage updater from running multiple times.
87 aboutViewPager.offscreenPageLimit = 10
89 // Connect the tab layout to the view pager.
90 aboutTabLayout.setupWithViewPager(aboutViewPager)