Update ReminderView to Material Design 3.

This commit is contained in:
Nicholas Tinsley 2022-09-08 11:50:37 -04:00 committed by Greyson Parrelli
parent beee3b7dc3
commit 46ec45b985
5 changed files with 126 additions and 131 deletions

View file

@ -35,7 +35,9 @@ final class ReminderActionsAdapter extends RecyclerView.Adapter<ReminderActionsA
TextView button = ((TextView) LayoutInflater.from(context).inflate(R.layout.reminder_action_button, parent, false));
if (importance == Reminder.Importance.NORMAL) {
button.setTextColor(ContextCompat.getColor(context, R.color.signal_accent_primary));
button.setTextColor(ContextCompat.getColor(context, R.color.signal_colorPrimary));
} else if (importance == Reminder.Importance.ERROR || importance == Reminder.Importance.TERMINAL) {
button.setTextColor(ContextCompat.getColor(context, R.color.signal_light_colorOnSurface));
}
return new ActionViewHolder(button);

View file

@ -17,6 +17,8 @@ import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.card.MaterialCardView;
import org.signal.core.util.DimensionUnit;
import org.thoughtcrime.securesms.R;
@ -28,8 +30,7 @@ import java.util.List;
public final class ReminderView extends FrameLayout {
private ProgressBar progressBar;
private TextView progressText;
private ViewGroup container;
private View background;
private MaterialCardView container;
private ImageButton closeButton;
private TextView title;
private TextView text;
@ -58,7 +59,6 @@ public final class ReminderView extends FrameLayout {
progressBar = findViewById(R.id.reminder_progress);
progressText = findViewById(R.id.reminder_progress_text);
container = findViewById(R.id.container);
background = findViewById(R.id.background);
closeButton = findViewById(R.id.cancel);
title = findViewById(R.id.reminder_title);
text = findViewById(R.id.reminder_text);
@ -75,6 +75,7 @@ public final class ReminderView extends FrameLayout {
title.setText("");
title.setVisibility(GONE);
space.setVisibility(VISIBLE);
text.setTextColor(ContextCompat.getColor(getContext(), R.color.signal_colorOnSurface));
}
if (!reminder.isDismissable()) {
@ -82,22 +83,17 @@ public final class ReminderView extends FrameLayout {
}
text.setText(reminder.getText());
switch (reminder.getImportance()) {
case NORMAL:
background.setBackgroundResource(R.drawable.reminder_background_normal);
title.setTextColor(ContextCompat.getColor(getContext(), R.color.signal_text_primary));
text.setTextColor(ContextCompat.getColor(getContext(), R.color.signal_text_primary));
title.setTextColor(ContextCompat.getColor(getContext(), R.color.signal_colorOnSurface));
text.setTextColor(ContextCompat.getColor(getContext(), R.color.signal_colorOnSurfaceVariant));
break;
case ERROR:
background.setBackgroundResource(R.drawable.reminder_background_error);
title.setTextColor(ContextCompat.getColor(getContext(), R.color.core_black));
text.setTextColor(ContextCompat.getColor(getContext(), R.color.core_black));
break;
case TERMINAL:
background.setBackgroundResource(R.drawable.reminder_background_terminal);
title.setTextColor(ContextCompat.getColor(getContext(), R.color.signal_button_primary_text));
text.setTextColor(ContextCompat.getColor(getContext(), R.color.signal_button_primary_text));
container.setStrokeWidth(0);
container.setCardBackgroundColor(ContextCompat.getColor(getContext(), R.color.reminder_background));
title.setTextColor(ContextCompat.getColor(getContext(), R.color.signal_light_colorOnSurface));
text.setTextColor(ContextCompat.getColor(getContext(), R.color.signal_light_colorOnSurface));
break;
default:
throw new IllegalStateException();
@ -118,7 +114,7 @@ public final class ReminderView extends FrameLayout {
});
if (reminder.getImportance() == Reminder.Importance.NORMAL) {
closeButton.setColorFilter(ContextCompat.getColor(getContext(), R.color.signal_text_primary));
closeButton.setColorFilter(ContextCompat.getColor(getContext(), R.color.signal_colorOnSurfaceVariant));
}
int progress = reminder.getProgress();

View file

@ -6,9 +6,9 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAllCaps="false"
android:textColor="@color/white"
android:textColor="@color/signal_colorPrimary"
android:textSize="14sp"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:layout_marginStart="3dp"
tools:text="Action" />

View file

@ -1,129 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:viewBindingIgnore="true"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:nextFocusRight="@+id/cancel"
android:layout_margin="12dp"
android:visibility="gone"
android:focusable="true"
app:cardBackgroundColor="@color/signal_colorSurface"
app:cardCornerRadius="12dp"
app:cardElevation="0dp"
app:strokeColor="@color/signal_colorOutline_38"
app:strokeWidth="1dp"
tools:viewBindingIgnore="true"
tools:visibility="visible">
<View
android:id="@+id/background"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/reminder_background_normal"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="@id/reminder_actions" />
<ProgressBar
android:id="@+id/reminder_progress"
style="@style/Widget.ProgressBar.Horizontal"
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:progressDrawable="@drawable/reminder_progress_ring"
android:rotation="90"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:progress="10" />
<TextView
android:id="@+id/reminder_progress_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/reminder_progress"
app:layout_constraintEnd_toEndOf="@id/reminder_progress"
app:layout_constraintStart_toStartOf="@id/reminder_progress"
app:layout_constraintTop_toTopOf="@id/reminder_progress"
tools:text="100%" />
android:nextFocusRight="@+id/cancel">
<TextView
android:id="@+id/reminder_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="6dp"
android:textColor="@color/white"
android:textSize="20sp"
android:fontFamily="sans-serif-medium"
app:layout_constraintBottom_toTopOf="@id/reminder_text"
app:layout_constraintEnd_toStartOf="@id/cancel"
app:layout_constraintStart_toEndOf="@id/reminder_progress"
app:layout_constraintTop_toTopOf="parent"
app:layout_goneMarginStart="16dp"
tools:text="Invite to Signal" />
<ProgressBar
android:id="@+id/reminder_progress"
style="@style/Widget.ProgressBar.Horizontal"
android:layout_width="52dp"
android:layout_height="52dp"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:progressDrawable="@drawable/reminder_progress_ring"
android:rotation="90"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:progress="10" />
<TextView
android:id="@+id/reminder_text"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
style="@style/Signal.Text.Preview"
android:textColor="@color/white"
app:layout_constraintBottom_toTopOf="@id/reminder_actions"
app:layout_constraintEnd_toStartOf="@id/reminder_space"
app:layout_constraintStart_toEndOf="@id/reminder_progress"
app:layout_constraintTop_toBottomOf="@id/reminder_title"
app:layout_goneMarginBottom="16dp"
app:layout_goneMarginEnd="16dp"
app:layout_goneMarginStart="16dp"
app:layout_goneMarginTop="16dp"
tools:text="Take your conversation with Otto Octavius to the next level." />
<TextView
android:id="@+id/reminder_progress_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="16sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@id/reminder_progress"
app:layout_constraintEnd_toEndOf="@id/reminder_progress"
app:layout_constraintStart_toStartOf="@id/reminder_progress"
app:layout_constraintTop_toTopOf="@id/reminder_progress"
tools:text="100%" />
<Space
android:id="@+id/reminder_space"
android:layout_width="48dp"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/reminder_title"
style="@style/Signal.Text.BodyLarge"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="6dp"
android:textColor="@color/signal_colorOnSurface"
app:layout_constraintBottom_toTopOf="@id/reminder_text"
app:layout_constraintEnd_toStartOf="@id/cancel"
app:layout_constraintStart_toEndOf="@id/reminder_progress"
app:layout_constraintTop_toTopOf="parent"
app:layout_goneMarginStart="16dp"
tools:text="Invite to Signal" />
<ImageButton
android:id="@+id/cancel"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="2dp"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/InviteActivity_cancel"
android:focusable="true"
android:nextFocusLeft="@+id/container"
android:nextFocusRight="@+id/container"
android:src="@drawable/ic_close_white_24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/reminder_text"
style="@style/Signal.Text.BodyMedium"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:textColor="@color/signal_colorOnSurfaceVariant"
app:layout_constraintBottom_toTopOf="@id/reminder_actions"
app:layout_constraintEnd_toStartOf="@id/reminder_space"
app:layout_constraintStart_toEndOf="@id/reminder_progress"
app:layout_constraintTop_toBottomOf="@id/reminder_title"
app:layout_goneMarginBottom="16dp"
app:layout_goneMarginEnd="16dp"
app:layout_goneMarginStart="16dp"
app:layout_goneMarginTop="16dp"
tools:text="Take your conversation with Otto Octavius to the next level!" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/reminder_actions"
android:layout_width="0dip"
android:layout_height="46dp"
android:orientation="horizontal"
android:overScrollMode="never"
android:visibility="gone"
tools:visibility="visible"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintTop_toBottomOf="@id/reminder_text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:reverseLayout="true"
tools:itemCount="2"
tools:listitem="@layout/reminder_action_button" />
<Space
android:id="@+id/reminder_space"
android:layout_width="48dp"
android:layout_height="0dp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/toolbar_shadow"
app:layout_constraintTop_toBottomOf="@id/background" />
<ImageButton
android:id="@+id/cancel"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="2dp"
android:background="?selectableItemBackgroundBorderless"
android:contentDescription="@string/InviteActivity_cancel"
android:focusable="true"
android:nextFocusLeft="@+id/container"
android:nextFocusRight="@+id/container"
android:src="@drawable/ic_close_white_24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/reminder_actions"
android:layout_width="0dp"
android:layout_height="46dp"
android:orientation="horizontal"
android:overScrollMode="never"
android:visibility="gone"
android:layout_marginEnd="16dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/reminder_text"
app:reverseLayout="true"
tools:itemCount="2"
tools:listitem="@layout/reminder_action_button"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>

View file

@ -16,7 +16,7 @@
<color name="core_white">#ffffff</color>
<color name="core_black">#000000</color>
<color name="reminder_background">#fcf0d9</color>
<color name="reminder_background">#faf0dc</color>
<color name="core_grey_02">#f6f6f6</color>
<color name="core_grey_05">#e9e9e9</color>