Local contact groups insert without permissions

This commit is contained in:
M66B 2022-03-27 21:06:49 +02:00
parent aaf6bde09a
commit cc5db29320
1 changed files with 17 additions and 18 deletions

View File

@ -1600,8 +1600,7 @@ public class FragmentCompose extends FragmentBase {
menu.findItem(R.id.menu_zoom).setEnabled(state == State.LOADED); menu.findItem(R.id.menu_zoom).setEnabled(state == State.LOADED);
menu.findItem(R.id.menu_media).setEnabled(state == State.LOADED); menu.findItem(R.id.menu_media).setEnabled(state == State.LOADED);
menu.findItem(R.id.menu_compact).setEnabled(state == State.LOADED); menu.findItem(R.id.menu_compact).setEnabled(state == State.LOADED);
menu.findItem(R.id.menu_contact_group).setEnabled( menu.findItem(R.id.menu_contact_group).setEnabled(state == State.LOADED);
state == State.LOADED && hasPermission(Manifest.permission.READ_CONTACTS));
menu.findItem(R.id.menu_manage_local_contacts).setEnabled(state == State.LOADED); menu.findItem(R.id.menu_manage_local_contacts).setEnabled(state == State.LOADED);
menu.findItem(R.id.menu_answer_insert).setEnabled(state == State.LOADED); menu.findItem(R.id.menu_answer_insert).setEnabled(state == State.LOADED);
menu.findItem(R.id.menu_answer_create).setEnabled(state == State.LOADED); menu.findItem(R.id.menu_answer_create).setEnabled(state == State.LOADED);
@ -6776,22 +6775,22 @@ public class FragmentCompose extends FragmentBase {
ContactsContract.Groups.ACCOUNT_TYPE, ContactsContract.Groups.ACCOUNT_TYPE,
}; };
Cursor contacts; Cursor contacts = new MatrixCursor(projection);
try { if (Helper.hasPermission(context, Manifest.permission.READ_CONTACTS))
ContentResolver resolver = context.getContentResolver(); try {
contacts = resolver.query( ContentResolver resolver = context.getContentResolver();
ContactsContract.Groups.CONTENT_SUMMARY_URI, contacts = resolver.query(
projection, ContactsContract.Groups.CONTENT_SUMMARY_URI,
// ContactsContract.Groups.GROUP_VISIBLE + " = 1" + " AND " + projection,
ContactsContract.Groups.DELETED + " = 0" + // ContactsContract.Groups.GROUP_VISIBLE + " = 1" + " AND " +
" AND " + ContactsContract.Groups.SUMMARY_COUNT + " > 0", ContactsContract.Groups.DELETED + " = 0" +
null, " AND " + ContactsContract.Groups.SUMMARY_COUNT + " > 0",
ContactsContract.Groups.TITLE null,
); ContactsContract.Groups.TITLE
} catch (SecurityException ex) { );
Log.w(ex); } catch (SecurityException ex) {
contacts = new MatrixCursor(projection); Log.w(ex);
} }
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
Cursor local = db.contact().getGroups( Cursor local = db.contact().getGroups(