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)
57 // Run the default commands.
58 super.onCreate(savedInstanceState)
60 // Get the intent that launched the activity.
61 val launchingIntent = intent
63 // Store the blocklist versions.
64 val blocklistVersions = launchingIntent.getStringArrayExtra(BLOCKLIST_VERSIONS)!!
66 // Set the content view.
68 setContentView(R.layout.about_bottom_appbar)
70 setContentView(R.layout.about_top_appbar)
73 // Get handles for the views.
74 val toolbar = findViewById<Toolbar>(R.id.about_toolbar)
75 val aboutTabLayout = findViewById<TabLayout>(R.id.about_tablayout)
76 val aboutViewPager = findViewById<ViewPager>(R.id.about_viewpager)
78 // Set the support action bar.
79 setSupportActionBar(toolbar)
81 // Get a handle for the action bar.
82 val actionBar = supportActionBar!!
84 // Display the home arrow on the action bar.
85 actionBar.setDisplayHomeAsUpEnabled(true)
87 // Initialize the about pager adapter.
88 aboutPagerAdapter = AboutPagerAdapter(supportFragmentManager, applicationContext, blocklistVersions)
90 // Set the view pager adapter.
91 aboutViewPager.adapter = aboutPagerAdapter
93 // Keep all the tabs in memory. This prevents the memory usage updater from running multiple times.
94 aboutViewPager.offscreenPageLimit = 10
96 // Connect the tab layout to the view pager.
97 aboutTabLayout.setupWithViewPager(aboutViewPager)