android {
compileSdkVersion 24
- buildToolsVersion "24.0.2"
+ buildToolsVersion "24.0.3"
defaultConfig {
minSdkVersion 19
targetSdkVersion 24
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;
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;
//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;
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
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"
<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. -->