X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.java;h=91c3a71ebbaa125590debe2d2bbf99ead47a0e2f;hb=7ab6a9027175e6a8f72b3f3683f8c4e05643d8bc;hp=39b95dca65d30d4ab5f35a3b31b1d47fd6969873;hpb=514e93baaa8389dc9c5abdb79e68c890c260b8d3;p=PrivacyBrowserAndroid.git 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 39b95dca..91c3a71e 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.java @@ -127,11 +127,11 @@ import com.google.android.material.tabs.TabLayout; import com.stoutner.privacybrowser.R; import com.stoutner.privacybrowser.adapters.WebViewPagerAdapter; -import com.stoutner.privacybrowser.asynctasks.SaveUrl; -import com.stoutner.privacybrowser.asynctasks.SaveWebpageImage; import com.stoutner.privacybrowser.coroutines.GetHostIpAddressesCoroutine; import com.stoutner.privacybrowser.coroutines.PopulateBlocklistsCoroutine; import com.stoutner.privacybrowser.coroutines.PrepareSaveDialogCoroutine; +import com.stoutner.privacybrowser.coroutines.SaveUrlCoroutine; +import com.stoutner.privacybrowser.coroutines.SaveWebpageImageCoroutine; import com.stoutner.privacybrowser.dataclasses.PendingDialogDataClass; import com.stoutner.privacybrowser.dialogs.CreateBookmarkDialog; import com.stoutner.privacybrowser.dialogs.CreateBookmarkFolderDialog; @@ -363,7 +363,12 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook 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); + // Instantiate the save URL coroutine. + SaveUrlCoroutine saveUrlCoroutine = new SaveUrlCoroutine(); + + // Save the URL. + saveUrlCoroutine.save(getApplicationContext(), resultLauncherActivityHandle, saveUrlString, fileUri, currentWebView.getSettings().getUserAgentString(), + currentWebView.getAcceptCookies()); } // Reset the save URL string. @@ -456,8 +461,11 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook public void onActivityResult(Uri fileUri) { // Only save the webpage image if the file URI is not null, which happens if the user exited the file picker by pressing back. if (fileUri != null) { + // Instantiate the save webpage image coroutine. + SaveWebpageImageCoroutine saveWebpageImageCoroutine = new SaveWebpageImageCoroutine(); + // Save the webpage image. - new SaveWebpageImage(resultLauncherActivityHandle, fileUri, currentWebView).execute(); + saveWebpageImageCoroutine.save(resultLauncherActivityHandle, fileUri, currentWebView); } } }); @@ -751,8 +759,18 @@ public class MainWebViewActivity extends AppCompatActivity implements CreateBook } } } else { // The app has been restarted. - // Set the saved tab position to be the size of the saved state array list. The tab position is 0 based, meaning the at the new tab will be the tab position that is restored. - savedTabPosition = savedStateArrayList.size(); + // Get the information from the intent. + String intentAction = intent.getAction(); + Uri intentUriData = intent.getData(); + String intentStringExtra = intent.getStringExtra(Intent.EXTRA_TEXT); + + // Determine if this is a web search. + boolean isWebSearch = ((intentAction != null) && intentAction.equals(Intent.ACTION_WEB_SEARCH)); + + // If the new intent will open a new tab, set the saved tab position to be the size of the saved state array list. + // The tab position is 0 based, meaning the at the new tab will be the tab position that is restored. + if (intentUriData != null || intentStringExtra != null || isWebSearch) + savedTabPosition = savedStateArrayList.size(); // Replace the intent that started the app with this one. This will load the tab after the others have been restored. setIntent(intent);