]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blob - app/src/main/java/com/stoutner/privacybrowser/fragments/GuideTabFragment.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 / fragments / GuideTabFragment.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.fragments;
21
22 import android.os.Bundle;
23 import android.support.v4.app.Fragment;
24 import android.view.LayoutInflater;
25 import android.view.View;
26 import android.view.ViewGroup;
27 import android.webkit.WebView;
28
29 import com.stoutner.privacybrowser.R;
30
31 public class GuideTabFragment extends Fragment {
32     // `tabNumber` is used in `onCreate()` and `onCreateView()`.
33     private int tabNumber;
34
35     // GuideTabFragment.createTab stores the tab number in the bundle arguments so it can be referenced from onCreate().
36     public static GuideTabFragment createTab (int tab) {
37         Bundle thisTabArguments = new Bundle();
38         thisTabArguments.putInt("Tab", tab);
39
40         GuideTabFragment thisTab = new GuideTabFragment();
41         thisTab.setArguments(thisTabArguments);
42         return thisTab;
43     }
44
45     @Override
46     public void onCreate(Bundle savedInstanceState) {
47         super.onCreate(savedInstanceState);
48
49         // Store the tab number in `tabNumber`.
50         tabNumber = getArguments().getInt("Tab");
51     }
52
53     @Override
54     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
55         // Setting false at the end of inflater.inflate does not attach the inflated layout as a child of container.
56         // The fragment will take care of attaching the root automatically.
57         View tabLayout = inflater.inflate(R.layout.guide_tab_webview, container, false);
58         WebView tabWebView = (WebView) tabLayout;
59
60         // Tab numbers start at 0.
61         switch (tabNumber) {
62             case 0:
63                 tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_overview.html");
64                 break;
65
66             case 1:
67                 tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_javascript.html");
68                 break;
69
70             case 2:
71                 tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_local_storage.html");
72                 break;
73
74             case 3:
75                 tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_user_agent.html");
76                 break;
77
78             case 4:
79                 tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_domain_settings.html");
80                 break;
81
82             case 5:
83                 tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_tor.html");
84                 break;
85
86             case 6:
87                 tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_tracking_ids.html");
88                 break;
89
90             case 7:
91                 tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_clear_and_exit.html");
92                 break;
93
94             case 8:
95                 tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_planned_features.html");
96                 break;
97         }
98
99         return tabLayout;
100     }
101 }