From baec75dc62056b9b904b1a823dde92401e1498f8 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 19 Jul 2018 20:12:03 +0200 Subject: [PATCH] add some more buttons at the bottom of the Editor --- .../gallery/activities/EditActivity.kt | 79 ++++++++++++++---- .../res/drawable-hdpi/ic_photo_filter.png | Bin 0 -> 292 bytes .../res/drawable-xhdpi/ic_photo_filter.png | Bin 0 -> 324 bytes .../res/drawable-xxhdpi/ic_photo_filter.png | Bin 0 -> 473 bytes .../res/drawable-xxxhdpi/ic_photo_filter.png | Bin 0 -> 585 bytes app/src/main/res/layout/activity_edit.xml | 14 +++- ... => bottom_editor_crop_rotate_actions.xml} | 3 +- .../layout/bottom_editor_primary_actions.xml | 37 ++++++++ 8 files changed, 112 insertions(+), 21 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_photo_filter.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_photo_filter.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_photo_filter.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_photo_filter.png rename app/src/main/res/layout/{bottom_editor_actions.xml => bottom_editor_crop_rotate_actions.xml} (96%) create mode 100644 app/src/main/res/layout/bottom_editor_primary_actions.xml 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 0d38df221..d8e53214b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -24,7 +24,8 @@ import com.simplemobiletools.gallery.extensions.openEditor import com.theartofdev.edmodo.cropper.CropImageView import kotlinx.android.synthetic.main.activity_edit.* import kotlinx.android.synthetic.main.bottom_actions_aspect_ratio.* -import kotlinx.android.synthetic.main.bottom_editor_actions.* +import kotlinx.android.synthetic.main.bottom_editor_crop_rotate_actions.* +import kotlinx.android.synthetic.main.bottom_editor_primary_actions.* import java.io.* class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener { @@ -38,17 +39,22 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private val ASPECT_RATIO_SIXTEEN_NINE = 3 // constants for bottom primary action groups - private val PRIMARY_NONE = 0 - private val PRIMARY_ASPECT_RATIO = 1 + private val PRIMARY_ACTION_NONE = 0 + private val PRIMARY_ACTION_FILTER = 1 + private val PRIMARY_ACTION_CROP_ROTATE = 2 + + private val CROP_ROTATE_NONE = 0 + private val CROP_ROTATE_ASPECT_RATIO = 1 private lateinit var uri: Uri private lateinit var saveUri: Uri private var resizeWidth = 0 private var resizeHeight = 0 - private var currPrimaryAction = PRIMARY_NONE + private var currPrimaryAction = PRIMARY_ACTION_NONE + private var currCropRotateAction = CROP_ROTATE_NONE + private var currAspectRatio = ASPECT_RATIO_FREE private var isCropIntent = false private var isEditingWithThirdParty = false - private var currentAspectRatio = ASPECT_RATIO_FREE override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -104,14 +110,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener guidelines = CropImageView.Guidelines.ON if (isCropIntent && shouldCropSquare()) { - currentAspectRatio = ASPECT_RATIO_ONE_ONE + currAspectRatio = ASPECT_RATIO_ONE_ONE setFixedAspectRatio(true) bottom_aspect_ratio.beGone() } } setupBottomActions() - bottom_aspect_ratio.performClick() } override fun onResume() { @@ -142,10 +147,31 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener private fun setupBottomActions() { setupPrimaryActionButtons() + setupCropRotateActionButtons() setupAspectRatioButtons() } private fun setupPrimaryActionButtons() { + bottom_primary_filter.setOnClickListener { + currPrimaryAction = if (currPrimaryAction == PRIMARY_ACTION_FILTER) { + PRIMARY_ACTION_NONE + } else { + PRIMARY_ACTION_FILTER + } + updatePrimaryActionButtons() + } + + bottom_primary_crop_rotate.setOnClickListener { + currPrimaryAction = if (currPrimaryAction == PRIMARY_ACTION_CROP_ROTATE) { + PRIMARY_ACTION_NONE + } else { + PRIMARY_ACTION_CROP_ROTATE + } + updatePrimaryActionButtons() + } + } + + private fun setupCropRotateActionButtons() { bottom_rotate.setOnClickListener { crop_image_view.rotateImage(90) } @@ -164,16 +190,16 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener } bottom_aspect_ratio.setOnClickListener { - currPrimaryAction = if (currPrimaryAction == PRIMARY_ASPECT_RATIO) { + currCropRotateAction = if (currCropRotateAction == CROP_ROTATE_ASPECT_RATIO) { crop_image_view.guidelines = CropImageView.Guidelines.OFF bottom_aspect_ratios.beGone() - PRIMARY_NONE + CROP_ROTATE_NONE } else { crop_image_view.guidelines = CropImageView.Guidelines.ON bottom_aspect_ratios.beVisible() - PRIMARY_ASPECT_RATIO + CROP_ROTATE_ASPECT_RATIO } - updatePrimaryActionButtons() + updateCropRotateActionButtons() } } @@ -196,8 +222,29 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener updateAspectRatioButtons() } + private fun updatePrimaryActionButtons() { + arrayOf(bottom_primary_filter, bottom_primary_crop_rotate).forEach { + it.applyColorFilter(Color.WHITE) + } + + val currentPrimaryActionButton = when (currPrimaryAction) { + PRIMARY_ACTION_FILTER -> bottom_primary_filter + PRIMARY_ACTION_CROP_ROTATE -> bottom_primary_crop_rotate + else -> null + } + + currentPrimaryActionButton?.applyColorFilter(config.primaryColor) + if (currPrimaryAction == PRIMARY_ACTION_CROP_ROTATE) { + bottom_editor_edit_actions.beVisible() + } else { + bottom_aspect_ratios.beGone() + bottom_editor_edit_actions.beGone() + currCropRotateAction = CROP_ROTATE_NONE + } + } + private fun updateAspectRatio(aspectRatio: Int) { - currentAspectRatio = aspectRatio + currAspectRatio = aspectRatio updateAspectRatioButtons() crop_image_view.apply { @@ -220,7 +267,7 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener it.setTextColor(Color.WHITE) } - val currentAspectRatioButton = when (currentAspectRatio) { + val currentAspectRatioButton = when (currAspectRatio) { ASPECT_RATIO_FREE -> bottom_aspect_ratio_free ASPECT_RATIO_ONE_ONE -> bottom_aspect_ratio_one_one ASPECT_RATIO_FOUR_THREE -> bottom_aspect_ratio_four_three @@ -230,13 +277,13 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener currentAspectRatioButton.setTextColor(config.primaryColor) } - private fun updatePrimaryActionButtons() { + private fun updateCropRotateActionButtons() { arrayOf(bottom_aspect_ratio).forEach { it.applyColorFilter(Color.WHITE) } - val primaryActionView = when (currPrimaryAction) { - PRIMARY_ASPECT_RATIO -> bottom_aspect_ratio + val primaryActionView = when (currCropRotateAction) { + CROP_ROTATE_ASPECT_RATIO -> bottom_aspect_ratio else -> null } diff --git a/app/src/main/res/drawable-hdpi/ic_photo_filter.png b/app/src/main/res/drawable-hdpi/ic_photo_filter.png new file mode 100644 index 0000000000000000000000000000000000000000..724d01d695c74706f9ce1caac761e19a3a9a8004 GIT binary patch literal 292 zcmV+<0o(qGP)j1^Vig3;>doHE_GR{$nXGOkh_Py?^S~U00009x$jC5zxmJA0*i;CV2&2Vpaok0M W$Y|Ui5!AE*00002x|B!Bnt}hxwk9#4Lb1pb1b2L>c%NL6oBy!C#FoYTw8{K*Z+E7=Bi@IyE6NrDKmpNMN>xAaPEuRnQ)F~^WMz+`I)=# z@a;Ndj4{R-Gcgvjo4b4`CoUw)xyAsVwg5_a2%tBh2^0q~kM3{*R8yUIz(EKY&`w+4 z0e8X$u!M++CHV$?3K(z}fHV09{0{Z=pb_t+!T_rHi}#mueF3`}Zo8@g zs@TC#hWo(|DpUk8pL+f>o?p~6S9Aa?I71JU>EaAaMFvnqI}vdV(#Cpu0oAl62-qz1 z5n3Ma5we%qKBF<_e0DM1PGLVX+GtZYN+h52X~L@)Hq3DbfHO+RX=cYgG0uxz&~P&D zoX;vE23aC1fbt|SC!Mr9Co5okk~yC`Hi!zKh>r~Sk)mwJXI|KV0;3gl1w3Q4XG#Jn zroc5j5|Nx=^Gwkw z7{0NkHNbBzY7Ow4yP5;4sa74}S%3vtfCX591z3OuC=2+AETu^U?jp$-mlTJQ + android:id="@+id/bottom_editor_edit_actions" + layout="@layout/bottom_editor_crop_rotate_actions" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_above="@+id/bottom_editor_primary_actions" + android:visibility="gone"/> + + diff --git a/app/src/main/res/layout/bottom_editor_actions.xml b/app/src/main/res/layout/bottom_editor_crop_rotate_actions.xml similarity index 96% rename from app/src/main/res/layout/bottom_editor_actions.xml rename to app/src/main/res/layout/bottom_editor_crop_rotate_actions.xml index 04a19515d..da48247b9 100644 --- a/app/src/main/res/layout/bottom_editor_actions.xml +++ b/app/src/main/res/layout/bottom_editor_crop_rotate_actions.xml @@ -5,8 +5,7 @@ android:id="@+id/bottom_editor_actions_wrapper" android:layout_width="match_parent" android:layout_height="@dimen/bottom_actions_height" - android:layout_alignParentBottom="true" - android:background="@drawable/gradient_background_lighter"> + android:layout_alignParentBottom="true"> + + + + + + +