/*
- * Copyright © 2016-2017 Soren Stoutner <soren@stoutner.com>.
+ * Copyright © 2016-2018 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser <https://www.stoutner.com/privacy-browser>.
*
import android.annotation.SuppressLint;
import android.os.Bundle;
+import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
// `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().
+ // Store the tab number in the arguments bundle.
public static GuideTabFragment createTab (int tab) {
- Bundle thisTabArguments = new Bundle();
- thisTabArguments.putInt("Tab", tab);
+ // Create a bundle.
+ Bundle bundle = new Bundle();
- GuideTabFragment thisTab = new GuideTabFragment();
- thisTab.setArguments(thisTabArguments);
- return thisTab;
+ // Store the tab number in the bundle.
+ bundle.putInt("Tab", tab);
+
+ // Add the bundle to the fragment.
+ GuideTabFragment guideTabFragment = new GuideTabFragment();
+ guideTabFragment.setArguments(bundle);
+
+ // Return the new fragment.
+ return guideTabFragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
+ // Run the default commands.
super.onCreate(savedInstanceState);
- // Store the tab number in `tabNumber`.
+ // Remove the lint warning that `getArguments()` might be null.
+ assert getArguments() != null;
+
+ // Store the tab number in a class variable.
tabNumber = getArguments().getInt("Tab");
}
@SuppressLint("SetJavaScriptEnabled")
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ public View onCreateView(@NonNull 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.bare_webview, container, false);
case 7:
tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_tracking_ids_dark.html");
break;
+
+ case 8:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_bookmarks_dark.html");
+ break;
}
} else { // The light theme is applied.
// Tab numbers start at 0.
case 7:
tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_tracking_ids_light.html");
break;
+
+ case 8:
+ tabWebView.loadUrl("file:///android_asset/" + getString(R.string.android_asset_path) + "/guide_bookmarks_light.html");
}
}
// Return the formatted `tabLayout`.
return tabLayout;
}
-}
+}
\ No newline at end of file