]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blob - app/src/main/java/com/stoutner/privacybrowser/AboutActivity.java
c5d7bf779cf87d8607a41a12f2c8e4113c6b9f11
[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.AppCompatActivity;
29
30 public class AboutActivity extends AppCompatActivity {
31     @Override
32     protected void onCreate(Bundle savedInstanceState) {
33         super.onCreate(savedInstanceState);
34         setContentView(R.layout.about_linearlayout);
35
36         //  Setup the ViewPager.
37         ViewPager aboutViewPager = (ViewPager) findViewById(R.id.about_viewpager);
38         assert aboutViewPager != null; // This assert removes the incorrect warning on the following line that aboutViewPager might be null.
39         aboutViewPager.setAdapter(new aboutPagerAdapter(getSupportFragmentManager()));
40
41         // Setup the TabLayout and connect it to the ViewPager.
42         TabLayout aboutTabLayout = (TabLayout) findViewById(R.id.about_tablayout);
43         assert aboutTabLayout != null; // This assert removes the incorrect warning on the following line that aboutTabLayout might be null.
44         aboutTabLayout.setupWithViewPager(aboutViewPager);
45     }
46
47     public class aboutPagerAdapter extends FragmentPagerAdapter {
48         public aboutPagerAdapter(FragmentManager fm) {
49             super(fm);
50         }
51
52         @Override
53         // Get the count of the number of tabs.
54         public int getCount() {
55             return 5;
56         }
57
58         @Override
59         // Get the name of each tab.
60         public CharSequence getPageTitle(int tab) {
61             switch (tab) {
62                 case 0:
63                     return getString(R.string.version);
64
65                 case 1:
66                     return getString(R.string.permissions);
67
68                 case 2:
69                     return getString(R.string.changelog);
70
71                 case 3:
72                     return getString(R.string.license);
73
74                 case 4:
75                     return getString(R.string.contributors);
76
77                 default:
78                     return "";
79             }
80         }
81
82         @Override
83         // Setup each tab.
84         public Fragment getItem(int tab) {
85             return AboutTabFragment.createTab(tab);
86         }
87     }
88
89
90 }