From 5f10bebb19417cb136351d6d1a6c82b97ebdc6e6 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 16 Dec 2018 16:54:56 +0100 Subject: [PATCH] hide the Other Folder button at the widget folder picker --- .../pro/activities/WidgetConfigureActivity.kt | 2 +- .../pro/dialogs/PickDirectoryDialog.kt | 30 +++++++++++-------- .../gallery/pro/dialogs/PickMediumDialog.kt | 2 +- .../gallery/pro/extensions/Activity.kt | 2 +- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt index 22c10231d..9b3a26bf7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/WidgetConfigureActivity.kt @@ -128,7 +128,7 @@ class WidgetConfigureActivity : SimpleActivity() { } private fun changeSelectedFolder() { - PickDirectoryDialog(this, mFolderPath) { + PickDirectoryDialog(this, mFolderPath, false) { updateFolderImage(it) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt index 3bf2aa3d4..3acdf41a5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickDirectoryDialog.kt @@ -16,7 +16,7 @@ import com.simplemobiletools.gallery.pro.helpers.VIEW_TYPE_GRID import com.simplemobiletools.gallery.pro.models.Directory import kotlinx.android.synthetic.main.dialog_directory_picker.view.* -class PickDirectoryDialog(val activity: BaseSimpleActivity, val sourcePath: String, val callback: (path: String) -> Unit) { +class PickDirectoryDialog(val activity: BaseSimpleActivity, val sourcePath: String, val showOtherFolderButton: Boolean, val callback: (path: String) -> Unit) { var dialog: AlertDialog var shownDirectories = ArrayList() var view = activity.layoutInflater.inflate(R.layout.dialog_directory_picker, null) @@ -29,22 +29,26 @@ class PickDirectoryDialog(val activity: BaseSimpleActivity, val sourcePath: Stri spanCount = if (isGridViewType) activity.config.dirColumnCnt else 1 } - dialog = AlertDialog.Builder(activity) + val builder = AlertDialog.Builder(activity) .setPositiveButton(R.string.ok, null) .setNegativeButton(R.string.cancel, null) - .setNeutralButton(R.string.other_folder) { dialogInterface, i -> showOtherFolder() } - .create().apply { - activity.setupDialogStuff(view, this, R.string.select_destination) { - view.directories_show_hidden.beVisibleIf(!context.config.shouldShowHidden) - view.directories_show_hidden.setOnClickListener { - activity.handleHiddenFolderPasswordProtection { - view.directories_show_hidden.beGone() - showHidden = true - fetchDirectories(true) - } - } + + if (showOtherFolderButton) { + builder.setNeutralButton(R.string.other_folder) { dialogInterface, i -> showOtherFolder() } + } + + dialog = builder.create().apply { + activity.setupDialogStuff(view, this, R.string.select_destination) { + view.directories_show_hidden.beVisibleIf(!context.config.shouldShowHidden) + view.directories_show_hidden.setOnClickListener { + activity.handleHiddenFolderPasswordProtection { + view.directories_show_hidden.beGone() + showHidden = true + fetchDirectories(true) } } + } + } fetchDirectories(false) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickMediumDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickMediumDialog.kt index ae5675356..b1f83527b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickMediumDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/PickMediumDialog.kt @@ -53,7 +53,7 @@ class PickMediumDialog(val activity: BaseSimpleActivity, val path: String, val c } private fun showOtherFolder() { - PickDirectoryDialog(activity, path) { + PickDirectoryDialog(activity, path, true) { callback(it) dialog.dismiss() } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt index 21cf823ce..3c742da68 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt @@ -183,7 +183,7 @@ fun BaseSimpleActivity.tryCopyMoveFilesTo(fileDirItems: ArrayList, } val source = fileDirItems[0].getParentPath() - PickDirectoryDialog(this, source) { + PickDirectoryDialog(this, source, true) { copyMoveFilesTo(fileDirItems, source.trimEnd('/'), it, isCopyOperation, true, config.shouldShowHidden, callback) } }