]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blob - app/src/main/java/com/stoutner/privacybrowser/AboutActivity.java
Remove the third-party cookies icon from the list of additional icons to display...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / AboutActivity.java
1 /**
2  * Copyright 2016 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;
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 public class AboutActivity extends AppCompatActivity {
33     @Override
34     protected void onCreate(Bundle savedInstanceState) {
35         super.onCreate(savedInstanceState);
36         setContentView(R.layout.about_coordinatorlayout);
37
38         // We need to use the SupportActionBar from android.support.v7.app.ActionBar until the minimum API is >= 21.
39         Toolbar aboutAppBar = (Toolbar) findViewById(R.id.about_toolbar);
40         setSupportActionBar(aboutAppBar);
41
42         // Display the home arrow on supportAppBar.
43         final ActionBar appBar = getSupportActionBar();
44         assert appBar != null;// This assert removes the incorrect warning in Android Studio on the following line that appBar might be null.
45         appBar.setDisplayHomeAsUpEnabled(true);
46
47         //  Setup the ViewPager.
48         ViewPager aboutViewPager = (ViewPager) findViewById(R.id.about_viewpager);
49         assert aboutViewPager != null; // This assert removes the incorrect warning in Android Studio on the following line that aboutViewPager might be null.
50         aboutViewPager.setAdapter(new aboutPagerAdapter(getSupportFragmentManager()));
51
52         // Setup the TabLayout and connect it to the ViewPager.
53         TabLayout aboutTabLayout = (TabLayout) findViewById(R.id.about_tablayout);
54         assert aboutTabLayout != null; // This assert removes the incorrect warning in Android Studio on the following line that aboutTabLayout might be null.
55         aboutTabLayout.setupWithViewPager(aboutViewPager);
56     }
57
58     public class aboutPagerAdapter extends FragmentPagerAdapter {
59         public aboutPagerAdapter(FragmentManager fm) {
60             super(fm);
61         }
62
63         @Override
64         // Get the count of the number of tabs.
65         public int getCount() {
66             return 7;
67         }
68
69         @Override
70         // Get the name of each tab.  Tab numbers start at 0.
71         public CharSequence getPageTitle(int tab) {
72             switch (tab) {
73                 case 0:
74                     return getString(R.string.version);
75
76                 case 1:
77                     return getString(R.string.permissions);
78
79                 case 2:
80                     return getString(R.string.privacy_policy);
81
82                 case 3:
83                     return getString(R.string.changelog);
84
85                 case 4:
86                     return getString(R.string.licenses);
87
88                 case 5:
89                     return getString(R.string.contributors);
90
91                 case 6:
92                     return getString(R.string.links);
93
94                 default:
95                     return "";
96             }
97         }
98
99         @Override
100         // Setup each tab.
101         public Fragment getItem(int tab) {
102             return AboutTabFragment.createTab(tab);
103         }
104     }
105 }