From e0ec397a3b779f93397903283952a05a2b30f701 Mon Sep 17 00:00:00 2001 From: Sam Steele Date: Tue, 24 May 2022 09:56:26 -0400 Subject: [PATCH] Fix remove pin appearing incorrectly for archived channels --- build.gradle | 2 +- .../android/activity/MainActivity.java | 31 +++++++------------ 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/build.gradle b/build.gradle index 30d906aa..e08db951 100644 --- a/build.gradle +++ b/build.gradle @@ -69,7 +69,7 @@ android { testBuildType "mockdata" defaultConfig { - versionCode 325 + versionCode 326 versionName "4.28" minSdkVersion 22 targetSdkVersion 31 diff --git a/src/com/irccloud/android/activity/MainActivity.java b/src/com/irccloud/android/activity/MainActivity.java index 2300b1e9..8575753d 100644 --- a/src/com/irccloud/android/activity/MainActivity.java +++ b/src/com/irccloud/android/activity/MainActivity.java @@ -3836,28 +3836,17 @@ else if (buffer.isConsole()) @Override public boolean onPrepareOptionsMenu(Menu menu) { if (menu != null && buffer != null && buffer.getType() != null && NetworkConnection.getInstance().ready) { + if (menu.findItem(R.id.menu_pin) != null) { + menu.findItem(R.id.menu_pin).setVisible(!buffer.isPinned()); + menu.findItem(R.id.menu_pin).setEnabled(!buffer.isPinned()); + } + if (menu.findItem(R.id.menu_remove_pin) != null) { + menu.findItem(R.id.menu_remove_pin).setVisible(buffer.isPinned()); + menu.findItem(R.id.menu_remove_pin).setEnabled(buffer.isPinned()); + } if (buffer.getArchived() == 0) { if (menu.findItem(R.id.menu_archive) != null) menu.findItem(R.id.menu_archive).setTitle(R.string.menu_archive); - if(buffer.isPinned()) { - if (menu.findItem(R.id.menu_pin) != null) { - menu.findItem(R.id.menu_pin).setVisible(false); - menu.findItem(R.id.menu_pin).setEnabled(false); - } - if (menu.findItem(R.id.menu_remove_pin) != null) { - menu.findItem(R.id.menu_remove_pin).setVisible(true); - menu.findItem(R.id.menu_remove_pin).setEnabled(true); - } - } else { - if (menu.findItem(R.id.menu_pin) != null) { - menu.findItem(R.id.menu_pin).setVisible(true); - menu.findItem(R.id.menu_pin).setEnabled(true); - } - if (menu.findItem(R.id.menu_remove_pin) != null) { - menu.findItem(R.id.menu_remove_pin).setVisible(false); - menu.findItem(R.id.menu_remove_pin).setEnabled(false); - } - } } else { if (menu.findItem(R.id.menu_archive) != null) menu.findItem(R.id.menu_archive).setTitle(R.string.menu_unarchive); @@ -3865,6 +3854,10 @@ public boolean onPrepareOptionsMenu(Menu menu) { menu.findItem(R.id.menu_pin).setVisible(false); menu.findItem(R.id.menu_pin).setEnabled(false); } + if (menu.findItem(R.id.menu_remove_pin) != null) { + menu.findItem(R.id.menu_remove_pin).setVisible(false); + menu.findItem(R.id.menu_remove_pin).setEnabled(false); + } } if (buffer.isChannel()) { if (ChannelsList.getInstance().getChannelForBuffer(buffer.getBid()) == null) {