Add option to (un-)archive threads.

This commit is contained in:
B. Petersen
2017-10-31 22:05:25 +01:00
parent 9615a47f03
commit dff6fedb67
5 changed files with 42 additions and 0 deletions
+13
View File
@@ -379,6 +379,12 @@ JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_marknoticedChat(JNIEnv *env, jc
}
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_archiveChat(JNIEnv *env, jclass cls, jint chat_id, jint archive)
{
return (jlong)mrmailbox_archive_chat(get_mrmailbox_t(env, cls), chat_id, archive);
}
JNIEXPORT jint Java_com_b44t_messenger_MrMailbox_createChatByContactId(JNIEnv *env, jclass cls, jint contact_id)
{
return (jint)mrmailbox_create_chat_by_contact_id(get_mrmailbox_t(env, cls), contact_id);
@@ -668,6 +674,13 @@ JNIEXPORT jint Java_com_b44t_messenger_MrChat_getType(JNIEnv *env, jclass cls)
}
JNIEXPORT jint Java_com_b44t_messenger_MrChat_getArchived(JNIEnv *env, jclass cls)
{
mrchat_t* ths = get_mrchat_t(env, cls); if( ths == NULL ) { return 0; }
return ths->m_archived;
}
JNIEXPORT jstring Java_com_b44t_messenger_MrChat_getName(JNIEnv *env, jclass cls)
{
mrchat_t* ths = get_mrchat_t(env, cls); if( ths == NULL ) { return JSTRING_NEW(NULL); }
@@ -420,6 +420,29 @@ public class ChatlistActivity extends BaseFragment implements NotificationCenter
}
});
listView.setOnItemLongClickListener(new RecyclerListView.OnItemLongClickListener() {
@Override
public boolean onItemClick(View view, int position) {
RecyclerView.Adapter adapter = listView.getAdapter();
if (adapter == chatlistAdapter) {
final MrChat mrChat = chatlistAdapter.getItem(position);
if (mrChat != null) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
CharSequence[] items = new CharSequence[]{context.getString(mrChat.getArchived()==0? R.string.ArchiveChat : R.string.UnarchiveChat)};
builder.setItems(items, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
MrMailbox.archiveChat(mrChat.getId(), mrChat.getArchived()==0? 1: 0);
MrMailbox.MrCallback(MrMailbox.MR_EVENT_MSGS_CHANGED, 0, 0);
}
});
showDialog(builder.create());
}
}
return false;
}
});
searchEmptyView = new EmptyTextProgressView(context);
searchEmptyView.setVisibility(View.GONE);
searchEmptyView.setShowAtCenter(true);
@@ -48,6 +48,7 @@ public class MrChat {
public native int getId();
public native int getType();
public native int getArchived();
public native String getName();
public native String getSubtitle();
@@ -125,6 +125,7 @@ public class MrMailbox {
public native static int markseenMsgs (int msg_ids[]);
public native static int marknoticedChat (int chat_id);
public native static int archiveChat (int chat_id, int archive);
public native static int getChatIdByContactId (int contact_id);
public native static int createChatByContactId(int contact_id); // returns chat_id
@@ -372,6 +373,7 @@ public class MrMailbox {
case 35: s = "<c#808080>"+ApplicationLoader.applicationContext.getString(R.string.EncrinfoNoE2EExplain)+"</c>"; break;
case 36: s = "<c#808080>"+ApplicationLoader.applicationContext.getString(R.string.E2eeOffBecauseOfUser)+"</c>"; break;
case 37: s = "<c#808080>"+ApplicationLoader.applicationContext.getString(R.string.E2eeOffBecauseOfRecipient)+"</c>"; break;
case 40: s = ApplicationLoader.applicationContext.getString(R.string.ArchivedChats); break;
}
return String2CPtr(s);
@@ -408,4 +408,7 @@
<string name="E2eeOffBecauseOfUser">To enable end-to-end-encryption, check the corresponding option in your settings.</string>
<string name="E2eeOffBecauseOfRecipient">Encryption will switch to end-to-end if the contact enables the corresponding option.</string>
<string name="NotNow">Not now</string>
<string name="ArchiveChat">Archive chat</string>
<string name="UnarchiveChat">Unarchive chat</string>
<string name="ArchivedChats">Archived chats</string>
</resources>