Insert contact group: permission warning

pull/214/head
M66B 1 year ago
parent 8081d733c9
commit 31f3960c99

@ -62,6 +62,7 @@ public class FragmentDialogContactGroup extends FragmentDialogBase {
final Spinner spGroup = dview.findViewById(R.id.spGroup);
final Spinner spTarget = dview.findViewById(R.id.spTarget);
final Spinner spType = dview.findViewById(R.id.spType);
final TextView tvNoPermission = dview.findViewById(R.id.tvNoPermission);
ibInfo.setOnClickListener(new View.OnClickListener() {
@Override
@ -70,6 +71,9 @@ public class FragmentDialogContactGroup extends FragmentDialogBase {
}
});
spTarget.setSelection(focussed);
tvNoPermission.setVisibility(View.GONE);
new SimpleTask<Cursor>() {
@Override
protected Cursor onExecute(Context context, Bundle args) {
@ -81,8 +85,11 @@ public class FragmentDialogContactGroup extends FragmentDialogBase {
ContactsContract.Groups.ACCOUNT_TYPE,
};
boolean permission = Helper.hasPermission(context, Manifest.permission.READ_CONTACTS);
args.putBoolean("permission", permission);
Cursor contacts = new MatrixCursor(projection);
if (Helper.hasPermission(context, Manifest.permission.READ_CONTACTS))
if (permission)
try {
ContentResolver resolver = context.getContentResolver();
contacts = resolver.query(
@ -140,6 +147,9 @@ public class FragmentDialogContactGroup extends FragmentDialogBase {
});
spGroup.setAdapter(adapter);
boolean permission = args.getBoolean("permission");
tvNoPermission.setVisibility(permission ? View.GONE : View.VISIBLE);
}
@Override
@ -148,8 +158,6 @@ public class FragmentDialogContactGroup extends FragmentDialogBase {
}
}.execute(this, new Bundle(), "compose:groups");
spTarget.setSelection(focussed);
return new AlertDialog.Builder(context)
.setView(dview)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

@ -64,5 +64,20 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spGroup" />
<TextView
android:id="@+id/tvNoPermission"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:drawableStart="@drawable/twotone_warning_24"
android:drawablePadding="6dp"
android:text="@string/title_setup_permissions_explanation"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning"
app:drawableTint="?attr/colorWarning"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spType" />
</androidx.constraintlayout.widget.ConstraintLayout>
</eu.faircode.email.ScrollViewEx>

Loading…
Cancel
Save