aboutsummaryrefslogtreecommitdiffstats
path: root/src/de/gultsch/chat/utils
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-20 17:00:50 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-20 17:00:50 +0100
commitc82179c0b8728a9c2cd567d4227c60c758a1e682 (patch)
treeb866a099bb79225bf31a6498374f24f757af163e /src/de/gultsch/chat/utils
parent94ab61d5c0b060e2aea5caf58ac06864f980956b (diff)
adding and removing roster items now possible. basic error display on error messages
Diffstat (limited to 'src/de/gultsch/chat/utils')
-rw-r--r--src/de/gultsch/chat/utils/MessageParser.java15
-rw-r--r--src/de/gultsch/chat/utils/UIHelper.java22
2 files changed, 36 insertions, 1 deletions
diff --git a/src/de/gultsch/chat/utils/MessageParser.java b/src/de/gultsch/chat/utils/MessageParser.java
index aec492c8..1dca7343 100644
--- a/src/de/gultsch/chat/utils/MessageParser.java
+++ b/src/de/gultsch/chat/utils/MessageParser.java
@@ -116,4 +116,19 @@ public class MessageParser {
Conversation conversation = service.findOrCreateConversation(account, parts[0],false);
return new Message(conversation,fullJid, message.findChild("body").getContent(), Message.ENCRYPTION_NONE,status);
}
+
+ public static Message parseError(MessagePacket packet, Account account, XmppConnectionService service) {
+
+ String[] fromParts = packet.getFrom().split("/");
+ Conversation conversation = service.findOrCreateConversation(account, fromParts[0],false);
+ Element error = packet.findChild("error");
+ String errorName = error.getChildren().get(0).getName();
+ String displayError;
+ if (errorName.equals("service-unavailable")) {
+ displayError = "Contact is offline and does not have offline storage";
+ } else {
+ displayError = errorName.replace("-", " ");
+ }
+ return new Message(conversation, packet.getFrom(), displayError, Message.ENCRYPTION_NONE, Message.STATUS_ERROR);
+ }
}
diff --git a/src/de/gultsch/chat/utils/UIHelper.java b/src/de/gultsch/chat/utils/UIHelper.java
index 52292a0f..5e81f099 100644
--- a/src/de/gultsch/chat/utils/UIHelper.java
+++ b/src/de/gultsch/chat/utils/UIHelper.java
@@ -54,7 +54,7 @@ public class UIHelper {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
return sdf.format(date);
} else {
- SimpleDateFormat sdf = new SimpleDateFormat("M/D");
+ SimpleDateFormat sdf = new SimpleDateFormat("MM/dd");
return sdf.format(date);
}
}
@@ -85,6 +85,26 @@ public class UIHelper {
return bitmap;
}
+
+ public static Bitmap getErrorPicture(int size) {
+ Bitmap bitmap = Bitmap
+ .createBitmap(size, size, Bitmap.Config.ARGB_8888);
+ Canvas canvas = new Canvas(bitmap);
+
+ bitmap.eraseColor(0xFFe92727);
+
+ Paint paint = new Paint();
+ paint.setColor(0xffe5e5e5);
+ paint.setTextSize((float) (size * 0.9));
+ paint.setAntiAlias(true);
+ Rect rect = new Rect();
+ paint.getTextBounds("!", 0, 1, rect);
+ float width = paint.measureText("!");
+ canvas.drawText("!", (size / 2) - (width / 2), (size / 2)
+ + (rect.height() / 2), paint);
+
+ return bitmap;
+ }
public static Notification getUnreadMessageNotification(Context context,
Conversation conversation) {