- // Populate the new folder icon bitmap.
- val folderIconBitmap: Bitmap = if (defaultFolderIconRadioButton.isChecked) {
- // Get the default folder icon drawable.
- val folderIconDrawable = defaultFolderIconImageView.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.
- // Copy the favorite icon bitmap to the folder icon bitmap.
- favoriteIconBitmap
- }
-
- // Create a folder icon byte array output stream.
+ // 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)
+
+ // Create a new folder icon byte array output stream.