From f94b568d0ac851e10766e88e67c5df823d34f28a Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 29 Oct 2022 11:00:18 +0200 Subject: [PATCH] Fix issue #378 - Allow to pin & unpin messages --- .../fedilab/android/ui/drawer/StatusAdapter.java | 14 ++++++++++++-- app/src/main/res/menu/option_toot.xml | 4 ++++ app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java index eba2cdf40..8eb67d761 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java @@ -1649,7 +1649,10 @@ public class StatusAdapter extends RecyclerView.Adapter popup.getMenu().findItem(R.id.action_mute_conversation).setTitle(R.string.unmute_conversation); else popup.getMenu().findItem(R.id.action_mute_conversation).setTitle(R.string.mute_conversation); - + if (statusToDeal.pinned) + popup.getMenu().findItem(R.id.action_pin).setTitle(R.string.action_unpin); + else + popup.getMenu().findItem(R.id.action_pin).setTitle(R.string.action_pin); final String[] stringArrayConf; if (statusToDeal.visibility.equals("direct") || (statusToDeal.visibility.equals("private") && !isOwner)) popup.getMenu().findItem(R.id.action_schedule_boost).setVisible(false); @@ -1661,6 +1664,7 @@ public class StatusAdapter extends RecyclerView.Adapter popup.getMenu().findItem(R.id.action_block_domain).setVisible(false); stringArrayConf = context.getResources().getStringArray(R.array.more_action_owner_confirm); } else { + popup.getMenu().findItem(R.id.action_pin).setVisible(false); popup.getMenu().findItem(R.id.action_redraft).setVisible(false); popup.getMenu().findItem(R.id.action_remove).setVisible(false); if (statusToDeal.account.acct.split("@").length < 2) @@ -1761,7 +1765,13 @@ public class StatusAdapter extends RecyclerView.Adapter } else { statusesVM.mute(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id).observe((LifecycleOwner) context, status1 -> Toasty.info(context, context.getString(R.string.toast_mute_conversation)).show()); } - + return true; + } else if (itemId == R.id.action_pin) { + if (statusToDeal.pinned) { + statusesVM.unPin(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id).observe((LifecycleOwner) context, status1 -> Toasty.info(context, context.getString(R.string.toast_unmute_conversation)).show()); + } else { + statusesVM.pin(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusToDeal.id).observe((LifecycleOwner) context, status1 -> Toasty.info(context, context.getString(R.string.toast_mute_conversation)).show()); + } return true; } else if (itemId == R.id.action_bookmark) { if (statusToDeal.bookmarked) { diff --git a/app/src/main/res/menu/option_toot.xml b/app/src/main/res/menu/option_toot.xml index ccece807c..5a3b3dd8d 100644 --- a/app/src/main/res/menu/option_toot.xml +++ b/app/src/main/res/menu/option_toot.xml @@ -17,6 +17,10 @@ android:id="@+id/action_open_browser" android:title="@string/action_open_in_web" app:showAsAction="never" /> + Pickup a logo Change logo Change the logo of the app on your device + Pin message + Unpin message