add some helper menu buttons for emptying and disabling recycle bin
This commit is contained in:
parent
0856abfb83
commit
8397ebac66
|
@ -198,6 +198,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
findItem(R.id.unhide_folder).isVisible = isFolderHidden && !mShowAll && mPath != FAVORITES && mPath != RECYCLE_BIN
|
findItem(R.id.unhide_folder).isVisible = isFolderHidden && !mShowAll && mPath != FAVORITES && mPath != RECYCLE_BIN
|
||||||
findItem(R.id.exclude_folder).isVisible = !mShowAll && mPath != FAVORITES && mPath != RECYCLE_BIN
|
findItem(R.id.exclude_folder).isVisible = !mShowAll && mPath != FAVORITES && 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.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
|
||||||
findItem(R.id.about).isVisible = mShowAll
|
findItem(R.id.about).isVisible = mShowAll
|
||||||
|
@ -219,6 +222,8 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.sort -> showSortingDialog()
|
R.id.sort -> showSortingDialog()
|
||||||
R.id.filter -> showFilterMediaDialog()
|
R.id.filter -> showFilterMediaDialog()
|
||||||
|
R.id.empty_recycle_bin -> emptyRecycleBin()
|
||||||
|
R.id.empty_disable_recycle_bin -> emptyAndDisableRecycleBin()
|
||||||
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()
|
||||||
|
@ -418,6 +423,18 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun emptyRecycleBin() {
|
||||||
|
emptyTheRecycleBin {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun emptyAndDisableRecycleBin() {
|
||||||
|
emptyAndDisableTheRecycleBin {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun toggleFilenameVisibility() {
|
private fun toggleFilenameVisibility() {
|
||||||
config.displayFileNames = !config.displayFileNames
|
config.displayFileNames = !config.displayFileNames
|
||||||
getMediaAdapter()?.updateDisplayFilenames(config.displayFileNames)
|
getMediaAdapter()?.updateDisplayFilenames(config.displayFileNames)
|
||||||
|
|
|
@ -204,3 +204,21 @@ fun BaseSimpleActivity.movePathsInRecycleBin(paths: ArrayList<String>, callback:
|
||||||
callback?.invoke(pathsCnt == 0)
|
callback?.invoke(pathsCnt == 0)
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun BaseSimpleActivity.emptyTheRecycleBin(callback: () -> Unit) {
|
||||||
|
Thread {
|
||||||
|
filesDir.deleteRecursively()
|
||||||
|
galleryDB.MediumDao().clearRecycleBin()
|
||||||
|
galleryDB.DirectoryDao().deleteRecycleBin()
|
||||||
|
callback()
|
||||||
|
}.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun BaseSimpleActivity.emptyAndDisableTheRecycleBin(callback: () -> Unit) {
|
||||||
|
Thread {
|
||||||
|
emptyTheRecycleBin {
|
||||||
|
config.useRecycleBin = false
|
||||||
|
callback()
|
||||||
|
}
|
||||||
|
}.start()
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.arch.persistence.room.Dao
|
||||||
import android.arch.persistence.room.Insert
|
import android.arch.persistence.room.Insert
|
||||||
import android.arch.persistence.room.OnConflictStrategy.REPLACE
|
import android.arch.persistence.room.OnConflictStrategy.REPLACE
|
||||||
import android.arch.persistence.room.Query
|
import android.arch.persistence.room.Query
|
||||||
|
import com.simplemobiletools.gallery.helpers.RECYCLE_BIN
|
||||||
import com.simplemobiletools.gallery.models.Directory
|
import com.simplemobiletools.gallery.models.Directory
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
|
@ -25,4 +26,7 @@ interface DirectoryDao {
|
||||||
|
|
||||||
@Query("UPDATE directories SET thumbnail = :thumbnail, filename = :name, path = :newPath WHERE path = :oldPath COLLATE NOCASE")
|
@Query("UPDATE directories SET thumbnail = :thumbnail, filename = :name, path = :newPath WHERE path = :oldPath COLLATE NOCASE")
|
||||||
fun updateDirectoryAfterRename(thumbnail: String, name: String, newPath: String, oldPath: String)
|
fun updateDirectoryAfterRename(thumbnail: String, name: String, newPath: String, oldPath: String)
|
||||||
|
|
||||||
|
@Query("DELETE FROM directories WHERE path = \'$RECYCLE_BIN\' COLLATE NOCASE")
|
||||||
|
fun deleteRecycleBin()
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,4 +37,7 @@ interface MediumDao {
|
||||||
|
|
||||||
@Query("UPDATE media SET deleted_ts = :deletedTS WHERE full_path = :path COLLATE NOCASE")
|
@Query("UPDATE media SET deleted_ts = :deletedTS WHERE full_path = :path COLLATE NOCASE")
|
||||||
fun updateDeleted(path: String, deletedTS: Long)
|
fun updateDeleted(path: String, deletedTS: Long)
|
||||||
|
|
||||||
|
@Query("DELETE FROM media WHERE deleted_ts != 0")
|
||||||
|
fun clearRecycleBin()
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,14 @@
|
||||||
android:icon="@drawable/ic_filter"
|
android:icon="@drawable/ic_filter"
|
||||||
android:title="@string/filter_media"
|
android:title="@string/filter_media"
|
||||||
app:showAsAction="ifRoom"/>
|
app:showAsAction="ifRoom"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/empty_recycle_bin"
|
||||||
|
android:title="@string/empty_recycle_bin"
|
||||||
|
app:showAsAction="never"/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/empty_disable_recycle_bin"
|
||||||
|
android:title="@string/empty_and_disable_recycle_bin"
|
||||||
|
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 New Issue