Skip to content

Commit

Permalink
fix(android): auto-scaling mode must stretch ImageView if both width/…
Browse files Browse the repository at this point in the history
…height set (#13077)

Fixes TIMOB-28537

Co-authored-by: Lokesh Choudhary <lchoudhary@axway.com>
  • Loading branch information
jquick-axway and lokeshchdhry committed Sep 23, 2021
1 parent bdf7e68 commit ea0d99c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
Expand Up @@ -47,7 +47,6 @@ public class TiImageView extends ViewGroup implements Handler.Callback, OnClickL

private OnClickListener clickListener;

private boolean enableScale;
private boolean enableZoomControls;

private boolean isImageRippleEnabled;
Expand Down Expand Up @@ -99,7 +98,6 @@ public TiImageView(Context context)
imageView.setAdjustViewBounds(true);
imageView.setScaleType(ScaleType.MATRIX);
addView(imageView);
setEnableScale(true);

gestureDetector = new GestureDetector(getContext(), new GestureDetector.SimpleOnGestureListener() {
@Override
Expand Down Expand Up @@ -172,12 +170,6 @@ public TiImageView(Context context, TiViewProxy proxy)
this.proxy = new WeakReference<>(proxy);
}

public void setEnableScale(boolean enableScale)
{
this.enableScale = enableScale;
requestLayout();
}

public void setEnableZoomControls(boolean enableZoomControls)
{
this.enableZoomControls = enableZoomControls;
Expand Down Expand Up @@ -407,7 +399,7 @@ private void computeBaseMatrix()
// Apply "scalingMode" to image.
int scalingMode = this.scalingMode;
if (scalingMode == MediaModule.IMAGE_SCALING_AUTO) {
if (!this.enableZoomControls && !this.enableScale && this.viewWidthDefined && this.viewHeightDefined) {
if (this.viewWidthDefined && this.viewHeightDefined) {
scalingMode = MediaModule.IMAGE_SCALING_FILL;
} else {
scalingMode = MediaModule.IMAGE_SCALING_ASPECT_FIT;
Expand Down
Expand Up @@ -32,7 +32,6 @@
import ti.modules.titanium.filesystem.FileProxy;
import ti.modules.titanium.media.MediaModule;
import ti.modules.titanium.ui.ImageViewProxy;
import ti.modules.titanium.ui.ScrollViewProxy;
import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Handler;
Expand Down Expand Up @@ -777,12 +776,6 @@ public void processProperties(KrollDict d)
setTintColor(d.getString("tintColor"));
}

// If height and width is not defined, disable scaling for scrollview since an image
// can extend beyond the screensize in scrollview.
if (proxy.getParent() instanceof ScrollViewProxy && !heightDefined && !widthDefined) {
view.setEnableScale(false);
}

super.processProperties(d);
}

Expand Down

0 comments on commit ea0d99c

Please sign in to comment.