2 * Copyright © 2016-2017 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
6 * Privacy Browser 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 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. If not, see <http://www.gnu.org/licenses/>.
20 package com.stoutner.privacybrowser.activities;
22 import android.os.Bundle;
23 import android.support.design.widget.TabLayout;
24 import android.support.v4.app.Fragment;
25 import android.support.v4.app.FragmentManager;
26 import android.support.v4.app.FragmentPagerAdapter;
27 import android.support.v4.view.ViewPager;
28 import android.support.v7.app.ActionBar;
29 import android.support.v7.app.AppCompatActivity;
30 import android.support.v7.widget.Toolbar;
32 import com.stoutner.privacybrowser.fragments.GuideTabFragment;
33 import com.stoutner.privacybrowser.R;
35 public class GuideActivity extends AppCompatActivity {
37 protected void onCreate(Bundle savedInstanceState) {
39 if (MainWebViewActivity.darkTheme) {
40 setTheme(R.style.PrivacyBrowserDark_SecondaryActivity);
42 setTheme(R.style.PrivacyBrowserLight_SecondaryActivity);
45 // Run the default commands.
46 super.onCreate(savedInstanceState);
48 // Set the content view.
49 setContentView(R.layout.guide_coordinatorlayout);
51 // We need to use `SupportActionBar` from `android.support.v7.app.ActionBar` until the minimum API is >= 21.
52 Toolbar guideAppBar = (Toolbar) findViewById(R.id.guide_toolbar);
53 setSupportActionBar(guideAppBar);
55 // Display the home arrow on `ppBar`.
56 final ActionBar appBar = getSupportActionBar();
57 assert appBar != null; // This assert removes the incorrect lint warning in Android Studio on the following line that `appBar` might be `null`.
58 appBar.setDisplayHomeAsUpEnabled(true);
60 // Setup the ViewPager.
61 ViewPager aboutViewPager = (ViewPager) findViewById(R.id.guide_viewpager);
62 assert aboutViewPager != null; // This assert removes the incorrect warning in Android Studio on the following line that aboutViewPager might be null.
63 aboutViewPager.setAdapter(new guidePagerAdapter(getSupportFragmentManager()));
65 // Setup the TabLayout and connect it to the ViewPager.
66 TabLayout aboutTabLayout = (TabLayout) findViewById(R.id.guide_tablayout);
67 assert aboutTabLayout != null; // This assert removes the incorrect warning in Android Studio on the following line that aboutTabLayout might be null.
68 aboutTabLayout.setupWithViewPager(aboutViewPager);
71 private class guidePagerAdapter extends FragmentPagerAdapter {
72 private guidePagerAdapter(FragmentManager fm) {
77 // Get the count of the number of tabs.
78 public int getCount() {
83 // Get the name of each tab. Tab numbers start at 0.
84 public CharSequence getPageTitle(int tab) {
87 return getString(R.string.overview);
90 return getString(R.string.javascript);
93 return getString(R.string.local_storage);
96 return getString(R.string.user_agent);
99 return getString(R.string.domain_settings);
102 return getString(R.string.tor);
105 return getString(R.string.tracking_ids);
114 public Fragment getItem(int tab) {
115 return GuideTabFragment.createTab(tab);