Skip to content

Commit

Permalink
add 'show in chat' menu entry to 'saved messages'
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed May 20, 2024
1 parent f78a718 commit daa9ffe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions res/menu/conversation_context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
android:id="@+id/menu_context_reply_privately"
app:showAsAction="never" />

<item android:title="@string/show_in_chat"
android:id="@+id/menu_show_in_chat"
app:showAsAction="never" />

<item android:title="@string/resend"
android:id="@+id/menu_resend"
app:showAsAction="never" />
Expand Down
5 changes: 5 additions & 0 deletions src/org/thoughtcrime/securesms/ConversationFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ protected void setCorrectMenuVisibility(Menu menu) {
menu.findItem(R.id.menu_context_reply).setVisible(false);
menu.findItem(R.id.menu_context_reply_privately).setVisible(false);
menu.findItem(R.id.menu_add_to_home_screen).setVisible(false);
menu.findItem(R.id.menu_show_in_chat).setVisible(false);
} else {
DcMsg messageRecord = messageRecords.iterator().next();
DcChat chat = getListAdapter().getChat();
Expand All @@ -341,6 +342,7 @@ protected void setCorrectMenuVisibility(Menu menu) {
boolean showReplyPrivately = chat.isMultiUser() && !messageRecord.isOutgoing() && canReply;
menu.findItem(R.id.menu_context_reply_privately).setVisible(showReplyPrivately);
menu.findItem(R.id.menu_add_to_home_screen).setVisible(messageRecord.getType() == DcMsg.DC_MSG_WEBXDC);
menu.findItem(R.id.menu_show_in_chat).setVisible(messageRecord.getOriginalMsg() != null);
}

// if one of the selected items cannot be saved, disable saving.
Expand Down Expand Up @@ -965,6 +967,9 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
case R.id.menu_resend:
handleResendMessage(getListAdapter().getSelectedItems());
return true;
case R.id.menu_show_in_chat:
handleShowInChat(getSelectedMessageRecord(getListAdapter().getSelectedItems()).getOriginalMsg());
return true;
}

return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class ConversationAdaptiveActionsToolbar extends Toolbar {
private static final int ID_NEVER_SHOW_AS_ACTION_2 = R.id.menu_add_to_home_screen;
private static final int ID_NEVER_SHOW_AS_ACTION_3 = R.id.menu_context_save_attachment;
private static final int ID_NEVER_SHOW_AS_ACTION_4 = R.id.menu_resend;
private static final int ID_NEVER_SHOW_AS_ACTION_5 = R.id.menu_show_in_chat;
private static final int ID_ALWAYS_SHOW_AS_ACTION = R.id.menu_context_forward;

private final int maxShown;
Expand Down Expand Up @@ -83,7 +84,8 @@ public static void adjustMenuActions(@NonNull Menu menu, int maxToShow, int tool
boolean neverShowAsAction = item.getItemId() == ID_NEVER_SHOW_AS_ACTION_1
|| item.getItemId() == ID_NEVER_SHOW_AS_ACTION_2
|| item.getItemId() == ID_NEVER_SHOW_AS_ACTION_3
|| item.getItemId() == ID_NEVER_SHOW_AS_ACTION_4;
|| item.getItemId() == ID_NEVER_SHOW_AS_ACTION_4
|| item.getItemId() == ID_NEVER_SHOW_AS_ACTION_5;
boolean alwaysShowAsAction = item.getItemId() == ID_ALWAYS_SHOW_AS_ACTION;

if (alwaysShowAsAction) continue;
Expand Down

0 comments on commit daa9ffe

Please sign in to comment.