From a03a2460330b1be6c04a2ccc4efa9a9e3730f617 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 23 Jan 2023 15:37:54 +0100 Subject: [PATCH] fix #2659, #2004, add an Open Recycle Bin menu item, if it is enabled --- app/build.gradle | 2 +- .../gallery/pro/activities/MainActivity.kt | 2 ++ .../gallery/pro/activities/MediaActivity.kt | 11 ++++++++++- .../gallery/pro/extensions/Activity.kt | 9 +++++++++ app/src/main/res/menu/menu_main.xml | 5 +++++ app/src/main/res/menu/menu_media.xml | 5 +++++ 6 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 910f25f74..c251b980d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -78,7 +78,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:b9fb97bfe1' + implementation 'com.github.SimpleMobileTools:Simple-Commons:9428140d75' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.24' 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 8073e881c..c9c489a22 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 @@ -313,6 +313,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { main_menu.getToolbar().menu.apply { findItem(R.id.column_count).isVisible = config.viewTypeFolders == VIEW_TYPE_GRID findItem(R.id.set_as_default_folder).isVisible = !config.defaultFolder.isEmpty() + findItem(R.id.open_recycle_bin).isVisible = !config.useRecycleBin findItem(R.id.more_apps_from_us).isVisible = !resources.getBoolean(R.bool.hide_google_relations) } } @@ -361,6 +362,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener { R.id.temporarily_show_excluded -> tryToggleTemporarilyShowExcluded() R.id.stop_showing_excluded -> tryToggleTemporarilyShowExcluded() R.id.create_new_folder -> createNewFolder() + R.id.open_recycle_bin -> openRecycleBin() R.id.column_count -> changeColumnCount() R.id.set_as_default_folder -> setAsDefaultFolder() R.id.more_apps_from_us -> launchMoreAppsFromUsIntent() diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index ef60b6362..0b853931b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -242,6 +242,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { findItem(R.id.open_camera).isVisible = mShowAll findItem(R.id.about).isVisible = mShowAll findItem(R.id.create_new_folder).isVisible = !mShowAll && mPath != RECYCLE_BIN && mPath != FAVORITES + findItem(R.id.open_recycle_bin).isVisible = mPath != RECYCLE_BIN findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden findItem(R.id.stop_showing_hidden).isVisible = (!isRPlus() || isExternalStorageManager()) && config.temporarilyShowHidden @@ -279,6 +280,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { R.id.change_view_type -> changeViewType() R.id.group -> showGroupByDialog() R.id.create_new_folder -> createNewFolder() + R.id.open_recycle_bin -> openRecycleBin() R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden() R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden() R.id.column_count -> changeColumnCount() @@ -601,7 +603,14 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { } } - finish() + if (mPath == RECYCLE_BIN) { + media_empty_text_placeholder.setText(R.string.no_items_found) + media_empty_text_placeholder.beVisible() + media_empty_text_placeholder_2.beGone() + } else { + finish() + } + true } else { false 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 ec55cc5f3..5d80aad58 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 @@ -34,10 +34,12 @@ import com.simplemobiletools.commons.models.FAQItem import com.simplemobiletools.commons.models.FileDirItem import com.simplemobiletools.gallery.pro.BuildConfig import com.simplemobiletools.gallery.pro.R +import com.simplemobiletools.gallery.pro.activities.MediaActivity import com.simplemobiletools.gallery.pro.activities.SettingsActivity import com.simplemobiletools.gallery.pro.activities.SimpleActivity import com.simplemobiletools.gallery.pro.dialogs.AllFilesPermissionDialog import com.simplemobiletools.gallery.pro.dialogs.PickDirectoryDialog +import com.simplemobiletools.gallery.pro.helpers.DIRECTORY import com.simplemobiletools.gallery.pro.helpers.RECYCLE_BIN import com.simplemobiletools.gallery.pro.models.DateTaken import com.squareup.picasso.Picasso @@ -792,3 +794,10 @@ fun Activity.handleExcludedFolderPasswordProtection(callback: () -> Unit) { callback() } } + +fun Activity.openRecycleBin() { + Intent(this, MediaActivity::class.java).apply { + putExtra(DIRECTORY, RECYCLE_BIN) + startActivity(this) + } +} diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml index 2271f7606..ca2d66031 100644 --- a/app/src/main/res/menu/menu_main.xml +++ b/app/src/main/res/menu/menu_main.xml @@ -58,6 +58,11 @@ android:showAsAction="never" android:title="@string/create_new_folder" app:showAsAction="never" /> + +