Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve saved messages #3073

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions jni/dc_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -1729,6 +1729,12 @@ JNIEXPORT jlong Java_com_b44t_messenger_DcMsg_getParentCPtr(JNIEnv *env, jobject
}


JNIEXPORT jlong Java_com_b44t_messenger_DcMsg_getOriginalMsgCPtr(JNIEnv *env, jobject obj)
{
return (jlong)dc_msg_get_original_msg(get_dc_msg(env, obj));
}


JNIEXPORT jstring Java_com_b44t_messenger_DcMsg_getError(JNIEnv *env, jobject obj)
{
char* temp = dc_msg_get_error(get_dc_msg(env, obj));
Expand Down
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
6 changes: 6 additions & 0 deletions src/main/java/com/b44t/messenger/DcMsg.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ public DcMsg getParent() {
return cPtr != 0 ? new DcMsg(cPtr) : null;
}

public DcMsg getOriginalMsg() {
long cPtr = getOriginalMsgCPtr();
return cPtr != 0 ? new DcMsg(cPtr) : null;
}

public File getFileAsFile() {
if(getFile()==null)
throw new AssertionError("expected a file to be present.");
Expand Down Expand Up @@ -249,5 +254,6 @@ public boolean isSeen() {
private native void setQuoteCPtr (long quoteCPtr);
private native long getQuotedMsgCPtr ();
private native long getParentCPtr ();
private native long getOriginalMsgCPtr();
private native String getWebxdcInfoJson ();
};
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 @@ -180,7 +180,7 @@ public void bind(@NonNull DcMsg messageRecord,
bind(messageRecord, dcChat, batchSelected, pulseHighlight, recipients);
this.locale = locale;
this.glideRequests = glideRequests;
this.showSender = (dcChat.isMultiUser() && !messageRecord.isOutgoing()) || messageRecord.getOverrideSenderName() != null;
this.showSender = ((dcChat.isMultiUser() || dcChat.isSelfTalk()) && !messageRecord.isOutgoing()) || messageRecord.getOverrideSenderName() != null;

if (showSender) {
this.dcContact = dcContext.getContact(messageRecord.getFromId());
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
Loading