- // Get the new folder icon bitmap.
- val folderIconBitmap = if (defaultIconRadioButton.isChecked) {
- // Get the default folder icon drawable.
- val folderIconDrawable = defaultIconImageView.drawable
-
- // Convert the folder icon drawable to a bitmap drawable.
- val folderIconBitmapDrawable = folderIconDrawable as BitmapDrawable
-
- // Convert the folder icon bitmap drawable to a bitmap.
- folderIconBitmapDrawable.bitmap
- } else { // Use the `WebView` favorite icon.
- // Get a copy of the favorite icon bitmap.
- favoriteIconBitmap
- }
+ // Get the selected folder icon drawable.
+ val folderIconDrawable = if (defaultFolderIconRadioButton.isChecked) // The default folder icon is checked.
+ defaultFolderIconImageView.drawable
+ else if (webpageFavoriteIconRadioButton.isChecked) // The webpage favorite icon is checked.
+ webpageFavoriteIconImageView.drawable
+ else // The custom icon is checked.
+ customIconImageView.drawable
+
+ // Convert the folder icon drawable to a bitmap. Once the minimum API >= 33, this can use Bitmap.Config.RGBA_1010102.
+ val folderIconBitmap = folderIconDrawable.toBitmap(128, 128, Bitmap.Config.ARGB_8888)