From a633330c8ec559129df158e9434c01a8d6eaea56 Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 18 Jul 2018 21:14:03 +0200 Subject: [PATCH] add an aspect ratio selector to the Editor activity --- .../gallery/activities/EditActivity.kt | 11 ++++++++++- .../main/res/drawable-hdpi/ic_aspect_ratio.png | Bin 0 -> 198 bytes .../main/res/drawable-xhdpi/ic_aspect_ratio.png | Bin 0 -> 174 bytes .../main/res/drawable-xxhdpi/ic_aspect_ratio.png | Bin 0 -> 221 bytes .../res/drawable-xxxhdpi/ic_aspect_ratio.png | Bin 0 -> 289 bytes .../main/res/layout/bottom_editor_actions.xml | 15 +++++++++++++-- 6 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_aspect_ratio.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_aspect_ratio.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_aspect_ratio.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_aspect_ratio.png diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt index 3eb5c1fdb..fafa777a2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -29,12 +29,18 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private val ASPECT_Y = "aspectY" 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 saveUri: Uri private var resizeWidth = 0 private var resizeHeight = 0 private var isCropIntent = false private var isEditingWithThirdParty = false + private var currentAspectRatio = ASPECT_RATIO_ANY override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -88,8 +94,11 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener setOnCropImageCompleteListener(this@EditActivity) setImageUriAsync(uri) - if (isCropIntent && shouldCropSquare()) + if (isCropIntent && shouldCropSquare()) { + currentAspectRatio = ASPECT_RATIO_ONE_ONE setFixedAspectRatio(true) + bottom_aspect_ratio.beGone() + } } setupBottomActions() diff --git a/app/src/main/res/drawable-hdpi/ic_aspect_ratio.png b/app/src/main/res/drawable-hdpi/ic_aspect_ratio.png new file mode 100644 index 0000000000000000000000000000000000000000..81c7958d6259166b615863f9a33025da5a0e1e93 GIT binary patch literal 198 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k1|%Oc%$NbBdOcknLn;{GUf;;updjFuXm&Yj zE{C+(g(JN;-b6O3#kpGe{L^39DxT4IVG@S{qoBv!FqUQOXK>qJw@y2HKaBmY$j--; zQ@i%^d5LJ2B+U7}SRrBCx;x4mi5&i1r<`qP3NBD!wUk+-zvatv@gIEVEN>kI?Y#i>c|sp*S)U3?vLm!5Lqf59txgJG{O^K^lS zj}H81FqiqEF2HZ`pdsf1BfDI~lLiZg2M4+jFul-~zxTbZDQaP#%keXfrw)3Erzxpl X&`rN9s%O9sbO3{=tDnm{r-UW|RFppm literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxhdpi/ic_aspect_ratio.png b/app/src/main/res/drawable-xxhdpi/ic_aspect_ratio.png new file mode 100644 index 0000000000000000000000000000000000000000..cc07c4c257229df4d15f34d33236543406922c67 GIT binary patch literal 221 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY0wn)GsXhawmUy~2hEy=Vy}6OMDL{hZAv>?} ziHazrcNr--zdK_$_V>1iOzma7ve5xz@)k%=R>N z%NmQ|;`FdBPYX@Hq^ww8$rCYQscWa=Z1xD5Wklt2oYSbhZQgBjmavi>*6 z_ot_1i7_4yx&MB*Q1ZNN2Ej#%v$LCo7Nti1<;d`ij&nV}IU>PgQu&X%Q~loCIDylW>x?I literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/bottom_editor_actions.xml b/app/src/main/res/layout/bottom_editor_actions.xml index 7ffe42837..7dcbb0a9d 100644 --- a/app/src/main/res/layout/bottom_editor_actions.xml +++ b/app/src/main/res/layout/bottom_editor_actions.xml @@ -27,10 +27,21 @@ android:layout_height="wrap_content" android:padding="@dimen/medium_margin" 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_constraintStart_toEndOf="@+id/bottom_rotate"/> + + + app:layout_constraintStart_toEndOf="@+id/bottom_aspect_ratio"/>