add an aspect ratio selector to the Editor activity
This commit is contained in:
parent
4f4e1d4c73
commit
a633330c8e
6 changed files with 23 additions and 3 deletions
|
@ -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()
|
||||
|
|
BIN
app/src/main/res/drawable-hdpi/ic_aspect_ratio.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_aspect_ratio.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 198 B |
BIN
app/src/main/res/drawable-xhdpi/ic_aspect_ratio.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_aspect_ratio.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 174 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_aspect_ratio.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_aspect_ratio.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 221 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_aspect_ratio.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/ic_aspect_ratio.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 289 B |
|
@ -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"/>
|
||||
|
||||
<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
|
||||
android:id="@+id/bottom_flip_horizontally"
|
||||
style="@style/MyBorderlessBackgroundStyle"
|
||||
|
@ -40,7 +51,7 @@
|
|||
android:src="@drawable/ic_flip_horizontally"
|
||||
app:layout_constraintEnd_toStartOf="@+id/bottom_flip_vertically"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toEndOf="@+id/bottom_resize"/>
|
||||
app:layout_constraintStart_toEndOf="@+id/bottom_aspect_ratio"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bottom_flip_vertically"
|
||||
|
|
Loading…
Reference in a new issue