mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-26 22:20:20 +00:00
Rewrite AlertView to be a single ImageView.
This commit is contained in:
committed by
Greyson Parrelli
parent
9d8501cd64
commit
8d20669e46
@@ -1,23 +1,16 @@
|
||||
package org.thoughtcrime.securesms.components;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build.VERSION_CODES;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
public class AlertView extends LinearLayout {
|
||||
|
||||
private static final String TAG = Log.tag(AlertView.class);
|
||||
|
||||
private ImageView approvalIndicator;
|
||||
private ImageView failedIndicator;
|
||||
public class AlertView extends AppCompatImageView {
|
||||
|
||||
public AlertView(Context context) {
|
||||
this(context, null);
|
||||
@@ -25,53 +18,38 @@ public class AlertView extends LinearLayout {
|
||||
|
||||
public AlertView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initialize(attrs);
|
||||
initialize();
|
||||
}
|
||||
|
||||
public AlertView(final Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
initialize(attrs);
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize(AttributeSet attrs) {
|
||||
inflate(getContext(), R.layout.alert_view, this);
|
||||
|
||||
approvalIndicator = findViewById(R.id.pending_approval_indicator);
|
||||
failedIndicator = findViewById(R.id.sms_failed_indicator);
|
||||
|
||||
if (attrs != null) {
|
||||
TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.AlertView, 0, 0);
|
||||
boolean useSmallIcon = typedArray.getBoolean(R.styleable.AlertView_useSmallIcon, false);
|
||||
typedArray.recycle();
|
||||
|
||||
if (useSmallIcon) {
|
||||
int size = getResources().getDimensionPixelOffset(R.dimen.alertview_small_icon_size);
|
||||
failedIndicator.getLayoutParams().width = size;
|
||||
failedIndicator.getLayoutParams().height = size;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
private void initialize() {
|
||||
setImageResource(R.drawable.symbol_error_circle_compact_16);
|
||||
setScaleType(ScaleType.FIT_CENTER);
|
||||
}
|
||||
|
||||
public void setNone() {
|
||||
this.setVisibility(View.GONE);
|
||||
setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void setPendingApproval() {
|
||||
this.setVisibility(View.VISIBLE);
|
||||
approvalIndicator.setVisibility(View.VISIBLE);
|
||||
failedIndicator.setVisibility(View.GONE);
|
||||
setVisibility(View.VISIBLE);
|
||||
setColorFilter(ContextCompat.getColor(getContext(), R.color.signal_colorOnSurfaceVariant));
|
||||
setContentDescription(getContext().getString(R.string.conversation_item_sent__pending_approval_description));
|
||||
}
|
||||
|
||||
public void setFailed() {
|
||||
this.setVisibility(View.VISIBLE);
|
||||
approvalIndicator.setVisibility(View.GONE);
|
||||
failedIndicator.setVisibility(View.VISIBLE);
|
||||
setVisibility(View.VISIBLE);
|
||||
setColorFilter(ContextCompat.getColor(getContext(), R.color.signal_colorError));
|
||||
setContentDescription(getContext().getString(R.string.conversation_item_sent__send_failed_indicator_description));
|
||||
}
|
||||
|
||||
public void setRateLimited() {
|
||||
this.setVisibility(View.VISIBLE);
|
||||
approvalIndicator.setVisibility(View.VISIBLE);
|
||||
failedIndicator.setVisibility(View.GONE);
|
||||
setVisibility(View.VISIBLE);
|
||||
setColorFilter(ContextCompat.getColor(getContext(), R.color.signal_colorOnSurfaceVariant));
|
||||
setContentDescription(getContext().getString(R.string.conversation_item_sent__pending_approval_description));
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 280 B |
Binary file not shown.
|
Before Width: | Height: | Size: 192 B |
Binary file not shown.
|
Before Width: | Height: | Size: 380 B |
Binary file not shown.
|
Before Width: | Height: | Size: 614 B |
Binary file not shown.
|
Before Width: | Height: | Size: 840 B |
17
app/src/main/res/drawable/symbol_error_circle_compact_16.xml
Normal file
17
app/src/main/res/drawable/symbol_error_circle_compact_16.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16dp"
|
||||
android:height="16dp"
|
||||
android:viewportWidth="16"
|
||||
android:viewportHeight="16">
|
||||
<group>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M8 4.22c-0.5 0-0.9 0.44-0.85 0.94l0.32 3.63C7.49 9.06 7.72 9.28 8 9.28s0.51-0.22 0.53-0.5l0.32-3.62C8.9 4.66 8.5 4.22 8 4.22Z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M7.1 11c0-0.5 0.4-0.9 0.9-0.9s0.9 0.4 0.9 0.9-0.4 0.9-0.9 0.9-0.9-0.4-0.9-0.9Z"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M0.85 8c0-3.95 3.2-7.15 7.15-7.15s7.15 3.2 7.15 7.15-3.2 7.15-7.15 7.15S0.85 11.95 0.85 8ZM8 2.15C4.77 2.15 2.15 4.77 2.15 8c0 3.23 2.62 5.85 5.85 5.85 3.23 0 5.85-2.62 5.85-5.85 0-3.23-2.62-5.85-5.85-5.85Z"/>
|
||||
</group>
|
||||
</vector>
|
||||
@@ -1,27 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:viewBindingIgnore="true">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/sms_failed_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_error"
|
||||
android:visibility="gone"
|
||||
android:tint="@color/core_red"
|
||||
tools:visibility="visible"
|
||||
android:contentDescription="@string/conversation_item_sent__send_failed_indicator_description" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/pending_approval_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_error"
|
||||
android:tint="@color/core_grey_60"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:contentDescription="@string/conversation_item_sent__pending_approval_description" />
|
||||
|
||||
</merge>
|
||||
@@ -284,11 +284,10 @@
|
||||
|
||||
<org.thoughtcrime.securesms.components.AlertView
|
||||
android:id="@+id/indicators_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_toStartOf="@id/quoted_indicator"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<FrameLayout
|
||||
|
||||
@@ -162,11 +162,10 @@
|
||||
|
||||
<org.thoughtcrime.securesms.components.AlertView
|
||||
android:id="@+id/indicators_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical" />
|
||||
android:gravity="center_vertical" />
|
||||
|
||||
<org.thoughtcrime.securesms.reactions.ReactionsConversationView
|
||||
android:id="@+id/reactions_view"
|
||||
|
||||
@@ -216,12 +216,11 @@
|
||||
|
||||
<org.thoughtcrime.securesms.components.AlertView
|
||||
android:id="@+id/indicators_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_alignBottom="@id/body_bubble"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginStart="8dp"
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp" />
|
||||
|
||||
<FrameLayout
|
||||
|
||||
@@ -102,13 +102,11 @@
|
||||
|
||||
<org.thoughtcrime.securesms.components.AlertView
|
||||
android:id="@+id/indicators_parent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_marginStart="8dp"
|
||||
android:padding="8dp"
|
||||
android:orientation="vertical" />
|
||||
android:padding="8dp" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -87,7 +87,6 @@
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="@id/conversation_list_item_name"
|
||||
app:layout_constraintTop_toBottomOf="@id/conversation_list_item_name"
|
||||
app:useSmallIcon="true"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<org.thoughtcrime.securesms.components.emoji.SimpleEmojiTextView
|
||||
|
||||
@@ -150,8 +150,8 @@
|
||||
|
||||
<org.thoughtcrime.securesms.components.AlertView
|
||||
android:id="@+id/alert_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:visibility="gone"
|
||||
|
||||
@@ -84,10 +84,6 @@
|
||||
<attr name="iconColor" format="color" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="AlertView">
|
||||
<attr name="useSmallIcon" format="boolean" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="AudioView">
|
||||
<attr name="foregroundTintColor" format="color" />
|
||||
<attr name="backgroundTintColor" format="color" />
|
||||
|
||||
Reference in New Issue
Block a user