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 class AboutActivity : AppCompatActivity() {
36 // Declare the class variables.
37 private lateinit var aboutPagerAdapter: AboutPagerAdapter
40 // Define the companion object constants. These can be move to being public constants once MainWebViewActivity has been converted to Kotlin.
41 const val BLOCKLIST_VERSIONS = "blocklist_versions"
44 override fun onCreate(savedInstanceState: Bundle?) {
45 // Get a handle for the shared preferences.
46 val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this)
48 // Get the preferences.
49 val allowScreenshots = sharedPreferences.getBoolean(getString(R.string.allow_screenshots_key), false)
50 val bottomAppBar = sharedPreferences.getBoolean(getString(R.string.bottom_app_bar_key), false)
52 // Disable screenshots if not allowed.
53 if (!allowScreenshots) {
54 window.addFlags(WindowManager.LayoutParams.FLAG_SECURE)
58 setTheme(R.style.PrivacyBrowser)
60 // Run the default commands.
61 super.onCreate(savedInstanceState)
63 // Get the intent that launched the activity.
64 val launchingIntent = intent
66 // Store the blocklist versions.
67 val blocklistVersions = launchingIntent.getStringArrayExtra(BLOCKLIST_VERSIONS)!!
69 // Set the content view.
71 setContentView(R.layout.about_bottom_appbar)
73 setContentView(R.layout.about_top_appbar)
76 // Get handles for the views.
77 val toolbar = findViewById<Toolbar>(R.id.about_toolbar)
78 val aboutTabLayout = findViewById<TabLayout>(R.id.about_tablayout)
79 val aboutViewPager = findViewById<ViewPager>(R.id.about_viewpager)
81 // Set the support action bar.
82 setSupportActionBar(toolbar)
84 // Get a handle for the action bar.
85 val actionBar = supportActionBar!!
87 // Display the home arrow on the action bar.
88 actionBar.setDisplayHomeAsUpEnabled(true)
90 // Initialize the about pager adapter.
91 aboutPagerAdapter = AboutPagerAdapter(supportFragmentManager, applicationContext, blocklistVersions)
93 // Set the view pager adapter.
94 aboutViewPager.adapter = aboutPagerAdapter
96 // Keep all the tabs in memory. This prevents the memory usage updater from running multiple times.
97 aboutViewPager.offscreenPageLimit = 10
99 // Connect the tab layout to the view pager.
100 aboutTabLayout.setupWithViewPager(aboutViewPager)