From c681f62c306ee74745a15d9d4280993951a8d4d7 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 12 Dec 2019 14:24:25 +0100 Subject: [PATCH] allow adding Resize at the bottom actions --- .../pro/activities/PhotoVideoActivity.kt | 2 +- .../gallery/pro/activities/ViewPagerActivity.kt | 10 ++++++++-- .../pro/dialogs/ManageBottomActionsDialog.kt | 3 +++ .../gallery/pro/helpers/Constants.kt | 1 + app/src/main/res/layout/bottom_actions.xml | 17 ++++++++++++++++- .../res/layout/dialog_manage_bottom_actions.xml | 8 ++++++++ 6 files changed, 37 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt index 82ee18c29..9ea20f4a9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/PhotoVideoActivity.kt @@ -307,7 +307,7 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList private fun initBottomActionButtons() { arrayListOf(bottom_favorite, bottom_delete, bottom_rotate, bottom_properties, bottom_change_orientation, bottom_slideshow, bottom_show_on_map, - bottom_toggle_file_visibility, bottom_rename, bottom_copy, bottom_move).forEach { + bottom_toggle_file_visibility, bottom_rename, bottom_copy, bottom_move, bottom_resize).forEach { it.beGone() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 36e75e9ea..7f30b2096 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -177,7 +177,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View findItem(R.id.menu_move_to).isVisible = visibleBottomActions and BOTTOM_ACTION_MOVE == 0 findItem(R.id.menu_save_as).isVisible = rotationDegrees != 0 findItem(R.id.menu_print).isVisible = currentMedium.isImage() || currentMedium.isRaw() - findItem(R.id.menu_resize).isVisible = currentMedium.isImage() + findItem(R.id.menu_resize).isVisible = visibleBottomActions and BOTTOM_ACTION_RESIZE == 0 && currentMedium.isImage() findItem(R.id.menu_hide).isVisible = !currentMedium.isHidden() && visibleBottomActions and BOTTOM_ACTION_TOGGLE_VISIBILITY == 0 && !currentMedium.getIsInRecycleBin() findItem(R.id.menu_unhide).isVisible = currentMedium.isHidden() && visibleBottomActions and BOTTOM_ACTION_TOGGLE_VISIBILITY == 0 && !currentMedium.getIsInRecycleBin() findItem(R.id.menu_add_to_favorites).isVisible = !currentMedium.isFavorite && visibleBottomActions and BOTTOM_ACTION_TOGGLE_FAVORITE == 0 && !currentMedium.getIsInRecycleBin() @@ -832,6 +832,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View bottom_move.setOnClickListener { moveFileTo() } + + bottom_resize.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_RESIZE != 0 && currentMedium?.isImage() == true) + bottom_resize.setOnClickListener { + resizeImage() + } } private fun updateBottomActionIcons(medium: Medium?) { @@ -1230,7 +1235,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View if (bottom_actions.isVisible()) { bottom_actions.animate().alpha(newAlpha).start() arrayOf(bottom_favorite, bottom_edit, bottom_share, bottom_delete, bottom_rotate, bottom_properties, bottom_change_orientation, - bottom_slideshow, bottom_show_on_map, bottom_toggle_file_visibility, bottom_rename).forEach { + bottom_slideshow, bottom_show_on_map, bottom_toggle_file_visibility, bottom_rename, bottom_set_as, bottom_copy, bottom_move, + bottom_resize).forEach { it.isClickable = !mIsFullScreen } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ManageBottomActionsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ManageBottomActionsDialog.kt index 217559e73..cfbe131f8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ManageBottomActionsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/ManageBottomActionsDialog.kt @@ -28,6 +28,7 @@ class ManageBottomActionsDialog(val activity: BaseSimpleActivity, val callback: manage_bottom_actions_set_as.isChecked = actions and BOTTOM_ACTION_SET_AS != 0 manage_bottom_actions_copy.isChecked = actions and BOTTOM_ACTION_COPY != 0 manage_bottom_actions_move.isChecked = actions and BOTTOM_ACTION_MOVE != 0 + manage_bottom_actions_resize.isChecked = actions and BOTTOM_ACTION_RESIZE != 0 } AlertDialog.Builder(activity) @@ -69,6 +70,8 @@ class ManageBottomActionsDialog(val activity: BaseSimpleActivity, val callback: result += BOTTOM_ACTION_COPY if (manage_bottom_actions_move.isChecked) result += BOTTOM_ACTION_MOVE + if (manage_bottom_actions_resize.isChecked) + result += BOTTOM_ACTION_RESIZE } activity.config.visibleBottomActions = result diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt index 0697dfe0c..5e2ab2d33 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt @@ -195,6 +195,7 @@ const val BOTTOM_ACTION_RENAME = 1024 const val BOTTOM_ACTION_SET_AS = 2048 const val BOTTOM_ACTION_COPY = 4096 const val BOTTOM_ACTION_MOVE = 8192 +const val BOTTOM_ACTION_RESIZE = 16384 const val DEFAULT_BOTTOM_ACTIONS = BOTTOM_ACTION_TOGGLE_FAVORITE or BOTTOM_ACTION_EDIT or BOTTOM_ACTION_SHARE or BOTTOM_ACTION_DELETE diff --git a/app/src/main/res/layout/bottom_actions.xml b/app/src/main/res/layout/bottom_actions.xml index 88906f599..e03791630 100644 --- a/app/src/main/res/layout/bottom_actions.xml +++ b/app/src/main/res/layout/bottom_actions.xml @@ -213,10 +213,25 @@ android:padding="@dimen/medium_margin" android:src="@drawable/ic_move" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintEnd_toStartOf="@+id/bottom_resize" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toEndOf="@+id/bottom_copy" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.0"/> + + diff --git a/app/src/main/res/layout/dialog_manage_bottom_actions.xml b/app/src/main/res/layout/dialog_manage_bottom_actions.xml index fb76d7666..2ddeb0afc 100644 --- a/app/src/main/res/layout/dialog_manage_bottom_actions.xml +++ b/app/src/main/res/layout/dialog_manage_bottom_actions.xml @@ -126,5 +126,13 @@ android:paddingBottom="@dimen/activity_margin" android:text="@string/move"/> + +