]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Partial Find on Page implimentation.
authorSoren Stoutner <soren@stoutner.com>
Sun, 23 Oct 2016 00:28:58 +0000 (17:28 -0700)
committerSoren Stoutner <soren@stoutner.com>
Sun, 23 Oct 2016 00:28:58 +0000 (17:28 -0700)
16 files changed:
app/build.gradle
app/src/main/assets/de/about_licenses.html
app/src/main/assets/en/about_licenses.html
app/src/main/assets/en/images/ic_close.png [new file with mode: 0644]
app/src/main/assets/en/images/ic_expand_less.png [new file with mode: 0644]
app/src/main/assets/en/images/ic_expand_more.png [new file with mode: 0644]
app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java
app/src/main/res/drawable/close.xml [new file with mode: 0644]
app/src/main/res/drawable/next.xml [new file with mode: 0644]
app/src/main/res/drawable/previous.xml [new file with mode: 0644]
app/src/main/res/layout/find_on_page_app_bar.xml [new file with mode: 0644]
app/src/main/res/layout/url_app_bar.xml [new file with mode: 0644]
app/src/main/res/layout/url_bar.xml [deleted file]
app/src/main/res/menu/webview_options_menu.xml
app/src/main/res/values/strings.xml
build.gradle

index 3f2a08d4bd4520c8bb76de7a2aba159bba7404e0..823eb5e86be9be0f25bd938a127aebca897025df 100644 (file)
@@ -60,5 +60,5 @@ dependencies {
     compile fileTree(dir: 'libs', include: ['*.jar'])
     compile 'com.android.support:design:24.2.1'
     // Only compile `com.google.android.gms:play-services-ads` for the free flavor.
-    freeCompile 'com.google.android.gms:play-services-ads:9.6.1'
+    freeCompile 'com.google.android.gms:play-services-ads:9.8.00'
 }
index 83ee46c002a1600f14233daf5b78206e29183c59..a4aa2f0c8365e04d1c419c61502ae5a40e0d69d1 100644 (file)
 <p><img class="icon" src="../en/images/ic_vertical_align_top.png"> ic_vertical_align_top.</p>
 
 <p><img class="icon" src="../en/images/ic_web.png"> ic_web.</p>
+
+<p><img class="icon" src="../en/images/ic_expand_less.png"> ic_expand_less.</p>
+
+<p><img class="icon" src="../en/images/ic_expand_more.png"> ic_expand_more.</p>
+
+<p><img class="icon" src="../en/images/ic_close.png"> ic_close.</p>
+
 <hr/>
 
 <h3>GNU General Public License</h3>
index 9c46415e2be64887da042c3e683711cbefb2d88a..3ee97602c7f410f83e678dc36cea71eba0b63be0 100644 (file)
 
 <p><img class="icon" src="images/ic_web.png"> ic_web.</p>
 
+<p><img class="icon" src="images/ic_expand_less.png"> ic_expand_less.</p>
+
+<p><img class="icon" src="images/ic_expand_more.png"> ic_expand_more.</p>
+
+<p><img class="icon" src="images/ic_close.png"> ic_close.</p>
+
 <br/>
 
 <p><img class="left" src="images/cookie.png"> cookie was created by Google.
     It is released under the <a href ="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>
     and can be downloaded from <a href="https://materialdesignicons.com/icon/cookie">Material Design Icons</a>.</p>
+
 <hr/>
 
 <h3>GNU General Public License</h3>
