From 31be5d3d95b4ac36a5533ea8d96ca49b811373d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 20 Jul 2023 14:18:24 +0200 Subject: [PATCH] Remove empty recycle bin menu item if there are no recycle bin conversations --- .../activities/RecycleBinConversationsActivity.kt | 7 +++++++ .../smsmessenger/databases/MessagesDatabase.kt | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/RecycleBinConversationsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/RecycleBinConversationsActivity.kt index cd13f825..91a61bf4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/RecycleBinConversationsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/RecycleBinConversationsActivity.kt @@ -58,6 +58,12 @@ class RecycleBinConversationsActivity : SimpleActivity() { } } + private fun updateOptionsMenu(conversations: ArrayList) { + recycle_bin_toolbar.menu.apply { + findItem(R.id.empty_recycle_bin).isVisible = conversations.isNotEmpty() + } + } + private fun updateMenuColors() { updateStatusbarColor(getProperBackgroundColor()) } @@ -117,6 +123,7 @@ class RecycleBinConversationsActivity : SimpleActivity() { ).toMutableList() as ArrayList showOrHidePlaceholder(conversations.isEmpty()) + updateOptionsMenu(conversations) try { getOrCreateConversationsAdapter().apply { diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/databases/MessagesDatabase.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/databases/MessagesDatabase.kt index 6ecddfc0..55b5c701 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/databases/MessagesDatabase.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/databases/MessagesDatabase.kt @@ -118,7 +118,7 @@ abstract class MessagesDatabase : RoomDatabase() { override fun migrate(database: SupportSQLiteDatabase) { database.apply { execSQL("ALTER TABLE conversations ADD COLUMN archived INTEGER NOT NULL DEFAULT 0") - execSQL("CREATE TABLE IF NOT EXISTS `recycle_bin_messages` (`id` INTEGER PRIMARY KEY, `deleted_ts` INTEGER NOT NULL)") + execSQL("CREATE TABLE IF NOT EXISTS `recycle_bin_messages` (`id` INTEGER NOT NULL PRIMARY KEY, `deleted_ts` INTEGER NOT NULL)") execSQL("CREATE UNIQUE INDEX IF NOT EXISTS `index_recycle_bin_messages_id` ON `recycle_bin_messages` (`id`)") } }