Skip to content

Commit 9fc7eee

Browse files
committed
First step at extracting the old editor (moving Media related method to the EditPostActivity, they should end up in their own class/lib)
1 parent 4917b74 commit 9fc7eee

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

WordPressUtils/src/main/java/org/wordpress/android/util/ImageUtils.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import android.graphics.Color;
1010
import android.graphics.Matrix;
1111
import android.graphics.Paint;
12+
import android.graphics.Point;
1213
import android.graphics.PorterDuff;
1314
import android.graphics.PorterDuffXfermode;
1415
import android.graphics.Rect;
@@ -557,4 +558,21 @@ public static Bitmap getRoundedEdgeBitmap(final Bitmap bitmap, int radius) {
557558

558559
return output;
559560
}
561+
562+
/**
563+
* Get the maximum size a thumbnail can be to fit in either portrait or landscape orientations.
564+
*/
565+
private static int sMaximumThumbnailWidthForEditor;
566+
public static int getMaximumThumbnailWidthForEditor(Context context) {
567+
if (sMaximumThumbnailWidthForEditor == 0) {
568+
Point size = DisplayUtils.getDisplayPixelSize(context);
569+
int screenWidth = size.x;
570+
int screenHeight = size.y;
571+
sMaximumThumbnailWidthForEditor = (screenWidth > screenHeight) ? screenHeight : screenWidth;
572+
// 48dp of padding on each side so you can still place the cursor next to the image.
573+
int padding = DisplayUtils.dpToPx(context, 48) * 2;
574+
sMaximumThumbnailWidthForEditor -= padding;
575+
}
576+
return sMaximumThumbnailWidthForEditor;
577+
}
560578
}

0 commit comments

Comments
 (0)