Listen for recipient changes in conversations and group updates.
Closes #4079 // FREEBIEpull/1/head
parent
a7e05c4cd6
commit
0794380ca8
@ -1,33 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<org.thoughtcrime.securesms.ConversationItem
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/conversation_item"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="8dp">
|
|
||||||
|
|
||||||
<TextView android:id="@+id/conversation_item_body"
|
|
||||||
android:autoLink="all"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:linksClickable="true"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textStyle="italic"
|
|
||||||
android:textColor="?attr/conversation_group_member_name"
|
|
||||||
android:textSize="14sp" />
|
|
||||||
<TextView android:id="@+id/conversation_item_date"
|
|
||||||
android:autoLink="all"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:linksClickable="false"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
|
||||||
android:layout_gravity="right"
|
|
||||||
android:fontFamily="sans-serif-light"
|
|
||||||
android:textColor="?conversation_item_sent_text_secondary_color"
|
|
||||||
android:text="date"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:visibility="gone"/>
|
|
||||||
|
|
||||||
</org.thoughtcrime.securesms.ConversationItem>
|
|
@ -0,0 +1,30 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<org.thoughtcrime.securesms.ConversationUpdateItem
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/conversation_update_item"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="20dp">
|
||||||
|
|
||||||
|
<LinearLayout android:orientation="horizontal"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<ImageView android:id="@+id/conversation_update_icon"
|
||||||
|
android:layout_marginRight="7dp"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<TextView android:id="@+id/conversation_update_body"
|
||||||
|
android:autoLink="all"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:linksClickable="true"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
|
android:textStyle="italic"
|
||||||
|
android:textColor="?attr/conversation_group_member_name"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</org.thoughtcrime.securesms.ConversationUpdateItem>
|
@ -0,0 +1,98 @@
|
|||||||
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.thoughtcrime.securesms.database.model.MessageRecord;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||||
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||||
|
import org.thoughtcrime.securesms.util.GroupUtil;
|
||||||
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
|
|
||||||
|
public class ConversationUpdateItem extends LinearLayout
|
||||||
|
implements Recipients.RecipientsModifiedListener, Recipient.RecipientModifiedListener, Unbindable, View.OnClickListener
|
||||||
|
{
|
||||||
|
private static final String TAG = ConversationUpdateItem.class.getSimpleName();
|
||||||
|
|
||||||
|
private ImageView icon;
|
||||||
|
private TextView body;
|
||||||
|
private Recipient sender;
|
||||||
|
private MessageRecord messageRecord;
|
||||||
|
|
||||||
|
public ConversationUpdateItem(Context context) {
|
||||||
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConversationUpdateItem(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFinishInflate() {
|
||||||
|
super.onFinishInflate();
|
||||||
|
|
||||||
|
this.icon = (ImageView)findViewById(R.id.conversation_update_icon);
|
||||||
|
this.body = (TextView)findViewById(R.id.conversation_update_body);
|
||||||
|
|
||||||
|
setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(MessageRecord messageRecord) {
|
||||||
|
this.messageRecord = messageRecord;
|
||||||
|
this.sender = messageRecord.getIndividualRecipient();
|
||||||
|
|
||||||
|
this.sender.addListener(this);
|
||||||
|
|
||||||
|
if (messageRecord.isGroupAction()) {
|
||||||
|
icon.setImageDrawable(getContext().getResources().getDrawable(R.drawable.ic_group_grey600_24dp));
|
||||||
|
|
||||||
|
if (messageRecord.isGroupQuit() && messageRecord.isOutgoing()) {
|
||||||
|
body.setText(R.string.MessageRecord_left_group);
|
||||||
|
} else if (messageRecord.isGroupQuit()) {
|
||||||
|
body.setText(getContext().getString(R.string.ConversationItem_group_action_left, sender.toShortString()));
|
||||||
|
} else {
|
||||||
|
GroupUtil.GroupDescription description = GroupUtil.getDescription(getContext(), messageRecord.getBody().getBody());
|
||||||
|
description.addListener(this);
|
||||||
|
body.setText(description.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onModified(Recipients recipients) {
|
||||||
|
onModified(recipients.getPrimaryRecipient());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onModified(Recipient recipient) {
|
||||||
|
Util.runOnMain(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
set(messageRecord);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (messageRecord.isIdentityUpdate()) {
|
||||||
|
Intent intent = new Intent(getContext(), RecipientPreferenceActivity.class);
|
||||||
|
intent.putExtra(RecipientPreferenceActivity.RECIPIENTS_EXTRA,
|
||||||
|
new long[] {messageRecord.getIndividualRecipient().getRecipientId()});
|
||||||
|
|
||||||
|
getContext().startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unbind() {
|
||||||
|
if (sender != null) {
|
||||||
|
sender.removeListener(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package org.thoughtcrime.securesms;
|
||||||
|
|
||||||
|
public interface Unbindable {
|
||||||
|
public void unbind();
|
||||||
|
}
|
Loading…
Reference in New Issue