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 000000000..724d01d69 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_photo_filter.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_photo_filter.png b/app/src/main/res/drawable-xhdpi/ic_photo_filter.png new file mode 100644 index 000000000..05226c215 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_photo_filter.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_photo_filter.png b/app/src/main/res/drawable-xxhdpi/ic_photo_filter.png new file mode 100644 index 000000000..d555dd355 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_photo_filter.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_photo_filter.png b/app/src/main/res/drawable-xxxhdpi/ic_photo_filter.png new file mode 100644 index 000000000..f947149cb Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_photo_filter.png differ diff --git a/app/src/main/res/layout/activity_edit.xml b/app/src/main/res/layout/activity_edit.xml index 2c55b5509..50fc8e022 100644 --- a/app/src/main/res/layout/activity_edit.xml +++ b/app/src/main/res/layout/activity_edit.xml @@ -19,11 +19,19 @@ layout="@layout/bottom_actions_aspect_ratio" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_above="@+id/bottom_editor_actions" + android:layout_above="@+id/bottom_editor_edit_actions" android:visibility="gone"/> + 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"> + + + + + + +