adding an Other aspect ratio button to the editor
This commit is contained in:
parent
bfb8b09a68
commit
2b49095ab5
4 changed files with 230 additions and 4 deletions
|
@ -27,6 +27,7 @@ import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import com.simplemobiletools.gallery.pro.adapters.FiltersAdapter
|
import com.simplemobiletools.gallery.pro.adapters.FiltersAdapter
|
||||||
|
import com.simplemobiletools.gallery.pro.dialogs.OtherAspectRatioDialog
|
||||||
import com.simplemobiletools.gallery.pro.dialogs.ResizeDialog
|
import com.simplemobiletools.gallery.pro.dialogs.ResizeDialog
|
||||||
import com.simplemobiletools.gallery.pro.dialogs.SaveAsDialog
|
import com.simplemobiletools.gallery.pro.dialogs.SaveAsDialog
|
||||||
import com.simplemobiletools.gallery.pro.extensions.config
|
import com.simplemobiletools.gallery.pro.extensions.config
|
||||||
|
@ -58,6 +59,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
private val ASPECT_RATIO_ONE_ONE = 1
|
private val ASPECT_RATIO_ONE_ONE = 1
|
||||||
private val ASPECT_RATIO_FOUR_THREE = 2
|
private val ASPECT_RATIO_FOUR_THREE = 2
|
||||||
private val ASPECT_RATIO_SIXTEEN_NINE = 3
|
private val ASPECT_RATIO_SIXTEEN_NINE = 3
|
||||||
|
private val ASPECT_RATIO_OTHER = 4
|
||||||
|
|
||||||
// constants for bottom primary action groups
|
// constants for bottom primary action groups
|
||||||
private val PRIMARY_ACTION_NONE = 0
|
private val PRIMARY_ACTION_NONE = 0
|
||||||
|
@ -71,6 +73,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
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 lastOtherAspectRatio: Pair<Int, Int>? = null
|
||||||
private var currPrimaryAction = PRIMARY_ACTION_NONE
|
private var currPrimaryAction = PRIMARY_ACTION_NONE
|
||||||
private var currCropRotateAction = CROP_ROTATE_NONE
|
private var currCropRotateAction = CROP_ROTATE_NONE
|
||||||
private var currAspectRatio = ASPECT_RATIO_FREE
|
private var currAspectRatio = ASPECT_RATIO_FREE
|
||||||
|
@ -328,6 +331,14 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
bottom_aspect_ratio_sixteen_nine.setOnClickListener {
|
bottom_aspect_ratio_sixteen_nine.setOnClickListener {
|
||||||
updateAspectRatio(ASPECT_RATIO_SIXTEEN_NINE)
|
updateAspectRatio(ASPECT_RATIO_SIXTEEN_NINE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bottom_aspect_ratio_other.setOnClickListener {
|
||||||
|
OtherAspectRatioDialog(this) {
|
||||||
|
lastOtherAspectRatio = it
|
||||||
|
updateAspectRatio(ASPECT_RATIO_OTHER)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateAspectRatioButtons()
|
updateAspectRatioButtons()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,7 +420,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
val newAspectRatio = when (aspectRatio) {
|
val newAspectRatio = when (aspectRatio) {
|
||||||
ASPECT_RATIO_ONE_ONE -> Pair(1, 1)
|
ASPECT_RATIO_ONE_ONE -> Pair(1, 1)
|
||||||
ASPECT_RATIO_FOUR_THREE -> Pair(4, 3)
|
ASPECT_RATIO_FOUR_THREE -> Pair(4, 3)
|
||||||
else -> Pair(16, 9)
|
ASPECT_RATIO_SIXTEEN_NINE -> Pair(16, 9)
|
||||||
|
else -> Pair(lastOtherAspectRatio!!.first, lastOtherAspectRatio!!.second)
|
||||||
}
|
}
|
||||||
|
|
||||||
setAspectRatio(newAspectRatio.first, newAspectRatio.second)
|
setAspectRatio(newAspectRatio.first, newAspectRatio.second)
|
||||||
|
@ -418,7 +430,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateAspectRatioButtons() {
|
private fun updateAspectRatioButtons() {
|
||||||
arrayOf(bottom_aspect_ratio_free, bottom_aspect_ratio_one_one, bottom_aspect_ratio_four_three, bottom_aspect_ratio_sixteen_nine).forEach {
|
arrayOf(bottom_aspect_ratio_free, bottom_aspect_ratio_one_one, bottom_aspect_ratio_four_three, bottom_aspect_ratio_sixteen_nine, bottom_aspect_ratio_other).forEach {
|
||||||
it.setTextColor(Color.WHITE)
|
it.setTextColor(Color.WHITE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,7 +438,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
||||||
ASPECT_RATIO_FREE -> bottom_aspect_ratio_free
|
ASPECT_RATIO_FREE -> bottom_aspect_ratio_free
|
||||||
ASPECT_RATIO_ONE_ONE -> bottom_aspect_ratio_one_one
|
ASPECT_RATIO_ONE_ONE -> bottom_aspect_ratio_one_one
|
||||||
ASPECT_RATIO_FOUR_THREE -> bottom_aspect_ratio_four_three
|
ASPECT_RATIO_FOUR_THREE -> bottom_aspect_ratio_four_three
|
||||||
else -> bottom_aspect_ratio_sixteen_nine
|
ASPECT_RATIO_SIXTEEN_NINE -> bottom_aspect_ratio_sixteen_nine
|
||||||
|
else -> bottom_aspect_ratio_other
|
||||||
}
|
}
|
||||||
|
|
||||||
currentAspectRatioButton.setTextColor(config.primaryColor)
|
currentAspectRatioButton.setTextColor(config.primaryColor)
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.simplemobiletools.gallery.pro.dialogs
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
|
import com.simplemobiletools.gallery.pro.R
|
||||||
|
import kotlinx.android.synthetic.main.dialog_other_aspect_ratio.view.*
|
||||||
|
|
||||||
|
class OtherAspectRatioDialog(val activity: BaseSimpleActivity, val callback: (aspectRatio: Pair<Int, Int>) -> Unit) {
|
||||||
|
private val dialog: AlertDialog
|
||||||
|
|
||||||
|
init {
|
||||||
|
val view = activity.layoutInflater.inflate(R.layout.dialog_other_aspect_ratio, null).apply {
|
||||||
|
other_aspect_ratio_2_1.setOnClickListener { ratioPicked(Pair(2, 1)) }
|
||||||
|
other_aspect_ratio_3_2.setOnClickListener { ratioPicked(Pair(3, 2)) }
|
||||||
|
other_aspect_ratio_4_3.setOnClickListener { ratioPicked(Pair(4, 3)) }
|
||||||
|
other_aspect_ratio_5_3.setOnClickListener { ratioPicked(Pair(5, 3)) }
|
||||||
|
other_aspect_ratio_16_9.setOnClickListener { ratioPicked(Pair(16, 9)) }
|
||||||
|
other_aspect_ratio_19_9.setOnClickListener { ratioPicked(Pair(19, 9)) }
|
||||||
|
|
||||||
|
other_aspect_ratio_1_2.setOnClickListener { ratioPicked(Pair(1, 2)) }
|
||||||
|
other_aspect_ratio_2_3.setOnClickListener { ratioPicked(Pair(2, 3)) }
|
||||||
|
other_aspect_ratio_3_4.setOnClickListener { ratioPicked(Pair(3, 4)) }
|
||||||
|
other_aspect_ratio_3_5.setOnClickListener { ratioPicked(Pair(3, 5)) }
|
||||||
|
other_aspect_ratio_9_16.setOnClickListener { ratioPicked(Pair(9, 16)) }
|
||||||
|
other_aspect_ratio_9_19.setOnClickListener { ratioPicked(Pair(9, 19)) }
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog = AlertDialog.Builder(activity)
|
||||||
|
.setNegativeButton(R.string.cancel, null)
|
||||||
|
.create().apply {
|
||||||
|
activity.setupDialogStuff(view, this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun ratioPicked(pair: Pair<Int, Int>) {
|
||||||
|
callback(pair)
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
}
|
|
@ -56,8 +56,22 @@
|
||||||
android:text="16:9"
|
android:text="16:9"
|
||||||
android:textColor="@android:color/white"
|
android:textColor="@android:color/white"
|
||||||
android:textSize="@dimen/big_text_size"
|
android:textSize="@dimen/big_text_size"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toStartOf="@+id/bottom_aspect_ratio_other"
|
||||||
app:layout_constraintHorizontal_bias="0.5"
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
app:layout_constraintStart_toEndOf="@+id/bottom_aspect_ratio_four_three"/>
|
app:layout_constraintStart_toEndOf="@+id/bottom_aspect_ratio_four_three"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/bottom_aspect_ratio_other"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackgroundBorderless"
|
||||||
|
android:padding="@dimen/activity_margin"
|
||||||
|
android:text="@string/other_aspect_ratio"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="@dimen/big_text_size"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/bottom_aspect_ratio_sixteen_nine"/>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
159
app/src/main/res/layout/dialog_other_aspect_ratio.xml
Normal file
159
app/src/main/res/layout/dialog_other_aspect_ratio.xml
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ScrollView
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/other_aspect_ratio_dialog_scrollview"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/other_aspect_ratio_dialog_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
|
android:paddingTop="@dimen/activity_margin"
|
||||||
|
android:paddingRight="@dimen/activity_margin"
|
||||||
|
tools:ignore="HardcodedText">
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/other_aspect_ratio_dialog_radio_1"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/medium_margin"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/other_aspect_ratio_2_1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/small_margin"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:text="2:1"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/other_aspect_ratio_3_2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/small_margin"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:text="3:2"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/other_aspect_ratio_4_3"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/small_margin"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:text="4:3"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/other_aspect_ratio_5_3"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/small_margin"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:text="5:3"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/other_aspect_ratio_16_9"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/small_margin"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:text="16:9"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/other_aspect_ratio_19_9"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/small_margin"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:text="19:9"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/other_aspect_ratio_dialog_radio_2"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="@dimen/medium_margin"
|
||||||
|
android:layout_weight="1">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/other_aspect_ratio_1_2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/small_margin"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:text="1:2"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/other_aspect_ratio_2_3"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/small_margin"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:text="2:3"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/other_aspect_ratio_3_4"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/small_margin"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:text="3:4"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/other_aspect_ratio_3_5"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/small_margin"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:text="3:5"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/other_aspect_ratio_9_16"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/small_margin"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:text="9:16"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyCompatRadioButton
|
||||||
|
android:id="@+id/other_aspect_ratio_9_19"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/small_margin"
|
||||||
|
android:paddingTop="@dimen/normal_margin"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:text="9:19"
|
||||||
|
android:textSize="@dimen/bigger_text_size"/>
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
Loading…
Reference in a new issue