made ui with sending images a little smoother
This commit is contained in:
parent
513f3c47b2
commit
bdf9770a61
|
@ -28,6 +28,7 @@
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:maxHeight="288dp"
|
android:maxHeight="288dp"
|
||||||
android:maxWidth="288dp"
|
android:maxWidth="288dp"
|
||||||
|
android:paddingBottom="2dp"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:maxHeight="288dp"
|
android:maxHeight="288dp"
|
||||||
android:maxWidth="288dp"
|
android:maxWidth="288dp"
|
||||||
|
android:paddingBottom="2dp"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
<string name="just_now">just now</string>
|
<string name="just_now">just now</string>
|
||||||
<string name="sending">sending…</string>
|
<string name="sending">sending…</string>
|
||||||
<string name="announce_pgp">Renew PGP announcement</string>
|
<string name="announce_pgp">Renew PGP announcement</string>
|
||||||
<string name="encrypted_message">Decrypting message. please wait…</string>
|
<string name="encrypted_message">Decrypting message. Please wait…</string>
|
||||||
<string name="conference_details">Conference Details</string>
|
<string name="conference_details">Conference Details</string>
|
||||||
<string name="nick_in_use">Nickname is already in use</string>
|
<string name="nick_in_use">Nickname is already in use</string>
|
||||||
<string name="moderator">Moderator</string>
|
<string name="moderator">Moderator</string>
|
||||||
|
@ -52,4 +52,6 @@
|
||||||
<string name="add_contact">Add contact</string>
|
<string name="add_contact">Add contact</string>
|
||||||
<string name="send_failed">unsuccessful delivery</string>
|
<string name="send_failed">unsuccessful delivery</string>
|
||||||
<string name="send_rejected">rejected</string>
|
<string name="send_rejected">rejected</string>
|
||||||
|
<string name="receiving_image">Receiving image file. Please wait…</string>
|
||||||
|
<string name="preparing_image">Preparing image for transmission. Please wait…</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -15,6 +15,7 @@ public class Message extends AbstractEntity {
|
||||||
public static final int STATUS_SEND = 2;
|
public static final int STATUS_SEND = 2;
|
||||||
public static final int STATUS_SEND_FAILED = 3;
|
public static final int STATUS_SEND_FAILED = 3;
|
||||||
public static final int STATUS_SEND_REJECTED = 4;
|
public static final int STATUS_SEND_REJECTED = 4;
|
||||||
|
public static final int STATUS_PREPARING = 5;
|
||||||
|
|
||||||
public static final int ENCRYPTION_NONE = 0;
|
public static final int ENCRYPTION_NONE = 0;
|
||||||
public static final int ENCRYPTION_PGP = 1;
|
public static final int ENCRYPTION_PGP = 1;
|
||||||
|
|
|
@ -401,15 +401,28 @@ public class XmppConnectionService extends Service {
|
||||||
return this.fileBackend;
|
return this.fileBackend;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Message attachImageToConversation(Conversation conversation, String presence, Uri uri) {
|
public void attachImageToConversation(final Conversation conversation, final String presence, final Uri uri) {
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
Message message = new Message(conversation, "", Message.ENCRYPTION_NONE);
|
Message message = new Message(conversation, "", Message.ENCRYPTION_NONE);
|
||||||
message.setPresence(presence);
|
message.setPresence(presence);
|
||||||
message.setType(Message.TYPE_IMAGE);
|
message.setType(Message.TYPE_IMAGE);
|
||||||
File file = this.fileBackend.copyImageToPrivateStorage(message, uri);
|
message.setStatus(Message.STATUS_PREPARING);
|
||||||
conversation.getMessages().add(message);
|
conversation.getMessages().add(message);
|
||||||
|
if (convChangedListener!=null) {
|
||||||
|
convChangedListener.onConversationListChanged();
|
||||||
|
}
|
||||||
|
getFileBackend().copyImageToPrivateStorage(message, uri);
|
||||||
|
message.setStatus(Message.STATUS_UNSEND);
|
||||||
databaseBackend.createMessage(message);
|
databaseBackend.createMessage(message);
|
||||||
|
if (convChangedListener!=null) {
|
||||||
|
convChangedListener.onConversationListChanged();
|
||||||
|
}
|
||||||
sendMessage(message, null);
|
sendMessage(message, null);
|
||||||
return message;
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -205,20 +205,19 @@ public class ConversationFragment extends Fragment {
|
||||||
case SENT:
|
case SENT:
|
||||||
view = (View) inflater.inflate(R.layout.message_sent,
|
view = (View) inflater.inflate(R.layout.message_sent,
|
||||||
null);
|
null);
|
||||||
viewHolder.imageView = (ImageView) view
|
viewHolder.contact_picture = (ImageView) view
|
||||||
.findViewById(R.id.message_photo);
|
.findViewById(R.id.message_photo);
|
||||||
viewHolder.imageView.setImageBitmap(selfBitmap);
|
viewHolder.contact_picture.setImageBitmap(selfBitmap);
|
||||||
viewHolder.indicator = (ImageView) view.findViewById(R.id.security_indicator);
|
|
||||||
break;
|
break;
|
||||||
case RECIEVED:
|
case RECIEVED:
|
||||||
view = (View) inflater.inflate(
|
view = (View) inflater.inflate(
|
||||||
R.layout.message_recieved, null);
|
R.layout.message_recieved, null);
|
||||||
viewHolder.imageView = (ImageView) view
|
viewHolder.contact_picture = (ImageView) view
|
||||||
.findViewById(R.id.message_photo);
|
.findViewById(R.id.message_photo);
|
||||||
viewHolder.indicator = (ImageView) view.findViewById(R.id.security_indicator);
|
|
||||||
if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
|
if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
|
||||||
|
|
||||||
viewHolder.imageView.setImageBitmap(mBitmapCache
|
viewHolder.contact_picture.setImageBitmap(mBitmapCache
|
||||||
.get(item.getConversation().getName(useSubject), item
|
.get(item.getConversation().getName(useSubject), item
|
||||||
.getConversation().getContact(),
|
.getConversation().getContact(),
|
||||||
getActivity()
|
getActivity()
|
||||||
|
@ -230,6 +229,7 @@ public class ConversationFragment extends Fragment {
|
||||||
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.image = (ImageView) view.findViewById(R.id.message_image);
|
||||||
viewHolder.messageBody = (TextView) view
|
viewHolder.messageBody = (TextView) view
|
||||||
.findViewById(R.id.message_body);
|
.findViewById(R.id.message_body);
|
||||||
|
@ -242,29 +242,47 @@ public class ConversationFragment extends Fragment {
|
||||||
if (type == RECIEVED) {
|
if (type == RECIEVED) {
|
||||||
if (item.getConversation().getMode() == Conversation.MODE_MULTI) {
|
if (item.getConversation().getMode() == Conversation.MODE_MULTI) {
|
||||||
if (item.getCounterpart() != null) {
|
if (item.getCounterpart() != null) {
|
||||||
viewHolder.imageView.setImageBitmap(mBitmapCache
|
viewHolder.contact_picture.setImageBitmap(mBitmapCache
|
||||||
.get(item.getCounterpart(), null,
|
.get(item.getCounterpart(), null,
|
||||||
getActivity()
|
getActivity()
|
||||||
.getApplicationContext()));
|
.getApplicationContext()));
|
||||||
} else {
|
} else {
|
||||||
viewHolder.imageView.setImageBitmap(mBitmapCache
|
viewHolder.contact_picture.setImageBitmap(mBitmapCache
|
||||||
.get(item.getConversation().getName(useSubject),
|
.get(item.getConversation().getName(useSubject),
|
||||||
null, getActivity()
|
null, getActivity()
|
||||||
.getApplicationContext()));
|
.getApplicationContext()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.getEncryption() == Message.ENCRYPTION_NONE) {
|
||||||
|
viewHolder.indicator.setVisibility(View.GONE);
|
||||||
|
} else {
|
||||||
|
viewHolder.indicator.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (item.getType() == Message.TYPE_IMAGE) {
|
if (item.getType() == Message.TYPE_IMAGE) {
|
||||||
viewHolder.image.setVisibility(View.VISIBLE);
|
if (item.getStatus() == Message.STATUS_PREPARING) {
|
||||||
if (item.getStatus() != Message.STATUS_RECIEVING) {
|
viewHolder.image.setVisibility(View.GONE);
|
||||||
|
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
||||||
|
viewHolder.messageBody.setText(getString(R.string.preparing_image));
|
||||||
|
viewHolder.messageBody.setTextColor(0xff33B5E5);
|
||||||
|
viewHolder.messageBody.setTypeface(null,Typeface.ITALIC);
|
||||||
|
} else if (item.getStatus() == Message.STATUS_RECIEVING) {
|
||||||
|
viewHolder.image.setVisibility(View.GONE);
|
||||||
|
viewHolder.messageBody.setVisibility(View.GONE);
|
||||||
|
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
||||||
|
viewHolder.messageBody.setText(getString(R.string.receiving_image));
|
||||||
|
viewHolder.messageBody.setTextColor(0xff33B5E5);
|
||||||
|
viewHolder.messageBody.setTypeface(null,Typeface.ITALIC);
|
||||||
|
} else {
|
||||||
viewHolder.image.setImageBitmap(activity.xmppConnectionService.getFileBackend().getThumbnailFromMessage(item,(int) (metrics.density * 288)));
|
viewHolder.image.setImageBitmap(activity.xmppConnectionService.getFileBackend().getThumbnailFromMessage(item,(int) (metrics.density * 288)));
|
||||||
viewHolder.messageBody.setVisibility(View.GONE);
|
viewHolder.messageBody.setVisibility(View.GONE);
|
||||||
} else {
|
viewHolder.image.setVisibility(View.VISIBLE);
|
||||||
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
|
||||||
viewHolder.messageBody.setText("receiving image file");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (viewHolder.image != null) viewHolder.image.setVisibility(View.GONE);
|
viewHolder.image.setVisibility(View.GONE);
|
||||||
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
viewHolder.messageBody.setVisibility(View.VISIBLE);
|
||||||
String body = item.getBody();
|
String body = item.getBody();
|
||||||
if (body != null) {
|
if (body != null) {
|
||||||
|
@ -274,22 +292,17 @@ public class ConversationFragment extends Fragment {
|
||||||
viewHolder.messageBody.setTextColor(0xff33B5E5);
|
viewHolder.messageBody.setTextColor(0xff33B5E5);
|
||||||
viewHolder.messageBody.setTypeface(null,
|
viewHolder.messageBody.setTypeface(null,
|
||||||
Typeface.ITALIC);
|
Typeface.ITALIC);
|
||||||
viewHolder.indicator.setVisibility(View.VISIBLE);
|
|
||||||
} else if ((item.getEncryption() == Message.ENCRYPTION_OTR)||(item.getEncryption() == Message.ENCRYPTION_DECRYPTED)) {
|
} else if ((item.getEncryption() == Message.ENCRYPTION_OTR)||(item.getEncryption() == Message.ENCRYPTION_DECRYPTED)) {
|
||||||
viewHolder.messageBody.setText(body.trim());
|
viewHolder.messageBody.setText(body.trim());
|
||||||
viewHolder.messageBody.setTextColor(0xff333333);
|
viewHolder.messageBody.setTextColor(0xff333333);
|
||||||
viewHolder.messageBody.setTypeface(null,
|
viewHolder.messageBody.setTypeface(null,
|
||||||
Typeface.NORMAL);
|
Typeface.NORMAL);
|
||||||
viewHolder.indicator.setVisibility(View.VISIBLE);
|
|
||||||
} else {
|
} else {
|
||||||
viewHolder.messageBody.setText(body.trim());
|
viewHolder.messageBody.setText(body.trim());
|
||||||
viewHolder.messageBody.setTextColor(0xff333333);
|
viewHolder.messageBody.setTextColor(0xff333333);
|
||||||
viewHolder.messageBody.setTypeface(null,
|
viewHolder.messageBody.setTypeface(null,
|
||||||
Typeface.NORMAL);
|
Typeface.NORMAL);
|
||||||
viewHolder.indicator.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
viewHolder.indicator.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch (item.getStatus()) {
|
switch (item.getStatus()) {
|
||||||
|
@ -607,7 +620,7 @@ public class ConversationFragment extends Fragment {
|
||||||
protected ImageView indicator;
|
protected ImageView indicator;
|
||||||
protected TextView time;
|
protected TextView time;
|
||||||
protected TextView messageBody;
|
protected TextView messageBody;
|
||||||
protected ImageView imageView;
|
protected ImageView contact_picture;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue