X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fcom%2Fstoutner%2Fprivacybrowser%2Factivities%2FMainWebViewActivity.kt;h=dc63adf65cb190d9b0adfa2edd14e6b75758dfb0;hb=227f44a771ae2d21259b1a8a5c9377f2c2b1d627;hp=5f103f509a7871795eaf5ff747e1c4e01660a133;hpb=f95501b3f5d609aac90ef75acad30b7d19448c3d;p=PrivacyBrowserAndroid.git diff --git a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt index 5f103f50..dc63adf6 100644 --- a/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt +++ b/app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt @@ -3216,6 +3216,10 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook val tabFavoriteIconImageView = tabCustomView.findViewById(R.id.favorite_icon_imageview) val tabTitleTextView = tabCustomView.findViewById(R.id.title_textview) + // Store the current values in case they need to be restored. + nestedScrollWebView.previousFavoriteIconDrawable = tabFavoriteIconImageView.drawable + nestedScrollWebView.previousWebpageTitle = tabTitleTextView.text.toString() + // Set the default favorite icon as the favorite icon for this tab. tabFavoriteIconImageView.setImageBitmap(Bitmap.createScaledBitmap(nestedScrollWebView.getFavoriteIcon(), 64, 64, true)) @@ -4933,6 +4937,29 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook pendingDialogsArrayList.add(PendingDialogDataClass(saveDialogFragment, getString(R.string.save_dialog))) } } + + // Get the current page position. + val currentPagePosition = webViewStateAdapter!!.getPositionForId(nestedScrollWebView.webViewFragmentId) + + // Get the corresponding tab. + val tab = tabLayout.getTabAt(currentPagePosition)!! + + // Get the tab custom view. + val tabCustomView = tab.customView!! + + // Get the tab views. + val tabFavoriteIconImageView = tabCustomView.findViewById(R.id.favorite_icon_imageview) + val tabTitleTextView = tabCustomView.findViewById(R.id.title_textview) + + // Restore the previous webpage favorite icon and title if the title is currently set to `Loading...`. + if (tabTitleTextView.text.toString() == getString(R.string.loading)) { + // Restore the previous webpage title text. + tabTitleTextView.text = nestedScrollWebView.previousWebpageTitle + + // Restore the previous webpage favorite icon if it is not null. + if (nestedScrollWebView.previousFavoriteIconDrawable != null) + tabFavoriteIconImageView.setImageDrawable(nestedScrollWebView.previousFavoriteIconDrawable) + } } // Update the find on page count.