Always show calendar button for events

pull/178/head
M66B 5 years ago
parent 09a447c5bd
commit 115b0b6659

@ -410,6 +410,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private ImageButton ibSeen;
private Flow flow;
private ImageButton ibCalendar;
private TextView tvCalendarSummary;
private TextView tvCalendarDescription;
private TextView tvCalendarLocation;
@ -419,7 +420,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private Button btnCalendarAccept;
private Button btnCalendarDecline;
private Button btnCalendarMaybe;
private ImageButton ibCalendar;
private ContentLoadingProgressBar pbCalendarWait;
private RecyclerView rvImage;
@ -553,6 +553,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
pbHeaders = vsBody.findViewById(R.id.pbHeaders);
tvNoInternetHeaders = vsBody.findViewById(R.id.tvNoInternetHeaders);
ibCalendar = vsBody.findViewById(R.id.ibCalendar);
tvCalendarSummary = vsBody.findViewById(R.id.tvCalendarSummary);
tvCalendarDescription = vsBody.findViewById(R.id.tvCalendarDescription);
tvCalendarLocation = vsBody.findViewById(R.id.tvCalendarLocation);
@ -562,7 +563,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
btnCalendarAccept = vsBody.findViewById(R.id.btnCalendarAccept);
btnCalendarDecline = vsBody.findViewById(R.id.btnCalendarDecline);
btnCalendarMaybe = vsBody.findViewById(R.id.btnCalendarMaybe);
ibCalendar = vsBody.findViewById(R.id.ibCalendar);
pbCalendarWait = vsBody.findViewById(R.id.pbCalendarWait);
rvAttachment = attachments.findViewById(R.id.rvAttachment);
@ -684,10 +684,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvBody.setOnTouchListener(this);
tvBody.addOnLayoutChangeListener(this);
ibCalendar.setOnClickListener(this);
btnCalendarAccept.setOnClickListener(this);
btnCalendarDecline.setOnClickListener(this);
btnCalendarMaybe.setOnClickListener(this);
ibCalendar.setOnClickListener(this);
btnCalendarAccept.setOnLongClickListener(this);
btnCalendarDecline.setOnLongClickListener(this);
@ -1210,6 +1210,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void clearCalendar() {
ibCalendar.setVisibility(View.GONE);
tvCalendarSummary.setVisibility(View.GONE);
tvCalendarDescription.setVisibility(View.GONE);
tvCalendarLocation.setVisibility(View.GONE);
@ -2299,6 +2300,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Organizer organizer = event.getOrganizer();
ibCalendar.setVisibility(View.VISIBLE);
tvCalendarSummary.setText(summary);
tvCalendarSummary.setVisibility(TextUtils.isEmpty(summary) ? View.GONE : View.VISIBLE);
@ -2376,11 +2379,19 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
attendee.add(email);
}
int status;
if (icalendar.getMethod().isRequest())
status = CalendarContract.Events.STATUS_TENTATIVE;
else if (icalendar.getMethod().isCancel())
status = CalendarContract.Events.STATUS_CANCELED;
else
status = CalendarContract.Events.STATUS_CONFIRMED;
// https://developer.android.com/guide/topics/providers/calendar-provider.html#intent-insert
Intent intent = new Intent(Intent.ACTION_INSERT)
.setData(CalendarContract.Events.CONTENT_URI)
.putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY)
.putExtra(CalendarContract.Events.STATUS, CalendarContract.Events.STATUS_CONFIRMED);
.putExtra(CalendarContract.Events.STATUS, status);
if (summary != null)
intent.putExtra(CalendarContract.Events.TITLE, summary);

@ -16,6 +16,20 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageButton
android:id="@+id/ibCalendar"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_icalendar_calendar"
android:foregroundTint="?android:attr/textColorSecondary"
android:padding="6dp"
android:scaleType="fitCenter"
android:tooltipText="@string/title_icalendar_accept"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorCalendar"
app:srcCompat="@drawable/baseline_event_24" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvCalendarSummary"
android:layout_width="0dp"
@ -26,7 +40,7 @@
android:text="Summary"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@+id/ibCalendar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorCalendar" />
@ -39,7 +53,7 @@
android:layout_marginEnd="6dp"
android:text="Description"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@id/ibCalendar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCalendarSummary" />
@ -52,7 +66,7 @@
android:layout_marginEnd="6dp"
android:text="Location"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@id/ibCalendar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCalendarDescription" />
@ -65,7 +79,7 @@
android:layout_marginEnd="6dp"
android:text="12:00:00"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@id/ibCalendar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCalendarLocation" />
@ -78,7 +92,7 @@
android:layout_marginEnd="6dp"
android:text="12:00:00"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@id/ibCalendar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCalendarStart" />
@ -91,7 +105,7 @@
android:layout_marginEnd="6dp"
android:text="You, me"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@id/ibCalendar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCalendarEnd" />
@ -128,18 +142,6 @@
app:layout_constraintStart_toEndOf="@id/btnCalendarDecline"
app:layout_constraintTop_toBottomOf="@id/tvAttendees" />
<ImageButton
android:id="@+id/ibCalendar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="?attr/colorActionBackground"
android:contentDescription="@string/title_icalendar_calendar"
android:tint="@color/action_foreground"
android:tooltipText="@string/title_icalendar_accept"
app:layout_constraintBottom_toBottomOf="@id/btnCalendarAccept"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/baseline_event_24" />
<View
android:id="@+id/paddingBottom"
android:layout_width="wrap_content"
@ -169,5 +171,5 @@
android:id="@+id/grpCalendarResponse"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="btnCalendarAccept,btnCalendarDecline,btnCalendarMaybe,ibCalendar" />
app:constraint_referenced_ids="btnCalendarAccept,btnCalendarDecline,btnCalendarMaybe" />
</androidx.constraintlayout.widget.ConstraintLayout>
Loading…
Cancel
Save