X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserAndroid.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.java;h=bef36d6a3de96444a723cf23bb4503c04be2c226;hp=971eaad1fa5c36082d82d5878f5faaf459e16568;hb=f825cc15f0383acce10bb16443e027edb869a11e;hpb=23de13bf1815ffc666157997ca3bff6930e1762c diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java index 971eaad1..bef36d6a 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -1756,7 +1756,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook PrintDocumentAdapter printDocumentAdapter = currentWebView.createPrintDocumentAdapter(); // Print the document. - printManager.print(getString(R.string.privacy_browser_web_page), printDocumentAdapter, null); + printManager.print(getString(R.string.privacy_browser_webpage), printDocumentAdapter, null); // Consume the event. return true; @@ -2544,20 +2544,20 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook assert dialog != null; // Get handles for the views in the dialog fragment. - EditText createFolderNameEditText = dialog.findViewById(R.id.create_folder_name_edittext); - RadioButton defaultFolderIconRadioButton = dialog.findViewById(R.id.create_folder_default_icon_radiobutton); - ImageView folderIconImageView = dialog.findViewById(R.id.create_folder_default_icon); + EditText folderNameEditText = dialog.findViewById(R.id.folder_name_edittext); + RadioButton defaultIconRadioButton = dialog.findViewById(R.id.default_icon_radiobutton); + ImageView defaultIconImageView = dialog.findViewById(R.id.default_icon_imageview); // Get new folder name string. - String folderNameString = createFolderNameEditText.getText().toString(); + String folderNameString = folderNameEditText.getText().toString(); // Create a folder icon bitmap. Bitmap folderIconBitmap; // Set the folder icon bitmap according to the dialog. - if (defaultFolderIconRadioButton.isChecked()) { // Use the default folder icon. + if (defaultIconRadioButton.isChecked()) { // Use the default folder icon. // Get the default folder icon drawable. - Drawable folderIconDrawable = folderIconImageView.getDrawable(); + Drawable folderIconDrawable = defaultIconImageView.getDrawable(); // Convert the folder icon drawable to a bitmap drawable. BitmapDrawable folderIconBitmapDrawable = (BitmapDrawable) folderIconDrawable; @@ -2609,10 +2609,10 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook assert dialog != null; // Get handles for the views from the dialog. - EditText editFolderNameEditText = dialog.findViewById(R.id.edit_folder_name_edittext); - RadioButton currentFolderIconRadioButton = dialog.findViewById(R.id.edit_folder_current_icon_radiobutton); - RadioButton defaultFolderIconRadioButton = dialog.findViewById(R.id.edit_folder_default_icon_radiobutton); - ImageView defaultFolderIconImageView = dialog.findViewById(R.id.edit_folder_default_icon_imageview); + RadioButton currentFolderIconRadioButton = dialog.findViewById(R.id.current_icon_radiobutton); + RadioButton defaultFolderIconRadioButton = dialog.findViewById(R.id.default_icon_radiobutton); + ImageView defaultFolderIconImageView = dialog.findViewById(R.id.default_icon_imageview); + EditText editFolderNameEditText = dialog.findViewById(R.id.folder_name_edittext); // Get the new folder name. String newFolderNameString = editFolderNameEditText.getText().toString(); @@ -2652,7 +2652,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Update the folder icon in the database. bookmarksDatabaseHelper.updateFolder(selectedFolderDatabaseId, newFolderIconByteArray); } else { // The folder icon and the name have changed. - // Get the new folder icon `Bitmap`. + // Get the new folder icon bitmap. Bitmap folderIconBitmap; if (defaultFolderIconRadioButton.isChecked()) { // Get the default folder icon drawable. @@ -3595,6 +3595,8 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook @Override public void onDrawerClosed(@NonNull View drawerView) { + // Reset the drawer icon when the drawer is closed. Otherwise, it is an arrow if the drawer is open when the app is restarted. + actionBarDrawerToggle.syncState(); } @Override @@ -4868,9 +4870,6 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook if (webViewPagerAdapter.deletePage(currentTabNumber, webViewPager)) { setCurrentWebView(currentTabNumber); } - - // Expand the app bar if it is currently collapsed. - appBarLayout.setExpanded(true); } private void saveWebpageArchive(String filePath) { @@ -5429,6 +5428,17 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Get the file name from the content disposition. String fileNameString = PrepareSaveDialog.getFileNameFromHeaders(this, contentDisposition, mimetype, downloadUrl); + // Prevent the dialog from displaying if the app window is not visible. + // The download listener continues to function even when the WebView is paused. Attempting to display a dialog in that state leads to a crash. + while (!activity.getWindow().isActive()) { + try { + // The window is not active. Wait 1 second. + wait(1000); + } catch (InterruptedException e) { + // Do nothing. + } + } + // Instantiate the save dialog. DialogFragment saveDialogFragment = SaveWebpageDialog.saveWebpage(StoragePermissionDialog.SAVE_URL, downloadUrl, formattedFileSizeString, fileNameString, userAgent, nestedScrollWebView.getAcceptFirstPartyCookies()); @@ -6430,6 +6440,17 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Store the SSL error handler. nestedScrollWebView.setSslErrorHandler(handler); + // Prevent the dialog from displaying if the app window is not visible. + // The SSL error handler continues to function even when the WebView is paused. Attempting to display a dialog in that state leads to a crash. + while (!activity.getWindow().isActive()) { + try { + // The window is not active. Wait 1 second. + wait(1000); + } catch (InterruptedException e) { + // Do nothing. + } + } + // Instantiate an SSL certificate error alert dialog. DialogFragment sslCertificateErrorDialogFragment = SslCertificateErrorDialog.displayDialog(error, nestedScrollWebView.getWebViewFragmentId());