diff --git a/app/build.gradle b/app/build.gradle
index 0c42440c..df66f58a 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -35,7 +35,7 @@ android {
buildTypes {
release {
- minifyEnabled false
+ minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
@@ -43,21 +43,19 @@ android {
productFlavors {
standard {
applicationId "com.stoutner.privacybrowser.standard"
- versionName "1.1-standard"
+ versionName "1.2-standard"
}
free {
applicationId "com.stoutner.privacybrowser.free"
- versionName "1.1-free"
+ versionName "1.2-free"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:appcompat-v7:23.2.1'
- compile 'com.android.support:design:23.2.1'
- compile 'com.android.support:support-v4:23.2.1'
+ compile 'com.android.support:design:23.3.0'
// Only compile com.google.android.gms:play-services-ads for the free version so that the standard version can build of F-Droid.
freeCompile 'com.google.android.gms:play-services-ads:8.4.0'
}
diff --git a/app/src/main/assets/about_text.html b/app/src/main/assets/about_text.html
index fc6db0a3..9a5a27b4 100644
--- a/app/src/main/assets/about_text.html
+++ b/app/src/main/assets/about_text.html
@@ -13,9 +13,27 @@
which is part of the Android Material icon set. It is released under the CC-BY license.
Modifications were made by Soren Stoutner in 2016.
-
/app.src/main/res/drawable/world.xml is part of the Android Material icon set, where it is named ic_language.
+
app/src/main/res/drawable/world.xml is part of the Android Material icon set, where it is named ic_language.
It is released under the CC-BY license. Changes to fill color and size were made by Soren Stoutner in 2016.
+
app/src/main/res/drawable/back.xml is part of the Android Material icon set, where it is named ic_arrow_back.
+ It is released under the CC-BY license.
+
+
app/src/main/res/drawable/forward.xml is part of the Android Material icon set, where it is named ic_arrow_forward.
+ It is released under the CC-BY license.
+
+
app/src/main/res/drawable/settings.xml is part of the Android Material icon set, where it is named ic_settings.
+ It is released under the CC-BY license.
+
+
app/src/main/res/drawable/downloads.xml is part of the Android Material icon set, where it is named ic_file_download.
+ It is released under the CC-BY license.
+
+
app/src/main/res/drawable/exit.xml is part of the Android Material icon set, where it is named ic_exit_to_app.
+ It is released under the CC-BY license.
+
+
app/src/main/res/drawable/about.xml is part of the Android Material icon set, where it is named ic_info.
+ It is released under the CC-BY license.
+
diff --git a/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java
index 96f49b5b..13600840 100644
--- a/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java
+++ b/app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java
@@ -24,13 +24,16 @@ import android.app.Activity;
import android.app.DownloadManager;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
+import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.app.DialogFragment;
+import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBar;
@@ -61,14 +64,16 @@ import java.net.URL;
import java.net.URLEncoder;
// We need to use AppCompatActivity from android.support.v7.app.AppCompatActivity to have access to the SupportActionBar until the minimum API is >= 21.
-public class MainWebViewActivity extends AppCompatActivity implements CreateHomeScreenShortcut.CreateHomeScreenSchortcutListener {
+public class MainWebViewActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener, CreateHomeScreenShortcut.CreateHomeScreenSchortcutListener {
// favoriteIcon is public static so it can be accessed from CreateHomeScreenShortcut.
public static Bitmap favoriteIcon;
- // mainWebView is public static so it can be accessed from AboutDialog. It is also used in onCreate(), onOptionsItemSelected(), and loadUrlFromTextBox().
+ // mainWebView is public static so it can be accessed from AboutDialog. It is also used in onCreate(), onOptionsItemSelected(), onNavigationItemSelected(), and loadUrlFromTextBox().
public static WebView mainWebView;
- // DrawerTottle is use in onCrate() and onPostCreate().
+ // drawerToggle is used in onCreate(), onPostCreate(), onConfigurationChanged(), onNewIntent(), and onNavigationItemSelected().
private ActionBarDrawerToggle drawerToggle;
+ // drawerLayout is used in onCreate(), onNewIntent(), and onBackPressed().
+ private DrawerLayout drawerLayout;
// mainMenu is used in onCreateOptionsMenu() and onOptionsItemSelected().
private Menu mainMenu;
// formattedUrlString is used in onCreate(), onOptionsItemSelected(), onCreateHomeScreenShortcutCreate(), and loadUrlFromTextBox().
@@ -85,7 +90,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
private boolean saveFormDataEnabled;
*/
- // cookieManager is used in onCreate() and onOptionsItemSelected().
+ // cookieManager is used in onCreate(), onOptionsItemSelected(), and onNavigationItemSelected().
private CookieManager cookieManager;
// cookiesEnabled is used in onCreate(), onCreateOptionsMenu(), and onOptionsItemSelected().
private boolean cookiesEnabled;
@@ -151,7 +156,16 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
});
}
- DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
+ // Create the navigation drawer.
+ drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
+ // The DrawerTitle identifies the drawer in accessibility mode.
+ drawerLayout.setDrawerTitle(GravityCompat.START, getString(R.string.navigation_drawer));
+
+ // Listen for touches on the navigation menu.
+ final NavigationView navigationView = (NavigationView) findViewById(R.id.navigationView);
+ navigationView.setNavigationItemSelectedListener(this);
+
+ // drawerToggle creates the hamburger icon at the start of the AppBar.
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, supportAppBar, R.string.open_navigation, R.string.close_navigation);
mainWebView.setWebViewClient(new WebViewClient() {
@@ -352,6 +366,11 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
formattedUrlString = intentUriData.toString();
}
+ // Close the navigation drawer if it is open.
+ if (drawerLayout.isDrawerVisible(GravityCompat.START)) {
+ drawerLayout.closeDrawer(GravityCompat.START);
+ }
+
// Load the website.
mainWebView.loadUrl(formattedUrlString);
@@ -362,7 +381,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
- getMenuInflater().inflate(R.menu.menu_webview, menu);
+ getMenuInflater().inflate(R.menu.menu_options, menu);
// Set mainMenu so it can be used by onOptionsItemSelected.
mainMenu = menu;
@@ -402,14 +421,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
MenuItem clearCookies = menu.findItem(R.id.clearCookies);
clearCookies.setEnabled(cookieManager.hasCookies());
- // Enable Back if canGoBack().
- MenuItem back = menu.findItem(R.id.back);
- back.setEnabled(mainWebView.canGoBack());
-
- // Enable forward if canGoForward().
- MenuItem forward = menu.findItem(R.id.forward);
- forward.setEnabled(mainWebView.canGoForward());
-
// Run all the other default commands.
super.onPrepareOptionsMenu(menu);
@@ -556,6 +567,14 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
Snackbar.make(findViewById(R.id.mainWebView), R.string.cookies_deleted, Snackbar.LENGTH_SHORT).show();
return true;
+ case R.id.share:
+ Intent shareIntent = new Intent();
+ shareIntent.setAction(Intent.ACTION_SEND);
+ shareIntent.putExtra(Intent.EXTRA_TEXT, urlTextBox.getText().toString());
+ shareIntent.setType("text/plain");
+ startActivity(Intent.createChooser(shareIntent, "Share URL"));
+ return true;
+
case R.id.addToHomescreen:
// Show the CreateHomeScreenShortcut AlertDialog and name this instance createShortcut.
AppCompatDialogFragment shortcutDialog = new CreateHomeScreenShortcut();
@@ -564,47 +583,55 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
//Everything else will be handled by CreateHomeScreenShortcut and the associated listeners below.
return true;
- case R.id.downloads:
- // Launch the system Download Manager.
- Intent downloadManagerIntent = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS);
-
- // Launch as a new task so that Download Manager and Privacy Browser show as separate windows in the recent tasks list.
- downloadManagerIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ default:
+ return super.onOptionsItemSelected(menuItem);
+ }
+ }
- startActivity(downloadManagerIntent);
- return true;
+ @Override
+ // removeAllCookies is deprecated, but it is required for API < 21.
+ @SuppressWarnings("deprecation")
+ public boolean onNavigationItemSelected(MenuItem menuItem) {
+ int menuItemId = menuItem.getItemId();
+ switch (menuItemId) {
case R.id.home:
mainWebView.loadUrl(homepage);
- return true;
+ break;
case R.id.back:
- mainWebView.goBack();
- return true;
+ if (mainWebView.canGoBack()) {
+ mainWebView.goBack();
+ }
+ break;
case R.id.forward:
- mainWebView.goForward();
- return true;
+ if (mainWebView.canGoForward()) {
+ mainWebView.goForward();
+ }
+ break;
- case R.id.share:
- Intent shareIntent = new Intent();
- shareIntent.setAction(Intent.ACTION_SEND);
- shareIntent.putExtra(Intent.EXTRA_TEXT, urlTextBox.getText().toString());
- shareIntent.setType("text/plain");
- startActivity(Intent.createChooser(shareIntent, "Share URL"));
- return true;
+ case R.id.downloads:
+ // Launch the system Download Manager.
+ Intent downloadManagerIntent = new Intent(DownloadManager.ACTION_VIEW_DOWNLOADS);
+
+ // Launch as a new task so that Download Manager and Privacy Browser show as separate windows in the recent tasks list.
+ downloadManagerIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+
+ startActivity(downloadManagerIntent);
+ break;
case R.id.settings:
// Launch SettingsActivity.
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
- return true;
+ break;
case R.id.about:
// Show the AboutDialog AlertDialog and name this instance aboutDialog.
AppCompatDialogFragment aboutDialog = new AboutDialog();
aboutDialog.show(getSupportFragmentManager(), "aboutDialog");
- return true;
+ break;
case R.id.clearAndExit:
// Clear DOM storage.
@@ -627,11 +654,15 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
} else {
finish();
}
- return true;
+ break;
default:
- return super.onOptionsItemSelected(menuItem);
+ break;
}
+
+ // Close the navigation drawer.
+ drawerLayout.closeDrawer(GravityCompat.START);
+ return true;
}
@Override
@@ -642,6 +673,14 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
drawerToggle.syncState();
}
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ // Update the status of the drawerToggle icon.
+ drawerToggle.onConfigurationChanged(newConfig);
+ }
+
@Override
public void onCreateHomeScreenShortcutCancel(DialogFragment dialog) {
// Do nothing because the user selected "Cancel".
@@ -666,15 +705,22 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateHome
sendBroadcast(placeBookmarkShortcut);
}
- // Override onBackPressed so that if mainWebView can go back it does when the system back button is pressed.
+ // Override onBackPressed to handle the navigation drawer and mainWebView.
@Override
public void onBackPressed() {
final WebView mainWebView = (WebView) findViewById(R.id.mainWebView);
- if (mainWebView.canGoBack()) {
- mainWebView.goBack();
+ // Close the navigation drawer if it is available. GravityCompat.START is the drawer on the left on Left-to-Right layout text.
+ if (drawerLayout.isDrawerVisible(GravityCompat.START)) {
+ drawerLayout.closeDrawer(GravityCompat.START);
} else {
- super.onBackPressed();
+ // Load the previous URL if available.
+ if (mainWebView.canGoBack()) {
+ mainWebView.goBack();
+ } else {
+ // Pass onBackPressed to the system.
+ super.onBackPressed();
+ }
}
}
diff --git a/app/src/main/res/drawable/about.xml b/app/src/main/res/drawable/about.xml
new file mode 100644
index 00000000..52f03076
--- /dev/null
+++ b/app/src/main/res/drawable/about.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/back.xml b/app/src/main/res/drawable/back.xml
new file mode 100644
index 00000000..beafea39
--- /dev/null
+++ b/app/src/main/res/drawable/back.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/downloads.xml b/app/src/main/res/drawable/downloads.xml
new file mode 100644
index 00000000..492b41d3
--- /dev/null
+++ b/app/src/main/res/drawable/downloads.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/exit.xml b/app/src/main/res/drawable/exit.xml
new file mode 100644
index 00000000..6f40d772
--- /dev/null
+++ b/app/src/main/res/drawable/exit.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/forward.xml b/app/src/main/res/drawable/forward.xml
new file mode 100644
index 00000000..cf9e208e
--- /dev/null
+++ b/app/src/main/res/drawable/forward.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/home.xml b/app/src/main/res/drawable/home.xml
new file mode 100644
index 00000000..70fb2910
--- /dev/null
+++ b/app/src/main/res/drawable/home.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/drawable/settings.xml b/app/src/main/res/drawable/settings.xml
new file mode 100644
index 00000000..ace746c4
--- /dev/null
+++ b/app/src/main/res/drawable/settings.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/app/src/main/res/layout/coordinator_layout.xml b/app/src/main/res/layout/coordinator_layout.xml
index 4f11f609..fae9a510 100644
--- a/app/src/main/res/layout/coordinator_layout.xml
+++ b/app/src/main/res/layout/coordinator_layout.xml
@@ -20,9 +20,10 @@
+ android:layout_width="match_parent">
@@ -65,12 +66,12 @@
-
+ app:headerLayout="@layout/navigation_header"
+ app:menu="@menu/menu_navigation"/>
\ No newline at end of file
diff --git a/app/src/main/res/layout/navigation_header.xml b/app/src/main/res/layout/navigation_header.xml
new file mode 100644
index 00000000..7ed9685e
--- /dev/null
+++ b/app/src/main/res/layout/navigation_header.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
diff --git a/app/src/main/res/menu/menu_navigation.xml b/app/src/main/res/menu/menu_navigation.xml
new file mode 100644
index 00000000..6e5a31f3
--- /dev/null
+++ b/app/src/main/res/menu/menu_navigation.xml
@@ -0,0 +1,72 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_webview.xml b/app/src/main/res/menu/menu_options.xml
similarity index 64%
rename from app/src/main/res/menu/menu_webview.xml
rename to app/src/main/res/menu/menu_options.xml
index a8c38b4a..e6bdeadd 100644
--- a/app/src/main/res/menu/menu_webview.xml
+++ b/app/src/main/res/menu/menu_options.xml
@@ -65,65 +65,15 @@
android:orderInCategory="60"
app:showAsAction="never" />
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 6cf2bf62..f8a25db2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -40,23 +40,26 @@
Favorite Icon
-
- JavaScript
- DOM Storage
- Cookies
- Clear DOM Storage
- Clear Cookies
- Add to Home Screen
- Downloads
+
+ Navigation DrawerNavigationHomeBackForward
- Share
+ DownloadsSettingsAboutClear and Exit
+
+ JavaScript
+ DOM Storage
+ Cookies
+ Clear DOM Storage
+ Clear Cookies
+ Share
+ Add to Home Screen
+
Shortcut nameCancel
diff --git a/build.gradle b/build.gradle
index a6fcfe1f..cb984014 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.5.0'
+ classpath 'com.android.tools.build:gradle:2.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 0c71e760..60509da6 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Wed Apr 10 15:27:10 PDT 2013
+#Thu Apr 07 11:52:03 MST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
--
2.45.2