experimental gui to display read status

This commit is contained in:
iNPUTmice 2014-06-04 21:40:17 +02:00
parent dc50e0a7e3
commit 83e919f8af
3 changed files with 122 additions and 11 deletions

View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:paddingRight="6dp"
android:paddingLeft="24dp">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@+id/message_photo"
android:background="@drawable/message_border"
android:minHeight="dp"
android:visibility="gone">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:background="#ededed"
android:orientation="vertical">
<TextView
android:layout_gravity="center_vertical"
android:id="@+id/message_body"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#333333"
android:textSize="14sp"
android:text="your contact has read up to this point"/>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/message_photo"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginRight="-1.5dp"
android:padding="0dp"
android:scaleType="fitXY"
android:src="@drawable/ic_profile" />
</RelativeLayout>

View file

@ -32,6 +32,7 @@ public class Message extends AbstractEntity {
public static final int TYPE_TEXT = 0; public static final int TYPE_TEXT = 0;
public static final int TYPE_IMAGE = 1; public static final int TYPE_IMAGE = 1;
public static final int TYPE_AUDIO = 2; public static final int TYPE_AUDIO = 2;
public static final int TYPE_STATUS = 3;
public static String CONVERSATION = "conversationUuid"; public static String CONVERSATION = "conversationUuid";
public static String COUNTERPART = "counterpart"; public static String COUNTERPART = "counterpart";
@ -55,6 +56,10 @@ public class Message extends AbstractEntity {
protected transient JingleConnection jingleConnection = null; protected transient JingleConnection jingleConnection = null;
private Message() {
}
public Message(Conversation conversation, String body, int encryption) { public Message(Conversation conversation, String body, int encryption) {
this(java.util.UUID.randomUUID().toString(), conversation.getUuid(), this(java.util.UUID.randomUUID().toString(), conversation.getUuid(),
conversation.getContactJid(), body, System.currentTimeMillis(), encryption, conversation.getContactJid(), body, System.currentTimeMillis(), encryption,
@ -205,4 +210,11 @@ public class Message extends AbstractEntity {
public JingleConnection getJingleConnection() { public JingleConnection getJingleConnection() {
return this.jingleConnection; return this.jingleConnection;
} }
public static Message createStatusMessage(Conversation conversation) {
Message message = new Message();
message.setType(Message.TYPE_STATUS);
message.setConversation(conversation);
return message;
}
} }

View file

@ -170,15 +170,18 @@ public class ConversationFragment extends Fragment {
private static final int SENT = 0; private static final int SENT = 0;
private static final int RECIEVED = 1; private static final int RECIEVED = 1;
private static final int STATUS = 2;
@Override @Override
public int getViewTypeCount() { public int getViewTypeCount() {
return 2; return 3;
} }
@Override @Override
public int getItemViewType(int position) { public int getItemViewType(int position) {
if (getItem(position).getStatus() <= Message.STATUS_RECIEVED) { if (getItem(position).getType() == Message.TYPE_STATUS) {
return STATUS;
} else if (getItem(position).getStatus() <= Message.STATUS_RECIEVED) {
return RECIEVED; return RECIEVED;
} else { } else {
return SENT; return SENT;
@ -360,6 +363,15 @@ public class ConversationFragment extends Fragment {
viewHolder.contact_picture = (ImageView) view viewHolder.contact_picture = (ImageView) view
.findViewById(R.id.message_photo); .findViewById(R.id.message_photo);
viewHolder.contact_picture.setImageBitmap(selfBitmap); viewHolder.contact_picture.setImageBitmap(selfBitmap);
viewHolder.indicator = (ImageView) view
.findViewById(R.id.security_indicator);
viewHolder.image = (ImageView) view
.findViewById(R.id.message_image);
viewHolder.messageBody = (TextView) view
.findViewById(R.id.message_body);
viewHolder.time = (TextView) view
.findViewById(R.id.message_time);
view.setTag(viewHolder);
break; break;
case RECIEVED: case RECIEVED:
view = (View) inflater.inflate( view = (View) inflater.inflate(
@ -381,25 +393,47 @@ public class ConversationFragment extends Fragment {
getActivity() getActivity()
.getApplicationContext())); .getApplicationContext()));
}
viewHolder.indicator = (ImageView) view
.findViewById(R.id.security_indicator);
viewHolder.image = (ImageView) view
.findViewById(R.id.message_image);
viewHolder.messageBody = (TextView) view
.findViewById(R.id.message_body);
viewHolder.time = (TextView) view
.findViewById(R.id.message_time);
view.setTag(viewHolder);
break;
case STATUS:
view = (View) inflater.inflate(
R.layout.message_status, null);
viewHolder.contact_picture = (ImageView) view
.findViewById(R.id.message_photo);
if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
viewHolder.contact_picture
.setImageBitmap(mBitmapCache.get(
item.getConversation().getName(
useSubject), item
.getConversation()
.getContact(),
getActivity()
.getApplicationContext()));
} }
break; break;
default: default:
viewHolder = null; viewHolder = null;
break; break;
} }
viewHolder.indicator = (ImageView) view
.findViewById(R.id.security_indicator);
viewHolder.image = (ImageView) view
.findViewById(R.id.message_image);
viewHolder.messageBody = (TextView) view
.findViewById(R.id.message_body);
viewHolder.time = (TextView) view
.findViewById(R.id.message_time);
view.setTag(viewHolder);
} else { } else {
viewHolder = (ViewHolder) view.getTag(); viewHolder = (ViewHolder) view.getTag();
} }
if (type == STATUS) {
return view;
}
if (type == RECIEVED) { if (type == RECIEVED) {
if (item.getConversation().getMode() == Conversation.MODE_MULTI) { if (item.getConversation().getMode() == Conversation.MODE_MULTI) {
viewHolder.contact_picture.setImageBitmap(mBitmapCache viewHolder.contact_picture.setImageBitmap(mBitmapCache
@ -620,6 +654,7 @@ public class ConversationFragment extends Fragment {
} }
this.messageList.clear(); this.messageList.clear();
this.messageList.addAll(this.conversation.getMessages()); this.messageList.addAll(this.conversation.getMessages());
updateStatusMessages();
this.messageListAdapter.notifyDataSetChanged(); this.messageListAdapter.notifyDataSetChanged();
if (conversation.getMode() == Conversation.MODE_SINGLE) { if (conversation.getMode() == Conversation.MODE_SINGLE) {
if (messageList.size() >= 1) { if (messageList.size() >= 1) {
@ -650,6 +685,21 @@ public class ConversationFragment extends Fragment {
} }
} }
protected void updateStatusMessages() {
if (conversation.getMode() == Conversation.MODE_SINGLE) {
for(int i = this.messageList.size() - 1; i >= 0; --i) {
if (this.messageList.get(i).getStatus() == Message.STATUS_RECIEVED) {
return;
} else {
if (this.messageList.get(i).getStatus() == Message.STATUS_SEND_DISPLAYED) {
this.messageList.add(i+1, Message.createStatusMessage(conversation));
return;
}
}
}
}
}
protected void makeFingerprintWarning(int latestEncryption) { protected void makeFingerprintWarning(int latestEncryption) {
final LinearLayout fingerprintWarning = (LinearLayout) getView() final LinearLayout fingerprintWarning = (LinearLayout) getView()
.findViewById(R.id.new_fingerprint); .findViewById(R.id.new_fingerprint);