Add extra protection to image editor crop.

Adds an extra 72dp (height of radial dial) to the protection value
for crop mode. This guarantees that the image is NOT going to have
the bottom inaccessible due to overlap with the radial dial.
fork-5.53.8
Alex Hart 2021-10-06 08:56:21 -03:00
rodzic c225c2b37d
commit 8ef3d3fbbf
1 zmienionych plików z 14 dodań i 4 usunięć

Wyświetl plik

@ -84,7 +84,8 @@ public final class ImageEditorFragment extends Fragment implements ImageEditorHu
private static final int SELECT_STICKER_REQUEST_CODE = 124;
private static final int HUD_PROTECTION = ViewUtil.dpToPx(72);
private static final int DRAW_HUD_PROTECTION = ViewUtil.dpToPx(72);
private static final int CROP_HUD_PROTECTION = ViewUtil.dpToPx(144);
private EditorModel restoredModel;
@ -477,16 +478,25 @@ public final class ImageEditorFragment extends Fragment implements ImageEditorHu
{
boolean shouldScaleViewPortForCurrentMode = shouldScaleViewPort(mode);
boolean shouldScaleViewPortForPreviousMode = shouldScaleViewPort(previousMode);
int hudProtection = getHudProtection(mode);
if (shouldScaleViewPortForCurrentMode != shouldScaleViewPortForPreviousMode || force) {
if (shouldScaleViewPortForCurrentMode) {
scaleViewPortForDrawing(orientation);
scaleViewPortForDrawing(orientation, hudProtection);
} else {
restoreViewPortScaling(orientation);
}
}
}
private int getHudProtection(ImageEditorHudV2.Mode mode) {
if (mode == ImageEditorHudV2.Mode.CROP) {
return CROP_HUD_PROTECTION;
} else {
return DRAW_HUD_PROTECTION;
}
}
@Override
public void onColorChange(int color) {
imageEditorView.setDrawingBrushColor(color);
@ -675,7 +685,7 @@ public final class ImageEditorFragment extends Fragment implements ImageEditorHu
private ResizeAnimation resizeAnimation;
private void scaleViewPortForDrawing(int orientation) {
private void scaleViewPortForDrawing(int orientation, int protection) {
if (resizeAnimation != null) {
resizeAnimation.cancel();
}
@ -683,7 +693,7 @@ public final class ImageEditorFragment extends Fragment implements ImageEditorHu
float aspectRatio = getAspectRatioForOrientation(orientation);
int targetWidth = getWidthForOrientation(orientation) - ViewUtil.dpToPx(32);
int targetHeight = (int) ((1 / aspectRatio) * targetWidth);
int maxHeight = getHeightForOrientation(orientation) - HUD_PROTECTION;
int maxHeight = getHeightForOrientation(orientation) - protection;
if (targetHeight > maxHeight) {
targetHeight = maxHeight;