diff --git a/res/layout/chat_bubble_incoming.xml b/res/layout/chat_bubble_incoming.xml
index 97a41d860..6eb6418f8 100644
--- a/res/layout/chat_bubble_incoming.xml
+++ b/res/layout/chat_bubble_incoming.xml
@@ -32,10 +32,11 @@
+ android:layout_height="5dp" />
emoticons = new HashMap();
static {
emoticons.put(":)", R.drawable.emo_im_happy);
@@ -99,12 +98,13 @@ public class BubbleChat {
emoticons.put(":'(", R.drawable.emo_im_crying);
emoticons.put("$.$", R.drawable.emo_im_money_mouth);
}
-
- private RelativeLayout view;
+
+ private LinearLayout view;
private ImageView statusView;
private LinphoneChatMessage nativeMessage;
private Context mContext;
private static final int SIZE_MAX = 512;
+ private ProgressBar spinner;
@SuppressLint("InflateParams")
public BubbleChat(final Context context, LinphoneChatMessage message) {
@@ -113,50 +113,29 @@ public class BubbleChat {
}
nativeMessage = message;
mContext = context;
-
- view = new RelativeLayout(context);
- LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
-
- if (message.isOutgoing()) {
- layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
- view.setBackgroundResource(R.drawable.chat_bubble_outgoing);
- }
- else {
- layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
- view.setBackgroundResource(R.drawable.chat_bubble_incoming);
- }
- layoutParams.setMargins(10, 0, 10, 0);
-
- view.setId(message.getStorageId());
- view.setLayoutParams(layoutParams);
-
- LinearLayout layout;
- if (context.getResources().getBoolean(R.bool.display_time_aside)) {
- if (message.isOutgoing()) {
- layout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.chat_bubble_alt_outgoing, null);
- } else {
- layout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.chat_bubble_alt_incoming, null);
- }
- } else {
- if (message.isOutgoing()) {
- layout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.chat_bubble_outgoing, null);
- } else {
- layout = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.chat_bubble_incoming, null);
- }
- }
+ if (message.isOutgoing()) {
+ view = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.chat_bubble_outgoing, null);
+ view.setBackgroundResource(R.drawable.chat_bubble_outgoing);
+ } else {
+ view = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.chat_bubble_incoming, null);
+ view.setBackgroundResource(R.drawable.chat_bubble_incoming);
+ }
+
+ spinner = (ProgressBar) view.findViewById(R.id.spinner);
String externalBodyUrl = message.getExternalBodyUrl();
LinphoneContent fileTransferContent = message.getFileTransferInformation();
if (externalBodyUrl != null || fileTransferContent != null) {
- Button download = (Button) layout.findViewById(R.id.download);
- ImageView imageView = (ImageView) layout.findViewById(R.id.image);
+ Button download = (Button) view.findViewById(R.id.download);
+ ImageView imageView = (ImageView) view.findViewById(R.id.image);
String appData = message.getAppData();
if (appData == null) {
+ LinphoneManager.addListener(this);
if(LinphoneManager.getInstance().isMessagePending(nativeMessage)){
download.setEnabled(false);
- ProgressBar spinner = (ProgressBar) layout.findViewById(R.id.spinner);
+ ProgressBar spinner = (ProgressBar) view.findViewById(R.id.spinner);
spinner.setVisibility(View.VISIBLE);
download.setVisibility(View.GONE);
} else {
@@ -165,7 +144,6 @@ public class BubbleChat {
@Override
public void onClick(View v) {
v.setEnabled(false);
- ProgressBar spinner = (ProgressBar) view.findViewById(R.id.spinner);
spinner.setVisibility(View.VISIBLE);
v.setVisibility(View.GONE);
@@ -178,11 +156,12 @@ public class BubbleChat {
});
}
} else {
+ LinphoneManager.removeListener(this);
imageView.setVisibility(View.VISIBLE);
loadBitmap(appData, imageView);
}
} else {
- TextView msgView = (TextView) layout.findViewById(R.id.message);
+ TextView msgView = (TextView) view.findViewById(R.id.message);
if (msgView != null) {
Spanned text = null;
String msg = message.getText();
@@ -199,11 +178,11 @@ public class BubbleChat {
}
}
- TextView timeView = (TextView) layout.findViewById(R.id.time);
+ TextView timeView = (TextView) view.findViewById(R.id.time);
timeView.setText(timestampToHumanDate(context, message.getTime()));
LinphoneChatMessage.State status = message.getStatus();
- statusView = (ImageView) layout.findViewById(R.id.status);
+ statusView = (ImageView) view.findViewById(R.id.status);
if (statusView != null) {
if (status == LinphoneChatMessage.State.Delivered) {
statusView.setImageResource(R.drawable.chat_message_delivered);
@@ -214,7 +193,7 @@ public class BubbleChat {
}
}
- view.addView(layout);
+ //view.addView(layout);
}
public void updateStatusView() {
@@ -443,4 +422,22 @@ public class BubbleChat {
}
return null;
}
+
+ @Override
+ public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state) {
+ }
+
+ @Override
+ public void onLinphoneChatMessageFileTransferReceived(LinphoneChatMessage msg, LinphoneContent content, LinphoneBuffer buffer) {
+ }
+
+ @Override
+ public void onLinphoneChatMessageFileTransferSent(LinphoneChatMessage msg, LinphoneContent content, int offset, int size, LinphoneBuffer bufferToFill) {
+ }
+
+ @Override
+ public void onLinphoneChatMessageFileTransferProgressChanged(LinphoneChatMessage msg, LinphoneContent content, int offset, int total) {
+ if(nativeMessage.getStorageId() == msg.getStorageId())
+ spinner.setProgress(offset * 100 / total);
+ }
}