X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;ds=sidebyside;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Ffragments%2FGuideTabFragment.java;fp=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Ffragments%2FGuideTabFragment.java;h=5c8a07b59733aa3fbd6d064f86165cd9a74edc20;hb=61a76e491469916f2f30aebb47b98cda7cceb557;hp=0000000000000000000000000000000000000000;hpb=348acd7bd2c9ba9638ff87b34df4e7501214ca27;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/fragments/GuideTabFragment.java b/app/src/main/java/com/stoutner/privacybrowser/fragments/GuideTabFragment.java new file mode 100644 index 00000000..5c8a07b5 --- /dev/null +++ b/app/src/main/java/com/stoutner/privacybrowser/fragments/GuideTabFragment.java @@ -0,0 +1,100 @@ +/* + * Copyright 2016-2017 Soren Stoutner . + * + * This file is part of Privacy Browser . + * + * Privacy Browser is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Privacy Browser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Privacy Browser. If not, see . + */ + +package com.stoutner.privacybrowser.fragments; + +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.webkit.WebView; + +import com.stoutner.privacybrowser.R; + +public class GuideTabFragment extends Fragment { + // `tabNumber` is used in `onCreate()` and `onCreateView()`. + private int tabNumber; + + // GuideTabFragment.createTab stores the tab number in the bundle arguments so it can be referenced from onCreate(). + public static GuideTabFragment createTab (int tab) { + Bundle thisTabArguments = new Bundle(); + thisTabArguments.putInt("Tab", tab); + + GuideTabFragment thisTab = new GuideTabFragment(); + thisTab.setArguments(thisTabArguments); + return thisTab; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Store the tab number in `tabNumber`. + tabNumber = getArguments().getInt("Tab"); + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + // Setting false at the end of inflater.inflate does not attach the inflated layout as a child of container. + // The fragment will take care of attaching the root automatically. + View tabLayout = inflater.inflate(R.layout.guide_tab_webview, container, false); + WebView tabWebView = (WebView) tabLayout; + + // Tab numbers start at 0. + switch (tabNumber) { + case 0: + tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_overview.html"); + break; + + case 1: + tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_javascript.html"); + break; + + case 2: + tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_local_storage.html"); + break; + + case 3: + tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_user_agent.html"); + break; + + case 4: + tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_tor.html"); + break; + + case 5: + tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_tracking_ids.html"); + break; + + case 6: + tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_clear_and_exit.html"); + break; + + case 7: + tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_planned_features.html"); + break; + + default: + break; + } + + return tabLayout; + } +}