// Get the current WebView fragment. Instantiate item returns the current item if it already exists.
Fragment webViewFragment = (Fragment) webViewPagerAdapter.instantiateItem(webViewPager, position);
+ // Remove the lint error below that the WebView fragment might be null.
+ assert webViewFragment.getView() != null;
+
// Store the current WebView.
- currentWebView = (NestedScrollWebView) webViewFragment.getView();
+ currentWebView = webViewFragment.getView().findViewById(R.id.nestedscroll_webview);
// Select the corresponding tab if it does not match the currently selected page. This will happen if the page was scrolled via swiping in the view pager.
if (tabLayout.getSelectedTabPosition() != position) {
// Set the swipe to refresh color according to the theme.
if (darkTheme) {
- swipeRefreshLayout.setColorSchemeResources(R.color.blue_600);
+ swipeRefreshLayout.setColorSchemeResources(R.color.blue_800);
swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.gray_850);
} else {
- swipeRefreshLayout.setColorSchemeResources(R.color.blue_700);
+ swipeRefreshLayout.setColorSchemeResources(R.color.blue_500);
}
// `DrawerTitle` identifies the `DrawerLayouts` in accessibility mode.
}
@Override
- public void initializeWebView(NestedScrollWebView nestedScrollWebView, int tabNumber) {
+ public void initializeWebView(int tabNumber, ProgressBar progressBar, NestedScrollWebView nestedScrollWebView) {
// Get handles for the activity views.
final FrameLayout rootFrameLayout = findViewById(R.id.root_framelayout);
final DrawerLayout drawerLayout = findViewById(R.id.drawerlayout);
ImageView tabFavoriteIconImageView = currentTabView.findViewById(R.id.favorite_icon_imageview);
TextView tabTitleTextView = currentTabView.findViewById(R.id.title_textview);
-
- //TODO
- final ProgressBar progressBar = findViewById(R.id.progress_bar);
-
// Get a handle for the shared preferences.
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ProgressBar;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
public class WebViewTabFragment extends Fragment {
// The public interface is used to send information back to the parent activity.
public interface NewTabListener {
- void initializeWebView(NestedScrollWebView nestedScrollWebView, int tabNumber);
+ void initializeWebView(int tabNumber, ProgressBar progressBar, NestedScrollWebView nestedScrollWebView);
}
// The new tab listener is used in `onAttach()` and `onCreateView()`.
int tabNumber = arguments.getInt("tab_number");
// Inflate the tab's WebView. 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 tabView = layoutInflater.inflate(R.layout.nestedscroll_webview, container, false);
+ View tabView = layoutInflater.inflate(R.layout.webview_framelayout, container, false);
// Get a handle for the nested scroll WebView.
NestedScrollWebView nestedScrollWebView = tabView.findViewById(R.id.nestedscroll_webview);
+ ProgressBar progressBar = tabView.findViewById(R.id.progress_bar);
// Request the main activity initialize the WebView.
- newTabListener.initializeWebView(nestedScrollWebView, tabNumber);
+ newTabListener.initializeWebView(tabNumber, progressBar, nestedScrollWebView);
// Return the tab view.
return tabView;
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:src="@drawable/add_light"
- android:tint="@color/gray_700"
+ android:tint="?attr/addTabIconTintColor"
android:onClick="addTab"
android:contentDescription="@string/add_tab" />
</LinearLayout>
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
- <!-- The frame layout allows the progress bar to float above the WebView. -->
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
<androidx.viewpager.widget.ViewPager
android:id="@+id/webviewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
-
- <!-- `android:max` changes the maximum `ProgressBar` value from 10000 to 100 to match progress percentage.
- `android:layout_height="2dp"` works best for API >= 23, but `3dp` is required for visibility on API <= 22.
- `tools:ignore="UnusedAttribute"` removes the lint warning about `progressTint` and `progressBackgroundTint` not applying to API < 21. -->
- <ProgressBar
- android:id="@+id/progress_bar"
- style="?android:attr/progressBarStyleHorizontal"
- android:layout_height="3dp"
- android:layout_width="match_parent"
- android:max="100"
- android:progressTint="?attr/progressTintColor"
- android:progressBackgroundTint="@color/transparent"
- android:visibility="gone"
- tools:ignore="UnusedAttribute" />
- </FrameLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</RelativeLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
- Copyright © 2019 Soren Stoutner <soren@stoutner.com>.
-
- This file is part of Privacy Browser <https://www.stoutner.com/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 <http://www.gnu.org/licenses/>. -->
-
-<com.stoutner.privacybrowser.views.NestedScrollWebView
- android:id="@+id/nestedscroll_webview"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_height="match_parent"
- android:layout_width="match_parent"
- android:focusable="true"
- android:focusableInTouchMode="true" />
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Copyright © 2019 Soren Stoutner <soren@stoutner.com>.
+
+ This file is part of Privacy Browser <https://www.stoutner.com/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 <http://www.gnu.org/licenses/>. -->
+
+<!-- The frame layout allows the progress bar to float above the WebView. -->
+<FrameLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <com.stoutner.privacybrowser.views.NestedScrollWebView
+ android:id="@+id/nestedscroll_webview"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:focusable="true"
+ android:focusableInTouchMode="true" />
+
+ <!-- `android:max` changes the maximum `ProgressBar` value from 10000 to 100 to match progress percentage.
+ `android:layout_height="2dp"` works best for API >= 23, but `3dp` is required for visibility on API <= 22.
+ `tools:ignore="UnusedAttribute"` removes the lint warning about `progressTint` and `progressBackgroundTint` not applying to API < 21. -->
+ <ProgressBar
+ android:id="@+id/progress_bar"
+ style="?android:attr/progressBarStyleHorizontal"
+ android:layout_height="3dp"
+ android:layout_width="match_parent"
+ android:max="100"
+ android:progressTint="?attr/progressTintColor"
+ android:progressBackgroundTint="@color/transparent"
+ android:visibility="gone"
+ tools:ignore="UnusedAttribute" />
+</FrameLayout>
\ No newline at end of file
<!-- `android:windowTranslucentStatus` makes the system status bar translucent. When it is specified the root layout should include `android:fitsSystemWindows="true"`. -->
<style name="PrivacyBrowserLight" parent="Theme.AppCompat.Light.NoActionBar" >
<item name="android:windowTranslucentStatus">true</item>
- <item name="mainStatusBarBackground">@color/gray_500</item>
+ <item name="addTabIconTintColor">@color/gray_700</item>
<item name="android:textColorPrimary">@color/primary_text_color_selector_light</item>
<item name="colorAccent">@color/blue_700</item>
<item name="android:textColorHighlight">@color/blue_200</item>
+ <item name="mainStatusBarBackground">@color/gray_500</item>
<item name="navigationHeaderBackground">@color/blue_700</item>
<item name="navigationHeaderTextColor">@color/white</item>
<item name="appBarTheme">@style/PrivacyBrowserAppBarLight</item>
- <item name="progressTintColor">@color/blue_700</item>
+ <item name="progressTintColor">@color/blue_500</item>
<item name="navigationIconTintColor">@color/blue_800</item>
<item name="findOnPageIconTintColor">@color/blue_800</item>
<item name="viewSourceIconTintColor">@color/black</item>
<!-- `android:windowTranslucentStatus` makes the system status bar translucent. When it is specified the root layout should include `android:fitsSystemWindows="true"`. -->
<style name="PrivacyBrowserDark" parent="Theme.AppCompat.NoActionBar" >
<item name="android:windowTranslucentStatus">true</item>
- <item name="mainStatusBarBackground">@color/black</item>
+ <item name="addTabIconTintColor">@color/gray_400</item>
<item name="android:textColorPrimary">@color/primary_text_color_selector_dark</item>
<item name="colorAccent">@color/blue_600</item>
<item name="android:textColorHighlight">@color/blue_800</item>
+ <item name="mainStatusBarBackground">@color/black</item>
<item name="navigationHeaderBackground">@color/blue_800</item>
<item name="navigationHeaderTextColor">@color/gray_300</item>
<item name="appBarTheme">@style/PrivacyBrowserAppBarDark</item>
- <item name="progressTintColor">@color/blue_600</item>
+ <item name="progressTintColor">@color/blue_800</item>
<item name="navigationIconTintColor">@color/blue_600</item>
<item name="findOnPageIconTintColor">@color/blue_600</item>
<item name="viewSourceIconTintColor">@color/gray_300</item>
<attr name="navigationHeaderBackground" format="reference" />
<attr name="navigationHeaderTextColor" format="reference" />
- <attr name="progressTintColor" format="reference" />
- <attr name="navigationIconTintColor" format="reference" />
- <attr name="findOnPageIconTintColor" format="reference" />
+ <attr name="addTabIconTintColor" format="reference" />
<attr name="domainSettingsIconTintColor" format="reference" />
+ <attr name="findOnPageIconTintColor" format="reference" />
+ <attr name="navigationIconTintColor" format="reference" />
+ <attr name="progressTintColor" format="reference" />
<attr name="viewSourceIconTintColor" format="reference" />
<attr name="listSelectorDrawable" format="reference" />
<!-- `android:windowTranslucentStatus` makes the system status bar translucent. When it is specified the root layout should include `android:fitsSystemWindows="true"`. -->
<style name="PrivacyBrowserLight" parent="Theme.AppCompat.Light.NoActionBar" >
<item name="android:windowTranslucentStatus">true</item>
- <item name="mainStatusBarBackground">@color/gray_500</item>
+ <item name="addTabIconTintColor">@color/gray_700</item>
<item name="android:textColorPrimary">@color/primary_text_color_selector_light</item>
<item name="colorAccent">@color/blue_700</item>
<item name="android:textColorHighlight">@color/blue_200</item>
+ <item name="mainStatusBarBackground">@color/gray_500</item>
<item name="navigationHeaderBackground">@color/blue_700</item>
<item name="navigationHeaderTextColor">@color/white</item>
<item name="appBarTheme">@style/PrivacyBrowserAppBarLight</item>
- <item name="progressTintColor">@color/blue_700</item>
+ <item name="progressTintColor">@color/blue_500</item>
<item name="navigationIconTintColor">@color/blue_800</item>
<item name="findOnPageIconTintColor">@color/blue_800</item>
<item name="viewSourceIconTintColor">@color/black</item>
<!-- `android:windowTranslucentStatus` makes the system status bar translucent. When it is specified the root layout should include `android:fitsSystemWindows="true"`. -->
<style name="PrivacyBrowserDark" parent="Theme.AppCompat.NoActionBar" >
<item name="android:windowTranslucentStatus">true</item>
- <item name="mainStatusBarBackground">@color/black</item>
+ <item name="addTabIconTintColor">@color/gray_400</item>
<item name="android:textColorPrimary">@color/primary_text_color_selector_dark</item>
<item name="colorAccent">@color/blue_600</item>
<item name="android:textColorHighlight">@color/blue_800</item>
+ <item name="mainStatusBarBackground">@color/black</item>
<item name="navigationHeaderBackground">@color/blue_800</item>
<item name="navigationHeaderTextColor">@color/gray_300</item>
<item name="appBarTheme">@style/PrivacyBrowserAppBarDark</item>
- <item name="progressTintColor">@color/blue_600</item>
+ <item name="progressTintColor">@color/blue_800</item>
<item name="navigationIconTintColor">@color/blue_600</item>
<item name="findOnPageIconTintColor">@color/blue_600</item>
<item name="viewSourceIconTintColor">@color/gray_300</item>