From 635b8b893e89947e28f6527636a1ba30ea9aeae2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 4 Jan 2019 17:58:33 +0100 Subject: [PATCH] allow adding a Copy button to the bottom actions --- .../gallery/pro/activities/PhotoVideoActivity.kt | 2 +- .../gallery/pro/activities/ViewPagerActivity.kt | 6 ++++++ .../pro/dialogs/ManageBottomActionsDialog.kt | 3 +++ .../gallery/pro/helpers/Constants.kt | 1 + app/src/main/res/layout/bottom_actions.xml | 13 ++++++++++++- .../res/layout/dialog_manage_bottom_actions.xml | 8 ++++++++ 6 files changed, 31 insertions(+), 2 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 b5b1c0fff..8f660124d 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 @@ -240,7 +240,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).forEach { + bottom_toggle_file_visibility, bottom_rename, bottom_copy).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 e91c97ee3..3da6a06ac 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 @@ -162,6 +162,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View findItem(R.id.menu_rename).isVisible = visibleBottomActions and BOTTOM_ACTION_RENAME == 0 && !currentMedium.getIsInRecycleBin() findItem(R.id.menu_rotate).isVisible = currentMedium.isImage() && visibleBottomActions and BOTTOM_ACTION_ROTATE == 0 findItem(R.id.menu_set_as).isVisible = visibleBottomActions and BOTTOM_ACTION_SET_AS == 0 + findItem(R.id.menu_copy_to).isVisible = visibleBottomActions and BOTTOM_ACTION_COPY == 0 findItem(R.id.menu_save_as).isVisible = mRotationDegrees != 0 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() @@ -863,6 +864,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View bottom_set_as.setOnClickListener { setAs(getCurrentPath()) } + + bottom_copy.beVisibleIf(visibleBottomActions and BOTTOM_ACTION_COPY != 0) + bottom_copy.setOnClickListener { + copyMoveTo(true) + } } private fun updateBottomActionIcons(medium: Medium?) { 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 94a16c3be..760f51be2 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 @@ -26,6 +26,7 @@ class ManageBottomActionsDialog(val activity: BaseSimpleActivity, val callback: manage_bottom_actions_toggle_visibility.isChecked = actions and BOTTOM_ACTION_TOGGLE_VISIBILITY != 0 manage_bottom_actions_rename.isChecked = actions and BOTTOM_ACTION_RENAME != 0 manage_bottom_actions_set_as.isChecked = actions and BOTTOM_ACTION_SET_AS != 0 + manage_bottom_actions_copy.isChecked = actions and BOTTOM_ACTION_COPY != 0 } AlertDialog.Builder(activity) @@ -63,6 +64,8 @@ class ManageBottomActionsDialog(val activity: BaseSimpleActivity, val callback: result += BOTTOM_ACTION_RENAME if (manage_bottom_actions_set_as.isChecked) result += BOTTOM_ACTION_SET_AS + if (manage_bottom_actions_copy.isChecked) + result += BOTTOM_ACTION_COPY } 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 16e61ddc8..3b234336e 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 @@ -164,6 +164,7 @@ const val BOTTOM_ACTION_SHOW_ON_MAP = 256 const val BOTTOM_ACTION_TOGGLE_VISIBILITY = 512 const val BOTTOM_ACTION_RENAME = 1024 const val BOTTOM_ACTION_SET_AS = 2048 +const val BOTTOM_ACTION_COPY = 4096 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 2cb308bbc..48bacf38d 100644 --- a/app/src/main/res/layout/bottom_actions.xml +++ b/app/src/main/res/layout/bottom_actions.xml @@ -137,8 +137,19 @@ android:background="?attr/selectableItemBackgroundBorderless" android:padding="@dimen/medium_margin" android:src="@drawable/ic_set_as" - app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintEnd_toEndOf="@+id/bottom_copy" app:layout_constraintHorizontal_bias="0.5" app:layout_constraintStart_toEndOf="@+id/bottom_rename"/> + + 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 3e5f7f790..39fc8555d 100644 --- a/app/src/main/res/layout/dialog_manage_bottom_actions.xml +++ b/app/src/main/res/layout/dialog_manage_bottom_actions.xml @@ -110,5 +110,13 @@ android:paddingBottom="@dimen/activity_margin" android:text="@string/set_as"/> + +