Messaging: Fix warnings about drawables and colors

* They need the theme provided now
* Follow the suggestion by AS
  (sometimes we use ResourcesCompat, sometimes not)

Change-Id: Ie3023fee13a6fc04bd4b912721ba19dcc08befba
This commit is contained in:
Michael W
2024-12-26 14:55:13 +01:00
parent fd63d5f125
commit d430161ca0
17 changed files with 116 additions and 71 deletions
@@ -644,7 +644,8 @@ public class BugleNotifications {
notificationState.mNotificationBuilder notificationState.mNotificationBuilder
.setSmallIcon(notificationState.getIcon()) .setSmallIcon(notificationState.getIcon())
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE) .setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
.setColor(context.getResources().getColor(R.color.notification_accent_color)) .setColor(context.getResources().getColor(R.color.notification_accent_color,
context.getTheme()))
// .setPublicVersion(null) // TODO: when/if we ever support different // .setPublicVersion(null) // TODO: when/if we ever support different
// text on the lockscreen, instead of "contents hidden" // text on the lockscreen, instead of "contents hidden"
.setCategory(CATEGORY_MESSAGE); .setCategory(CATEGORY_MESSAGE);
@@ -729,7 +730,8 @@ public class BugleNotifications {
final NotificationCompat.Builder notifBuilder = notificationState.mNotificationBuilder; final NotificationCompat.Builder notifBuilder = notificationState.mNotificationBuilder;
notifBuilder.setStyle(notificationState.mNotificationStyle); notifBuilder.setStyle(notificationState.mNotificationStyle);
notifBuilder.setColor(context.getResources().getColor(R.color.notification_accent_color)); notifBuilder.setColor(context.getResources().getColor(R.color.notification_accent_color,
context.getTheme()));
final WearableExtender wearableExtender = new WearableExtender(); final WearableExtender wearableExtender = new WearableExtender();
setWearableGroupOptions(notifBuilder, notificationState); setWearableGroupOptions(notifBuilder, notificationState);
@@ -1134,7 +1134,7 @@ public abstract class MessageNotificationState extends NotificationState {
final SpannableStringBuilder spanBuilder = new SpannableStringBuilder(); final SpannableStringBuilder spanBuilder = new SpannableStringBuilder();
spanBuilder.append(text); spanBuilder.append(text);
spanBuilder.setSpan(new ForegroundColorSpan(context.getResources().getColor( spanBuilder.setSpan(new ForegroundColorSpan(context.getResources().getColor(
R.color.notification_warning_color)), 0, text.length(), R.color.notification_warning_color, context.getTheme())), 0, text.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
return spanBuilder; return spanBuilder;
} }
@@ -30,6 +30,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.exifinterface.media.ExifInterface; import androidx.exifinterface.media.ExifInterface;
import androidx.core.content.res.ResourcesCompat;
import com.android.messaging.R; import com.android.messaging.R;
import com.android.messaging.util.Assert; import com.android.messaging.util.Assert;
@@ -81,8 +82,8 @@ public class SimSelectorAvatarRequest extends AvatarRequest {
final Canvas canvas = new Canvas(bitmap); final Canvas canvas = new Canvas(bitmap);
if (sRegularSimIcon == null) { if (sRegularSimIcon == null) {
final BitmapDrawable regularSim = (BitmapDrawable) mContext.getResources() final BitmapDrawable regularSim = (BitmapDrawable) ResourcesCompat.getDrawable(
.getDrawable(R.drawable.ic_sim_card_send); mContext.getResources(), R.drawable.ic_sim_card_send, mContext.getTheme());
sRegularSimIcon = regularSim.getBitmap(); sRegularSimIcon = regularSim.getBitmap();
} }
@@ -17,6 +17,7 @@
package com.android.messaging.ui; package com.android.messaging.ui;
import android.content.Context; import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Path; import android.graphics.Path;
@@ -32,6 +33,8 @@ import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import androidx.core.content.res.ResourcesCompat;
import com.android.messaging.Factory; import com.android.messaging.Factory;
import com.android.messaging.R; import com.android.messaging.R;
import com.android.messaging.datamodel.data.MessagePartData; import com.android.messaging.datamodel.data.MessagePartData;
@@ -350,11 +353,13 @@ public class AudioAttachmentView extends LinearLayout {
mChronometer.setVisibility(GONE); mChronometer.setVisibility(GONE);
((MarginLayoutParams) mPlayPauseButton.getLayoutParams()).setMargins(0, 0, 0, 0); ((MarginLayoutParams) mPlayPauseButton.getLayoutParams()).setMargins(0, 0, 0, 0);
final ImageView playButton = (ImageView) findViewById(R.id.play_button); final ImageView playButton = (ImageView) findViewById(R.id.play_button);
final Resources res = getResources();
final Resources.Theme theme = getContext().getTheme();
playButton.setImageDrawable( playButton.setImageDrawable(
getResources().getDrawable(R.drawable.ic_preview_play)); ResourcesCompat.getDrawable(res, R.drawable.ic_preview_play, theme));
final ImageView pauseButton = (ImageView) findViewById(R.id.pause_button); final ImageView pauseButton = (ImageView) findViewById(R.id.pause_button);
pauseButton.setImageDrawable( pauseButton.setImageDrawable(
getResources().getDrawable(R.drawable.ic_preview_pause)); ResourcesCompat.getDrawable(res, R.drawable.ic_preview_pause, theme));
break; break;
default: default:
@@ -76,7 +76,8 @@ public class ContactIconView extends AsyncImageView {
mIconSize = 0; mIconSize = 0;
Assert.fail("Unsupported ContactIconView icon size attribute"); Assert.fail("Unsupported ContactIconView icon size attribute");
} }
mColorPressedId = resources.getColor(R.color.contact_avatar_pressed_color); mColorPressedId = resources.getColor(R.color.contact_avatar_pressed_color,
context.getTheme());
setImage(null); setImage(null);
a.recycle(); a.recycle();
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -20,6 +21,8 @@ import android.content.res.Resources;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import androidx.core.content.res.ResourcesCompat;
import com.android.messaging.Factory; import com.android.messaging.Factory;
import com.android.messaging.R; import com.android.messaging.R;
import com.android.messaging.util.ImageUtils; import com.android.messaging.util.ImageUtils;
@@ -71,33 +74,37 @@ public class ConversationDrawables {
public void updateDrawables() { public void updateDrawables() {
final Resources resources = mContext.getResources(); final Resources resources = mContext.getResources();
final Resources.Theme theme = mContext.getTheme();
mIncomingBubbleNoArrowDrawable = mIncomingBubbleNoArrowDrawable = ResourcesCompat.getDrawable(resources,
resources.getDrawable(R.drawable.message_bubble_incoming_no_arrow); R.drawable.message_bubble_incoming_no_arrow, theme);
mOutgoingBubbleNoArrowDrawable = mOutgoingBubbleNoArrowDrawable = ResourcesCompat.getDrawable(resources,
resources.getDrawable(R.drawable.message_bubble_outgoing_no_arrow); R.drawable.message_bubble_outgoing_no_arrow, theme);
mAudioPlayButtonDrawable = resources.getDrawable(R.drawable.ic_play_light); mAudioPlayButtonDrawable = ResourcesCompat.getDrawable(resources,
mAudioPauseButtonDrawable = resources.getDrawable(R.drawable.ic_pause_light); R.drawable.ic_play_light, theme);
mIncomingAudioProgressBackgroundDrawable = mAudioPauseButtonDrawable = ResourcesCompat.getDrawable(resources,
resources.getDrawable(R.drawable.audio_progress_bar_background_incoming); R.drawable.ic_pause_light, theme);
mOutgoingAudioProgressBackgroundDrawable = mIncomingAudioProgressBackgroundDrawable = ResourcesCompat.getDrawable(resources,
resources.getDrawable(R.drawable.audio_progress_bar_background_outgoing); R.drawable.audio_progress_bar_background_incoming, theme);
mAudioProgressForegroundDrawable = mOutgoingAudioProgressBackgroundDrawable = ResourcesCompat.getDrawable(resources,
resources.getDrawable(R.drawable.audio_progress_bar_progress); R.drawable.audio_progress_bar_background_outgoing, theme);
mFastScrollThumbDrawable = resources.getDrawable(R.drawable.fastscroll_thumb); mAudioProgressForegroundDrawable = ResourcesCompat.getDrawable(resources,
mFastScrollThumbPressedDrawable = R.drawable.audio_progress_bar_progress, theme);
resources.getDrawable(R.drawable.fastscroll_thumb_pressed); mFastScrollThumbDrawable = ResourcesCompat.getDrawable(resources,
mFastScrollPreviewDrawableLeft = R.drawable.fastscroll_thumb, theme);
resources.getDrawable(R.drawable.fastscroll_preview_left); mFastScrollThumbPressedDrawable = ResourcesCompat.getDrawable(resources,
mFastScrollPreviewDrawableRight = R.drawable.fastscroll_thumb_pressed, theme);
resources.getDrawable(R.drawable.fastscroll_preview_right); mFastScrollPreviewDrawableLeft = ResourcesCompat.getDrawable(resources,
mOutgoingBubbleColor = resources.getColor(R.color.message_bubble_color_outgoing); R.drawable.fastscroll_preview_left, theme);
mFastScrollPreviewDrawableRight = ResourcesCompat.getDrawable(resources,
R.drawable.fastscroll_preview_right, theme);
mOutgoingBubbleColor = resources.getColor(R.color.message_bubble_color_outgoing, theme);
mIncomingErrorBubbleColor = mIncomingErrorBubbleColor =
resources.getColor(R.color.message_error_bubble_color_incoming); resources.getColor(R.color.message_error_bubble_color_incoming, theme);
mIncomingAudioButtonColor = mIncomingAudioButtonColor =
resources.getColor(R.color.message_audio_button_color_incoming); resources.getColor(R.color.message_audio_button_color_incoming, theme);
mSelectedBubbleColor = resources.getColor(R.color.message_bubble_color_selected); mSelectedBubbleColor = resources.getColor(R.color.message_bubble_color_selected, theme);
mThemeColor = resources.getColor(R.color.primary_color); mThemeColor = resources.getColor(R.color.primary_color, theme);
mColors = resources.obtainTypedArray(R.array.letter_tile_colors); mColors = resources.obtainTypedArray(R.array.letter_tile_colors);
} }
@@ -42,11 +42,12 @@ public class ViewPagerTabStrip extends LinearLayout {
super(context, attrs); super(context, attrs);
final Resources res = context.getResources(); final Resources res = context.getResources();
final Resources.Theme theme = context.getTheme();
mSelectedUnderlineThickness = mSelectedUnderlineThickness =
res.getDimensionPixelSize(R.dimen.pager_tab_underline_selected); res.getDimensionPixelSize(R.dimen.pager_tab_underline_selected);
int underlineColor = res.getColor(R.color.contact_picker_tab_underline); int underlineColor = res.getColor(R.color.contact_picker_tab_underline, theme);
int backgroundColor = res.getColor(R.color.action_bar_background_color); int backgroundColor = res.getColor(R.color.action_bar_background_color, theme);
mSelectedUnderlinePaint = new Paint(); mSelectedUnderlinePaint = new Paint();
mSelectedUnderlinePaint.setColor(underlineColor); mSelectedUnderlinePaint.setColor(underlineColor);
@@ -101,6 +101,7 @@ public class ViewGroupItemVerticalExplodeAnimation {
public void startAnimation() { public void startAnimation() {
final Context context = mViewToAnimate.getContext(); final Context context = mViewToAnimate.getContext();
final Resources resources = context.getResources(); final Resources resources = context.getResources();
final Resources.Theme theme = context.getTheme();
final View decorView = ((Activity) context).getWindow().getDecorView(); final View decorView = ((Activity) context).getWindow().getDecorView();
final ViewOverlay viewOverlay = decorView.getOverlay(); final ViewOverlay viewOverlay = decorView.getOverlay();
if (viewOverlay instanceof ViewGroupOverlay) { if (viewOverlay instanceof ViewGroupOverlay) {
@@ -119,7 +120,7 @@ public class ViewGroupItemVerticalExplodeAnimation {
shadowContainerLayer.setBottom(containerRect.bottom); shadowContainerLayer.setBottom(containerRect.bottom);
shadowContainerLayer.setRight(containerRect.right); shadowContainerLayer.setRight(containerRect.right);
shadowContainerLayer.setBackgroundColor(resources.getColor( shadowContainerLayer.setBackgroundColor(resources.getColor(
R.color.open_conversation_animation_background_shadow)); R.color.open_conversation_animation_background_shadow, theme));
// Per design request, temporarily clear out the background of the item content // Per design request, temporarily clear out the background of the item content
// to not show any ripple effects during animation. // to not show any ripple effects during animation.
if (!(oldBackground instanceof ColorDrawable)) { if (!(oldBackground instanceof ColorDrawable)) {
@@ -150,8 +151,8 @@ public class ViewGroupItemVerticalExplodeAnimation {
expandLayer.setTop(viewRect.top); expandLayer.setTop(viewRect.top);
expandLayer.setBottom(viewRect.bottom); expandLayer.setBottom(viewRect.bottom);
expandLayer.setRight(viewRect.right); expandLayer.setRight(viewRect.right);
expandLayer.setBackgroundColor(resources.getColor( expandLayer.setBackgroundColor(resources.getColor(R.color.conversation_background,
R.color.conversation_background)); theme));
ViewCompat.setElevation(expandLayer, elevation); ViewCompat.setElevation(expandLayer, elevation);
// Conditionally stage the snapshot in the overlay. // Conditionally stage the snapshot in the overlay.
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -55,11 +56,13 @@ public class AddContactsConfirmationDialog implements DialogInterface.OnClickLis
final Resources resources = mContext.getResources(); final Resources resources = mContext.getResources();
final Button cancelButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); final Button cancelButton = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
if (cancelButton != null) { if (cancelButton != null) {
cancelButton.setTextColor(resources.getColor(R.color.contact_picker_button_text_color)); cancelButton.setTextColor(resources.getColor(R.color.contact_picker_button_text_color,
mContext.getTheme()));
} }
final Button addButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); final Button addButton = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
if (addButton != null) { if (addButton != null) {
addButton.setTextColor(resources.getColor(R.color.contact_picker_button_text_color)); addButton.setTextColor(resources.getColor(R.color.contact_picker_button_text_color,
mContext.getTheme()));
} }
} }
@@ -174,7 +174,7 @@ public class ContactPickerFragment extends Fragment implements ContactPickerData
mCustomHeaderViewPager.setViewHolders(viewHolders); mCustomHeaderViewPager.setViewHolders(viewHolders);
mCustomHeaderViewPager.setViewPagerTabHeight(CustomHeaderViewPager.DEFAULT_TAB_STRIP_SIZE); mCustomHeaderViewPager.setViewPagerTabHeight(CustomHeaderViewPager.DEFAULT_TAB_STRIP_SIZE);
mCustomHeaderViewPager.setBackgroundColor(getResources() mCustomHeaderViewPager.setBackgroundColor(getResources()
.getColor(R.color.contact_picker_background)); .getColor(R.color.contact_picker_background, getContext().getTheme()));
// The view pager defaults to the frequent contacts page. // The view pager defaults to the frequent contacts page.
mCustomHeaderViewPager.setCurrentItem(0); mCustomHeaderViewPager.setCurrentItem(0);
@@ -554,7 +554,8 @@ public class ContactPickerFragment extends Fragment implements ContactPickerData
// etc. will take the spot of the action bar. // etc. will take the spot of the action bar.
actionBar.hide(); actionBar.hide();
UiUtils.setStatusBarColor(getActivity(), UiUtils.setStatusBarColor(getActivity(),
getResources().getColor(R.color.compose_notification_bar_background)); getResources().getColor(R.color.compose_notification_bar_background,
getActivity().getTheme()));
} }
private GetOrCreateConversationActionMonitor mMonitor; private GetOrCreateConversationActionMonitor mMonitor;
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -29,6 +30,8 @@ import android.view.KeyEvent;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.TextView; import android.widget.TextView;
import androidx.core.content.res.ResourcesCompat;
import com.android.ex.chips.RecipientEditTextView; import com.android.ex.chips.RecipientEditTextView;
import com.android.ex.chips.RecipientEntry; import com.android.ex.chips.RecipientEntry;
import com.android.ex.chips.recipientchip.DrawableRecipientChip; import com.android.ex.chips.recipientchip.DrawableRecipientChip;
@@ -113,8 +116,9 @@ public class ContactRecipientAutoCompleteView extends RecipientEditTextView {
addTextChangedListener(new ContactChipsWatcher()); addTextChangedListener(new ContactChipsWatcher());
setOnFocusListShrinkRecipients(false); setOnFocusListShrinkRecipients(false);
setBackground(context.getResources().getDrawable( setBackground(ResourcesCompat.getDrawable(context.getResources(),
androidx.appcompat.R.drawable.abc_textfield_search_default_mtrl_alpha)); androidx.appcompat.R.drawable.abc_textfield_search_default_mtrl_alpha,
context.getTheme()));
} }
public void setContactChipsListener(final ContactChipsChangeListener listener) { public void setContactChipsListener(final ContactChipsChangeListener listener) {
@@ -441,7 +441,8 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
subscriptionEntry.displayName; subscriptionEntry.displayName;
mSimNameView.setText(simNameText); mSimNameView.setText(simNameText);
mSimNameView.setTextColor(showSimIconAsIncoming ? getResources().getColor( mSimNameView.setTextColor(showSimIconAsIncoming ? getResources().getColor(
R.color.timestamp_text_incoming) : subscriptionEntry.displayColor); R.color.timestamp_text_incoming, getContext().getTheme()) :
subscriptionEntry.displayColor);
mSimNameView.setVisibility(VISIBLE); mSimNameView.setVisibility(VISIBLE);
} else { } else {
mSimNameView.setText(null); mSimNameView.setText(null);
@@ -834,7 +835,8 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
mMessageAttachmentsView.setGravity(gravity); mMessageAttachmentsView.setGravity(gravity);
// Tint image/video attachments when selected // Tint image/video attachments when selected
final int selectedImageTint = getResources().getColor(R.color.message_image_selected_tint); final int selectedImageTint = getResources().getColor(R.color.message_image_selected_tint,
getContext().getTheme());
if (mMessageImageView.getVisibility() == View.VISIBLE) { if (mMessageImageView.getVisibility() == View.VISIBLE) {
if (isSelected()) { if (isSelected()) {
mMessageImageView.setColorFilter(selectedImageTint); mMessageImageView.setColorFilter(selectedImageTint);
@@ -947,24 +949,25 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
break; break;
} }
} }
final int messageColor = getResources().getColor(messageColorResId); final Resources.Theme theme = getContext().getTheme();
final int messageColor = getResources().getColor(messageColorResId, theme);
mMessageTextView.setTextColor(messageColor); mMessageTextView.setTextColor(messageColor);
mMessageTextView.setLinkTextColor(messageColor); mMessageTextView.setLinkTextColor(messageColor);
mSubjectText.setTextColor(messageColor); mSubjectText.setTextColor(messageColor);
if (statusColorResId >= 0) { if (statusColorResId >= 0) {
mTitleTextView.setTextColor(getResources().getColor(statusColorResId)); mTitleTextView.setTextColor(getResources().getColor(statusColorResId, theme));
} }
if (infoColorResId >= 0) { if (infoColorResId >= 0) {
mMmsInfoTextView.setTextColor(getResources().getColor(infoColorResId)); mMmsInfoTextView.setTextColor(getResources().getColor(infoColorResId, theme));
} }
if (timestampColorResId == R.color.timestamp_text_incoming && if (timestampColorResId == R.color.timestamp_text_incoming &&
mData.hasAttachments() && !shouldShowMessageTextBubble()) { mData.hasAttachments() && !shouldShowMessageTextBubble()) {
timestampColorResId = R.color.timestamp_text_outgoing; timestampColorResId = R.color.timestamp_text_outgoing;
} }
mStatusTextView.setTextColor(getResources().getColor(timestampColorResId)); mStatusTextView.setTextColor(getResources().getColor(timestampColorResId, theme));
mSubjectLabel.setTextColor(getResources().getColor(subjectLabelColorResId)); mSubjectLabel.setTextColor(getResources().getColor(subjectLabelColorResId, theme));
mSenderNameTextView.setTextColor(getResources().getColor(timestampColorResId)); mSenderNameTextView.setTextColor(getResources().getColor(timestampColorResId, theme));
} }
/** /**
@@ -1103,8 +1106,9 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
detailsTextColorRes = mData.getIsIncoming() ? R.color.timestamp_text_incoming detailsTextColorRes = mData.getIsIncoming() ? R.color.timestamp_text_incoming
: R.color.timestamp_text_outgoing; : R.color.timestamp_text_outgoing;
} }
personView.setNameTextColor(getResources().getColor(nameTextColorRes)); Resources.Theme theme = getContext().getTheme();
personView.setDetailsTextColor(getResources().getColor(detailsTextColorRes)); personView.setNameTextColor(getResources().getColor(nameTextColorRes, theme));
personView.setDetailsTextColor(getResources().getColor(detailsTextColorRes, theme));
} }
@Override @Override
@@ -22,6 +22,7 @@ import android.database.Cursor;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import androidx.core.text.BidiFormatter; import androidx.core.text.BidiFormatter;
import androidx.core.text.TextDirectionHeuristicsCompat; import androidx.core.text.TextDirectionHeuristicsCompat;
@@ -37,6 +38,8 @@ import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.core.content.res.ResourcesCompat;
import com.android.messaging.Factory; import com.android.messaging.Factory;
import com.android.messaging.R; import com.android.messaging.R;
import com.android.messaging.annotation.VisibleForAnimation; import com.android.messaging.annotation.VisibleForAnimation;
@@ -162,8 +165,9 @@ public class ConversationListItemView extends FrameLayout implements OnClickList
mSnippetTextView.addOnLayoutChangeListener(this); mSnippetTextView.addOnLayoutChangeListener(this);
final Resources resources = getContext().getResources(); final Resources resources = getContext().getResources();
mListItemReadColor = resources.getColor(R.color.conversation_list_item_read); final Resources.Theme theme = getContext().getTheme();
mListItemUnreadColor = resources.getColor(R.color.conversation_list_item_unread); mListItemReadColor = resources.getColor(R.color.conversation_list_item_read, theme);
mListItemUnreadColor = resources.getColor(R.color.conversation_list_item_unread, theme);
mListItemReadTypeface = Typefaces.getRobotoNormal(); mListItemReadTypeface = Typefaces.getRobotoNormal();
mListItemUnreadTypeface = Typefaces.getRobotoBold(); mListItemUnreadTypeface = Typefaces.getRobotoBold();
@@ -403,7 +407,8 @@ public class ConversationListItemView extends FrameLayout implements OnClickList
final boolean isDefaultSmsApp = PhoneUtils.getDefault().isDefaultSmsApp(); final boolean isDefaultSmsApp = PhoneUtils.getDefault().isDefaultSmsApp();
// don't show the error state unless we're the default sms app // don't show the error state unless we're the default sms app
if (mData.getIsFailedStatus() && isDefaultSmsApp) { if (mData.getIsFailedStatus() && isDefaultSmsApp) {
mTimestampTextView.setTextColor(resources.getColor(R.color.conversation_list_error)); mTimestampTextView.setTextColor(resources.getColor(R.color.conversation_list_error,
getContext().getTheme()));
mTimestampTextView.setTypeface(mListItemReadTypeface, typefaceStyle); mTimestampTextView.setTypeface(mListItemReadTypeface, typefaceStyle);
int failureMessageId = R.string.message_status_download_failed; int failureMessageId = R.string.message_status_download_failed;
if (mData.getIsMessageTypeOutgoing()) { if (mData.getIsMessageTypeOutgoing()) {
@@ -499,16 +504,15 @@ public class ConversationListItemView extends FrameLayout implements OnClickList
mAudioAttachmentView.setOnLongClickListener(this); mAudioAttachmentView.setOnLongClickListener(this);
mAudioAttachmentView.setVisibility(audioPreviewVisiblity); mAudioAttachmentView.setVisibility(audioPreviewVisiblity);
Drawable archiveDrawable = ResourcesCompat.getDrawable(
getResources(), R.drawable.ic_archive_small_dark, getContext().getTheme());
if (PrefsUtils.isSwipeRightToDeleteEnabled()) { if (PrefsUtils.isSwipeRightToDeleteEnabled()) {
mCrossSwipeArchiveLeftImageView.setImageDrawable(getResources() mCrossSwipeArchiveLeftImageView.setImageDrawable(ResourcesCompat.getDrawable(
.getDrawable(R.drawable.ic_delete_small_dark)); getResources(), R.drawable.ic_delete_small_dark, getContext().getTheme()));
mCrossSwipeArchiveRightImageView.setImageDrawable(getResources() mCrossSwipeArchiveRightImageView.setImageDrawable(archiveDrawable);
.getDrawable(R.drawable.ic_archive_small_dark));
} else { } else {
mCrossSwipeArchiveLeftImageView.setImageDrawable(getResources() mCrossSwipeArchiveLeftImageView.setImageDrawable(archiveDrawable);
.getDrawable(R.drawable.ic_archive_small_dark)); mCrossSwipeArchiveRightImageView.setImageDrawable(archiveDrawable);
mCrossSwipeArchiveRightImageView.setImageDrawable(getResources()
.getDrawable(R.drawable.ic_archive_small_dark));
} }
} }
@@ -17,6 +17,7 @@
package com.android.messaging.ui.mediapicker; package com.android.messaging.ui.mediapicker;
import android.content.Context; import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.Rect; import android.graphics.Rect;
@@ -32,6 +33,8 @@ import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.core.content.res.ResourcesCompat;
import com.android.messaging.Factory; import com.android.messaging.Factory;
import com.android.messaging.R; import com.android.messaging.R;
import com.android.messaging.datamodel.data.DraftMessageData.DraftMessageSubscriptionDataProvider; import com.android.messaging.datamodel.data.DraftMessageData.DraftMessageSubscriptionDataProvider;
@@ -222,9 +225,12 @@ public class AudioRecordView extends FrameLayout implements
} }
private void updateRecordButtonAppearance() { private void updateRecordButtonAppearance() {
final Drawable foregroundDrawable = getResources().getDrawable(R.drawable.ic_mp_audio_mic); final Resources res = getResources();
final GradientDrawable backgroundDrawable = ((GradientDrawable) getResources() final Resources.Theme theme = getContext().getTheme();
.getDrawable(R.drawable.audio_record_control_button_background)); final Drawable foregroundDrawable = ResourcesCompat.getDrawable(res,
R.drawable.ic_mp_audio_mic, theme);
final GradientDrawable backgroundDrawable = ((GradientDrawable) ResourcesCompat.getDrawable(
res, R.drawable.audio_record_control_button_background, theme));
if (isRecording()) { if (isRecording()) {
foregroundDrawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); foregroundDrawable.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
backgroundDrawable.setColor(mThemeColor); backgroundDrawable.setColor(mThemeColor);
@@ -17,6 +17,7 @@
package com.android.messaging.ui.mediapicker; package com.android.messaging.ui.mediapicker;
import android.content.Context; import android.content.Context;
import android.content.res.Resources;
import android.database.Cursor; import android.database.Cursor;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.Rect; import android.graphics.Rect;
@@ -161,9 +162,10 @@ public class GalleryGridItemView extends FrameLayout {
mAdditionalInfo.setVisibility(VISIBLE); mAdditionalInfo.setVisibility(VISIBLE);
} else { } else {
final String contentType = mData.getContentType(); final String contentType = mData.getContentType();
Resources.Theme theme = getContext().getTheme();
if (ContentType.isAudioType(contentType)) { if (ContentType.isAudioType(contentType)) {
setBackgroundColor( setBackgroundColor(
getResources().getColor(R.color.gallery_image_default_background)); getResources().getColor(R.color.gallery_image_default_background, theme));
mIcon.setImageResource(R.drawable.ic_music); mIcon.setImageResource(R.drawable.ic_music);
mIcon.setColorFilter( mIcon.setColorFilter(
ConversationDrawables.get().getConversationThemeColor(), ConversationDrawables.get().getConversationThemeColor(),
@@ -178,7 +180,7 @@ public class GalleryGridItemView extends FrameLayout {
} else { // For image and video types } else { // For image and video types
mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP); mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
setBackgroundColor( setBackgroundColor(
getResources().getColor(R.color.gallery_image_default_background)); getResources().getColor(R.color.gallery_image_default_background, theme));
mImageView.setImageResourceId(mData.getImageRequestDescriptor()); mImageView.setImageResourceId(mData.getImageRequestDescriptor());
mImageView.setVisibility(VISIBLE); mImageView.setVisibility(VISIBLE);
if (ContentType.isVideoType(mData.getContentType())) { if (ContentType.isVideoType(mData.getContentType())) {
@@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2015 The Android Open Source Project * Copyright (C) 2015 The Android Open Source Project
* Copyright (C) 2024 The LineageOS Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -170,7 +171,8 @@ public class WidgetConversationListService extends RemoteViewsService {
builder.setSpan(new StyleSpan(Typeface.ITALIC), 0, text.length(), builder.setSpan(new StyleSpan(Typeface.ITALIC), 0, text.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
builder.setSpan(new ForegroundColorSpan( builder.setSpan(new ForegroundColorSpan(
resources.getColor(R.color.widget_text_color)), resources.getColor(R.color.widget_text_color,
mContext.getTheme())),
0, text.length(), 0, text.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
remoteViews.setTextViewText(R.id.errorText, builder); remoteViews.setTextViewText(R.id.errorText, builder);
@@ -389,7 +389,8 @@ public class WidgetConversationService extends RemoteViewsService {
final Spannable colorStr = new SpannableString(statusText); final Spannable colorStr = new SpannableString(statusText);
if (showInRed) { if (showInRed) {
colorStr.setSpan(new ForegroundColorSpan( colorStr.setSpan(new ForegroundColorSpan(
mContext.getResources().getColor(R.color.timestamp_text_failed)), mContext.getResources().getColor(R.color.timestamp_text_failed,
mContext.getTheme())),
0, statusText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); 0, statusText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
} }
remoteViews.setTextViewText(R.id.date, colorStr); remoteViews.setTextViewText(R.id.date, colorStr);