mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-12 15:38:34 +00:00
parent
83919c087d
commit
580a3182ab
@ -23,6 +23,7 @@ import android.content.Intent;
|
|||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@ -100,6 +101,10 @@ public class ConversationItem extends LinearLayout {
|
|||||||
private Button mmsDownloadButton;
|
private Button mmsDownloadButton;
|
||||||
private TextView mmsDownloadingLabel;
|
private TextView mmsDownloadingLabel;
|
||||||
|
|
||||||
|
private int defaultBubbleColor;
|
||||||
|
private Drawable selectedBackground;
|
||||||
|
private Drawable normalBackground;
|
||||||
|
|
||||||
private final MmsDownloadClickListener mmsDownloadClickListener = new MmsDownloadClickListener();
|
private final MmsDownloadClickListener mmsDownloadClickListener = new MmsDownloadClickListener();
|
||||||
private final MmsPreferencesClickListener mmsPreferencesClickListener = new MmsPreferencesClickListener();
|
private final MmsPreferencesClickListener mmsPreferencesClickListener = new MmsPreferencesClickListener();
|
||||||
private final ClickListener clickListener = new ClickListener();
|
private final ClickListener clickListener = new ClickListener();
|
||||||
@ -119,6 +124,7 @@ public class ConversationItem extends LinearLayout {
|
|||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
|
|
||||||
|
initializeAttributes();
|
||||||
ViewGroup pendingIndicatorStub = (ViewGroup) findViewById(R.id.pending_indicator_stub);
|
ViewGroup pendingIndicatorStub = (ViewGroup) findViewById(R.id.pending_indicator_stub);
|
||||||
|
|
||||||
if (pendingIndicatorStub != null) {
|
if (pendingIndicatorStub != null) {
|
||||||
@ -181,6 +187,18 @@ public class ConversationItem extends LinearLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initializeAttributes() {
|
||||||
|
final int[] attributes = new int[] {R.attr.conversation_item_bubble_background,
|
||||||
|
R.attr.conversation_list_item_background_selected,
|
||||||
|
R.attr.conversation_item_background};
|
||||||
|
final TypedArray attrs = context.obtainStyledAttributes(attributes);
|
||||||
|
|
||||||
|
defaultBubbleColor = attrs.getColor(0, Color.WHITE);
|
||||||
|
selectedBackground = attrs.getDrawable(1);
|
||||||
|
normalBackground = attrs.getDrawable(2);
|
||||||
|
attrs.recycle();
|
||||||
|
}
|
||||||
|
|
||||||
public void unbind() {
|
public void unbind() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,12 +209,8 @@ public class ConversationItem extends LinearLayout {
|
|||||||
/// MessageRecord Attribute Parsers
|
/// MessageRecord Attribute Parsers
|
||||||
|
|
||||||
private void setBubbleState(MessageRecord messageRecord) {
|
private void setBubbleState(MessageRecord messageRecord) {
|
||||||
int[] attributes = new int[]{R.attr.conversation_item_bubble_background};
|
|
||||||
TypedArray colors = context.obtainStyledAttributes(attributes);
|
|
||||||
int defaultColor = colors.getColor(0, Color.WHITE);
|
|
||||||
|
|
||||||
if (messageRecord.isOutgoing()) {
|
if (messageRecord.isOutgoing()) {
|
||||||
bodyBubble.getBackground().setColorFilter(defaultColor, PorterDuff.Mode.MULTIPLY);
|
bodyBubble.getBackground().setColorFilter(defaultBubbleColor, PorterDuff.Mode.MULTIPLY);
|
||||||
} else {
|
} else {
|
||||||
bodyBubble.getBackground().setColorFilter(messageRecord.getIndividualRecipient()
|
bodyBubble.getBackground().setColorFilter(messageRecord.getIndividualRecipient()
|
||||||
.getColor()
|
.getColor()
|
||||||
@ -204,22 +218,14 @@ public class ConversationItem extends LinearLayout {
|
|||||||
PorterDuff.Mode.MULTIPLY);
|
PorterDuff.Mode.MULTIPLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
colors.recycle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSelectionBackgroundDrawables(MessageRecord messageRecord) {
|
private void setSelectionBackgroundDrawables(MessageRecord messageRecord) {
|
||||||
int[] attributes = new int[]{R.attr.conversation_list_item_background_selected,
|
|
||||||
R.attr.conversation_item_background};
|
|
||||||
|
|
||||||
TypedArray drawables = context.obtainStyledAttributes(attributes);
|
|
||||||
|
|
||||||
if (batchSelected.contains(messageRecord)) {
|
if (batchSelected.contains(messageRecord)) {
|
||||||
setBackgroundDrawable(drawables.getDrawable(0));
|
setBackgroundDrawable(selectedBackground);
|
||||||
} else {
|
} else {
|
||||||
setBackgroundDrawable(drawables.getDrawable(1));
|
setBackgroundDrawable(normalBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawables.recycle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasConversationBubble(MessageRecord messageRecord) {
|
private boolean hasConversationBubble(MessageRecord messageRecord) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user