toggle bottom edit action buttons on press

This commit is contained in:
tibbi 2018-07-18 21:28:03 +02:00
parent a633330c8e
commit d116f66228
1 changed files with 26 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import android.app.Activity
import android.content.Intent import android.content.Intent
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.Bitmap.CompressFormat import android.graphics.Bitmap.CompressFormat
import android.graphics.Color
import android.graphics.Point import android.graphics.Point
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
@ -18,6 +19,7 @@ import com.simplemobiletools.commons.models.FileDirItem
import com.simplemobiletools.gallery.R import com.simplemobiletools.gallery.R
import com.simplemobiletools.gallery.dialogs.ResizeDialog import com.simplemobiletools.gallery.dialogs.ResizeDialog
import com.simplemobiletools.gallery.dialogs.SaveAsDialog import com.simplemobiletools.gallery.dialogs.SaveAsDialog
import com.simplemobiletools.gallery.extensions.config
import com.simplemobiletools.gallery.extensions.openEditor import com.simplemobiletools.gallery.extensions.openEditor
import com.theartofdev.edmodo.cropper.CropImageView import com.theartofdev.edmodo.cropper.CropImageView
import kotlinx.android.synthetic.main.activity_edit.* import kotlinx.android.synthetic.main.activity_edit.*
@ -34,10 +36,15 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
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
// constants for bottom primary action groups
private val PRIMARY_NONE = 0
private val PRIMARY_ASPECT_RATIO = 1
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 currPrimaryAction = 0
private var isCropIntent = false private var isCropIntent = false
private var isEditingWithThirdParty = false private var isEditingWithThirdParty = false
private var currentAspectRatio = ASPECT_RATIO_ANY private var currentAspectRatio = ASPECT_RATIO_ANY
@ -147,6 +154,25 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
bottom_flip_vertically.setOnClickListener { bottom_flip_vertically.setOnClickListener {
crop_image_view.flipImageVertically() crop_image_view.flipImageVertically()
} }
bottom_aspect_ratio.setOnClickListener {
currPrimaryAction = if (currPrimaryAction == PRIMARY_ASPECT_RATIO) 0 else PRIMARY_ASPECT_RATIO
updatePrimaryActions()
}
}
private fun updatePrimaryActions() {
val primaryColor = config.primaryColor
arrayOf(bottom_aspect_ratio).forEach {
it.applyColorFilter(Color.WHITE)
}
val primaryActionView = when (currPrimaryAction) {
PRIMARY_ASPECT_RATIO -> bottom_aspect_ratio
else -> null
}
primaryActionView?.applyColorFilter(primaryColor)
} }
private fun resizeImage() { private fun resizeImage() {