add some additional menu items for restoring recycle bin items
This commit is contained in:
parent
4923d5e4af
commit
2dc18e7166
7 changed files with 54 additions and 9 deletions
|
@ -200,6 +200,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
|
|
||||||
findItem(R.id.empty_recycle_bin).isVisible = mPath == RECYCLE_BIN
|
findItem(R.id.empty_recycle_bin).isVisible = mPath == RECYCLE_BIN
|
||||||
findItem(R.id.empty_disable_recycle_bin).isVisible = mPath == RECYCLE_BIN
|
findItem(R.id.empty_disable_recycle_bin).isVisible = mPath == RECYCLE_BIN
|
||||||
|
findItem(R.id.restore_all_files).isVisible = mPath == RECYCLE_BIN
|
||||||
|
|
||||||
findItem(R.id.folder_view).isVisible = mShowAll
|
findItem(R.id.folder_view).isVisible = mShowAll
|
||||||
findItem(R.id.open_camera).isVisible = mShowAll
|
findItem(R.id.open_camera).isVisible = mShowAll
|
||||||
|
@ -224,6 +225,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
R.id.filter -> showFilterMediaDialog()
|
R.id.filter -> showFilterMediaDialog()
|
||||||
R.id.empty_recycle_bin -> emptyRecycleBin()
|
R.id.empty_recycle_bin -> emptyRecycleBin()
|
||||||
R.id.empty_disable_recycle_bin -> emptyAndDisableRecycleBin()
|
R.id.empty_disable_recycle_bin -> emptyAndDisableRecycleBin()
|
||||||
|
R.id.restore_all_files -> restoreAllFiles()
|
||||||
R.id.toggle_filename -> toggleFilenameVisibility()
|
R.id.toggle_filename -> toggleFilenameVisibility()
|
||||||
R.id.open_camera -> launchCamera()
|
R.id.open_camera -> launchCamera()
|
||||||
R.id.folder_view -> switchToFolderView()
|
R.id.folder_view -> switchToFolderView()
|
||||||
|
@ -424,16 +426,27 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun emptyRecycleBin() {
|
private fun emptyRecycleBin() {
|
||||||
|
showRecycleBinEmptyingDialog {
|
||||||
emptyTheRecycleBin {
|
emptyTheRecycleBin {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun emptyAndDisableRecycleBin() {
|
private fun emptyAndDisableRecycleBin() {
|
||||||
|
showRecycleBinEmptyingDialog {
|
||||||
emptyAndDisableTheRecycleBin {
|
emptyAndDisableTheRecycleBin {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun restoreAllFiles() {
|
||||||
|
val paths = mMedia.filter { it is Medium }.map { (it as Medium).path } as ArrayList<String>
|
||||||
|
restoreRecycleBinPaths(paths) {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun toggleFilenameVisibility() {
|
private fun toggleFilenameVisibility() {
|
||||||
config.displayFileNames = !config.displayFileNames
|
config.displayFileNames = !config.displayFileNames
|
||||||
|
|
|
@ -16,6 +16,7 @@ import com.simplemobiletools.gallery.dialogs.ManageExtendedDetailsDialog
|
||||||
import com.simplemobiletools.gallery.extensions.config
|
import com.simplemobiletools.gallery.extensions.config
|
||||||
import com.simplemobiletools.gallery.extensions.emptyTheRecycleBin
|
import com.simplemobiletools.gallery.extensions.emptyTheRecycleBin
|
||||||
import com.simplemobiletools.gallery.extensions.galleryDB
|
import com.simplemobiletools.gallery.extensions.galleryDB
|
||||||
|
import com.simplemobiletools.gallery.extensions.showRecycleBinEmptyingDialog
|
||||||
import com.simplemobiletools.gallery.helpers.ROTATE_BY_ASPECT_RATIO
|
import com.simplemobiletools.gallery.helpers.ROTATE_BY_ASPECT_RATIO
|
||||||
import com.simplemobiletools.gallery.helpers.ROTATE_BY_DEVICE_ROTATION
|
import com.simplemobiletools.gallery.helpers.ROTATE_BY_DEVICE_ROTATION
|
||||||
import com.simplemobiletools.gallery.helpers.ROTATE_BY_SYSTEM_SETTING
|
import com.simplemobiletools.gallery.helpers.ROTATE_BY_SYSTEM_SETTING
|
||||||
|
@ -435,7 +436,7 @@ class SettingsActivity : SimpleActivity() {
|
||||||
if (mRecycleBinContentSize == 0L) {
|
if (mRecycleBinContentSize == 0L) {
|
||||||
toast(R.string.recycle_bin_empty)
|
toast(R.string.recycle_bin_empty)
|
||||||
} else {
|
} else {
|
||||||
ConfirmationDialog(this, "", R.string.empty_recycle_bin_confirmation, R.string.yes, R.string.no) {
|
showRecycleBinEmptyingDialog {
|
||||||
emptyTheRecycleBin()
|
emptyTheRecycleBin()
|
||||||
mRecycleBinContentSize = 0L
|
mRecycleBinContentSize = 0L
|
||||||
settings_empty_recycle_bin_size.text = 0L.formatSize()
|
settings_empty_recycle_bin_size.text = 0L.formatSize()
|
||||||
|
|
|
@ -214,16 +214,20 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList<Directo
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun emptyRecycleBin() {
|
private fun emptyRecycleBin() {
|
||||||
|
activity.showRecycleBinEmptyingDialog {
|
||||||
activity.emptyTheRecycleBin {
|
activity.emptyTheRecycleBin {
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun emptyAndDisableRecycleBin() {
|
private fun emptyAndDisableRecycleBin() {
|
||||||
|
activity.showRecycleBinEmptyingDialog {
|
||||||
activity.emptyAndDisableTheRecycleBin {
|
activity.emptyAndDisableTheRecycleBin {
|
||||||
listener?.refreshItems()
|
listener?.refreshItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateFolderNames() {
|
private fun updateFolderNames() {
|
||||||
val includedFolders = activity.config.includedFolders
|
val includedFolders = activity.config.includedFolders
|
||||||
|
|
|
@ -108,6 +108,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
||||||
findItem(R.id.cab_rename).isVisible = isOneItemSelected()
|
findItem(R.id.cab_rename).isVisible = isOneItemSelected()
|
||||||
findItem(R.id.cab_open_with).isVisible = isOneItemSelected()
|
findItem(R.id.cab_open_with).isVisible = isOneItemSelected()
|
||||||
findItem(R.id.cab_confirm_selection).isVisible = isAGetIntent && allowMultiplePicks && selectedPositions.size > 0
|
findItem(R.id.cab_confirm_selection).isVisible = isAGetIntent && allowMultiplePicks && selectedPositions.size > 0
|
||||||
|
findItem(R.id.cab_restore_recycle_bin_files).isVisible = getSelectedPaths().all { it.startsWith(activity.filesDir.toString()) }
|
||||||
|
|
||||||
checkHideBtnVisibility(this)
|
checkHideBtnVisibility(this)
|
||||||
checkFavoriteBtnVisibility(this)
|
checkFavoriteBtnVisibility(this)
|
||||||
|
@ -128,6 +129,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
||||||
R.id.cab_unhide -> toggleFileVisibility(false)
|
R.id.cab_unhide -> toggleFileVisibility(false)
|
||||||
R.id.cab_add_to_favorites -> toggleFavorites(true)
|
R.id.cab_add_to_favorites -> toggleFavorites(true)
|
||||||
R.id.cab_remove_from_favorites -> toggleFavorites(false)
|
R.id.cab_remove_from_favorites -> toggleFavorites(false)
|
||||||
|
R.id.cab_restore_recycle_bin_files -> restoreFiles()
|
||||||
R.id.cab_share -> shareMedia()
|
R.id.cab_share -> shareMedia()
|
||||||
R.id.cab_copy_to -> copyMoveTo(true)
|
R.id.cab_copy_to -> copyMoveTo(true)
|
||||||
R.id.cab_move_to -> copyMoveTo(false)
|
R.id.cab_move_to -> copyMoveTo(false)
|
||||||
|
@ -244,6 +246,13 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Thumbnai
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun restoreFiles() {
|
||||||
|
activity.restoreRecycleBinPaths(getSelectedPaths()) {
|
||||||
|
listener?.refreshItems()
|
||||||
|
finishActMode()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun shareMedia() {
|
private fun shareMedia() {
|
||||||
if (selectedPositions.size == 1 && selectedPositions.first() != -1) {
|
if (selectedPositions.size == 1 && selectedPositions.first() != -1) {
|
||||||
activity.shareMediumPath(getSelectedMedia().first().path)
|
activity.shareMediumPath(getSelectedMedia().first().path)
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.provider.MediaStore
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
|
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.FAQItem
|
import com.simplemobiletools.commons.models.FAQItem
|
||||||
|
@ -232,7 +233,10 @@ fun BaseSimpleActivity.restoreRecycleBinPaths(paths: ArrayList<String>, callback
|
||||||
out?.close()
|
out?.close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runOnUiThread {
|
||||||
callback()
|
callback()
|
||||||
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,3 +258,9 @@ fun BaseSimpleActivity.emptyAndDisableTheRecycleBin(callback: () -> Unit) {
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun BaseSimpleActivity.showRecycleBinEmptyingDialog(callback: () -> Unit) {
|
||||||
|
ConfirmationDialog(this, "", R.string.empty_recycle_bin_confirmation, R.string.yes, R.string.no) {
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -56,6 +56,10 @@
|
||||||
android:icon="@drawable/ic_star_on"
|
android:icon="@drawable/ic_star_on"
|
||||||
android:title="@string/remove_from_favorites"
|
android:title="@string/remove_from_favorites"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/cab_restore_recycle_bin_files"
|
||||||
|
android:title="@string/restore_selected_files"
|
||||||
|
app:showAsAction="never"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/cab_open_with"
|
android:id="@+id/cab_open_with"
|
||||||
android:title="@string/open_with"
|
android:title="@string/open_with"
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
android:id="@+id/empty_disable_recycle_bin"
|
android:id="@+id/empty_disable_recycle_bin"
|
||||||
android:title="@string/empty_and_disable_recycle_bin"
|
android:title="@string/empty_and_disable_recycle_bin"
|
||||||
app:showAsAction="never"/>
|
app:showAsAction="never"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/restore_all_files"
|
||||||
|
android:title="@string/restore_all_files"
|
||||||
|
app:showAsAction="never"/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/folder_view"
|
android:id="@+id/folder_view"
|
||||||
android:title="@string/folder_view"
|
android:title="@string/folder_view"
|
||||||
|
|
Loading…
Reference in a new issue