center the drawing canvas at the editor

This commit is contained in:
tibbi 2019-01-14 16:10:05 +01:00
parent 0b0def35d8
commit 1a36625439
3 changed files with 15 additions and 11 deletions

View file

@ -85,6 +85,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
private var isCropIntent = false private var isCropIntent = false
private var isEditingWithThirdParty = false private var isEditingWithThirdParty = false
private var isSharingBitmap = false private var isSharingBitmap = false
private var wasDrawCanvasPositioned = false
private var oldExif: ExifInterface? = null private var oldExif: ExifInterface? = null
private var filterInitialBitmap: Bitmap? = null private var filterInitialBitmap: Bitmap? = null
@ -246,10 +247,14 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
default_image_view.beGone() default_image_view.beGone()
crop_image_view.beGone() crop_image_view.beGone()
editor_draw_canvas.beVisible() editor_draw_canvas.beVisible()
editor_draw_canvas.onGlobalLayout {
Thread { if (!wasDrawCanvasPositioned) {
fillCanvasBackground() wasDrawCanvasPositioned = true
}.start() editor_draw_canvas.onGlobalLayout {
Thread {
fillCanvasBackground()
}.start()
}
} }
} }
@ -275,7 +280,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
updateBackgroundBitmap(bitmap) updateBackgroundBitmap(bitmap)
layoutParams.width = bitmap.width layoutParams.width = bitmap.width
layoutParams.height = bitmap.height layoutParams.height = bitmap.height
(layoutParams as RelativeLayout.LayoutParams).removeRule(RelativeLayout.ABOVE) y = (height - bitmap.height) / 2f
requestLayout() requestLayout()
} }
} }

View file

@ -17,8 +17,7 @@
android:id="@+id/crop_image_view" android:id="@+id/crop_image_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_above="@+id/bottom_editor_crop_rotate_actions" android:layout_marginBottom="@dimen/bottom_actions_height_bigger"
android:layout_marginBottom="@dimen/bottom_actions_height"
android:visibility="gone" android:visibility="gone"
app:cropBackgroundColor="@color/crop_image_view_background" app:cropBackgroundColor="@color/crop_image_view_background"
app:cropInitialCropWindowPaddingRatio="0"/> app:cropInitialCropWindowPaddingRatio="0"/>
@ -27,10 +26,8 @@
android:id="@+id/editor_draw_canvas" android:id="@+id/editor_draw_canvas"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_above="@+id/bottom_editor_crop_rotate_actions" android:layout_centerHorizontal="true"
android:layout_alignParentTop="true" android:layout_marginBottom="@dimen/bottom_actions_height_double"
android:layout_centerInParent="true"
android:layout_marginBottom="@dimen/bottom_actions_height"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:visibility="gone"/> android:visibility="gone"/>

View file

@ -12,6 +12,8 @@
<dimen name="instant_change_bar_width">50dp</dimen> <dimen name="instant_change_bar_width">50dp</dimen>
<dimen name="list_view_folder_thumbnail_size">72dp</dimen> <dimen name="list_view_folder_thumbnail_size">72dp</dimen>
<dimen name="bottom_actions_height">64dp</dimen> <dimen name="bottom_actions_height">64dp</dimen>
<dimen name="bottom_actions_height_double">128dp</dimen>
<dimen name="bottom_actions_height_bigger">164dp</dimen>
<dimen name="bottom_editor_color_picker_size">48dp</dimen> <dimen name="bottom_editor_color_picker_size">48dp</dimen>
<dimen name="bottom_filters_thumbnail_size">76dp</dimen> <dimen name="bottom_filters_thumbnail_size">76dp</dimen>
<dimen name="bottom_filters_height">90dp</dimen> <dimen name="bottom_filters_height">90dp</dimen>