+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
- Copyright 2016 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/>. -->
-
-<!-- android:layout_martinTop="?attr/actionBarSize" moves adRelativeLayout below the appBarLayout, which otherwise would cover the top of mainWebView. -->
-<RelativeLayout
- android:id="@+id/adRelativeLayout"
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- xmlns:ads="http://schemas.android.com/apk/res-auto"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginTop="?attr/actionBarSize"
- tools:context="com.stoutner.privacybrowser.MainWebViewActivity"
- tools:showIn="@layout/activity_webview">
-
- <!-- Set to visibility="gone" in the standard flavor. -->
- <com.google.android.gms.ads.AdView
- android:id="@+id/adView"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_alignParentBottom="true"
- ads:adSize="BANNER"
- ads:adUnitId="@string/ad_id">
- </com.google.android.gms.ads.AdView>
-
- <android.support.v4.widget.SwipeRefreshLayout
- android:id="@+id/swipeRefreshLayout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_above="@id/adView">
-
- <!-- Google does not currently want to support hiding the AppBar on scroll for a WebView child with the Support Toolbar. https://code.google.com/p/android/issues/detail?id=200394 -->
- <WebView
- android:id="@+id/mainWebView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:focusable="true"
- android:focusableInTouchMode="true"/>
- </android.support.v4.widget.SwipeRefreshLayout>
-</RelativeLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Copyright 2016 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/>. -->
+
+<!-- android:layout_martinTop="?attr/actionBarSize" moves adRelativeLayout below the appBarLayout, which otherwise would cover the top of mainWebView. -->
+<RelativeLayout
+ android:id="@+id/adRelativeLayout"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ xmlns:ads="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_marginTop="?attr/actionBarSize"
+ tools:context="com.stoutner.privacybrowser.MainWebViewActivity"
+ tools:showIn="@layout/activity_webview">
+
+ <com.google.android.gms.ads.AdView
+ android:id="@+id/adView"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerHorizontal="true"
+ android:layout_alignParentBottom="true"
+ ads:adSize="BANNER"
+ ads:adUnitId="@string/ad_id">
+ </com.google.android.gms.ads.AdView>
+
+ <android.support.v4.widget.SwipeRefreshLayout
+ android:id="@+id/swipeRefreshLayout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_above="@id/adView">
+
+ <!-- Google does not currently want to support hiding the AppBar on scroll for a WebView child with the Support Toolbar. https://code.google.com/p/android/issues/detail?id=200394 -->
+ <WebView
+ android:id="@+id/mainWebView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:focusable="true"
+ android:focusableInTouchMode="true"/>
+ </android.support.v4.widget.SwipeRefreshLayout>
+</RelativeLayout>
\ No newline at end of file
package com.stoutner.privacybrowser;
import android.annotation.SuppressLint;
-import android.annotation.TargetApi;
import android.app.Activity;
import android.app.DownloadManager;
import android.content.Intent;
import android.preference.PreferenceManager;
import android.support.design.widget.Snackbar;
import android.support.v4.app.DialogFragment;
+import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBar;
+import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatDialogFragment;
import android.support.v7.widget.Toolbar;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
-import android.widget.Toast;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
// mainWebView is public static so it can be accessed from AboutDialog. It is also used in onCreate(), onOptionsItemSelected(), and loadUrlFromTextBox().
public static WebView mainWebView;
+ // DrawerTottle is use in onCrate() and onPostCreate().
+ private ActionBarDrawerToggle drawerToggle;
// mainMenu is used in onCreateOptionsMenu() and onOptionsItemSelected().
private Menu mainMenu;
// formattedUrlString is used in onCreate(), onOptionsItemSelected(), onCreateHomeScreenShortcutCreate(), and loadUrlFromTextBox().
@SuppressLint("SetJavaScriptEnabled")
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_webview);
+ setContentView(R.layout.coordinator_layout);
// We need to use the SupportActionBar from android.support.v7.app.ActionBar until the minimum API is >= 21.
Toolbar supportAppBar = (Toolbar) findViewById(R.id.appBar);
});
}
+ DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
+ drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, supportAppBar, R.string.open_navigation, R.string.close_navigation);
+
mainWebView.setWebViewClient(new WebViewClient() {
// shouldOverrideUrlLoading makes this WebView the default handler for URLs inside the app, so that links are not kicked out to other apps.
@Override
}
}
+ @Override
+ public void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+
+ // Sync the state of the DrawerToggle after onRestoreInstanceState has finished.
+ drawerToggle.syncState();
+ }
+
@Override
public void onCreateHomeScreenShortcutCancel(DialogFragment dialog) {
// Do nothing because the user selected "Cancel".
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
- Copyright 2015-2016 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/>. -->
-
-<!-- Setting the layout root to be focusableInTouchMode prevents urlTextBox from stealing focus on launch and opening the keyboard. -->
-<android.support.design.widget.CoordinatorLayout
- android:id="@+id/rootCoordinatorLayout"
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- tools:context="com.stoutner.privacybrowser.MainWebViewActivity"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:focusable="true"
- android:focusableInTouchMode="true" >
-
- <android.support.design.widget.AppBarLayout
- android:id="@+id/appBarLayout"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:theme="@style/AppTheme.AppBarOverlay" >
-
- <android.support.v7.widget.Toolbar
- android:id="@+id/appBar"
- android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- android:background="?attr/colorPrimary"
- app:popupTheme="@style/AppTheme.PopupOverlay" />
- </android.support.design.widget.AppBarLayout>
-
- <include layout="@layout/ad_view" />
-
- <!-- fullScreenVideoFrameLayout is used to display full screen videos. It is initially android:visibility="gone" to hide it from view. -->
- <FrameLayout
- android:id="@+id/fullScreenVideoFrameLayout"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:visibility="gone"
- android:background="@color/black" />
-</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
- Copyright 2016 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/>. -->
-
-<!-- android:layout_martinTop="?attr/actionBarSize" moves adRelativeLayout below the appBarLayout, which otherwise would cover the top of mainWebView. -->
-<!-- the RelativeLayout has an id of adView in the standard flavor so that the ad commands (which do nothing in the standard flavor) don't produce errors. -->
-<RelativeLayout
- android:id="@+id/adView"
- 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"
- android:layout_marginTop="?attr/actionBarSize"
- tools:context="com.stoutner.privacybrowser.MainWebViewActivity"
- tools:showIn="@layout/activity_webview" >
-
- <android.support.v4.widget.SwipeRefreshLayout
- android:id="@+id/swipeRefreshLayout"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <!-- Google does not currently want to support hiding the AppBar on scroll for a WebView child with the Support Toolbar. https://code.google.com/p/android/issues/detail?id=200394 -->
- <WebView
- android:id="@+id/mainWebView"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:focusable="true"
- android:focusableInTouchMode="true"/>
- </android.support.v4.widget.SwipeRefreshLayout>
-</RelativeLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Copyright 2015-2016 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/>. -->
+
+<android.support.v4.widget.DrawerLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/drawerLayout"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent" >
+
+ <!-- The main content view. -->
+ <!-- android:fitsSystemWindows="true" moves rootCoordinatorLayout below the system status bar. -->
+ <!-- Setting the layout root to be focusableInTouchMode prevents urlTextBox from stealing focus on launch and opening the keyboard. -->
+ <android.support.design.widget.CoordinatorLayout
+ android:id="@+id/rootCoordinatorLayout"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ tools:context="com.stoutner.privacybrowser.MainWebViewActivity"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:fitsSystemWindows="true"
+ android:focusable="true"
+ android:focusableInTouchMode="true" >
+
+ <android.support.design.widget.AppBarLayout
+ android:id="@+id/appBarLayout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:theme="@style/AppTheme.AppBarOverlay" >
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/appBar"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ android:background="?attr/colorPrimary"
+ app:popupTheme="@style/AppTheme.PopupOverlay" />
+ </android.support.design.widget.AppBarLayout>
+
+ <include layout="@layout/main_webview" />
+
+ <!-- fullScreenVideoFrameLayout is used to display full screen videos. It is initially android:visibility="gone" to hide it from view. -->
+ <FrameLayout
+ android:id="@+id/fullScreenVideoFrameLayout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:visibility="gone"
+ android:background="@color/black" />
+ </android.support.design.widget.CoordinatorLayout>
+
+ <!-- The navigation drawer. -->
+ <ListView
+ android:id="@+id/navigationDrawer"
+ android:layout_width="240dp"
+ android:layout_height="match_parent"
+ android:layout_gravity="start"
+ android:choiceMode="singleChoice"
+ android:background="@color/white"/>
+
+</android.support.v4.widget.DrawerLayout>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Copyright 2016 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/>. -->
+
+<!-- android:layout_martinTop="?attr/actionBarSize" moves the RelativeLayout below the appBarLayout, which otherwise would cover the top of mainWebView. -->
+<!-- the RelativeLayout has an id of adView in the standard flavor so that the ad commands (which do nothing in the standard flavor) don't produce errors. -->
+<RelativeLayout
+ android:id="@+id/adView"
+ 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"
+ android:layout_marginTop="?attr/actionBarSize"
+ tools:context="com.stoutner.privacybrowser.MainWebViewActivity"
+ tools:showIn="@layout/coordinator_layout" >
+
+ <android.support.v4.widget.SwipeRefreshLayout
+ android:id="@+id/swipeRefreshLayout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <!-- Google does not currently want to support hiding the AppBar on scroll for a WebView child with the Support Toolbar. https://code.google.com/p/android/issues/detail?id=200394 -->
+ <WebView
+ android:id="@+id/mainWebView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:focusable="true"
+ android:focusableInTouchMode="true"/>
+ </android.support.v4.widget.SwipeRefreshLayout>
+</RelativeLayout>
+++ /dev/null
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
- Copyright 2016 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/>. -->
-
-<resources>
-
- <!-- android:actionBarSize is supported by API >= 11. actionBarSize is for older versions. -->
- <!-- The default actionBarSize is 56dp. 53dp is the smallest that doesn't cause the urlTextBox to scroll vertically with a font size of Huge. -->
- <style name="AppTheme" parent="Theme.AppCompat.Light">
- <item name="colorAccent">@color/blue</item>
- <item name="android:actionBarSize">53dp</item>
- </style>
-
-</resources>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Copyright 2016 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/>. -->
+
+<resources>
+
+ <!-- The default actionBarSize is 56dp. 53dp is the smallest that doesn't cause the urlTextBox to scroll vertically with a font size of Huge. -->
+ <!-- android:windowTranslucentStatus requires API >= 19. It makes the system status bar transparent. -->
+ <style name="AppTheme" parent="Theme.AppCompat.Light">
+ <item name="colorAccent">@color/blue</item>
+ <item name="android:actionBarSize">53dp</item>
+ </style>
+
+ <style name="AppTheme.NoActionBar">
+ <item name="windowActionBar">false</item>
+ <item name="windowNoTitle">true</item>
+ <item name="android:windowTranslucentStatus">true</item>
+ </style>
+
+ <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.ActionBar" />
+
+ <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
+
+</resources>
\ No newline at end of file
<!-- These color resources are hardcoded for vector drawables. Once the minimum API is >= 22 we can remove the hardcoded colors and reference these entries. -->
<resources>
<color name="black">#FF000000</color>
- <color name="blue">#1e88e5</color>
+ <color name="blue">#FF1976D2</color>
<color name="green">#FF64DD17</color>
<color name="red">#FFD50000</color>
<color name="white">#FFFFFFFF</color>
<string name="both_still_enabled">JavaScript disabled, DOM Storage and Cookies still enabled</string>
<string name="dom_storage_deleted">DOM Storage deleted</string>
<string name="cookies_deleted">Cookies deleted</string>
+ <string name="open_navigation">Open Navigation Drawer</string>
+ <string name="close_navigation">Close Navigation Drawer</string>
<!-- Custom App Bar. -->
<string name="favorite_icon">Favorite Icon</string>
<resources>
- <!-- android:actionBarSize is supported by API >= 11. actionBarSize is for older versions. -->
<!-- The default actionBarSize is 56dp. 53dp is the smallest that doesn't cause the urlTextBox to scroll vertically with a font size of Huge. -->
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="colorAccent">@color/blue</item>
- <item name="actionBarSize">53dp</item>
+ <item name="android:actionBarSize">53dp</item>
</style>
<style name="AppTheme.NoActionBar">
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
-</resources>
+</resources>
\ No newline at end of file