From 8d20669e46ddcc0d54969ea763fe8bbbba1ede12 Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Thu, 29 Jun 2023 11:42:23 -0300 Subject: [PATCH] Rewrite AlertView to be a single ImageView. --- .../securesms/components/AlertView.java | 60 ++++++------------ app/src/main/res/drawable-hdpi/ic_error.webp | Bin 280 -> 0 bytes app/src/main/res/drawable-mdpi/ic_error.webp | Bin 192 -> 0 bytes app/src/main/res/drawable-xhdpi/ic_error.webp | Bin 380 -> 0 bytes .../main/res/drawable-xxhdpi/ic_error.webp | Bin 614 -> 0 bytes .../main/res/drawable-xxxhdpi/ic_error.webp | Bin 840 -> 0 bytes .../symbol_error_circle_compact_16.xml | 17 +++++ app/src/main/res/layout/alert_view.xml | 27 -------- .../conversation_item_received_multimedia.xml | 5 +- .../conversation_item_received_text_only.xml | 7 +- .../conversation_item_sent_multimedia.xml | 5 +- .../conversation_item_sent_text_only.xml | 8 +-- .../layout/conversation_list_item_view.xml | 1 - .../layout/stories_group_text_reply_item.xml | 4 +- app/src/main/res/values/attrs.xml | 4 -- 15 files changed, 48 insertions(+), 90 deletions(-) delete mode 100644 app/src/main/res/drawable-hdpi/ic_error.webp delete mode 100644 app/src/main/res/drawable-mdpi/ic_error.webp delete mode 100644 app/src/main/res/drawable-xhdpi/ic_error.webp delete mode 100644 app/src/main/res/drawable-xxhdpi/ic_error.webp delete mode 100644 app/src/main/res/drawable-xxxhdpi/ic_error.webp create mode 100644 app/src/main/res/drawable/symbol_error_circle_compact_16.xml delete mode 100644 app/src/main/res/layout/alert_view.xml diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/AlertView.java b/app/src/main/java/org/thoughtcrime/securesms/components/AlertView.java index 3e41116c19..e0a7b2886c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/AlertView.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/AlertView.java @@ -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)); } } diff --git a/app/src/main/res/drawable-hdpi/ic_error.webp b/app/src/main/res/drawable-hdpi/ic_error.webp deleted file mode 100644 index 7d60a6e67bd44bf8602c4f2489630756ec958543..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 280 zcmV+z0q6cwNk&Ex0RRA3MM6+kP&iBk0RR9m9Y6;V4>AAqKmQ8bHd1qU_sq;6fFlqH z0Syff0^uVAA%JK|aNs~laBNgaAUpyL6bujo3Je-aQZ&!Z%s>8J-i6jdME@DMZQID| zZf`pI1Wdwm-mmYw_PGq$tc>35;+neM$byd|(C&|09je?Q<=gfSKZ2rkHFzZTg zIjrOxxf(@{mk17`MGc{8RfPwt=nLYTn>kK~Au)#=?-=O$TdpX`!hDDPXOHmV3_oG! z6P9G=tBfpXp70e;&O0Z6P24Yb{_1#rto&8+6RGAaok)-98+oH{q+Rf>+69M$>2ahm e(GE)87e|gX>L86+akNV_1rTN#Ak9#~H@g7_%zV-S diff --git a/app/src/main/res/drawable-mdpi/ic_error.webp b/app/src/main/res/drawable-mdpi/ic_error.webp deleted file mode 100644 index c4de1c10a83bea72af16ca841ee62fb66d0a93e2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 192 zcmV;x06+gyNk&Gv00012MM6+kP&iDh0000l6Tk!zuQ31fKmQ8aNK%7`&x{`4#s}a8 z1mVL&5b;1zASM`yi;4h7LPP?CMv@fGG4ri|um499BKohuZ5t&yX7~kug^q2`7PY{x z>NK)*c~DntiCL~aE2o@0}HvVSjm9QC9idR@zChmtu#OG?jDlYe~}*|P(eih83sVw z2C^qfTlxciFe=)46Jnd&BBK8c>lLqD>+oO6D+N9&O7BNZ52@%H^Cb5DILXIL>NwJ` zl2zWUW=S1-p_48wu!_fBqG>ZQ}+{ z_Vs@MGn=+e(sr%xK*#_@009^Ug607X;RApK>zt{k-_S3WEU2nmH-Z>K3T3H9YKu0U;gS38U+{oUfaZZQR6}W+wQtFdy zX<Hh<2MOp9b-I$4{2&dlkAJ(l1m;SqhaPJp zfr(P;BMaG#Y!lgmWZy}twNTNLM#dWCrm+T%wa-ms?He(N`%7ZZ4o0lwh7s$6Vr+H% zXB9rQ#8_;UQev@Pcu$et%cS;D!yn4--NK&1@G3JN5Tj%DDlk0Kl*1!UmCpke^=3$j zo#gU_N4Fa-P(%3=@uHCRz<{Xt24p=yWX~Ev=ozPpU<#hC2#W)cGu?hr1RL4TlIck* A4FCWD diff --git a/app/src/main/res/drawable-xxxhdpi/ic_error.webp b/app/src/main/res/drawable-xxxhdpi/ic_error.webp deleted file mode 100644 index 04af4a3de191f3e70229b0ffbc21cdb5fa18027a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 840 zcmV-O1GoHANk&FM0{{S5MM6+kP&iC80{{RoPrwrpCt@INoA@_<`k9#j`DfU+jpN+8 zq~86jZQF)HrXJpba{~bsNDu^2Wgrp@Kv)z6EFc)bqC-KL0Qhrs35977#A4ffW5~%s zI3kDw5C9xTvYj>xGcz+YGrRwu;=Hd|(k~#Q{|qEaak6U;xCY=3e;`yD$~1|v=n))dvq>&TQ^GsZ!NDj z6wa0=o(p=0=={&pVce-EVnMe%7)w+;RhfL^eQga|QQk%SF${uCa!99>^ zT-5_k#RcjsnYw{n34x_V;4-Inzd5PEfP%d6o{Br>g);M!4|yMUtTBEi%HCZqpP;w< zCNi&ahr+^iJf(ytrcQKlwiuv$XMSDdm;M>u>Er}AeX|3tA;CpI!=;1kP(^K_nQgK- z_$#+;85+N&!#{_L5^o%6U$RLa=;MzElUOm;9!`IB5o2?ymI6Mjli$FSO+UG)EXw&X zFuoPOcf3vKLkb=0EOEXT>g+lfstnOZ-7TWhgIVC{H3u)okQ+%ob-XR5K&HC#Wgdmq zL4*tMYN;Yq0|Ywt5kAW_-c;5svZy`%(>?+XD`6G_GsVaj@5AOo-8AssKkXJv3FfbW z=}7>SW9h4)4Z`hG40~0UfY6T!5tt2UNk{Vh5HI9FPEe+Y4BVaX<|0UG88h$N@pHcgGyz<^VU~ z%@6!m_#Lw4VUcGpEtk~r#QqfPHKwdT1ex#(35AhkmecDgUQ7F1oL3; zE1(Ea&C@za@^n#XYDegxtR11Jouh+m5dUlE&~}(wztd7TltX3E4&&EOr0rOxuB`gx zPdk=jJDXoWfMGv{Uq4FFe%_2tKaXKQlwUtt@axAjtTXVdg9v_g8o{rQB;<9joH}wk z>ReyS>u_rQQjyhEhZFqjgf_X=F>N}jvsP%GwPK{sYLiij@o SsqgGRM89O_KLnwH|0Dnjc8$pZ diff --git a/app/src/main/res/drawable/symbol_error_circle_compact_16.xml b/app/src/main/res/drawable/symbol_error_circle_compact_16.xml new file mode 100644 index 0000000000..7894a20398 --- /dev/null +++ b/app/src/main/res/drawable/symbol_error_circle_compact_16.xml @@ -0,0 +1,17 @@ + + + + + + + diff --git a/app/src/main/res/layout/alert_view.xml b/app/src/main/res/layout/alert_view.xml deleted file mode 100644 index 02297292c7..0000000000 --- a/app/src/main/res/layout/alert_view.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/conversation_item_received_multimedia.xml b/app/src/main/res/layout/conversation_item_received_multimedia.xml index 53fa450904..18b630070b 100644 --- a/app/src/main/res/layout/conversation_item_received_multimedia.xml +++ b/app/src/main/res/layout/conversation_item_received_multimedia.xml @@ -284,11 +284,10 @@ + android:gravity="center_vertical" /> + android:padding="8dp" /> - - - -