]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blob - app/src/main/java/com/stoutner/privacybrowser/activities/GuideActivity.java
Updates about_licenses, adding the full text of the Apache License 2.0 and the 3...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / GuideActivity.java
1 /*
2  * Copyright © 2016-2017 Soren Stoutner <soren@stoutner.com>.
3  *
4  * This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 package com.stoutner.privacybrowser.activities;
21
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;
31
32 import com.stoutner.privacybrowser.fragments.GuideTabFragment;
33 import com.stoutner.privacybrowser.R;
34
35 public class GuideActivity extends AppCompatActivity {
36     @Override
37     protected void onCreate(Bundle savedInstanceState) {
38         super.onCreate(savedInstanceState);
39         setContentView(R.layout.guide_coordinatorlayout);
40
41         // We need to use `SupportActionBar` from `android.support.v7.app.ActionBar` until the minimum API is >= 21.
42         Toolbar guideAppBar = (Toolbar) findViewById(R.id.guide_toolbar);
43         setSupportActionBar(guideAppBar);
44
45         // Display the home arrow on `ppBar`.
46         final ActionBar appBar = getSupportActionBar();
47         assert appBar != null;  // This assert removes the incorrect lint warning in Android Studio on the following line that `appBar` might be `null`.
48         appBar.setDisplayHomeAsUpEnabled(true);
49
50         //  Setup the ViewPager.
51         ViewPager aboutViewPager = (ViewPager) findViewById(R.id.guide_viewpager);
52         assert aboutViewPager != null; // This assert removes the incorrect warning in Android Studio on the following line that aboutViewPager might be null.
53         aboutViewPager.setAdapter(new guidePagerAdapter(getSupportFragmentManager()));
54
55         // Setup the TabLayout and connect it to the ViewPager.
56         TabLayout aboutTabLayout = (TabLayout) findViewById(R.id.guide_tablayout);
57         assert aboutTabLayout != null; // This assert removes the incorrect warning in Android Studio on the following line that aboutTabLayout might be null.
58         aboutTabLayout.setupWithViewPager(aboutViewPager);
59     }
60
61     private class guidePagerAdapter extends FragmentPagerAdapter {
62         private guidePagerAdapter(FragmentManager fm) {
63             super(fm);
64         }
65
66         @Override
67         // Get the count of the number of tabs.
68         public int getCount() {
69             return 9;
70         }
71
72         @Override
73         // Get the name of each tab.  Tab numbers start at 0.
74         public CharSequence getPageTitle(int tab) {
75             switch (tab) {
76                 case 0:
77                     return getString(R.string.overview);
78
79                 case 1:
80                     return getString(R.string.javascript);
81
82                 case 2:
83                     return getString(R.string.local_storage);
84
85                 case 3:
86                     return getString(R.string.user_agent);
87
88                 case 4:
89                     return getString(R.string.domain_settings);
90
91                 case 5:
92                     return getString(R.string.tor);
93
94                 case 6:
95                     return getString(R.string.tracking_ids);
96
97                 case 7:
98                     return getString(R.string.clear_and_exit);
99
100                 case 8:
101                     return getString(R.string.planned_features);
102
103                 default:
104                     return "";
105             }
106         }
107
108         @Override
109         // Setup each tab.
110         public Fragment getItem(int tab) {
111             return GuideTabFragment.createTab(tab);
112         }
113     }
114
115 }