mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-24 15:11:03 +00:00
Clear contacts by type
This commit is contained in:
parent
8f9dda9878
commit
905e79fc8b
2 changed files with 17 additions and 6 deletions
|
@ -103,7 +103,6 @@ public interface DaoContact {
|
||||||
int deleteContacts(long before);
|
int deleteContacts(long before);
|
||||||
|
|
||||||
@Query("DELETE FROM contact" +
|
@Query("DELETE FROM contact" +
|
||||||
" WHERE (type = " + EntityContact.TYPE_TO +
|
" WHERE type IN (:types)")
|
||||||
" OR type = " + EntityContact.TYPE_FROM + ")")
|
int clearContacts(int[] types);
|
||||||
int clearContacts();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,6 +205,8 @@ public class FragmentContacts extends FragmentBase {
|
||||||
public void onPrepareOptionsMenu(@NonNull Menu menu) {
|
public void onPrepareOptionsMenu(@NonNull Menu menu) {
|
||||||
super.onPrepareOptionsMenu(menu);
|
super.onPrepareOptionsMenu(menu);
|
||||||
menu.findItem(R.id.menu_junk).setChecked(junk);
|
menu.findItem(R.id.menu_junk).setChecked(junk);
|
||||||
|
menu.findItem(R.id.menu_import).setVisible(!junk);
|
||||||
|
menu.findItem(R.id.menu_export).setVisible(!junk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -253,7 +255,12 @@ public class FragmentContacts extends FragmentBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onMenuDeleteAll() {
|
private void onMenuDeleteAll() {
|
||||||
new FragmentDelete().show(getParentFragmentManager(), "contacts:delete");
|
Bundle args = new Bundle();
|
||||||
|
args.putBoolean("junk", junk);
|
||||||
|
|
||||||
|
FragmentDelete fragment = new FragmentDelete();
|
||||||
|
fragment.setArguments(args);
|
||||||
|
fragment.show(getParentFragmentManager(), "contacts:delete");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -482,8 +489,13 @@ public class FragmentContacts extends FragmentBase {
|
||||||
new SimpleTask<Void>() {
|
new SimpleTask<Void>() {
|
||||||
@Override
|
@Override
|
||||||
protected Void onExecute(Context context, Bundle args) {
|
protected Void onExecute(Context context, Bundle args) {
|
||||||
|
boolean junk = (args != null && args.getBoolean("junk"));
|
||||||
|
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);
|
DB db = DB.getInstance(context);
|
||||||
int count = db.contact().clearContacts();
|
int count = db.contact().clearContacts(types);
|
||||||
Log.i("Cleared contacts=" + count);
|
Log.i("Cleared contacts=" + count);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -492,7 +504,7 @@ public class FragmentContacts extends FragmentBase {
|
||||||
protected void onException(Bundle args, Throwable ex) {
|
protected void onException(Bundle args, Throwable ex) {
|
||||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||||
}
|
}
|
||||||
}.execute(getContext(), getActivity(), new Bundle(), "contacts:delete");
|
}.execute(getContext(), getActivity(), getArguments(), "contacts:delete");
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
|
Loading…
Reference in a new issue