Added selection of contact types/groups

This commit is contained in:
M66B 2022-04-12 20:45:46 +02:00
parent 76626cf19f
commit 1ec503080a
3 changed files with 30 additions and 4 deletions

View File

@ -3822,6 +3822,7 @@ public class FragmentCompose extends FragmentBase {
int target = args.getInt("target");
long group = args.getLong("group");
String gname = args.getString("name");
int type = args.getInt("type");
String to = args.getString("to");
String cc = args.getString("cc");
String bcc = args.getString("bcc");
@ -3847,11 +3848,13 @@ public class FragmentCompose extends FragmentBase {
+ ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE + "'",
new String[]{String.valueOf(group)}, null)) {
while (cursor != null && cursor.moveToNext()) {
// https://developer.android.com/reference/android/provider/ContactsContract.CommonDataKinds.Email
try (Cursor contact = getContext().getContentResolver().query(
ContactsContract.CommonDataKinds.Email.CONTENT_URI,
new String[]{
ContactsContract.Contacts.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Email.DATA
ContactsContract.CommonDataKinds.Email.DATA,
ContactsContract.CommonDataKinds.Email.TYPE,
},
ContactsContract.Data.CONTACT_ID + " = ?",
new String[]{cursor.getString(0)},
@ -3859,10 +3862,12 @@ public class FragmentCompose extends FragmentBase {
if (contact != null && contact.moveToNext()) {
String name = contact.getString(0);
String email = contact.getString(1);
int etype = contact.getInt(2);
Address address = new InternetAddress(email, name, StandardCharsets.UTF_8.name());
EntityLog.log(context, "Selected group=" + group +
" address=" + MessageHelper.formatAddresses(new Address[]{address}));
selected.add(address);
EntityLog.log(context, "Selected group=" + group + ":" + type +
" address=" + MessageHelper.formatAddresses(new Address[]{address}) + ":" + etype);
if (type == 0 || etype == type)
selected.add(address);
}
}
}
@ -6786,6 +6791,7 @@ public class FragmentCompose extends FragmentBase {
final ImageButton ibInfo = dview.findViewById(R.id.ibInfo);
final Spinner spGroup = dview.findViewById(R.id.spGroup);
final Spinner spTarget = dview.findViewById(R.id.spTarget);
final Spinner spType = dview.findViewById(R.id.spType);
ibInfo.setOnClickListener(new View.OnClickListener() {
@Override
@ -6890,6 +6896,7 @@ public class FragmentCompose extends FragmentBase {
args.putInt("target", target);
args.putLong("group", group);
args.putString("name", name);
args.putInt("type", spType.getSelectedItemPosition());
sendResult(RESULT_OK);
} else

View File

@ -54,5 +54,15 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spTarget" />
<Spinner
android:id="@+id/spType"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:entries="@array/contactGroupTypes"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spGroup" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx>

View File

@ -2311,6 +2311,15 @@
<item>Not blocked</item>
</string-array>
<string-array name="contactGroupTypes">
<item>Any</item>
<item>Home</item>
<item>Work</item>
<item>Other</item>
<item>Mobile</item>
</string-array>
<string name="fingerprint" translatable="false">17BA15C1AF55D925F98B99CEA4375D4CDF4C174B</string>
<string name="fingerprint_fdroid" translatable="false">77CD40058858DC3A38523E01C227A39AA019F88B</string>
<string name="fingerprint_amazon" translatable="false">200D0AA43A8ADBC7BB8237023C1553F4753CA7D2</string>