]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/commitdiff
Update the stored favorite icon when navigating history. https://redmine.stoutner...
authorSoren Stoutner <soren@stoutner.com>
Wed, 6 Mar 2024 18:45:49 +0000 (11:45 -0700)
committerSoren Stoutner <soren@stoutner.com>
Wed, 6 Mar 2024 18:45:49 +0000 (11:45 -0700)
app/src/main/java/com/stoutner/privacybrowser/activities/MainWebViewActivity.kt
app/src/main/java/com/stoutner/privacybrowser/views/NestedScrollWebView.kt

index b6086b4631889ec806ad3d3e596319f642591827..5036e86a490a89cae3698e86e7942157e3ff29e4 100644 (file)
@@ -5899,11 +5899,14 @@ class MainWebViewActivity : AppCompatActivity(), CreateBookmarkDialog.CreateBook
         // Get the favorite icon image view from the tab.
         val tabFavoriteIconImageView = tabView.findViewById<ImageView>(R.id.favorite_icon_imageview)
 
-        // Set the previous favorite icon.
+        // Store the previous favorite icon.
         if (previousFavoriteIcon == null)
-            tabFavoriteIconImageView.setImageBitmap(defaultFavoriteIconBitmap)
+            currentWebView!!.setFavoriteIcon(defaultFavoriteIconBitmap)
         else
-            tabFavoriteIconImageView.setImageBitmap(Bitmap.createScaledBitmap(previousFavoriteIcon, 64, 64, true))
+            currentWebView!!.setFavoriteIcon(previousFavoriteIcon)
+
+        // Display the previous favorite icon in the tab.
+        tabFavoriteIconImageView.setImageBitmap(Bitmap.createScaledBitmap(currentWebView!!.getFavoriteIcon(), 64, 64, true))
 
         // Load the history entry.
         currentWebView!!.goBackOrForward(steps)
index 45133be52c016316c0cfb8bfae9d21775f2d4c26..683c7aef14ea3df4ded5cf1376cfadeda4029ec4 100644 (file)
@@ -157,12 +157,10 @@ class NestedScrollWebView @JvmOverloads constructor(context: Context, attributeS
         favoriteIconHeight = icon.height
 
         // Scale the favorite icon bitmap down if it is larger than 256 x 256.  Filtering uses bilinear interpolation.
-        favoriteIcon = if (icon.height > 256 || icon.width > 256) {
+        favoriteIcon = if (icon.height > 256 || icon.width > 256)  // Scale the icon before storing it.
             Bitmap.createScaledBitmap(icon, 256, 256, true)
-        } else {
-            // Store the icon as presented.
+        else  // Store the icon as presented.
             icon
-        }
     }
 
     fun getFavoriteIcon(): Bitmap {