From 144409b7a9a50a7b692a947be068207b9384a6b3 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 12 Feb 2022 18:12:16 +0100 Subject: [PATCH] adding more menu visibility changes --- .../pro/activities/ExcludedFoldersActivity.kt | 4 +- .../gallery/pro/activities/MainActivity.kt | 1 + .../gallery/pro/dialogs/SaveAsDialog.kt | 66 ++++++++++--------- 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ExcludedFoldersActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ExcludedFoldersActivity.kt index e106475d4..dea72e8b9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ExcludedFoldersActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ExcludedFoldersActivity.kt @@ -5,6 +5,7 @@ import android.view.Menu import android.view.MenuItem import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.extensions.beVisibleIf +import com.simplemobiletools.commons.extensions.internalStoragePath import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID import com.simplemobiletools.commons.helpers.isRPlus import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener @@ -42,7 +43,6 @@ class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener { override fun onCreateOptionsMenu(menu: Menu): Boolean { menuInflater.inflate(R.menu.menu_add_folder, menu) - menu.findItem(R.id.add_folder).isVisible = !isRPlus() updateMenuItemColors(menu) return true } @@ -60,7 +60,7 @@ class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener { } private fun addFolder() { - FilePickerDialog(this, config.lastFilepickerPath, false, config.shouldShowHidden, false, true, true) { + FilePickerDialog(this, internalStoragePath, false, config.shouldShowHidden, false, true, true) { config.lastFilepickerPath = it config.addExcludedFolder(it) updateFolders() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt index 91113ffea..a62c08c0b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MainActivity.kt @@ -287,6 +287,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { findItem(R.id.hide_the_recycle_bin).isVisible = useBin && config.showRecycleBinAtFolders findItem(R.id.show_the_recycle_bin).isVisible = useBin && !config.showRecycleBinAtFolders findItem(R.id.set_as_default_folder).isVisible = !config.defaultFolder.isEmpty() + findItem(R.id.create_new_folder).isVisible = !isRPlus() setupSearch(this) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt index 4331b3120..71915fcf7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/dialogs/SaveAsDialog.kt @@ -8,8 +8,10 @@ import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.gallery.pro.R import kotlinx.android.synthetic.main.dialog_save_as.view.* -class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appendFilename: Boolean, val cancelCallback: (() -> Unit)? = null, - val callback: (savePath: String) -> Unit) { +class SaveAsDialog( + val activity: BaseSimpleActivity, val path: String, val appendFilename: Boolean, val cancelCallback: (() -> Unit)? = null, + val callback: (savePath: String) -> Unit +) { init { var realPath = path.getParentPath() @@ -42,45 +44,45 @@ class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appen } AlertDialog.Builder(activity) - .setPositiveButton(R.string.ok, null) - .setNegativeButton(R.string.cancel) { dialog, which -> cancelCallback?.invoke() } - .setOnCancelListener { cancelCallback?.invoke() } - .create().apply { - activity.setupDialogStuff(view, this, R.string.save_as) { - showKeyboard(view.save_as_name) - getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { - val filename = view.save_as_name.value - val extension = view.save_as_extension.value + .setPositiveButton(R.string.ok, null) + .setNegativeButton(R.string.cancel) { dialog, which -> cancelCallback?.invoke() } + .setOnCancelListener { cancelCallback?.invoke() } + .create().apply { + activity.setupDialogStuff(view, this, R.string.save_as) { + showKeyboard(view.save_as_name) + getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener { + val filename = view.save_as_name.value + val extension = view.save_as_extension.value - if (filename.isEmpty()) { - activity.toast(R.string.filename_cannot_be_empty) - return@setOnClickListener - } + if (filename.isEmpty()) { + activity.toast(R.string.filename_cannot_be_empty) + return@setOnClickListener + } - if (extension.isEmpty()) { - activity.toast(R.string.extension_cannot_be_empty) - return@setOnClickListener - } + if (extension.isEmpty()) { + activity.toast(R.string.extension_cannot_be_empty) + return@setOnClickListener + } - val newFilename = "$filename.$extension" - val newPath = "${realPath.trimEnd('/')}/$newFilename" - if (!newFilename.isAValidFilename()) { - activity.toast(R.string.filename_invalid_characters) - return@setOnClickListener - } + val newFilename = "$filename.$extension" + val newPath = "${realPath.trimEnd('/')}/$newFilename" + if (!newFilename.isAValidFilename()) { + activity.toast(R.string.filename_invalid_characters) + return@setOnClickListener + } - if (activity.getDoesFilePathExist(newPath)) { - val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename) - ConfirmationDialog(activity, title) { - callback(newPath) - dismiss() - } - } else { + if (activity.getDoesFilePathExist(newPath)) { + val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename) + ConfirmationDialog(activity, title) { callback(newPath) dismiss() } + } else { + callback(newPath) + dismiss() } } } + } } }