diff --git a/app/src/main/assets/en/images/ic_close.png b/app/src/main/assets/en/images/ic_close.png
new file mode 100644 (file)
index 0000000..0f1086a
Binary files /dev/null and b/app/src/main/assets/en/images/ic_close.png differ
diff --git a/app/src/main/assets/en/images/ic_expand_less.png b/app/src/main/assets/en/images/ic_expand_less.png
new file mode 100644 (file)
index 0000000..1140aa2
Binary files /dev/null and b/app/src/main/assets/en/images/ic_expand_less.png differ
diff --git a/app/src/main/assets/en/images/ic_expand_more.png b/app/src/main/assets/en/images/ic_expand_more.png
new file mode 100644 (file)
index 0000000..897b306
Binary files /dev/null and b/app/src/main/assets/en/images/ic_expand_more.png differ
index a27dddb2cf11cd00dd3232d147e38709c321c860..7872677dcceaa4f9c83eb532584bd4dd0b63a191 100644 (file)
@@ -81,7 +81,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
         SslCertificateError.SslCertificateErrorListener, DownloadFile.DownloadFileListener {
 
     // `appBar` is public static so it can be accessed from `OrbotProxyHelper`.
-    // It is also used in `onCreate()`.
+    // It is also used in `onCreate()` and `onOptionsItemSelected()`.
     public static ActionBar appBar;
 
     // `favoriteIcon` is public static so it can be accessed from `CreateHomeScreenShortcut`, `BookmarksActivity`, `CreateBookmark`, `CreateBookmarkFolder`, and `EditBookmark`.
@@ -154,6 +154,8 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
     // `sslErrorHandler` is used in `onCreate()`, `onSslErrorCancel()`, and `onSslErrorProceed`.
     private SslErrorHandler sslErrorHandler;
 
+    private MenuItem toggleJavaScript;
+
     @Override
     // 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")
@@ -169,8 +171,8 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
         // This is needed to get rid of the Android Studio warning that appBar might be null.
         assert appBar != null;
 
-        // Add the custom url_bar layout, which shows the favoriteIcon, urlTextBar, and progressBar.
-        appBar.setCustomView(R.layout.url_bar);
+        // Add the custom url_app_bar layout, which shows the favoriteIcon, urlTextBar, and progressBar.
+        appBar.setCustomView(R.layout.url_app_bar);
         appBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
 
         // Set the "go" button on the keyboard to load the URL in urlTextBox.
@@ -441,6 +443,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
         updatePrivacyIcons();
 
         // Get handles for the menu items.
+        toggleJavaScript = menu.findItem(R.id.toggleJavaScript);
         MenuItem toggleFirstPartyCookies = menu.findItem(R.id.toggleFirstPartyCookies);
         MenuItem toggleThirdPartyCookies = menu.findItem(R.id.toggleThirdPartyCookies);
         MenuItem toggleDomStorage = menu.findItem(R.id.toggleDomStorage);
@@ -732,6 +735,12 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
                 mainWebView.getSettings().setTextZoom(200);
                 return true;
 
+            case R.id.find_on_page:
+                appBar.setCustomView(R.layout.find_on_page_app_bar);
+                toggleJavaScript.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
+                appBar.invalidateOptionsMenu();
+                return true;
+
             case R.id.share:
                 Intent shareIntent = new Intent();
                 shareIntent.setAction(Intent.ACTION_SEND);
@@ -896,7 +905,7 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
         adView = findViewById(R.id.adView);
 
         // `invalidateOptionsMenu` should recalculate the number of action buttons from the menu to display on the app bar, but it doesn't because of the this bug:  https://code.google.com/p/android/issues/detail?id=20493#c8
-        invalidateOptionsMenu();
+        // invalidateOptionsMenu();
     }
 
     @Override
