]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Enable printing.
authorSoren Stoutner <soren@stoutner.com>
Wed, 5 Oct 2016 20:14:58 +0000 (13:14 -0700)
committerSoren Stoutner <soren@stoutner.com>
Wed, 5 Oct 2016 20:17:29 +0000 (13:17 -0700)
app/build.gradle
app/src/main/java/com/stoutner/privacybrowser/MainWebViewActivity.java
app/src/main/res/drawable-xxxhdpi/folder_blue_bitmap.png [new file with mode: 0644]
app/src/main/res/drawable-xxxhdpi/folder_grey_bitmap.png [new file with mode: 0644]
app/src/main/res/drawable-xxxhdpi/world.png [new file with mode: 0644]
app/src/main/res/layout/navigation_header.xml
app/src/main/res/menu/webview_options_menu.xml
app/src/main/res/values/strings.xml

index 8e28fdd4e67866c499e26030543d580c25d47755..3f2a08d4bd4520c8bb76de7a2aba159bba7404e0 100644 (file)
@@ -21,7 +21,7 @@ apply plugin: 'com.android.application'
 
 android {
     compileSdkVersion 24
-    buildToolsVersion "24.0.2"
+    buildToolsVersion "24.0.3"
     defaultConfig {
         minSdkVersion 19
         targetSdkVersion 24
index 104522b600f0b9f467e539d27dc6a69d29d84bce..a27dddb2cf11cd00dd3232d147e38709c321c860 100644 (file)
@@ -23,6 +23,7 @@ import android.annotation.SuppressLint;
 import android.app.Activity;
 import android.app.DialogFragment;
 import android.app.DownloadManager;
+import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.res.Configuration;
@@ -35,6 +36,8 @@ import android.net.http.SslError;
 import android.os.Build;
 import android.os.Bundle;
 import android.preference.PreferenceManager;
+import android.print.PrintDocumentAdapter;
+import android.print.PrintManager;
 import android.support.annotation.NonNull;
 import android.support.design.widget.NavigationView;
 import android.support.design.widget.Snackbar;
@@ -745,6 +748,17 @@ public class MainWebViewActivity extends AppCompatActivity implements Navigation
                 //Everything else will be handled by `CreateHomeScreenShortcut` and the associated listener below.
                 return true;
 
+            case R.id.print:
+                // Get a `PrintManager` instance.
+                PrintManager printManager = (PrintManager) getSystemService(Context.PRINT_SERVICE);
+
+                // Convert `mainWebView` to `printDocumentAdapter`.
+                PrintDocumentAdapter printDocumentAdapter = mainWebView.createPrintDocumentAdapter();
+
+                // Print the document.  The print attributes are `null`.
+                printManager.print(getResources().getString(R.string.privacy_browser_web_page), printDocumentAdapter, null);
+                return true;
+
             case R.id.refresh:
                 mainWebView.reload();
                 return true;
diff --git a/app/src/main/res/drawable-xxxhdpi/folder_blue_bitmap.png b/app/src/main/res/drawable-xxxhdpi/folder_blue_bitmap.png
new file mode 100644 (file)
index 0000000..225a217
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/folder_blue_bitmap.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/folder_grey_bitmap.png b/app/src/main/res/drawable-xxxhdpi/folder_grey_bitmap.png
new file mode 100644 (file)
index 0000000..00e682e
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/folder_grey_bitmap.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/world.png b/app/src/main/res/drawable-xxxhdpi/world.png
new file mode 100644 (file)
index 0000000..5b21393
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/world.png differ
index 0f6c443aaf5be1bf3fa103a68aff63bf1715af10..13d390b3aea2f6f7d948e46f7fd46e43c385d0cf 100644 (file)
@@ -18,7 +18,6 @@
   You should have received a copy of the GNU General Public License
   along with Privacy Browser.  If not, see <http://www.gnu.org/licenses/>. -->
 
-<!-- We can remove android:paddingLeft and android:PaddingRight once API >=17. -->
 <TextView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/navigationText"
     android:text="@string/navigation"
     android:paddingTop="60dp"
     android:paddingBottom="8dp"
-    android:paddingLeft="15dp"
-    android:paddingRight="15dp"
     android:paddingStart="15dp"
+    android:paddingEnd="15dp"
     android:textStyle="bold"
     android:textSize="20sp"
     android:background="@color/blue_700"
-    android:textColor="@color/white" />
-
+    android:textColor="@color/white" />
\ No newline at end of file
index 0d1f909397f9ee9f48882f6d429780cbfa933d3f..89f1bfbd46c532e09f5d7661fa0680133451a074 100644 (file)
         android:orderInCategory="110"
         app:showAsAction="never" />
 
+    <item
+        android:id="@+id/print"
+        android:title="@string/print"
+        android:orderInCategory="120"
+        app:showAsAction="never" />
+
     <item
         android:id="@+id/refresh"
         android:title="@string/refresh"
index 720173e7c286febfb3fbaead91ce9a8f238066c8..57c2c0a0b87b59822b891e80d3178954fb79ca5a 100644 (file)
         <string name="two_hundred_percent">200%</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>
 
     <!-- Create Home Screen Shortcut Alert Dialog. -->