From 1a366254398c3f3c0107f579f486e759ce3daa2f Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 14 Jan 2019 16:10:05 +0100 Subject: [PATCH] center the drawing canvas at the editor --- .../gallery/pro/activities/EditActivity.kt | 15 ++++++++++----- app/src/main/res/layout/activity_edit.xml | 9 +++------ app/src/main/res/values/dimens.xml | 2 ++ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt index e1c619a7f..be4ce6d94 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/EditActivity.kt @@ -85,6 +85,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private var isCropIntent = false private var isEditingWithThirdParty = false private var isSharingBitmap = false + private var wasDrawCanvasPositioned = false private var oldExif: ExifInterface? = null private var filterInitialBitmap: Bitmap? = null @@ -246,10 +247,14 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener default_image_view.beGone() crop_image_view.beGone() editor_draw_canvas.beVisible() - editor_draw_canvas.onGlobalLayout { - Thread { - fillCanvasBackground() - }.start() + + if (!wasDrawCanvasPositioned) { + wasDrawCanvasPositioned = true + editor_draw_canvas.onGlobalLayout { + Thread { + fillCanvasBackground() + }.start() + } } } @@ -275,7 +280,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener updateBackgroundBitmap(bitmap) layoutParams.width = bitmap.width layoutParams.height = bitmap.height - (layoutParams as RelativeLayout.LayoutParams).removeRule(RelativeLayout.ABOVE) + y = (height - bitmap.height) / 2f requestLayout() } } diff --git a/app/src/main/res/layout/activity_edit.xml b/app/src/main/res/layout/activity_edit.xml index bc2d1b016..dcf322124 100644 --- a/app/src/main/res/layout/activity_edit.xml +++ b/app/src/main/res/layout/activity_edit.xml @@ -17,8 +17,7 @@ android:id="@+id/crop_image_view" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_above="@+id/bottom_editor_crop_rotate_actions" - android:layout_marginBottom="@dimen/bottom_actions_height" + android:layout_marginBottom="@dimen/bottom_actions_height_bigger" android:visibility="gone" app:cropBackgroundColor="@color/crop_image_view_background" app:cropInitialCropWindowPaddingRatio="0"/> @@ -27,10 +26,8 @@ android:id="@+id/editor_draw_canvas" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_above="@+id/bottom_editor_crop_rotate_actions" - android:layout_alignParentTop="true" - android:layout_centerInParent="true" - android:layout_marginBottom="@dimen/bottom_actions_height" + android:layout_centerHorizontal="true" + android:layout_marginBottom="@dimen/bottom_actions_height_double" android:background="@android:color/transparent" android:visibility="gone"/> diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index bdebf85ea..d9854752f 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -12,6 +12,8 @@ 50dp 72dp 64dp + 128dp + 164dp 48dp 76dp 90dp