diff --git a/app/src/main/res/drawable/close.xml b/app/src/main/res/drawable/close.xml
new file mode 100644 (file)
index 0000000..003e13b
--- /dev/null
@@ -0,0 +1,15 @@
+<!-- close.xml comes from the Android Material icon set, where it is called ic_close.
+    It is released under the Apache License 2.0. -->
+
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:height="24dp"
+    android:width="24dp"
+    android:viewportHeight="24.0"
+    android:viewportWidth="24.0" >
+
+    <!-- We have to use a hard coded color code until API >= 21.  Then we can use `@color`. -->
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z" />
+</vector>
diff --git a/app/src/main/res/drawable/next.xml b/app/src/main/res/drawable/next.xml
new file mode 100644 (file)
index 0000000..0ed52fc
--- /dev/null
@@ -0,0 +1,15 @@
+<!-- next.xml comes from the Android Material icon set, where it is called ic_expand_more.
+    It is released under the Apache License 2.0. -->
+
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:height="24dp"
+    android:width="24dp"
+    android:viewportHeight="24.0"
+    android:viewportWidth="24.0" >
+
+    <!-- We have to use a hard coded color code until API >= 21.  Then we can use `@color`. -->
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6z"/>
+</vector>
diff --git a/app/src/main/res/drawable/previous.xml b/app/src/main/res/drawable/previous.xml
new file mode 100644 (file)
index 0000000..9908d7f
--- /dev/null
@@ -0,0 +1,15 @@
+<!-- previous.xml comes from the Android Material icon set, where it is called ic_expand_less.
+    It is released under the Apache License 2.0. -->
+
+<vector
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:height="24dp"
+    android:width="24dp"
+    android:viewportHeight="24.0"
+    android:viewportWidth="24.0" >
+
+    <!-- We have to use a hard coded color code until API >= 21.  Then we can use `@color`. -->
+    <path
+        android:fillColor="#FF000000"
+        android:pathData="M12,8l-6,6 1.41,1.41L12,10.83l4.59,4.58L18,14z"/>
+</vector>
diff --git a/app/src/main/res/layout/find_on_page_app_bar.xml b/app/src/main/res/layout/find_on_page_app_bar.xml
new file mode 100644 (file)
index 0000000..3cb0f99
--- /dev/null
@@ -0,0 +1,64 @@
+<?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/>. -->
+
+<RelativeLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/find_on_page_relativelayout"
+    android:layout_height="wrap_content"
+    android:layout_width="match_parent" >
+
+    <ImageView
+        android:id="@+id/close_find"
+        android:src="@drawable/close"
+        android:layout_alignParentEnd="true"
+        android:layout_width="30dp"
+        android:layout_height="30dp"
+        android:layout_centerVertical="true"
+        android:contentDescription="@string/close" />
+
+    <ImageView
+        android:id="@+id/find_next"
+        android:src="@drawable/next"
+        android:layout_toStartOf="@id/close_find"
+        android:layout_width="30dp"
+        android:layout_height="30dp"
+        android:layout_centerVertical="true"
+        android:contentDescription="@string/next" />
+
+    <ImageView
+        android:id="@+id/find_previous"
+        android:src="@drawable/previous"
+        android:layout_toStartOf="@id/find_next"
+        android:layout_width="30dp"
+        android:layout_height="30dp"
+        android:layout_centerVertical="true"
+        android:contentDescription="@string/previous" />
+
+    <!-- `android:imeOptions="actionGo"` sets the keyboard to have a `go` key instead of a `new line` key. -->
+    <EditText
+        android:id="@+id/find_on_page_edittext"
+        android:layout_toStartOf="@id/find_previous"
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent"
+        android:hint="@string/find_on_page"
+        android:imeOptions="actionGo" />
+
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/url_app_bar.xml b/app/src/main/res/layout/url_app_bar.xml
new file mode 100644 (file)
index 0000000..b2c7fb5
--- /dev/null
@@ -0,0 +1,70 @@
+<?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/>. -->
+
+<!-- `FrameLayout` lets the `ProgressBar` float on top of `urlTextBox`. -->
+<FrameLayout
+    xmlns:tools="http://schemas.android.com/tools"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_height="wrap_content"
+    android:layout_width="match_parent" >
+
+    <!-- `RelativeLayout` is used instead of a `LinearLayout` because `supportAppBar` does not let `android:layout_weight="1"` cause `urlTextBox` to fill all the available space. -->
+    <RelativeLayout
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent" >
+
+        <!-- Set the program icon as the initial `favoriteIcon`.
+            `layout_height` and `layout_width` of 26dp matches the `AppBar` icons. -->
+        <ImageView
+            android:id="@+id/favoriteIcon"
+            android:src="@drawable/world"
+            android:layout_height="26dp"
+            android:layout_width="26dp"
+            android:layout_centerVertical="true"
+            android:onClick="viewSslCertificate"
+            android:contentDescription="@string/favorite_icon" />
+
+        <!-- `android:imeOptions="actionGo"` sets the keyboard to have a `go` key instead of a `new line` key.
+            `android:inputType="textUri"` disables spell check in the `EditText`. -->
+        <EditText
+            android:id="@+id/urlTextBox"
+            android:layout_height="wrap_content"
+            android:layout_width="match_parent"
+            android:layout_toEndOf="@id/favoriteIcon"
+            android:hint="@string/url_or_search_terms"
+            android:imeOptions="actionGo"
+            android:inputType="textUri" />
+    </RelativeLayout>
+
+    <!-- `android:max` changes the maximum `ProgressBar` value from 10000 to 100 to match progress percentage.
+        `android:layout_height="2dp"` works best for API 23 Marshmallow, but `3dp` is required for visibility on API <= 22.
+        `tools:ignore="UnusedAttribute"` removes the lint waring about `progressTint` and `progressBackgroundTint` not applying to API < 21. -->
+    <ProgressBar
+        android:id="@+id/progressBar"
+        style="?android:attr/progressBarStyleHorizontal"
+        android:layout_width="fill_parent"
+        android:layout_height="3dp"
+        android:layout_gravity="bottom"
+        android:max="100"
+        android:progressTint="@color/blue_700"
+        android:progressBackgroundTint="@color/white"
+        android:visibility="gone"
+        tools:ignore="UnusedAttribute" />
+</FrameLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/url_bar.xml b/app/src/main/res/layout/url_bar.xml
deleted file mode 100644 (file)
index afe8651..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-<?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/>. -->
-
-<!-- FrameLayout lets the ProgressBar float on top of `urlTextBox`. -->
-<FrameLayout
-    xmlns:tools="http://schemas.android.com/tools"
-    android:id="@+id/addressBarFrameLayout"
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    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_height` and `layout_width` and of 26dp matches the AppBar icons. -->
-        <ImageView
-            android:id="@+id/favoriteIcon"
-            android:src="@drawable/world"
-            android:layout_height="26dp"
-            android:layout_width="26dp"
-            android:layout_centerVertical="true"
-            android:onClick="viewSslCertificate"
-            android:contentDescription="@string/favorite_icon" />
-
-        <!-- `android:imeOptions="actionGo"` sets the keyboard to have a "go" key instead of a "new line" key.
-            `android:inputType="textUri"` disables spell check in the EditText.
-            We can't use `android:imeOptions=flagNoExtractUi"` because it disables tapping to select in landscape orientation on small devices. -->
-        <EditText
-            android:id="@+id/urlTextBox"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_toEndOf="@id/favoriteIcon"
-            android:hint="@string/url_or_search_terms"
-            android:imeOptions="actionGo"
-            android:inputType="textUri" />
-    </RelativeLayout>
-
-    <!-- android:max changes the maximum ProgressBar value from 10000 to 100 to match progress percentage.
-        android:layout_height="2dp" works best for API 23 "Marshmallow", but "3dp" is required for visibility on API <= 22.
-        `tools:ignore="UnusedAttribute"` removes the lint waring about `progressTint` and `progressBackgroundTint`
-        not applying to API < 21.-->
-    <ProgressBar
-        android:id="@+id/progressBar"
-        style="?android:attr/progressBarStyleHorizontal"
-        android:layout_width="fill_parent"
-        android:layout_height="3dp"
-        android:layout_gravity="bottom"
-        android:max="100"
-        android:progressTint="@color/blue_700"
-        android:progressBackgroundTint="@color/white"
-        android:visibility="gone"
-        tools:ignore="UnusedAttribute" />
-</FrameLayout>
\ No newline at end of file
index 89f1bfbd46c532e09f5d7661fa0680133451a074..8dee5b1d2ff5856f7a01ca9841bcde076355f22f 100644 (file)
         </menu>
     </item>
 
