/*
- * Copyright 2019-2023 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2019-2024 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser Android <https://www.stoutner.com/privacy-browser-android>.
*
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Bitmap
-import android.graphics.drawable.BitmapDrawable
+import android.graphics.drawable.Drawable
import android.os.Bundle
import android.util.AttributeSet
import android.view.MotionEvent
import android.webkit.SslErrorHandler
import android.webkit.WebView
-import androidx.appcompat.content.res.AppCompatResources.getDrawable
import androidx.core.view.NestedScrollingChild2
import androidx.core.view.NestedScrollingChildHelper
import androidx.core.view.ViewCompat
-import com.stoutner.privacybrowser.R
import com.stoutner.privacybrowser.activities.MainWebViewActivity
import java.util.Collections
var httpAuthHandler: HttpAuthHandler? = null
var ignorePinnedDomainInformation = false
var pinnedIpAddresses = ""
+ var previousFavoriteIconDrawable: Drawable? = null
+ var previousWebpageTitle = ""
var sslErrorHandler: SslErrorHandler? = null
var swipeToRefresh = false
var ultraListEnabled = true
nestedScrollingChildHelper.isNestedScrollingEnabled = true
// Initialize the favorite icon.
- initializeFavoriteIcon()
+ resetFavoriteIcon()
}
// Favorite or default icon.
- fun initializeFavoriteIcon() {
- // Get the default favorite icon drawable.
- val favoriteIconDrawable = getDrawable(context, R.drawable.world)
-
- // Cast the favorite icon drawable to a bitmap drawable.
- val favoriteIconBitmapDrawable = (favoriteIconDrawable as BitmapDrawable?)!!
-
+ fun resetFavoriteIcon() {
// Store the default icon bitmap.
- favoriteIcon = favoriteIconBitmapDrawable.bitmap
+ favoriteIcon = MainWebViewActivity.defaultFavoriteIconBitmap
// Set the favorite icon height to be 0. This way any favorite icons presented by the website will overwrite it.
favoriteIconHeight = 0
// Store the current favorite icon height.
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) {
- Bitmap.createScaledBitmap(icon, 256, 256, true)
- } else {
- // Store the icon as presented.
+ // Scale the favorite icon bitmap down if it is larger than 128 in either direction. Filtering uses bilinear interpolation.
+ favoriteIcon = if (icon.height > 128 || icon.width > 128) // Scale the icon before storing it.
+ Bitmap.createScaledBitmap(icon, 128, 128, true)
+ else // Store the icon as presented.
icon
- }
}
fun getFavoriteIcon(): Bitmap {