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;
// It is also used in `onCreate()`, `onOptionsItemSelected()`, `onCreateHomeScreenShortcutCreate()`, and `loadUrlFromTextBox()`.
public static String formattedUrlString;
- // `customHeader` is public static so it can be accessed from `BookmarksActivity`. It is also used in `onCreate()`, `onOptionsItemSelected()`, and `loadUrlFromTextBox()`.
- public static Map<String, String> customHeaders = new HashMap<>();
-
// `sslCertificate` is public static so it can be accessed from `ViewSslCertificate`. It is also used in `onCreate()`.
public static SslCertificate sslCertificate;
// `cookieManager` is used in `onCreate()`, `onOptionsItemSelected()`, and `onNavigationItemSelected()`, and `onRestart()`.
private CookieManager cookieManager;
+ // `customHeader` is used in `onCreate()`, `onOptionsItemSelected()`, and `loadUrlFromTextBox()`.
+ private final Map<String, String> customHeaders = new HashMap<>();
+
// `javaScriptEnabled` is also used in `onCreate()`, `onCreateOptionsMenu()`, `onOptionsItemSelected()`, `loadUrlFromTextBox()`, and `applySettings()`.
// It is `Boolean` instead of `boolean` because `applySettings()` needs to know if it is `null`.
private Boolean javaScriptEnabled;
//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;
cookieManager.setAcceptCookie(firstPartyCookiesEnabled);
mainWebView.getSettings().setDomStorageEnabled(domStorageEnabled);
mainWebView.getSettings().setSaveFormData(saveFormDataEnabled);
+ mainWebView.getSettings().setTextZoom(Integer.valueOf(defaultFontSizeString));
// Set third-party cookies status if API >= 21.
if (Build.VERSION.SDK_INT >= 21) {
}
}
- // Apply the settings from `sharedPreferences`.
+ // Apply the other settings from `sharedPreferences`.
homepage = homepageString;
- mainWebView.getSettings().setTextZoom(Integer.valueOf(defaultFontSizeString));
swipeRefreshLayout.setEnabled(swipeToRefreshEnabled);
// Set the user agent initial status.