Delete visible local contacts

This commit is contained in:
M66B 2022-03-26 12:53:06 +01:00
parent 4d63204cc9
commit 8c54034f09
3 changed files with 11 additions and 5 deletions

View File

@ -104,6 +104,7 @@ public interface DaoContact {
int deleteContacts(long before);
@Query("DELETE FROM contact" +
" WHERE type IN (:types)")
int clearContacts(int[] types);
" WHERE (:account IS NULL OR account = :account)" +
" AND type IN (:types)")
int clearContacts(Long account, int[] types);
}

View File

@ -267,6 +267,7 @@ public class FragmentContacts extends FragmentBase {
private void onMenuDeleteAll() {
Bundle args = new Bundle();
args.putLong("account", account == null ? -1L : account);
args.putBoolean("junk", junk);
FragmentDelete fragment = new FragmentDelete();
@ -501,13 +502,17 @@ public class FragmentContacts extends FragmentBase {
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
boolean junk = (args != null && args.getBoolean("junk"));
Long account = args.getLong("account");
boolean junk = args.getBoolean("junk");
if (account < 0)
account = null;
int[] types = (junk
? new int[]{EntityContact.TYPE_JUNK, EntityContact.TYPE_NO_JUNK}
: new int[]{EntityContact.TYPE_FROM, EntityContact.TYPE_TO});
DB db = DB.getInstance(context);
int count = db.contact().clearContacts(types);
int count = db.contact().clearContacts(account, types);
Log.i("Cleared contacts=" + count);
return null;
}

View File

@ -1035,7 +1035,7 @@
<string name="title_delete_operation_flag">Flag operations</string>
<string name="title_delete_operation_delete">Delete operations</string>
<string name="title_delete_operation_deleted">%1$d operations deleted</string>
<string name="title_delete_contacts">Delete all local contacts?</string>
<string name="title_delete_contacts">Delete visible local contacts?</string>
<string name="title_no_operations">No pending operations</string>
<string name="title_check_operations">Checking for operations</string>
<string name="title_hint_operations">Deleting operations can result in disappearing messages and synchronization problems</string>