add an aspect ratio selector to the Editor activity

This commit is contained in:
tibbi 2018-07-18 21:14:03 +02:00
parent 4f4e1d4c73
commit a633330c8e
6 changed files with 23 additions and 3 deletions

View file

@ -29,12 +29,18 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
private val ASPECT_Y = "aspectY" private val ASPECT_Y = "aspectY"
private val CROP = "crop" private val CROP = "crop"
private val ASPECT_RATIO_ANY = 0
private val ASPECT_RATIO_ONE_ONE = 1
private val ASPECT_RATIO_FOUR_THREE = 2
private val ASPECT_RATIO_SIXTEEN_NINE = 3
private lateinit var uri: Uri private lateinit var uri: Uri
private lateinit var saveUri: Uri private lateinit var saveUri: Uri
private var resizeWidth = 0 private var resizeWidth = 0
private var resizeHeight = 0 private var resizeHeight = 0
private var isCropIntent = false private var isCropIntent = false
private var isEditingWithThirdParty = false private var isEditingWithThirdParty = false
private var currentAspectRatio = ASPECT_RATIO_ANY
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -88,8 +94,11 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
setOnCropImageCompleteListener(this@EditActivity) setOnCropImageCompleteListener(this@EditActivity)
setImageUriAsync(uri) setImageUriAsync(uri)
if (isCropIntent && shouldCropSquare()) if (isCropIntent && shouldCropSquare()) {
currentAspectRatio = ASPECT_RATIO_ONE_ONE
setFixedAspectRatio(true) setFixedAspectRatio(true)
bottom_aspect_ratio.beGone()
}
} }
setupBottomActions() setupBottomActions()

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

View file

@ -27,10 +27,21 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="@dimen/medium_margin" android:padding="@dimen/medium_margin"
android:src="@drawable/ic_minimize" android:src="@drawable/ic_minimize"
app:layout_constraintEnd_toStartOf="@+id/bottom_flip_horizontally" app:layout_constraintEnd_toStartOf="@+id/bottom_aspect_ratio"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/bottom_rotate"/> app:layout_constraintStart_toEndOf="@+id/bottom_rotate"/>
<ImageView
android:id="@+id/bottom_aspect_ratio"
style="@style/MyBorderlessBackgroundStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/medium_margin"
android:src="@drawable/ic_aspect_ratio"
app:layout_constraintEnd_toStartOf="@+id/bottom_flip_horizontally"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/bottom_resize"/>
<ImageView <ImageView
android:id="@+id/bottom_flip_horizontally" android:id="@+id/bottom_flip_horizontally"
style="@style/MyBorderlessBackgroundStyle" style="@style/MyBorderlessBackgroundStyle"
@ -40,7 +51,7 @@
android:src="@drawable/ic_flip_horizontally" android:src="@drawable/ic_flip_horizontally"
app:layout_constraintEnd_toStartOf="@+id/bottom_flip_vertically" app:layout_constraintEnd_toStartOf="@+id/bottom_flip_vertically"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/bottom_resize"/> app:layout_constraintStart_toEndOf="@+id/bottom_aspect_ratio"/>
<ImageView <ImageView
android:id="@+id/bottom_flip_vertically" android:id="@+id/bottom_flip_vertically"