aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2015-10-04 20:34:52 +0200
committersteckbrief <steckbrief@chefmail.de>2015-10-04 20:34:52 +0200
commitdafb125a4f29226b6a3e8aa93de3d5163126c9ce (patch)
treea00f9d8ab4be053a13759a5368734121b17a9d89 /src
parent0e272042d5d4080b12d2b4e543dfcd425779ae94 (diff)
Publishing additional information in message details dialog such as message type and message status
Diffstat (limited to '')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java160
-rw-r--r--src/main/res/layout/dialog_message_details.xml61
-rw-r--r--src/main/res/values-de/strings.xml21
-rw-r--r--src/main/res/values/strings.xml21
4 files changed, 235 insertions, 28 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java
index 05830c75..25d522f0 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ui/dialogs/MessageDetailsDialog.java
@@ -1,45 +1,56 @@
package de.thedevstack.conversationsplus.ui.dialogs;
import android.app.Activity;
-import android.app.AlertDialog;
import android.text.format.DateFormat;
+import android.util.Log;
import android.view.View;
import android.widget.TextView;
import java.util.Date;
import de.thedevstack.conversationsplus.R;
+import de.thedevstack.conversationsplus.entities.Conversation;
import de.thedevstack.conversationsplus.entities.Message;
import de.thedevstack.conversationsplus.utils.UIHelper;
/**
- * Created by tzur on 29.09.2015.
+ * Fills the contents to the message details dialog.
+ * The view definition is done in R.layout.dialog_message_details.
*/
public class MessageDetailsDialog extends AbstractAlertDialog {
- private AlertDialog.Builder builder;
+ /**
+ * Initializes the Message Details Dialog.
+ * @param context the context of this alert dialog (the parent activity).
+ * @param message the message to be displayed
+ */
public MessageDetailsDialog(Activity context, Message message) {
super(context, R.string.dlg_msg_details_title);
this.createView(context, message);
}
+ /**
+ * Creates the view for the message details alert dialog.
+ * @param context the context of this alert dialog (the parent activity).
+ * @param message the message to be displayed
+ */
protected void createView(Activity context, Message message) {
int viewId = R.layout.dialog_message_details;
View view = context.getLayoutInflater().inflate(viewId, null);
- TextView timeSent = (TextView) view.findViewById(R.id.dlgMsgDetTimeSent);
- timeSent.setText(DateFormat.format("dd.MM.yyyy kk:mm:ss", new Date(message.getMergedTimeSent())));
- TextView sender = (TextView) view.findViewById(R.id.dlgMsgDetSender);
- TextView receipient = (TextView) view.findViewById(R.id.dlgMsgDetReceipient);
- String me = message.getConversation().getAccount().getJid().getResourcepart();
- String other = message.getCounterpart().getResourcepart();
- if (Message.STATUS_RECEIVED == message.getStatus()) {
- sender.setText(other);
- receipient.setText(me);
- } else {
- sender.setText(me);
- receipient.setText(other);
- }
+ displayMessageSentTime(view, message);
+ displaySenderAndReceiver(view, message);
+ displayMessageTypeInfo(view, message);
+ displayMessageStatusInfo(view, message);
+ displayFileInfo(view, message);
+ }
+
+ /**
+ * Publishes file information, if message contains an image to view.
+ * @param view the dialog view
+ * @param message the message to display in dialog
+ */
+ protected void displayFileInfo(View view, Message message) {
if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE || message.getTransferable() != null) {
view.findViewById(R.id.dlgMsgDetFileTable).setVisibility(View.VISIBLE);
if (null != message.getFileParams()) {
@@ -53,7 +64,120 @@ public class MessageDetailsDialog extends AbstractAlertDialog {
this.setView(view);
}
- public void show() {
- this.builder.show();
+ /**
+ * Displays message status info to view.
+ * @param view the dialog view
+ * @param message the message to display in dialog
+ */
+ protected void displayMessageStatusInfo(View view, Message message) {
+ TextView msgStatusTextView = (TextView) view.findViewById(R.id.dlgMsgDetMsgStatus);
+ int msgStatusResId;
+ int msgStatusColorResId;
+ switch (message.getStatus()) {
+ case Message.STATUS_WAITING:
+ msgStatusResId = R.string.dlg_msg_details_msg_status_waiting;
+ msgStatusColorResId = R.color.black87;
+ break;
+ case Message.STATUS_UNSEND:
+ msgStatusResId = R.string.dlg_msg_details_msg_status_unsend;
+ msgStatusColorResId = R.color.black87;
+ break;
+ case Message.STATUS_OFFERED:
+ msgStatusResId = R.string.dlg_msg_details_msg_status_offered;
+ msgStatusColorResId = R.color.black87;
+ break;
+ case Message.STATUS_SEND_FAILED:
+ msgStatusResId = R.string.dlg_msg_details_msg_status_failed;
+ msgStatusColorResId = R.color.red500;
+ break;
+ case Message.STATUS_RECEIVED:
+ msgStatusResId = R.string.dlg_msg_details_msg_status_received;
+ msgStatusColorResId = R.color.black87;
+ break;
+ case Message.STATUS_SEND:
+ case Message.STATUS_SEND_DISPLAYED:
+ case Message.STATUS_SEND_RECEIVED:
+ default:
+ msgStatusResId = R.string.dlg_msg_details_msg_status_sent;
+ msgStatusColorResId = R.color.black87;
+ }
+ msgStatusTextView.setText(msgStatusResId);
+ msgStatusTextView.setTextColor(getContext().getResources().getColor(msgStatusColorResId));
+ }
+
+ /**
+ * Publishes message type information to view.
+ * @param view the dialog view
+ * @param message the message to display in dialog
+ */
+ protected void displayMessageTypeInfo(View view, Message message) {
+ TextView msgTypeTextView = (TextView) view.findViewById(R.id.dlgMsgDetMsgType);
+ int msgTypeResId;
+ switch (message.getType()) {
+ case Message.TYPE_PRIVATE:
+ msgTypeResId = R.string.dlg_msg_details_msg_type_private;
+ break;
+ case Message.TYPE_FILE:
+ msgTypeResId = R.string.dlg_msg_details_msg_type_file;
+ break;
+ case Message.TYPE_IMAGE:
+ msgTypeResId = R.string.dlg_msg_details_msg_type_image;
+ break;
+ case Message.TYPE_STATUS:
+ msgTypeResId = R.string.dlg_msg_details_msg_type_status;
+ break;
+ case Message.TYPE_TEXT:
+ default:
+ msgTypeResId = R.string.dlg_msg_details_msg_type_text;
+ }
+ msgTypeTextView.setText(msgTypeResId);
+ }
+
+ /**
+ * Publishes information about sending and receiving parties to view.
+ * @param view the dialog view
+ * @param message the message to display in dialog
+ */
+ protected void displaySenderAndReceiver(View view, Message message) {
+ Conversation conversation = message.getConversation();
+ // Get own resource name -> What about msg written on other client?
+ String me = conversation.getAccount().getJid().getResourcepart();
+ // Get resource name of chat partner, if available
+ String other = (message.getCounterpart().isBareJid()) ? "" : message.getCounterpart().getResourcepart();
+ Log.d("MesageDialog", "Me: " + me + ", other: " + other);
+ TextView sender = (TextView) view.findViewById(R.id.dlgMsgDetSender);
+ TextView receipient = (TextView) view.findViewById(R.id.dlgMsgDetReceipient);
+
+ if (conversation.getMode() == Conversation.MODE_MULTI) {
+ // Change label of sending and receiving party to MUC terminology
+ TextView senderLabel = (TextView) view.findViewById(R.id.dlgMsgDetLblSender);
+ senderLabel.setText(R.string.dlg_msg_details_sender_nick);
+ TextView receipientLabel = (TextView) view.findViewById(R.id.dlgMsgDetLblReceipient);
+ receipientLabel.setText(R.string.dlg_msg_details_receipient_nick);
+
+ // Get own nick for MUC
+ me = conversation.getMucOptions().getActualNick();
+ }
+ if (Message.STATUS_RECEIVED == message.getStatus()) {
+ // Sender was chat partner, if the status is for my account received
+ sender.setText(other);
+ // Set receipient to myself in case of normal chat or private message in MUC
+ if (conversation.getMode() == Conversation.MODE_SINGLE || Message.TYPE_PRIVATE == message.getType()) {
+ receipient.setText(me);
+ }
+ } else {
+ sender.setText(me);
+ receipient.setText(other);
+ }
+ }
+
+ /**
+ * Publishes information about message sent time to view.
+ * @param view the dialog view
+ * @param message the message to display in dialog
+ */
+ protected void displayMessageSentTime(View view, Message message) {
+ TextView timeSent = (TextView) view.findViewById(R.id.dlgMsgDetTimeSent);
+ timeSent.setText(DateFormat.format("dd.MM.yyyy kk:mm:ss", new Date(message.getMergedTimeSent())));
}
}
diff --git a/src/main/res/layout/dialog_message_details.xml b/src/main/res/layout/dialog_message_details.xml
index 67561ae7..4d63831e 100644
--- a/src/main/res/layout/dialog_message_details.xml
+++ b/src/main/res/layout/dialog_message_details.xml
@@ -11,7 +11,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Time Sent:"
+ android:text="@string/dlg_msg_details_time_sent"
android:id="@+id/dlgMsgDetLblTimeSent" />
<TextView
android:layout_width="wrap_content"
@@ -20,19 +20,21 @@
android:width="200dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
- android:layout_alignParentEnd="true" />
+ android:layout_alignParentEnd="true"
+ android:textAlignment="viewEnd"
+ android:gravity="end" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Sender Resource:"
- android:id="@+id/dlgMsgDetLblSender"
+ android:text="@string/dlg_msg_details_msg_type"
+ android:id="@+id/dlgMsgDetLblMsgType"
android:layout_below="@+id/dlgMsgDetLblTimeSent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:id="@+id/dlgMsgDetSender"
+ android:id="@+id/dlgMsgDetMsgType"
android:layout_below="@+id/dlgMsgDetTimeSent"
android:layout_alignRight="@+id/dlgMsgDetTimeSent"
android:layout_alignEnd="@+id/dlgMsgDetTimeSent"
@@ -42,7 +44,41 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Receipient Resource:"
+ android:text="@string/dlg_msg_details_msg_status"
+ android:id="@+id/dlgMsgDetLblMsgStatus"
+ android:layout_below="@+id/dlgMsgDetLblMsgType" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/dlgMsgDetMsgStatus"
+ android:layout_below="@+id/dlgMsgDetMsgType"
+ android:layout_alignRight="@+id/dlgMsgDetMsgType"
+ android:layout_alignEnd="@+id/dlgMsgDetMsgType"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentEnd="true" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/dlg_msg_details_sender_resource"
+ android:id="@+id/dlgMsgDetLblSender"
+ android:layout_below="@+id/dlgMsgDetLblMsgStatus" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/dlgMsgDetSender"
+ android:layout_below="@+id/dlgMsgDetMsgStatus"
+ android:layout_alignRight="@+id/dlgMsgDetMsgStatus"
+ android:layout_alignEnd="@+id/dlgMsgDetMsgStatus"
+ android:layout_alignParentRight="true"
+ android:layout_alignParentEnd="true" />
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/dlg_msg_details_receipient_resource"
android:id="@+id/dlgMsgDetLblReceipient"
android:layout_below="@+id/dlgMsgDetLblSender" />
@@ -63,7 +99,8 @@
android:layout_alignParentEnd="true"
android:stretchColumns="1"
android:background="@color/black87"
- android:id="@+id/dlgMsgDetFileTable">
+ android:id="@+id/dlgMsgDetFileTable"
+ android:visibility="gone">
<TableRow
android:layout_width="match_parent"
@@ -76,7 +113,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="File Details"
+ android:text="@string/dlg_msg_details_file_details"
android:layout_column="0"/>
</TableRow>
@@ -91,12 +128,14 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Mime Type" />
+ android:text="@string/dlg_msg_details_file_mime" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
+ android:textAlignment="textEnd"
+ android:gravity="end"
android:id="@+id/dlgMsgDetFileMimeType" />
</TableRow>
@@ -111,12 +150,14 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="Size" />
+ android:text="@string/dlg_msg_details_file_size" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
+ android:textAlignment="textEnd"
+ android:gravity="end"
android:id="@+id/dlgMsgDetFileSize"/>
</TableRow>
</TableLayout>
diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml
index c9724e5a..16ed5239 100644
--- a/src/main/res/values-de/strings.xml
+++ b/src/main/res/values-de/strings.xml
@@ -470,4 +470,25 @@
<string name="dlg_msg_details_title">Nachrichtendetails</string>
<string name="cplus_ok">Ok</string>
<string name="dlg_resources_title">%1$s (%2$d)</string><!-- %s = bare jid, %d = count of online resources -->
+ <string name="dlg_msg_details_receipient_resource">Empfänger Resource:</string>
+ <string name="dlg_msg_details_receipient_nick">Empfänger Nickname:</string>
+ <string name="dlg_msg_details_sender_resource">Absender Resource:</string>
+ <string name="dlg_msg_details_sender_nick">Absender Nickname:</string>
+ <string name="dlg_msg_details_time_sent">Gesendet:</string>
+ <string name="dlg_msg_details_msg_type">Nachrichtentyp:</string>
+ <string name="dlg_msg_details_msg_status">Nachrichtenstatus:</string>
+ <string name="dlg_msg_details_file_details">Dateidetails</string>
+ <string name="dlg_msg_details_file_mime">Mime Type</string>
+ <string name="dlg_msg_details_file_size">Größe</string>
+ <string name="dlg_msg_details_msg_type_text">Text</string>
+ <string name="dlg_msg_details_msg_type_image">Bild</string>
+ <string name="dlg_msg_details_msg_type_file">Datei</string>
+ <string name="dlg_msg_details_msg_type_status">Status</string>
+ <string name="dlg_msg_details_msg_type_private">Privat</string>
+ <string name="dlg_msg_details_msg_status_sent">Gesendet</string>
+ <string name="dlg_msg_details_msg_status_received">Empfangen</string>
+ <string name="dlg_msg_details_msg_status_waiting">Wartend</string>
+ <string name="dlg_msg_details_msg_status_unsend">In Übertragung</string>
+ <string name="dlg_msg_details_msg_status_offered">Angeboten</string>
+ <string name="dlg_msg_details_msg_status_failed">Fehlgeschlagen</string>
</resources>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 0bcbb9c4..b3786b35 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -499,4 +499,25 @@
<string name="dlg_msg_details_title">Message Details</string>
<string name="cplus_ok">Ok</string>
<string name="dlg_resources_title">%1$s (%2$d)</string><!-- %s = bare jid, %d = count of online resources -->
+ <string name="dlg_msg_details_receipient_resource">Receipient Resource:</string>
+ <string name="dlg_msg_details_receipient_nick">Receipient Nick:</string>
+ <string name="dlg_msg_details_sender_resource">Sender Resource:</string>
+ <string name="dlg_msg_details_sender_nick">Sender Nick:</string>
+ <string name="dlg_msg_details_time_sent">Time Sent:</string>
+ <string name="dlg_msg_details_msg_type">Message Type:</string>
+ <string name="dlg_msg_details_msg_status">Message Status:</string>
+ <string name="dlg_msg_details_file_details">File Details</string>
+ <string name="dlg_msg_details_file_mime">Mime Type</string>
+ <string name="dlg_msg_details_file_size">Size</string>
+ <string name="dlg_msg_details_msg_type_text">Text</string>
+ <string name="dlg_msg_details_msg_type_image">Image</string>
+ <string name="dlg_msg_details_msg_type_file">File</string>
+ <string name="dlg_msg_details_msg_type_status">Status</string>
+ <string name="dlg_msg_details_msg_type_private">Private</string>
+ <string name="dlg_msg_details_msg_status_sent">Sent</string>
+ <string name="dlg_msg_details_msg_status_received">Received</string>
+ <string name="dlg_msg_details_msg_status_waiting">Waiting</string>
+ <string name="dlg_msg_details_msg_status_unsend">Unsend</string>
+ <string name="dlg_msg_details_msg_status_offered">Offered</string>
+ <string name="dlg_msg_details_msg_status_failed">Failed</string>
</resources>