+ // Declare the helpers.
+ private BookmarksDatabaseHelper bookmarksDatabaseHelper;
+ private DomainsDatabaseHelper domainsDatabaseHelper;
+ private ProxyHelper proxyHelper;
+ private SanitizeUrlHelper sanitizeUrlHelper;
+
+ // Declare the class variables
+ private boolean bottomAppBar;
+ private boolean displayingFullScreenVideo;
+ private boolean downloadWithExternalApp;
+ private boolean fullScreenBrowsingModeEnabled;
+ private boolean hideAppBar;
+ private boolean incognitoModeEnabled;
+ private boolean inFullScreenBrowsingMode;
+ private boolean loadingNewIntent;
+ private BroadcastReceiver orbotStatusBroadcastReceiver;
+ private boolean reapplyAppSettingsOnRestart;
+ private boolean reapplyDomainSettingsOnRestart;
+ private boolean sanitizeAmpRedirects;
+ private boolean sanitizeTrackingQueries;
+ private boolean scrollAppBar;
+ private boolean waitingForProxy;
+ private String webViewDefaultUserAgent;
+
+ // Define the class variables.
+ private ObjectAnimator objectAnimator = new ObjectAnimator();
+ private String saveUrlString = "";
+
+ // Declare the class views.
+ private FrameLayout rootFrameLayout;
+ private DrawerLayout drawerLayout;
+ private CoordinatorLayout coordinatorLayout;
+ private Toolbar toolbar;
+ private RelativeLayout urlRelativeLayout;
+ private EditText urlEditText;
+ private ActionBar actionBar;
+ private LinearLayout findOnPageLinearLayout;
+ private LinearLayout tabsLinearLayout;
+ private TabLayout tabLayout;
+ private SwipeRefreshLayout swipeRefreshLayout;
+ private ViewPager webViewPager;
+ private FrameLayout fullScreenVideoFrameLayout;
+
+ // Declare the class menus.
+ private Menu optionsMenu;
+
+ // Declare the class menu items.
+ private MenuItem navigationBackMenuItem;
+ private MenuItem navigationForwardMenuItem;
+ private MenuItem navigationHistoryMenuItem;
+ private MenuItem navigationRequestsMenuItem;
+ private MenuItem optionsPrivacyMenuItem;
+ private MenuItem optionsRefreshMenuItem;
+ private MenuItem optionsCookiesMenuItem;
+ private MenuItem optionsDomStorageMenuItem;
+ private MenuItem optionsSaveFormDataMenuItem;
+ private MenuItem optionsClearDataMenuItem;
+ private MenuItem optionsClearCookiesMenuItem;
+ private MenuItem optionsClearDomStorageMenuItem;
+ private MenuItem optionsClearFormDataMenuItem;
+ private MenuItem optionsBlocklistsMenuItem;
+ private MenuItem optionsEasyListMenuItem;
+ private MenuItem optionsEasyPrivacyMenuItem;
+ private MenuItem optionsFanboysAnnoyanceListMenuItem;
+ private MenuItem optionsFanboysSocialBlockingListMenuItem;
+ private MenuItem optionsUltraListMenuItem;
+ private MenuItem optionsUltraPrivacyMenuItem;
+ private MenuItem optionsBlockAllThirdPartyRequestsMenuItem;
+ private MenuItem optionsProxyMenuItem;
+ private MenuItem optionsProxyNoneMenuItem;
+ private MenuItem optionsProxyTorMenuItem;
+ private MenuItem optionsProxyI2pMenuItem;
+ private MenuItem optionsProxyCustomMenuItem;
+ private MenuItem optionsUserAgentMenuItem;
+ private MenuItem optionsUserAgentPrivacyBrowserMenuItem;
+ private MenuItem optionsUserAgentWebViewDefaultMenuItem;
+ private MenuItem optionsUserAgentFirefoxOnAndroidMenuItem;
+ private MenuItem optionsUserAgentChromeOnAndroidMenuItem;
+ private MenuItem optionsUserAgentSafariOnIosMenuItem;
+ private MenuItem optionsUserAgentFirefoxOnLinuxMenuItem;
+ private MenuItem optionsUserAgentChromiumOnLinuxMenuItem;
+ private MenuItem optionsUserAgentFirefoxOnWindowsMenuItem;
+ private MenuItem optionsUserAgentChromeOnWindowsMenuItem;
+ private MenuItem optionsUserAgentEdgeOnWindowsMenuItem;
+ private MenuItem optionsUserAgentInternetExplorerOnWindowsMenuItem;
+ private MenuItem optionsUserAgentSafariOnMacosMenuItem;
+ private MenuItem optionsUserAgentCustomMenuItem;
+ private MenuItem optionsSwipeToRefreshMenuItem;
+ private MenuItem optionsWideViewportMenuItem;
+ private MenuItem optionsDisplayImagesMenuItem;
+ private MenuItem optionsDarkWebViewMenuItem;
+ private MenuItem optionsFontSizeMenuItem;
+ private MenuItem optionsAddOrEditDomainMenuItem;
+
+ // This variable won't be needed once the class is migrated to Kotlin, as can be seen in LogcatActivity or AboutVersionFragment.
+ private Activity resultLauncherActivityHandle;
+
+ // Define the save URL activity result launcher. It must be defined before `onCreate()` is run or the app will crash.
+ private final ActivityResultLauncher<String> saveUrlActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.CreateDocument(),
+ new ActivityResultCallback<Uri>() {
+ @Override
+ public void onActivityResult(Uri fileUri) {
+ // Only save the URL if the file URI is not null, which happens if the user exited the file picker by pressing back.
+ if (fileUri != null) {
+ new SaveUrl(getApplicationContext(), resultLauncherActivityHandle, fileUri, currentWebView.getSettings().getUserAgentString(), currentWebView.getAcceptCookies()).execute(saveUrlString);
+ }
+
+ // Reset the save URL string.
+ saveUrlString = "";
+ }
+ });
+
+ // Define the save webpage archive activity result launcher. It must be defined before `onCreate()` is run or the app will crash.
+ private final ActivityResultLauncher<String> saveWebpageArchiveActivityResultLauncher = registerForActivityResult(new ActivityResultContracts.CreateDocument(),
+ new ActivityResultCallback<Uri>() {
+ @Override
+ public void onActivityResult(Uri fileUri) {
+ // Only save the webpage archive if the file URI is not null, which happens if the user exited the file picker by pressing back.
+ if (fileUri != null) {
+ try {
+ // Create a temporary MHT file.
+ File temporaryMhtFile = File.createTempFile("temporary_mht_file", ".mht", getCacheDir());