Select default calendar for message

pull/212/head
M66B 2 years ago
parent 9ce0b9a601
commit 43dedad615

@ -3711,12 +3711,35 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Helper.hasPermission(context, Manifest.permission.WRITE_CALENDAR)) { Helper.hasPermission(context, Manifest.permission.WRITE_CALENDAR)) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("message", message.id); args.putLong("message", message.id);
args.putLong("account", message.account);
args.putInt("status", CalendarContract.Events.STATUS_TENTATIVE); args.putInt("status", CalendarContract.Events.STATUS_TENTATIVE);
FragmentDialogCalendar fragment = new FragmentDialogCalendar(); new SimpleTask<String>() {
fragment.setArguments(args); @Override
fragment.setTargetFragment(parentFragment, FragmentMessages.REQUEST_CALENDAR); protected String onExecute(Context context, Bundle args) throws Throwable {
fragment.show(parentFragment.getParentFragmentManager(), "insert:calendar"); long aid = args.getLong("account");
DB db = DB.getInstance(context);
EntityAccount account = db.account().getAccount(aid);
return (account == null ? null : account.calendar);
}
@Override
protected void onExecuted(Bundle args, String calendar) {
args.putString("calendar", calendar);
FragmentDialogCalendar fragment = new FragmentDialogCalendar();
fragment.setArguments(args);
fragment.setTargetFragment(parentFragment, FragmentMessages.REQUEST_CALENDAR);
fragment.show(parentFragment.getParentFragmentManager(), "insert:calendar");
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}
}.execute(context, owner, args, "insert:calendar");
return; return;
} }

@ -137,7 +137,6 @@ public class FragmentDialogCalendar extends FragmentDialogBase {
return builder.create(); return builder.create();
} }
private class Calendar { private class Calendar {
private long id; private long id;
private String account; private String account;

Loading…
Cancel
Save