diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index a2399ed96..6bf5ed082 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -54,6 +54,7 @@
- @string/scale_type_fit_width
- @string/scale_type_fit_height
- @string/scale_type_original_size
+ - @string/scale_type_smart_fit
@@ -62,6 +63,7 @@
- 3
- 4
- 5
+ - 6
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 2e4b5775b..1424644e7 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -103,6 +103,8 @@
Fit width
Fit height
Original size
+ Smart fit
+
Downloads directory
diff --git a/libs/SubsamplingScaleImageView/src/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java b/libs/SubsamplingScaleImageView/src/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java
index 0c8622099..40830d40a 100644
--- a/libs/SubsamplingScaleImageView/src/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java
+++ b/libs/SubsamplingScaleImageView/src/com/davemorrissey/labs/subscaleview/SubsamplingScaleImageView.java
@@ -124,11 +124,12 @@ public class SubsamplingScaleImageView extends View {
public static final int SCALE_TYPE_FIT_WIDTH = 3;
public static final int SCALE_TYPE_FIT_HEIGHT = 4;
public static final int SCALE_TYPE_ORIGINAL_SIZE = 5;
+ public static final int SCALE_TYPE_SMART_FIT = 6;
/** Scale the image so that both dimensions of the image will be equal to or less than the maxScale and equal to or larger than minScale. The image is then centered in the view. */
- public static final int SCALE_TYPE_CUSTOM = 6;
+ public static final int SCALE_TYPE_CUSTOM = 7;
- private static final List VALID_SCALE_TYPES = Arrays.asList(SCALE_TYPE_CENTER_CROP, SCALE_TYPE_CENTER_INSIDE, SCALE_TYPE_CUSTOM, SCALE_TYPE_FIT_WIDTH, SCALE_TYPE_FIT_HEIGHT, SCALE_TYPE_ORIGINAL_SIZE);
+ private static final List VALID_SCALE_TYPES = Arrays.asList(SCALE_TYPE_CENTER_CROP, SCALE_TYPE_CENTER_INSIDE, SCALE_TYPE_CUSTOM, SCALE_TYPE_FIT_WIDTH, SCALE_TYPE_FIT_HEIGHT, SCALE_TYPE_SMART_FIT, SCALE_TYPE_ORIGINAL_SIZE);
// Bitmap (preview or full image)
private Bitmap bitmap;
@@ -2019,6 +2020,14 @@ public class SubsamplingScaleImageView extends View {
return (getHeight() - vPadding) / (float) sHeight();
case SCALE_TYPE_ORIGINAL_SIZE:
return 1;
+ case SCALE_TYPE_SMART_FIT:
+ if (sWidth <= sHeight) {
+ // Fit to width
+ return (getWidth() - hPadding) / (float) sWidth();
+ } else {
+ // Fit to height
+ return (getHeight() - vPadding) / (float) sHeight();
+ }
case SCALE_TYPE_CUSTOM:
return minScale;
}