import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
+import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@Override
@NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
+ // Get a copy of the favorite icon bitmap.
+ Bitmap favoriteIconBitmap = MainWebViewActivity.favoriteIconBitmap;
+
+ // Scale the favorite icon bitmap down if it is larger than 256 x 256. Filtering uses bilinear interpolation.
+ if ((favoriteIconBitmap.getHeight() > 256) || (favoriteIconBitmap.getWidth() > 256)) {
+ favoriteIconBitmap = Bitmap.createScaledBitmap(favoriteIconBitmap, 256, 256, true);
+ }
+
// Create a drawable version of the favorite icon.
- Drawable favoriteIconDrawable = new BitmapDrawable(getResources(), MainWebViewActivity.favoriteIconBitmap);
+ Drawable favoriteIconDrawable = new BitmapDrawable(getResources(), favoriteIconBitmap);
- // Use `AlertDialog.Builder` to create the `AlertDialog`.
+ // Use an alert dialog builder to create the alert dialog.
AlertDialog.Builder dialogBuilder;
// Set the style according to the theme.
// Show the keyboard when the `AlertDialog` is displayed on the screen.
alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
- // The `AlertDialog` needs to be shown before `setOnKeyListener()` can be called.
+ // The alert dialog needs to be shown before `setOnKeyListener()` can be called.
alertDialog.show();
// Get a handle for `create_bookmark_name_edittext`.
}
});
- // `onCreateDialog()` requires the return of an `AlertDialog`.
+ // Return the alert dialog.
return alertDialog;
}
}
\ No newline at end of file