mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-06 03:49:58 +02:00
delete contacts in thread
This commit is contained in:
parent
0a119d9d8e
commit
179e8173c9
3 changed files with 18 additions and 13 deletions
|
@ -345,9 +345,9 @@ JNIEXPORT void Java_com_b44t_messenger_DcContext_blockContact(JNIEnv *env, jobje
|
|||
}
|
||||
|
||||
|
||||
JNIEXPORT jint Java_com_b44t_messenger_DcContext_deleteContact(JNIEnv *env, jobject obj, jint contact_id)
|
||||
JNIEXPORT jboolean Java_com_b44t_messenger_DcContext_deleteContact(JNIEnv *env, jobject obj, jint contact_id)
|
||||
{
|
||||
return (jint)dc_delete_contact(get_dc_context(env, obj), contact_id);
|
||||
return (jboolean)dc_delete_contact(get_dc_context(env, obj), contact_id);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ public class DcContext {
|
|||
public native int createContact (String name, String addr);
|
||||
public native void blockContact (int id, int block);
|
||||
public native String getContactEncrInfo (int contact_id);
|
||||
public native int deleteContact (int id);
|
||||
public native boolean deleteContact (int id);
|
||||
public native int addAddressBook (String adrbook);
|
||||
public @NonNull DcChatlist getChatlist (int listflags, String query, int queryId) { return new DcChatlist(getChatlistCPtr(listflags, query, queryId)); }
|
||||
public @NonNull DcChat getChat (int chat_id) { return new DcChat(getChatCPtr(chat_id)); }
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.thoughtcrime.securesms.contacts.ContactSelectionListItem;
|
|||
import org.thoughtcrime.securesms.mms.GlideApp;
|
||||
import org.thoughtcrime.securesms.permissions.Permissions;
|
||||
import org.thoughtcrime.securesms.util.StickyHeaderDecoration;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
@ -176,16 +177,20 @@ public class ContactSelectionListFragment extends Fragment
|
|||
|
||||
private void handleDeleteSelected() {
|
||||
ContactSelectionListAdapter adapter = getContactSelectionListAdapter();
|
||||
SparseIntArray actionModeSelection = adapter.getActionModeSelection();
|
||||
final SparseIntArray actionModeSelection = adapter.getActionModeSelection().clone();
|
||||
new Thread(() -> {
|
||||
boolean failed = false;
|
||||
for (int index = 0; index < actionModeSelection.size(); index++) {
|
||||
int contactId = actionModeSelection.valueAt(index);
|
||||
boolean currentFailed = DcHelper.getContext(getContext()).deleteContact(contactId) == 0;
|
||||
boolean currentFailed = dcContext.deleteContact(contactId);
|
||||
failed = currentFailed || failed;
|
||||
}
|
||||
if (failed) {
|
||||
Util.runOnMain(()-> {
|
||||
Toast.makeText(getActivity(), R.string.ContactSelectionListFragment_error_deleting_contacts_check_existing_conversations, Toast.LENGTH_LONG).show();
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
adapter.resetActionModeSelection();
|
||||
actionMode.finish();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue