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)); TextView button = ((TextView) LayoutInflater.from(context).inflate(R.layout.reminder_action_button, parent, false));
if (importance == Reminder.Importance.NORMAL) { 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); return new ActionViewHolder(button);

View file

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

View file

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

View file

@ -1,129 +1,126 @@
<?xml version="1.0" encoding="utf-8"?> <?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" xmlns:app="http://schemas.android.com/apk/res-auto"
tools:viewBindingIgnore="true"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container" android:id="@+id/container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:focusable="true" android:layout_margin="12dp"
android:nextFocusRight="@+id/cancel"
android:visibility="gone" 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"> tools:visibility="visible">
<View <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/background"
android:layout_width="match_parent" 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:layout_height="wrap_content"
android:textColor="@color/white" android:nextFocusRight="@+id/cancel">
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%" />
<TextView <ProgressBar
android:id="@+id/reminder_title" android:id="@+id/reminder_progress"
android:layout_width="0dp" style="@style/Widget.ProgressBar.Horizontal"
android:layout_height="wrap_content" android:layout_width="52dp"
android:layout_marginStart="16dp" android:layout_height="52dp"
android:layout_marginTop="20dp" android:layout_marginStart="12dp"
android:layout_marginBottom="6dp" android:layout_marginTop="12dp"
android:textColor="@color/white" android:layout_marginBottom="12dp"
android:textSize="20sp" android:progressDrawable="@drawable/reminder_progress_ring"
android:fontFamily="sans-serif-medium" android:rotation="90"
app:layout_constraintBottom_toTopOf="@id/reminder_text" android:visibility="gone"
app:layout_constraintEnd_toStartOf="@id/cancel" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toEndOf="@id/reminder_progress" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintTop_toTopOf="parent" tools:progress="10" />
app:layout_goneMarginStart="16dp"
tools:text="Invite to Signal" />
<TextView <TextView
android:id="@+id/reminder_text" android:id="@+id/reminder_progress_text"
android:layout_width="0dip" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp" android:textColor="@color/white"
android:layout_marginEnd="12dp" android:textSize="16sp"
style="@style/Signal.Text.Preview" android:visibility="gone"
android:textColor="@color/white" app:layout_constraintBottom_toBottomOf="@id/reminder_progress"
app:layout_constraintBottom_toTopOf="@id/reminder_actions" app:layout_constraintEnd_toEndOf="@id/reminder_progress"
app:layout_constraintEnd_toStartOf="@id/reminder_space" app:layout_constraintStart_toStartOf="@id/reminder_progress"
app:layout_constraintStart_toEndOf="@id/reminder_progress" app:layout_constraintTop_toTopOf="@id/reminder_progress"
app:layout_constraintTop_toBottomOf="@id/reminder_title" tools:text="100%" />
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." />
<Space <TextView
android:id="@+id/reminder_space" android:id="@+id/reminder_title"
android:layout_width="48dp" style="@style/Signal.Text.BodyLarge"
android:layout_height="0dp" android:layout_width="0dp"
android:visibility="gone" android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent" android:layout_marginStart="16dp"
app:layout_constraintTop_toTopOf="parent" /> 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 <TextView
android:id="@+id/cancel" android:id="@+id/reminder_text"
android:layout_width="48dp" style="@style/Signal.Text.BodyMedium"
android:layout_height="48dp" android:layout_width="0dp"
android:layout_marginTop="2dp" android:layout_height="wrap_content"
android:background="?selectableItemBackgroundBorderless" android:layout_marginStart="16dp"
android:contentDescription="@string/InviteActivity_cancel" android:layout_marginEnd="16dp"
android:focusable="true" android:textColor="@color/signal_colorOnSurfaceVariant"
android:nextFocusLeft="@+id/container" app:layout_constraintBottom_toTopOf="@id/reminder_actions"
android:nextFocusRight="@+id/container" app:layout_constraintEnd_toStartOf="@id/reminder_space"
android:src="@drawable/ic_close_white_24dp" app:layout_constraintStart_toEndOf="@id/reminder_progress"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/reminder_title"
app:layout_constraintTop_toTopOf="parent" /> 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 <Space
android:id="@+id/reminder_actions" android:id="@+id/reminder_space"
android:layout_width="0dip" android:layout_width="48dp"
android:layout_height="46dp" android:layout_height="0dp"
android:orientation="horizontal" android:visibility="gone"
android:overScrollMode="never" app:layout_constraintEnd_toEndOf="parent"
android:visibility="gone" app:layout_constraintTop_toTopOf="parent" />
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" />
<View <ImageButton
android:layout_width="match_parent" android:id="@+id/cancel"
android:layout_height="5dp" android:layout_width="48dp"
android:background="@drawable/toolbar_shadow" android:layout_height="48dp"
app:layout_constraintTop_toBottomOf="@id/background" /> 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_white">#ffffff</color>
<color name="core_black">#000000</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_02">#f6f6f6</color>
<color name="core_grey_05">#e9e9e9</color> <color name="core_grey_05">#e9e9e9</color>