Messaging: Use xml drawables
Replace the pngs with xml drawables Change-Id: I71be32c36194d3b34b54287a09789f73087600ef
This commit is contained in:
@@ -33,9 +33,6 @@ public class ConversationDrawables {
|
||||
|
||||
// Cache the color filtered bubble drawables so that we don't need to create a
|
||||
// new one for each ConversationMessageView.
|
||||
private Drawable mIncomingBubbleDrawable;
|
||||
private Drawable mOutgoingBubbleDrawable;
|
||||
private Drawable mIncomingErrorBubbleDrawable;
|
||||
private Drawable mIncomingBubbleNoArrowDrawable;
|
||||
private Drawable mOutgoingBubbleNoArrowDrawable;
|
||||
private Drawable mAudioPlayButtonDrawable;
|
||||
@@ -75,15 +72,12 @@ public class ConversationDrawables {
|
||||
public void updateDrawables() {
|
||||
final Resources resources = mContext.getResources();
|
||||
|
||||
mIncomingBubbleDrawable = resources.getDrawable(R.drawable.msg_bubble_incoming);
|
||||
mIncomingBubbleNoArrowDrawable =
|
||||
resources.getDrawable(R.drawable.message_bubble_incoming_no_arrow);
|
||||
mIncomingErrorBubbleDrawable = resources.getDrawable(R.drawable.msg_bubble_error);
|
||||
mOutgoingBubbleDrawable = resources.getDrawable(R.drawable.msg_bubble_outgoing);
|
||||
mOutgoingBubbleNoArrowDrawable =
|
||||
resources.getDrawable(R.drawable.message_bubble_outgoing_no_arrow);
|
||||
mAudioPlayButtonDrawable = resources.getDrawable(R.drawable.ic_audio_play);
|
||||
mAudioPauseButtonDrawable = resources.getDrawable(R.drawable.ic_audio_pause);
|
||||
mAudioPlayButtonDrawable = resources.getDrawable(R.drawable.ic_play_light);
|
||||
mAudioPauseButtonDrawable = resources.getDrawable(R.drawable.ic_pause_light);
|
||||
mIncomingAudioProgressBackgroundDrawable =
|
||||
resources.getDrawable(R.drawable.audio_progress_bar_background_incoming);
|
||||
mOutgoingAudioProgressBackgroundDrawable =
|
||||
@@ -108,16 +102,9 @@ public class ConversationDrawables {
|
||||
}
|
||||
|
||||
public Drawable getBubbleDrawable(final boolean selected, final boolean incoming,
|
||||
final boolean needArrow, final boolean isError, final String identifier) {
|
||||
final boolean isError, final String identifier) {
|
||||
final Drawable protoDrawable;
|
||||
if (needArrow) {
|
||||
if (incoming) {
|
||||
protoDrawable = isError && !selected ?
|
||||
mIncomingErrorBubbleDrawable : mIncomingBubbleDrawable;
|
||||
} else {
|
||||
protoDrawable = mOutgoingBubbleDrawable;
|
||||
}
|
||||
} else if (incoming) {
|
||||
if (incoming) {
|
||||
protoDrawable = mIncomingBubbleNoArrowDrawable;
|
||||
} else {
|
||||
protoDrawable = mOutgoingBubbleNoArrowDrawable;
|
||||
|
||||
@@ -282,14 +282,6 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
|
||||
return mData.getCanClusterWithPreviousMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether we need to show message bubble arrow. We don't show arrow if the message
|
||||
* contains media attachments or if shouldShowSimplifiedVisualStyle() is true.
|
||||
*/
|
||||
private boolean shouldShowMessageBubbleArrow() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether we need to show a message bubble for text content.
|
||||
*/
|
||||
@@ -665,7 +657,6 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
|
||||
final ConversationDrawables drawableProvider = ConversationDrawables.get();
|
||||
final boolean incoming = mData.getIsIncoming();
|
||||
final boolean outgoing = !incoming;
|
||||
final boolean showArrow = shouldShowMessageBubbleArrow();
|
||||
|
||||
final int messageTopPaddingClustered =
|
||||
res.getDimensionPixelSize(R.dimen.message_padding_same_author);
|
||||
@@ -699,7 +690,6 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
|
||||
textBackground = drawableProvider.getBubbleDrawable(
|
||||
isSelected(),
|
||||
incoming,
|
||||
false /* needArrow */,
|
||||
mData.hasIncomingErrorStatus(),
|
||||
mData.getSenderContactLookupKey());
|
||||
textMinHeight = messageTextMinHeightDefault;
|
||||
@@ -723,12 +713,11 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
|
||||
}
|
||||
} else {
|
||||
// Text only
|
||||
contentLeftPadding = (!showArrow && incoming) ? arrowWidth : 0;
|
||||
contentRightPadding = (!showArrow && outgoing) ? arrowWidth : 0;
|
||||
contentLeftPadding = incoming ? arrowWidth : 0;
|
||||
contentRightPadding = outgoing ? arrowWidth : 0;
|
||||
textBackground = drawableProvider.getBubbleDrawable(
|
||||
isSelected(),
|
||||
incoming,
|
||||
shouldShowMessageBubbleArrow(),
|
||||
mData.hasIncomingErrorStatus(),
|
||||
mData.getSenderContactLookupKey());
|
||||
textMinHeight = messageTextMinHeightDefault;
|
||||
@@ -736,16 +725,8 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
|
||||
textTopPadding = textTopPaddingDefault;
|
||||
textBottomPadding = textBottomPaddingDefault;
|
||||
mMessageTextView.setTextIsSelectable(isSelected());
|
||||
if (showArrow && incoming) {
|
||||
textLeftPadding = messageTextLeftRightPadding + arrowWidth;
|
||||
} else {
|
||||
textLeftPadding = messageTextLeftRightPadding;
|
||||
}
|
||||
if (showArrow && outgoing) {
|
||||
textRightPadding = messageTextLeftRightPadding + arrowWidth;
|
||||
} else {
|
||||
textRightPadding = messageTextLeftRightPadding;
|
||||
}
|
||||
textLeftPadding = messageTextLeftRightPadding;
|
||||
textRightPadding = messageTextLeftRightPadding;
|
||||
}
|
||||
|
||||
// These values do not depend on whether the message includes attachments
|
||||
@@ -1121,8 +1102,8 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
|
||||
final AudioAttachmentView audioView = (AudioAttachmentView) view;
|
||||
audioView.bindMessagePartData(attachment, mData.getIsIncoming(), isSelected());
|
||||
audioView.setBackground(ConversationDrawables.get().getBubbleDrawable(
|
||||
isSelected(), mData.getIsIncoming(), false /* needArrow */,
|
||||
mData.hasIncomingErrorStatus(), mData.getSenderContactLookupKey()));
|
||||
isSelected(), mData.getIsIncoming(), mData.hasIncomingErrorStatus(),
|
||||
mData.getSenderContactLookupKey()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1138,8 +1119,8 @@ public class ConversationMessageView extends FrameLayout implements View.OnClick
|
||||
personView.bind(DataModel.get().createVCardContactItemData(getContext(),
|
||||
attachment));
|
||||
personView.setBackground(ConversationDrawables.get().getBubbleDrawable(
|
||||
isSelected(), mData.getIsIncoming(), false /* needArrow */,
|
||||
mData.hasIncomingErrorStatus(), mData.getSenderContactLookupKey()));
|
||||
isSelected(), mData.getIsIncoming(), mData.hasIncomingErrorStatus(),
|
||||
mData.getSenderContactLookupKey()));
|
||||
final int nameTextColorRes;
|
||||
final int detailsTextColorRes;
|
||||
if (isSelected()) {
|
||||
|
||||
@@ -443,7 +443,7 @@ class CameraMediaChooser extends MediaChooser implements
|
||||
mVideoCounter.setVisibility(isRecording ? View.VISIBLE : View.GONE);
|
||||
|
||||
mSwapModeButton.setImageResource(videoMode ?
|
||||
R.drawable.ic_mp_camera_small_light :
|
||||
R.drawable.ic_camera_light :
|
||||
R.drawable.ic_mp_video_small_light);
|
||||
mSwapModeButton.setContentDescription(context.getString(videoMode ?
|
||||
R.string.camera_switch_to_still_mode : R.string.camera_switch_to_video_mode));
|
||||
@@ -451,15 +451,15 @@ class CameraMediaChooser extends MediaChooser implements
|
||||
mSwapModeButton.setEnabled(isCameraAvailable);
|
||||
|
||||
if (isRecording) {
|
||||
mCaptureButton.setImageResource(R.drawable.ic_mp_capture_stop_large_light);
|
||||
mCaptureButton.setImageResource(R.drawable.ic_mp_capture_stop_light);
|
||||
mCaptureButton.setContentDescription(context.getString(
|
||||
R.string.camera_stop_recording));
|
||||
} else if (videoMode) {
|
||||
mCaptureButton.setImageResource(R.drawable.ic_mp_video_large_light);
|
||||
mCaptureButton.setImageResource(R.drawable.ic_mp_video_small_light);
|
||||
mCaptureButton.setContentDescription(context.getString(
|
||||
R.string.camera_start_recording));
|
||||
} else {
|
||||
mCaptureButton.setImageResource(R.drawable.ic_checkmark_large_light);
|
||||
mCaptureButton.setImageResource(R.drawable.ic_checkmark_light);
|
||||
mCaptureButton.setContentDescription(context.getString(
|
||||
R.string.camera_take_picture));
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ public class GalleryGridItemView extends FrameLayout {
|
||||
mImageView.setImageResourceId(mData.getImageRequestDescriptor());
|
||||
mImageView.setVisibility(VISIBLE);
|
||||
if (ContentType.isVideoType(mData.getContentType())) {
|
||||
mIcon.setImageResource(R.drawable.ic_video_play_light);
|
||||
mIcon.setImageResource(R.drawable.ic_play_light);
|
||||
mIcon.clearColorFilter();
|
||||
mIcon.setVisibility(VISIBLE);
|
||||
} else {
|
||||
|
||||
@@ -143,7 +143,7 @@ abstract class MediaChooser extends BasePagerViewHolder
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.show();
|
||||
// Use X instead of <- in the action bar
|
||||
actionBar.setHomeAsUpIndicator(R.drawable.ic_remove_small_light);
|
||||
actionBar.setHomeAsUpIndicator(R.drawable.ic_cancel_small_light);
|
||||
actionBar.setTitle(actionBarTitleResId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user