+    <item
+        android:id="@+id/find_on_page"
+        android:title="@string/find_on_page"
+        android:orderInCategory="100"
+        app:showAsAction="never|collapseActionView" />
+
     <item
         android:id="@+id/share"
         android:title="@string/share"
-        android:orderInCategory="100"
+        android:orderInCategory="110"
         app:showAsAction="never" />
 
     <item
         android:id="@+id/addToHomescreen"
         android:title="@string/add_to_home_screen"
-        android:orderInCategory="110"
+        android:orderInCategory="120"
         app:showAsAction="never" />
 
     <item
         android:id="@+id/print"
         android:title="@string/print"
-        android:orderInCategory="120"
+        android:orderInCategory="130"
         app:showAsAction="never" />
 
     <item
         android:id="@+id/refresh"
         android:title="@string/refresh"
-        android:orderInCategory="120"
+        android:orderInCategory="140"
         app:showAsAction="never" />
 </menu>
index 57c2c0a0b87b59822b891e80d3178954fb79ca5a..1a540fce0ebf0392a03a8cd3486e8ce90e8b55ed 100644 (file)
         <string name="one_hundred_fifty_percent">150%</string>
         <string name="one_hundred_seventy_five_percent">175%</string>
         <string name="two_hundred_percent">200%</string>
+    <string name="find_on_page">Find on Page</string>
     <string name="share">Share</string>
     <string name="add_to_home_screen">Add to Home Screen</string>
     <string name="print">Print</string>
         <string name="privacy_browser_web_page">Privacy Browser Web Page</string>
     <string name="refresh">Refresh</string>
 
+    <!-- Find on Page. -->
+    <string name="previous">Previous</string>
+    <string name="next">Next</string>
+
     <!-- Create Home Screen Shortcut Alert Dialog. -->
     <string name="create_shortcut">Create shortcut</string>
     <string name="shortcut_name">Shortcut name</string>
index 573f4fd696e86341e34d6e3f33e16a20f98008c6..ef7ae5ac828441e7d602c8ea3e1c7e25d32bd107 100644 (file)
@@ -5,7 +5,7 @@ buildscript {
         jcenter()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:2.2.1'
+        classpath 'com.android.tools.build:gradle:2.2.2'
 
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files