<dictionary name="soren">
<words>
<w>duckduckgo</w>
+ <w>privacybrowser</w>
<w>rehide</w>
<w>rehides</w>
<w>soren</w>
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.1.1/jars" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/design/23.1.1/jars" />
+ <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
+ <orderEntry type="library" exported="" name="design-23.1.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
</component>
</module>
\ No newline at end of file
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.1'
+ compile 'com.android.support:design:23.1.1'
+ compile 'com.android.support:support-v4:23.1.1'
}
<!-- Required to create homescreen shortcuts. -->
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
+ <!-- on API >= 23, app data is automatically backed up to Google cloud servers unless android:allowBackup="false" and android:fullBackupContent="false" is set. -->
<application
android:allowBackup="false"
android:fullBackupContent="false"
android:name=".MainWebViewActivity"
android:configChanges="orientation|screenSize"
android:label="@string/privacy_browser"
- android:launchMode="singleTask">
+ android:launchMode="singleTask"
+ android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.DialogFragment;
+import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatDialogFragment;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.view.Window;
import android.view.inputmethod.InputMethodManager;
import android.webkit.CookieManager;
import android.webkit.DownloadListener;
private EditText urlTextBox;
@Override
- // Remove Android Studio's warning about the dangers of using SetJavaScriptEnabled.
+ // Remove Android Studio's warning about the dangers of using SetJavaScriptEnabled. The whole premise of Privacy Browser is built around an understanding of these dangers.
@SuppressLint("SetJavaScriptEnabled")
protected void onCreate(Bundle savedInstanceState) {
- // Window.FEATURE_ACTION_BAR_OVERLAY must be enabled to set the app bar to HideOnContentScroll. It must be set before any content is added to the activity.
- if (Build.VERSION.SDK_INT >= 11) {
- requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
- }
-
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
// We need to use the SupportActionBar from android.support.v7.app.ActionBar until the minimum API is >= 21.
final ActionBar appBar = getSupportActionBar();
- mainWebView = (WebView) findViewById(R.id.mainWebView);
-
- if (appBar != null) {
- /* TODO Enable app bar scrolling.
- // Scroll the app bar, but only if the API supports overlay mode (>= 11).
- if (Build.VERSION.SDK_INT >= 11) {
- appBar.setHideOnContentScrollEnabled(true);
+ // Implement swipe to refresh
+ final SwipeRefreshLayout swipeToRefresh = (SwipeRefreshLayout) findViewById(R.id.swipeRefreshLayout);
+ swipeToRefresh.setColorSchemeResources(R.color.blue);
+ swipeToRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+ @Override
+ public void onRefresh() {
+ mainWebView.reload();
}
- */
+ });
- // Remove the title from the app bar.
- appBar.setDisplayShowTitleEnabled(false);
+ mainWebView = (WebView) findViewById(R.id.mainWebView);
+ if (appBar != null) {
// Add the custom url_bar layout, which shows the favoriteIcon, urlTextBar, and progressBar.
appBar.setCustomView(R.layout.url_bar);
appBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
progressBar.setVisibility(View.VISIBLE);
} else {
progressBar.setVisibility(View.GONE);
+
+ //Stop the SwipeToRefresh indicator if it is running
+ swipeToRefresh.setRefreshing(false);
}
}
}
// Load the website.
mainWebView.loadUrl(formattedUrlString);
+
+ // Clear the keyboard if displayed and remove the focus on the urlTextBar if it has it.
+ mainWebView.requestFocus();
}
@Override
mainWebView.loadUrl(homepage);
return true;
- case R.id.refresh:
- mainWebView.reload();
- return true;
-
case R.id.back:
mainWebView.goBack();
return true;
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. -->
-<RelativeLayout
- android:id="@+id/rootRelativeLayout"
+<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.v7.widget.Toolbar
- android:id="@+id/appBar"
+ <android.support.design.widget.AppBarLayout
+ android:id="@+id/appBarLayout"
android:layout_width="match_parent"
- android:layout_height="?attr/actionBarSize"
- android:background="?attr/colorPrimary"
- android:elevation="4dp"
- android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
- app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
-
- <WebView
- android:id="@+id/mainWebView"
- android:layout_below="@id/appBar"
+ 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>
+
+ <!-- android:layout_martinTop="?attr/actionBarSize" moves the SwipeRefreshLayout below the AppBarLayout, which otherwise would cover the top of the WebView. -->
+ <android.support.v4.widget.SwipeRefreshLayout
+ android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:focusable="true"
- android:focusableInTouchMode="true" />
+ android:layout_marginTop="?attr/actionBarSize">
+
+ <!-- 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>
<!-- fullScreenVideoFrameLayout is used to display full screen videos. It is initially android:visibility="gone" to hide it from view. -->
<FrameLayout
android:layout_height="match_parent"
android:visibility="gone"
android:background="@color/black" />
-</RelativeLayout>
+</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
android:layout_width="match_parent"
android:layout_height="wrap_content">
+ <!-- RelativeLayout is used instead of a LinearLayout because supportAppBar does not let android:layout_weight="1" to cause urlTextBox to fill all the available space. -->
<RelativeLayout
android:id="@+id/addressBarRelativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Set the program icon as the initial favoriteIcon. -->
- <!-- layout_width and layout_height of 28dp matches the appBar icons. -->
+ <!-- layout_width and layout_height of 26dp matches the AppBar icons. -->
<ImageView
android:id="@+id/favoriteIcon"
android:src="@drawable/ic_language_black_24dp"
- android:layout_width="28dp"
- android:layout_height="28dp"
+ android:layout_width="26dp"
+ android:layout_height="26dp"
android:layout_centerVertical="true"
android:contentDescription="@string/favorite_icon"/>
android:layout_height="3dp"
android:layout_gravity="bottom"
android:max="100"
- android:progressTint="@color/light_blue"
+ android:progressTint="@color/blue"
android:progressBackgroundTint="@color/white"
android:visibility="gone" />
+
</FrameLayout>
\ No newline at end of file
android:orderInCategory="91"
app:showAsAction="never" />
- <item
- android:id="@+id/refresh"
- android:title="@string/refresh"
- android:orderInCategory="92"
- app:showAsAction="never" />
-
<item
android:id="@+id/back"
android:title="@string/back"
- android:orderInCategory="93"
+ android:orderInCategory="92"
app:showAsAction="never" />
<item
android:id="@+id/forward"
android:title="@string/forward"
- android:orderInCategory="94"
+ android:orderInCategory="93"
app:showAsAction="never" />
</menu>
</item>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+
+ This file is part of Privacy Browser <https://privacybrowser.stoutner.com/>.
+
+ 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
<!-- 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="light_blue">#FF0091EA</color>
+ <color name="blue">#1e88e5</color>
<color name="green">#FF64DD17</color>
<color name="red">#FFD50000</color>
<color name="white">#FFFFFFFF</color>
<resources>
- <!-- We want to use .NoActionBar so that we can set a SupportActionBar. -->
<!-- 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.NoActionBar">
- <item name="colorAccent">@color/light_blue</item>
- <item name="android:actionBarSize">53dp</item>
+ <style name="AppTheme" parent="Theme.AppCompat.Light">
+ <item name="colorAccent">@color/blue</item>
<item name="actionBarSize">53dp</item>
</style>
+ <style name="AppTheme.NoActionBar">
+ <item name="windowActionBar">false</item>
+ <item name="windowNoTitle">true</item>
+ </style>
+
+ <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.ActionBar" />
+
+ <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
+
</resources>
android:key="privacy_settings"
android:title="@string/privacy_settings" >
- <CheckBoxPreference
+ <SwitchPreference
android:key="javascript_enabled"
android:title="@string/javascript_preference"
android:summary="@string/javascript_preference_summary"
android:defaultValue="false" />
- <CheckBoxPreference
+ <SwitchPreference
android:key="dom_storage_enabled"
android:title="@string/dom_storage_preference"
android:summary="@string/dom_storage_preference_summary"
android:defaultValue="false" />
- <CheckBoxPreference
+ <SwitchPreference
android:key="cookies_enabled"
android:title="@string/cookies_preference"
android:summary="@string/cookies_preference_summary"
android:key="homepage"
android:title="@string/homepage_preference"
android:summary="@string/homepage_preference_summary"
- android:defaultValue="https://www.duckduckgo.com" />
+ android:defaultValue="https://www.duckduckgo.com"
+ android:singleLine="true"/>
</PreferenceCategory>
</PreferenceScreen>
\ No newline at end of file