Display button to download chat image instead of doing it auto
This commit is contained in:
parent
58c85d0675
commit
0a397d1e99
10 changed files with 132 additions and 34 deletions
|
@ -19,6 +19,14 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/download"
|
||||||
|
android:text="@string/download_image"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/time"
|
android:id="@+id/time"
|
||||||
android:textColor="@android:color/darker_gray"
|
android:textColor="@android:color/darker_gray"
|
||||||
|
|
|
@ -19,6 +19,13 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/download"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:text="@string/download_image"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/time"
|
android:id="@+id/time"
|
||||||
android:textColor="@android:color/darker_gray"
|
android:textColor="@android:color/darker_gray"
|
||||||
|
|
|
@ -377,4 +377,7 @@
|
||||||
<string name="call_state_incoming">Reçu</string>
|
<string name="call_state_incoming">Reçu</string>
|
||||||
|
|
||||||
<string name="pref_background_mode">Actif en arrière plan</string>
|
<string name="pref_background_mode">Actif en arrière plan</string>
|
||||||
|
|
||||||
|
<string name="download_image">Télécharger</string>
|
||||||
|
<string name="download_image_failed">Téléchargement échoué. Vérifiez votre connexion internet ou reéssayez plus tard.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -425,4 +425,7 @@
|
||||||
<string name="call_state_incoming">Incoming</string>
|
<string name="call_state_incoming">Incoming</string>
|
||||||
|
|
||||||
<string name="pref_background_mode">Background mode</string>
|
<string name="pref_background_mode">Background mode</string>
|
||||||
|
|
||||||
|
<string name="download_image">Download</string>
|
||||||
|
<string name="download_image_failed">Download failed. Check your internet connection or try again later.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -308,10 +308,10 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
if (msg.getMessage() != null) {
|
if (msg.getMessage() != null) {
|
||||||
displayMessage(msg.getId(), msg.getMessage(), msg.getTimestamp(), msg.isIncoming(), msg.getStatus(), messagesLayout);
|
displayMessage(msg.getId(), msg.getMessage(), msg.getTimestamp(), msg.isIncoming(), msg.getStatus(), messagesLayout);
|
||||||
} else {
|
} else {
|
||||||
displayImageMessage(msg.getId(), msg.getImage(), msg.getTimestamp(), msg.isIncoming(), msg.getStatus(), messagesLayout);
|
displayImageMessage(msg.getId(), msg.getImage(), msg.getTimestamp(), msg.isIncoming(), msg.getStatus(), messagesLayout, msg.getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!msg.isRed())
|
if (!msg.isRead())
|
||||||
chatStorage.markMessageAsRead(msg.getId());
|
chatStorage.markMessageAsRead(msg.getId());
|
||||||
}
|
}
|
||||||
LinphoneActivity.instance().updateMissedChatCount();
|
LinphoneActivity.instance().updateMissedChatCount();
|
||||||
|
@ -373,13 +373,43 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
registerForContextMenu(v);
|
registerForContextMenu(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayImageMessage(int id, Bitmap image, String time, boolean isIncoming, LinphoneChatMessage.State status, RelativeLayout layout) {
|
private void displayImageMessage(final int id, Bitmap image, String time, boolean isIncoming, LinphoneChatMessage.State status, RelativeLayout layout, final String url) {
|
||||||
BubbleChat bubble = new BubbleChat(layout.getContext(), id, null, image, time, isIncoming, status, previousMessageID);
|
BubbleChat bubble = new BubbleChat(layout.getContext(), id, null, image, time, isIncoming, status, previousMessageID);
|
||||||
if (!isIncoming) {
|
if (!isIncoming) {
|
||||||
lastSentMessageBubble = bubble;
|
lastSentMessageBubble = bubble;
|
||||||
}
|
}
|
||||||
|
|
||||||
View v = bubble.getView();
|
final View v = bubble.getView();
|
||||||
|
bubble.setDownloadImageButtonListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final Bitmap bm = ChatFragment.downloadImage(url);
|
||||||
|
if (bm != null) {
|
||||||
|
LinphoneActivity.instance().getChatStorage().saveImage(id, bm);
|
||||||
|
mHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
((ImageView)v.findViewById(R.id.image)).setImageBitmap(bm);
|
||||||
|
v.findViewById(R.id.image).setVisibility(View.VISIBLE);
|
||||||
|
v.findViewById(R.id.download).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
mHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
LinphoneActivity.instance().displayCustomToast(getString(R.string.download_image_failed), Toast.LENGTH_LONG);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
previousMessageID = id;
|
previousMessageID = id;
|
||||||
layout.addView(v);
|
layout.addView(v);
|
||||||
registerForContextMenu(v);
|
registerForContextMenu(v);
|
||||||
|
@ -541,7 +571,7 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
latestImageMessages.put(newId, url);
|
latestImageMessages.put(newId, url);
|
||||||
|
|
||||||
displayImageMessage(newId, bitmap, String.valueOf(System.currentTimeMillis()), false, State.InProgress, messagesLayout);
|
displayImageMessage(newId, bitmap, String.valueOf(System.currentTimeMillis()), false, State.InProgress, messagesLayout, url);
|
||||||
scrollToEnd();
|
scrollToEnd();
|
||||||
} else if (!isNetworkReachable && LinphoneActivity.isInstanciated()) {
|
} else if (!isNetworkReachable && LinphoneActivity.isInstanciated()) {
|
||||||
LinphoneActivity.instance().displayCustomToast(getString(R.string.error_network_unreachable), Toast.LENGTH_LONG);
|
LinphoneActivity.instance().displayCustomToast(getString(R.string.error_network_unreachable), Toast.LENGTH_LONG);
|
||||||
|
@ -576,13 +606,22 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
});
|
});
|
||||||
} else if (message.getExternalBodyUrl() != null) {
|
} else if (message.getExternalBodyUrl() != null) {
|
||||||
byte[] rawImage = LinphoneActivity.instance().getChatStorage().getRawImageFromMessage(id);
|
byte[] rawImage = LinphoneActivity.instance().getChatStorage().getRawImageFromMessage(id);
|
||||||
final Bitmap bm = BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length);
|
if (rawImage == null) {
|
||||||
mHandler.post(new Runnable() {
|
mHandler.post(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
displayImageMessage(id, bm, String.valueOf(message.getTime()), true, null, messagesLayout);
|
displayImageMessage(id, null, String.valueOf(message.getTime()), true, null, messagesLayout, message.getExternalBodyUrl());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
final Bitmap bm = BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length);
|
||||||
|
mHandler.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
displayImageMessage(id, bm, String.valueOf(message.getTime()), true, null, messagesLayout, "");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
scrollToEnd();
|
scrollToEnd();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,13 +29,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
public class ChatMessage {
|
public class ChatMessage {
|
||||||
private String message;
|
private String message;
|
||||||
private String timestamp;
|
private String timestamp;
|
||||||
|
private String url;
|
||||||
private boolean incoming;
|
private boolean incoming;
|
||||||
private int status;
|
private int status;
|
||||||
private int id;
|
private int id;
|
||||||
private Bitmap image;
|
private Bitmap image;
|
||||||
private boolean isRed;
|
private boolean isRead;
|
||||||
|
|
||||||
public ChatMessage(int id, String message, byte[] rawImage, String timestamp, boolean incoming, int status, boolean red) {
|
public ChatMessage(int id, String message, byte[] rawImage, String timestamp, boolean incoming, int status, boolean read) {
|
||||||
super();
|
super();
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
@ -43,7 +44,7 @@ public class ChatMessage {
|
||||||
this.incoming = incoming;
|
this.incoming = incoming;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.image = rawImage != null ? BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length) : null;
|
this.image = rawImage != null ? BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length) : null;
|
||||||
this.isRed = red;
|
this.isRead = read;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
|
@ -86,7 +87,15 @@ public class ChatMessage {
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRed() {
|
public boolean isRead() {
|
||||||
return isRed;
|
return isRead;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class ChatStorage {
|
||||||
db.update(TABLE_NAME, values, "id LIKE " + id, null);
|
db.update(TABLE_NAME, values, "id LIKE " + id, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int saveMessage(String from, String to, String message, long time) {
|
public int saveTextMessage(String from, String to, String message, long time) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
if (from.equals("")) {
|
if (from.equals("")) {
|
||||||
values.put("localContact", from);
|
values.put("localContact", from);
|
||||||
|
@ -101,10 +101,7 @@ public class ChatStorage {
|
||||||
return (int) db.insert(TABLE_NAME, null, values);
|
return (int) db.insert(TABLE_NAME, null, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int saveMessage(String from, String to, Bitmap image, long time) {
|
public int saveImageMessage(String from, String to, Bitmap image, String url, long time) {
|
||||||
if (image == null)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
if (from.equals("")) {
|
if (from.equals("")) {
|
||||||
values.put("localContact", from);
|
values.put("localContact", from);
|
||||||
|
@ -119,13 +116,28 @@ public class ChatStorage {
|
||||||
values.put("read", NOT_READ);
|
values.put("read", NOT_READ);
|
||||||
values.put("status", LinphoneChatMessage.State.Idle.toInt());
|
values.put("status", LinphoneChatMessage.State.Idle.toInt());
|
||||||
}
|
}
|
||||||
|
values.put("url", url);
|
||||||
|
|
||||||
|
if (image != null) {
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
image.compress(CompressFormat.JPEG, 100, baos);
|
||||||
|
values.put("image", baos.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
values.put("time", time);
|
||||||
|
return (int) db.insert(TABLE_NAME, null, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveImage(int id, Bitmap image) {
|
||||||
|
if (image == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
image.compress(CompressFormat.JPEG, 100, baos);
|
image.compress(CompressFormat.JPEG, 100, baos);
|
||||||
values.put("image", baos.toByteArray());
|
values.put("image", baos.toByteArray());
|
||||||
|
|
||||||
values.put("time", time);
|
db.update(TABLE_NAME, values, "id LIKE " + id, null);
|
||||||
return (int) db.insert(TABLE_NAME, null, values);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int saveDraft(String to, String message) {
|
public int saveDraft(String to, String message) {
|
||||||
|
@ -186,7 +198,7 @@ public class ChatStorage {
|
||||||
|
|
||||||
while (c.moveToNext()) {
|
while (c.moveToNext()) {
|
||||||
try {
|
try {
|
||||||
String message, timestamp;
|
String message, timestamp, url;
|
||||||
int id = c.getInt(c.getColumnIndex("id"));
|
int id = c.getInt(c.getColumnIndex("id"));
|
||||||
int direction = c.getInt(c.getColumnIndex("direction"));
|
int direction = c.getInt(c.getColumnIndex("direction"));
|
||||||
message = c.getString(c.getColumnIndex("message"));
|
message = c.getString(c.getColumnIndex("message"));
|
||||||
|
@ -194,8 +206,10 @@ public class ChatStorage {
|
||||||
int status = c.getInt(c.getColumnIndex("status"));
|
int status = c.getInt(c.getColumnIndex("status"));
|
||||||
byte[] rawImage = c.getBlob(c.getColumnIndex("image"));
|
byte[] rawImage = c.getBlob(c.getColumnIndex("image"));
|
||||||
int read = c.getInt(c.getColumnIndex("read"));
|
int read = c.getInt(c.getColumnIndex("read"));
|
||||||
|
url = c.getString(c.getColumnIndex("url"));
|
||||||
|
|
||||||
ChatMessage chatMessage = new ChatMessage(id, message, rawImage, timestamp, direction == INCOMING, status, read == READ);
|
ChatMessage chatMessage = new ChatMessage(id, message, rawImage, timestamp, direction == INCOMING, status, read == READ);
|
||||||
|
chatMessage.setUrl(url);
|
||||||
chatMessages.add(chatMessage);
|
chatMessages.add(chatMessage);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -274,7 +288,7 @@ public class ChatStorage {
|
||||||
if (c.moveToFirst()) {
|
if (c.moveToFirst()) {
|
||||||
byte[] rawImage = c.getBlob(c.getColumnIndex("image"));
|
byte[] rawImage = c.getBlob(c.getColumnIndex("image"));
|
||||||
c.close();
|
c.close();
|
||||||
return rawImage;
|
return (rawImage == null || rawImage.length == 0) ? null : rawImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
c.close();
|
c.close();
|
||||||
|
@ -283,7 +297,7 @@ public class ChatStorage {
|
||||||
|
|
||||||
class ChatHelper extends SQLiteOpenHelper {
|
class ChatHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
private static final int DATABASE_VERSION = 14;
|
private static final int DATABASE_VERSION = 15;
|
||||||
private static final String DATABASE_NAME = "linphone-android";
|
private static final String DATABASE_NAME = "linphone-android";
|
||||||
|
|
||||||
ChatHelper(Context context) {
|
ChatHelper(Context context) {
|
||||||
|
@ -292,7 +306,7 @@ public class ChatStorage {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(SQLiteDatabase db) {
|
public void onCreate(SQLiteDatabase db) {
|
||||||
db.execSQL("CREATE TABLE " + TABLE_NAME + " (id INTEGER PRIMARY KEY AUTOINCREMENT, localContact TEXT NOT NULL, remoteContact TEXT NOT NULL, direction INTEGER, message TEXT, image BLOB, time NUMERIC, read INTEGER, status INTEGER);");
|
db.execSQL("CREATE TABLE " + TABLE_NAME + " (id INTEGER PRIMARY KEY AUTOINCREMENT, localContact TEXT NOT NULL, remoteContact TEXT NOT NULL, direction INTEGER, message TEXT, image BLOB, url TEXT, time NUMERIC, read INTEGER, status INTEGER);");
|
||||||
db.execSQL("CREATE TABLE " + DRAFT_TABLE_NAME + " (id INTEGER PRIMARY KEY AUTOINCREMENT, remoteContact TEXT NOT NULL, message TEXT);");
|
db.execSQL("CREATE TABLE " + DRAFT_TABLE_NAME + " (id INTEGER PRIMARY KEY AUTOINCREMENT, remoteContact TEXT NOT NULL, message TEXT);");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -739,12 +739,12 @@ public class LinphoneActivity extends FragmentActivity implements
|
||||||
|
|
||||||
public int onMessageSent(String to, String message) {
|
public int onMessageSent(String to, String message) {
|
||||||
getChatStorage().deleteDraft(to);
|
getChatStorage().deleteDraft(to);
|
||||||
return getChatStorage().saveMessage("", to, message, System.currentTimeMillis());
|
return getChatStorage().saveTextMessage("", to, message, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int onMessageSent(String to, Bitmap image, String imageURL) {
|
public int onMessageSent(String to, Bitmap image, String imageURL) {
|
||||||
getChatStorage().deleteDraft(to);
|
getChatStorage().deleteDraft(to);
|
||||||
return getChatStorage().saveMessage("", to, image, System.currentTimeMillis());
|
return getChatStorage().saveImageMessage("", to, image, imageURL, System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onMessageStateChanged(String to, String message, int newState) {
|
public void onMessageStateChanged(String to, String message, int newState) {
|
||||||
|
|
|
@ -95,7 +95,6 @@ import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.Editor;
|
import android.content.SharedPreferences.Editor;
|
||||||
import android.content.pm.PackageManager.NameNotFoundException;
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.hardware.Sensor;
|
import android.hardware.Sensor;
|
||||||
import android.hardware.SensorEvent;
|
import android.hardware.SensorEvent;
|
||||||
import android.hardware.SensorEventListener;
|
import android.hardware.SensorEventListener;
|
||||||
|
@ -1118,11 +1117,11 @@ public class LinphoneManager implements LinphoneCoreListener {
|
||||||
String notificationText = null;
|
String notificationText = null;
|
||||||
int id = -1;
|
int id = -1;
|
||||||
if (textMessage != null && textMessage.length() > 0) {
|
if (textMessage != null && textMessage.length() > 0) {
|
||||||
id = chatStorage.saveMessage(from.asStringUriOnly(), "", textMessage, message.getTime());
|
id = chatStorage.saveTextMessage(from.asStringUriOnly(), "", textMessage, message.getTime());
|
||||||
notificationText = textMessage;
|
notificationText = textMessage;
|
||||||
} else if (url != null && url.length() > 0) {
|
} else if (url != null && url.length() > 0) {
|
||||||
Bitmap bm = ChatFragment.downloadImage(url);
|
//Bitmap bm = ChatFragment.downloadImage(url);
|
||||||
id = chatStorage.saveMessage(from.asStringUriOnly(), "", bm, message.getTime());
|
id = chatStorage.saveImageMessage(from.asStringUriOnly(), "", null, message.getExternalBodyUrl(), message.getTime());
|
||||||
notificationText = url;
|
notificationText = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.linphone.LinphoneUtils;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.LinphoneChatMessage;
|
import org.linphone.core.LinphoneChatMessage;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
@ -37,6 +38,8 @@ import android.text.method.LinkMovementMethod;
|
||||||
import android.text.style.ImageSpan;
|
import android.text.style.ImageSpan;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.widget.Button;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
|
@ -46,6 +49,7 @@ import android.widget.TextView;
|
||||||
/**
|
/**
|
||||||
* @author Sylvain Berfini
|
* @author Sylvain Berfini
|
||||||
*/
|
*/
|
||||||
|
@SuppressLint("SimpleDateFormat")
|
||||||
public class BubbleChat {
|
public class BubbleChat {
|
||||||
private static final HashMap<String, Integer> emoticons = new HashMap<String, Integer>();
|
private static final HashMap<String, Integer> emoticons = new HashMap<String, Integer>();
|
||||||
static {
|
static {
|
||||||
|
@ -81,6 +85,7 @@ public class BubbleChat {
|
||||||
|
|
||||||
private RelativeLayout view;
|
private RelativeLayout view;
|
||||||
private ImageView statusView;
|
private ImageView statusView;
|
||||||
|
private Button download;
|
||||||
|
|
||||||
public BubbleChat(Context context, int id, String message, Bitmap image, String time, boolean isIncoming, LinphoneChatMessage.State status, int previousID) {
|
public BubbleChat(Context context, int id, String message, Bitmap image, String time, boolean isIncoming, LinphoneChatMessage.State status, int previousID) {
|
||||||
view = new RelativeLayout(context);
|
view = new RelativeLayout(context);
|
||||||
|
@ -144,6 +149,11 @@ public class BubbleChat {
|
||||||
imageView.setVisibility(View.GONE);
|
imageView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
download = (Button) layout.findViewById(R.id.download);
|
||||||
|
if (download != null && image == null && message == null) {
|
||||||
|
download.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
TextView timeView = (TextView) layout.findViewById(R.id.time);
|
TextView timeView = (TextView) layout.findViewById(R.id.time);
|
||||||
timeView.setText(timestampToHumanDate(context, time));
|
timeView.setText(timestampToHumanDate(context, time));
|
||||||
|
|
||||||
|
@ -261,4 +271,10 @@ public class BubbleChat {
|
||||||
|
|
||||||
return Html.fromHtml(text);
|
return Html.fromHtml(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setDownloadImageButtonListener(OnClickListener onClickListener) {
|
||||||
|
if (download != null) {
|
||||||
|
download.setOnClickListener(onClickListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue