From 00872106c24d693064ed4a4797483be2bbecaf1b Mon Sep 17 00:00:00 2001 From: nuclearfog Date: Fri, 5 May 2023 19:01:39 +0200 Subject: [PATCH] toolbar blur fix --- .../nuclearfog/twidda/backend/utils/AppStyles.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/org/nuclearfog/twidda/backend/utils/AppStyles.java b/app/src/main/java/org/nuclearfog/twidda/backend/utils/AppStyles.java index 1fcb1e31..6f45422f 100644 --- a/app/src/main/java/org/nuclearfog/twidda/backend/utils/AppStyles.java +++ b/app/src/main/java/org/nuclearfog/twidda/backend/utils/AppStyles.java @@ -258,19 +258,12 @@ public class AppStyles { // crop image to background size if (background.getMeasuredHeight() > 0 && background.getMeasuredWidth() > 0) { CropTransformation crop; - if (image.getWidth() > background.getMeasuredWidth()) { - int height = image.getWidth() * background.getMeasuredHeight() / background.getMeasuredWidth(); - crop = new CropTransformation(image.getWidth(), height, GravityHorizontal.CENTER, GravityVertical.CENTER); - } else if (image.getWidth() < background.getMeasuredWidth()) { - int width = image.getHeight() * background.getMeasuredWidth() / background.getMeasuredHeight(); - crop = new CropTransformation(width, image.getHeight(), GravityHorizontal.CENTER, GravityVertical.CENTER); - } else { - crop = new CropTransformation(image.getWidth(), background.getMeasuredHeight(), GravityHorizontal.CENTER, GravityVertical.CENTER); - } + int height = image.getWidth() * background.getMeasuredHeight() / background.getMeasuredWidth(); + crop = new CropTransformation(image.getWidth(), height, GravityHorizontal.CENTER, GravityVertical.CENTER); image = crop.transform(image); } int widthPixels = Resources.getSystem().getDisplayMetrics().widthPixels; - int blurRadius = Math.max(Math.round(widthPixels * 10.0f / image.getWidth()), 10); + int blurRadius = Math.max(Math.round((image.getWidth() * 20.0f) / widthPixels), 10); float toolbarRatio = activity.getResources().getDimension(R.dimen.profile_toolbar_height) / widthPixels; // do final transformations (crop first image to toolbar background size, then blur) BlurTransformation blur = new BlurTransformation(activity.getApplicationContext(), blurRadius);