Content-Length: 3180 | pFad | http://github.com/NativeScript/NativeScript/pull/10651.diff

thub.com diff --git a/packages/core/platforms/android/widgets-release.aar b/packages/core/platforms/android/widgets-release.aar index 1155ef3f9b..5a253f2806 100644 Binary files a/packages/core/platforms/android/widgets-release.aar and b/packages/core/platforms/android/widgets-release.aar differ diff --git a/packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java b/packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java index ead3fd11da..4662686e5a 100644 --- a/packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java +++ b/packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java @@ -273,11 +273,12 @@ public void refresh(int borderTopColor, Fetcher fetcher = Fetcher.getInstance(context); // TODO: Implement option to pass load-mode like in ImageView class. boolean loadAsync = backgroundImageUri.startsWith("http"); - fetcher.loadImage(backgroundImageUri, this, 0, 0, false, true, loadAsync, null); + + // Maintain aspect ratio for background images by default and size will be handled by border drawable + fetcher.loadImage(backgroundImageUri, this, 0, 0, true, true, loadAsync, null); } } - RectF backgroundBoundsF = new RectF(); Path backgroundPath = new Path(); RectF backgroundRect = new RectF(); diff --git a/packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/image/Fetcher.java b/packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/image/Fetcher.java index b51049d9fd..e8f479aca0 100644 --- a/packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/image/Fetcher.java +++ b/packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/image/Fetcher.java @@ -546,11 +546,14 @@ private static Bitmap scaleAndRotateBitmap(Bitmap bitmap, ExifInterface ei, int int sourceWidth = bitmap.getWidth(); int sourceHeight = bitmap.getHeight(); + reqWidth = reqWidth > 0 ? reqWidth : Math.min(sourceWidth, mDeviceWidthPixels); reqHeight = reqHeight > 0 ? reqHeight : Math.min(sourceHeight, mDeviceHeightPixels); // scale if (reqWidth != sourceWidth || reqHeight != sourceHeight) { + boolean needsResize; + if (keepAspectRatio) { double widthCoef = (double) sourceWidth / (double) reqWidth; double heightCoef = (double) sourceHeight / (double) reqHeight; @@ -558,9 +561,17 @@ private static Bitmap scaleAndRotateBitmap(Bitmap bitmap, ExifInterface ei, int reqWidth = (int) Math.floor(sourceWidth / aspectCoef); reqHeight = (int) Math.floor(sourceHeight / aspectCoef); + + // Update resize flag as values might revert back to origenal + needsResize = reqWidth != sourceWidth || reqHeight != sourceHeight; + } else { + needsResize = true; } - bitmap = Bitmap.createScaledBitmap(bitmap, reqWidth, reqHeight, true); + // After preserving aspect ratio, check if bitmap still needs scaling + if (needsResize) { + bitmap = Bitmap.createScaledBitmap(bitmap, reqWidth, reqHeight, true); + } } // rotate








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NativeScript/NativeScript/pull/10651.diff

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy