mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
adding more menu visibility changes
This commit is contained in:
parent
cfbeb85b0d
commit
144409b7a9
3 changed files with 37 additions and 34 deletions
|
@ -5,6 +5,7 @@ import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
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.VIEW_TYPE_GRID
|
||||||
import com.simplemobiletools.commons.helpers.isRPlus
|
import com.simplemobiletools.commons.helpers.isRPlus
|
||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
|
@ -42,7 +43,6 @@ class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.menu_add_folder, menu)
|
menuInflater.inflate(R.menu.menu_add_folder, menu)
|
||||||
menu.findItem(R.id.add_folder).isVisible = !isRPlus()
|
|
||||||
updateMenuItemColors(menu)
|
updateMenuItemColors(menu)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ class ExcludedFoldersActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addFolder() {
|
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.lastFilepickerPath = it
|
||||||
config.addExcludedFolder(it)
|
config.addExcludedFolder(it)
|
||||||
updateFolders()
|
updateFolders()
|
||||||
|
|
|
@ -287,6 +287,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
|
||||||
findItem(R.id.hide_the_recycle_bin).isVisible = useBin && config.showRecycleBinAtFolders
|
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.show_the_recycle_bin).isVisible = useBin && !config.showRecycleBinAtFolders
|
||||||
findItem(R.id.set_as_default_folder).isVisible = !config.defaultFolder.isEmpty()
|
findItem(R.id.set_as_default_folder).isVisible = !config.defaultFolder.isEmpty()
|
||||||
|
findItem(R.id.create_new_folder).isVisible = !isRPlus()
|
||||||
setupSearch(this)
|
setupSearch(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,10 @@ import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.gallery.pro.R
|
import com.simplemobiletools.gallery.pro.R
|
||||||
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
||||||
|
|
||||||
class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appendFilename: Boolean, val cancelCallback: (() -> Unit)? = null,
|
class SaveAsDialog(
|
||||||
val callback: (savePath: String) -> Unit) {
|
val activity: BaseSimpleActivity, val path: String, val appendFilename: Boolean, val cancelCallback: (() -> Unit)? = null,
|
||||||
|
val callback: (savePath: String) -> Unit
|
||||||
|
) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
var realPath = path.getParentPath()
|
var realPath = path.getParentPath()
|
||||||
|
@ -42,45 +44,45 @@ class SaveAsDialog(val activity: BaseSimpleActivity, val path: String, val appen
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder(activity)
|
AlertDialog.Builder(activity)
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel) { dialog, which -> cancelCallback?.invoke() }
|
.setNegativeButton(R.string.cancel) { dialog, which -> cancelCallback?.invoke() }
|
||||||
.setOnCancelListener { cancelCallback?.invoke() }
|
.setOnCancelListener { cancelCallback?.invoke() }
|
||||||
.create().apply {
|
.create().apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.save_as) {
|
activity.setupDialogStuff(view, this, R.string.save_as) {
|
||||||
showKeyboard(view.save_as_name)
|
showKeyboard(view.save_as_name)
|
||||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val filename = view.save_as_name.value
|
val filename = view.save_as_name.value
|
||||||
val extension = view.save_as_extension.value
|
val extension = view.save_as_extension.value
|
||||||
|
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
activity.toast(R.string.filename_cannot_be_empty)
|
activity.toast(R.string.filename_cannot_be_empty)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extension.isEmpty()) {
|
if (extension.isEmpty()) {
|
||||||
activity.toast(R.string.extension_cannot_be_empty)
|
activity.toast(R.string.extension_cannot_be_empty)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
val newFilename = "$filename.$extension"
|
val newFilename = "$filename.$extension"
|
||||||
val newPath = "${realPath.trimEnd('/')}/$newFilename"
|
val newPath = "${realPath.trimEnd('/')}/$newFilename"
|
||||||
if (!newFilename.isAValidFilename()) {
|
if (!newFilename.isAValidFilename()) {
|
||||||
activity.toast(R.string.filename_invalid_characters)
|
activity.toast(R.string.filename_invalid_characters)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activity.getDoesFilePathExist(newPath)) {
|
if (activity.getDoesFilePathExist(newPath)) {
|
||||||
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename)
|
val title = String.format(activity.getString(R.string.file_already_exists_overwrite), newFilename)
|
||||||
ConfirmationDialog(activity, title) {
|
ConfirmationDialog(activity, title) {
|
||||||
callback(newPath)
|
|
||||||
dismiss()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
callback(newPath)
|
callback(newPath)
|
||||||
dismiss()
|
dismiss()
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
callback(newPath)
|
||||||
|
dismiss()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue