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=cdb2c9fb105b737c6f4931df2091689a020d3948;hp=600db329efa991a46e11f99b35ed3bacbb59abea;hb=771125363f79df7b3a6b85321a08c7c201b54661;hpb=1003c7842a01f338c8aaf9d4f07216111f294202 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 600db329..cdb2c9fb 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -4757,6 +4757,9 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Get the intent that started the app. Intent intent = getIntent(); + // Reset the intent. This prevents a duplicate tab from being created on restart. + setIntent(new Intent()); + // Get the information from the intent. String intentAction = intent.getAction(); Uri intentUriData = intent.getData(); @@ -4842,6 +4845,12 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook } private void closeCurrentTab() { + // Pause the current WebView. + currentWebView.onPause(); + + // Pause the current WebView JavaScript timers. + currentWebView.pauseTimers(); + // Get the current tab number. int currentTabNumber = tabLayout.getSelectedTabPosition(); @@ -5411,7 +5420,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook } // Get the file name from the content disposition. - String fileNameString = PrepareSaveDialog.getFileNameFromContentDisposition(this, contentDisposition, downloadUrl); + String fileNameString = PrepareSaveDialog.getFileNameFromHeaders(this, contentDisposition, mimetype, downloadUrl); // Instantiate the save dialog. DialogFragment saveDialogFragment = SaveWebpageDialog.saveWebpage(StoragePermissionDialog.SAVE_URL, downloadUrl, formattedFileSizeString, fileNameString, userAgent, @@ -6288,7 +6297,7 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook } } - // Clear the cache and history if Incognito Mode is enabled. + // Clear the cache, history, and logcat if Incognito Mode is enabled. if (incognitoModeEnabled) { // Clear the cache. `true` includes disk files. nestedScrollWebView.clearCache(true); @@ -6308,9 +6317,17 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Delete the secondary `Service Worker` cache directory. // A `String[]` must be used because the directory contains a space and `Runtime.exec` will not escape the string correctly otherwise. Runtime.getRuntime().exec(new String[]{"rm", "-rf", privateDataDirectoryString + "/app_webview/Service Worker/"}); - } catch (IOException e) { + } catch (IOException exception) { // Do nothing if an error is thrown. } + + // Clear the logcat. + try { + // Clear the logcat. `-c` clears the logcat. `-b all` clears all the buffers (instead of just crash, main, and system). + Runtime.getRuntime().exec("logcat -b all -c"); + } catch (IOException exception) { + // Do nothing. + } } // Get the current page position. @@ -6452,6 +6469,9 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook // Get the intent that started the app. Intent launchingIntent = getIntent(); + // Reset the intent. This prevents a duplicate tab from being created on restart. + setIntent(new Intent()); + // Get the information from the intent. String launchingIntentAction = launchingIntent.getAction(); Uri launchingIntentUriData = launchingIntent.getData();