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