<data android:scheme="https" />
</intent-filter>
</activity>
+
+ <activity
+ android:name=".Settings"
+ android:label="@string/privacy_browser_settings"
+ android:parentActivityName=".MainWebView" >
+
+ <!-- android.support.PARENT_ACTIVITY is necessary for API <= 15. -->
+ <meta-data
+ android:name="android.support.PARENT_ACTIVITY"
+ android:value=".MainWebView" />
+ </activity>
+
</application>
</manifest>
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
+import android.preference.PreferenceManager;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
// formattedUrlString is used in onCreate(), onOptionsItemSelected(), onCreateHomeScreenShortcutCreate(), and loadUrlFromTextBox().
private String formattedUrlString;
// homepage is used in onCreate() and onOptionsItemSelected().
- private String homepage = "https://www.duckduckgo.com/";
+ private String homepage;
// javaScriptEnabled is used in onCreate(), onCreateOptionsMenu(), onOptionsItemSelected(), and loadUrlFromTextBox().
private boolean javaScriptEnabled;
// domStorageEnabled is used in onCreate(), onCreateOptionsMenu(), and onOptionsItemSelected().
mainWebView.getSettings().setDisplayZoomControls(false);
}
+ // Initialize the default preference values the first time the program is run.
+ PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
+
+ // Get the shared preference values.
+ SharedPreferences savedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
+
// Set JavaScript initial status.
- javaScriptEnabled = false;
+ javaScriptEnabled = savedPreferences.getBoolean("javascript_enabled", false);
mainWebView.getSettings().setJavaScriptEnabled(javaScriptEnabled);
- // Set DOM Storage initial status.
- domStorageEnabled = false;
+ // Set DOM storage initial status.
+ domStorageEnabled = savedPreferences.getBoolean("dom_storage_enabled", false);
mainWebView.getSettings().setDomStorageEnabled(domStorageEnabled);
/* Save Form Data does nothing until database storage is implemented.
mainWebView.getSettings().setSaveFormData(saveFormDataEnabled);
*/
- // Set Cookies initial status.
- cookiesEnabled = false;
+ // Set cookies initial status.
+ cookiesEnabled = savedPreferences.getBoolean("cookies_enabled", false);
cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(cookiesEnabled);
+ // Set hompage initial status.
+ homepage = savedPreferences.getString("homepage", "https://www.duckduckgo.com");
+
// Get the intent information that started the app.
final Intent intent = getIntent();
startActivity(downloadManangerIntent);
return true;
+ case R.id.settings:
+ // Start the Settings activity.
+ Intent intent = new Intent(this, Settings.class);
+ startActivity(intent);
+ return true;
+
case R.id.about:
// Show the AboutDialog AlertDialog and name this instance aboutDialog.
AppCompatDialogFragment aboutDialog = new AboutDialog();
--- /dev/null
+/**
+ * Copyright 2016 Soren Stoutner <soren@stoutner.com>.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+package com.stoutner.privacybrowser;
+
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+
+public class Settings extends PreferenceActivity {
+ @Override
+ // Once the minimum API is >= 11 we can switch from the deprecated PreferenceActivity to using a PreferenceFragment.
+ @SuppressWarnings("deprecation")
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.preferences);
+ }
+}
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
+
+ <!-- The fillColor must be hardcoded in this file unitl the minimum API is >= 22. Then the resources in colors.xml may be used instead. -->
<path
android:fillColor="#FFD50000"
android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zm0,-8c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/>
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
+
+ <!-- The fillColor must be hardcoded in this file unitl the minimum API is >= 22. Then the resources in colors.xml may be used instead. -->
<path
android:fillColor="#FF64DD17"
android:pathData="M12,7c2.76,0 5,2.24 5,5 0,0.65 -0.13,1.26 -0.36,1.83l2.92,2.92c1.51,-1.26 2.7,-2.89 3.43,-4.75 -1.73,-4.39 -6,-7.5 -11,-7.5 -1.4,0 -2.74,0.25 -3.98,0.7l2.16,2.16C10.74,7.13 11.35,7 12,7zM2,4.27l2.28,2.28 0.46,0.46C3.08,8.3 1.78,10.02 1,12c1.73,4.39 6,7.5 11,7.5 1.55,0 3.03,-0.3 4.38,-0.84l0.42,0.42L19.73,22 21,20.73 3.27,3 2,4.27zM7.53,9.8l1.55,1.55c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.66 1.34,3 3,3 0.22,0 0.44,-0.03 0.65,-0.08l1.55,1.55c-0.67,0.33 -1.41,0.53 -2.2,0.53 -2.76,0 -5,-2.24 -5,-5 0,-0.79 0.2,-1.53 0.53,-2.2zm4.31,-0.78l3.15,3.15 0.02,-0.16c0,-1.66 -1.34,-3 -3,-3l-0.17,0.01z"/>
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
+
+ <!-- The fillColor must be hardcoded in this file unitl the minimum API is >= 22. Then the resources in colors.xml may be used instead. -->
<path
android:fillColor="#FFFFD600"
android:pathData="M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zm0,-8c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z"/>
+<?xml version="1.0" encoding="utf-8"?>
+
<!--
Copyright 2015 Soren Stoutner <soren@stoutner.com>.
+<?xml version="1.0" encoding="utf-8"?>
+
<!--
Copyright 2015-2016 Soren Stoutner <soren@stoutner.com>.
android:orderInCategory="90"
app:showAsAction="never" />
+ <item
+ android:id="@+id/settings"
+ android:title="@string/settings"
+ android:orderInCategory="100"
+ app:showAsAction="never" />
+
<item
android:id="@+id/about"
android:title="@string/about"
- android:orderInCategory="100"
+ android:orderInCategory="110"
app:showAsAction="never" />
<item
android:id="@+id/clearAndExit"
android:title="@string/clear_and_exit"
- android:orderInCategory="110"
+ android:orderInCategory="120"
app:showAsAction="never" />
</menu>
+<?xml version="1.0" encoding="utf-8"?>
+
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
--- /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/>. -->
+
+<!-- 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="green">#FF64DD17</color>
+ <color name="red">#FFD50000</color>
+ <color name="yellow">#FFFFD600</color>
+</resources>
\ No newline at end of file
+<?xml version="1.0" encoding="utf-8"?>
+
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
+<?xml version="1.0" encoding="utf-8"?>
+
<!--
Copyright 2015-2016 Soren Stoutner <soren@stoutner.com>.
<resources>
<!-- Activities. -->
<string name="privacy_browser">Privacy Browser</string>
+ <string name="privacy_browser_settings">Privacy Browser Settings</string>
<!-- Custom App Bar. -->
<string name="favorite_icon">Favorite Icon</string>
<string name="share_url">Share URL</string>
<string name="add_to_home_screen">Add to Home Screen</string>
<string name="downloads">Downloads</string>
+ <string name="settings">Settings</string>
<string name="about">About</string>
<string name="clear_and_exit">Clear and Exit</string>
<string name="cancel">Cancel</string>
<string name="create">Create</string>
+ <!-- Preferences. -->
+ <string name="privacy_settings">Privacy Settings</string>
+ <string name="javascript_preference">JavaScript</string>
+ <string name="javascript_preference_summary">Enable JavaScript by default</string>
+ <string name="dom_storage_preference">DOM Storage</string>
+ <string name="dom_storage_preference_summary">Enable DOM storage by default</string>
+ <string name="cookies_preference">Cookies</string>
+ <string name="cookies_preference_summary">Enable cookies by default</string>
+ <string name="general_settings">General Settings</string>
+ <string name="homepage_preference">Homepage</string>
+ <string name="homepage_preference_summary">Set the homepage</string>
+
<!-- About Dialog. -->
<string name="about_privacy_browser">About Privacy Browser</string>
<string name="dismiss">Dismiss</string>
+<?xml version="1.0" encoding="utf-8"?>
+
<!--
- Copyright 2015 Soren Stoutner <soren@stoutner.com>.
+ Copyright 2015-2016 Soren Stoutner <soren@stoutner.com>.
This file is part of Privacy Browser <https://privacybrowser.stoutner.com/>.
--- /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/>. -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
+ <PreferenceCategory
+ android:key="privacy_settings"
+ android:title="@string/privacy_settings" >
+
+ <CheckBoxPreference
+ android:key="javascript_enabled"
+ android:title="@string/javascript_preference"
+ android:summary="@string/javascript_preference_summary"
+ android:defaultValue="false" />
+
+ <CheckBoxPreference
+ android:key="dom_storage_enabled"
+ android:title="@string/dom_storage_preference"
+ android:summary="@string/dom_storage_preference_summary"
+ android:defaultValue="false" />
+
+ <CheckBoxPreference
+ android:key="cookies_enabled"
+ android:title="@string/cookies_preference"
+ android:summary="@string/cookies_preference_summary"
+ android:defaultValue="false" />
+ </PreferenceCategory>
+
+ <PreferenceCategory
+ android:key="general_settings"
+ android:title="@string/general_settings" >
+
+ <EditTextPreference
+ android:key="homepage"
+ android:title="@string/homepage_preference"
+ android:summary="@string/homepage_preference_summary"
+ android:defaultValue="https://www.duckduckgo.com" />
+ </PreferenceCategory>
+</PreferenceScreen>
\ No newline at end of file