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