aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-10-15 19:32:12 +0200
committeriNPUTmice <daniel@gultsch.de>2014-10-15 19:32:12 +0200
commitcb4069f0f213ed1a38ce074d981b0c367dc2cdfd (patch)
tree9004af99e6da679e640fe97bdcdbf469832b8ab5 /src/eu/siacs/conversations/ui
parent1927a3d99c3a8e23535680ceb29e7dbb78bda185 (diff)
refactored file download status. make image http download available for carbon copied (sent) messages as well
Diffstat (limited to 'src/eu/siacs/conversations/ui')
-rw-r--r--src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java3
-rw-r--r--src/eu/siacs/conversations/ui/ContactDetailsActivity.java9
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java3
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java9
-rw-r--r--src/eu/siacs/conversations/ui/ManageAccountActivity.java6
-rw-r--r--src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java100
-rw-r--r--src/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java4
-rw-r--r--src/eu/siacs/conversations/ui/adapter/MessageAdapter.java46
8 files changed, 90 insertions, 90 deletions
diff --git a/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
index deddcad7..ca3bb4a2 100644
--- a/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
+++ b/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
@@ -199,7 +199,8 @@ public class ConferenceDetailsActivity extends XmppActivity {
}
private void populateView() {
- mAccountJid.setText(getString(R.string.using_account,conversation.getAccount().getJid()));
+ mAccountJid.setText(getString(R.string.using_account, conversation
+ .getAccount().getJid()));
mYourPhoto.setImageBitmap(conversation.getAccount().getImage(this, 48));
setTitle(conversation.getName());
mFullJid.setText(conversation.getContactJid().split("/", 2)[0]);
diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
index 394aab6e..65bd5cbf 100644
--- a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -56,7 +56,8 @@ public class ContactDetailsActivity extends XmppActivity {
@Override
public void onClick(DialogInterface dialog, int which) {
- ContactDetailsActivity.this.xmppConnectionService.deleteContactOnServer(contact);
+ ContactDetailsActivity.this.xmppConnectionService
+ .deleteContactOnServer(contact);
ContactDetailsActivity.this.finish();
}
};
@@ -78,7 +79,8 @@ public class ContactDetailsActivity extends XmppActivity {
@Override
public void onClick(View v) {
- AlertDialog.Builder builder = new AlertDialog.Builder(ContactDetailsActivity.this);
+ AlertDialog.Builder builder = new AlertDialog.Builder(
+ ContactDetailsActivity.this);
builder.setTitle(getString(R.string.action_add_phone_book));
builder.setMessage(getString(R.string.add_phone_book_text,
contact.getJid()));
@@ -309,7 +311,8 @@ public class ContactDetailsActivity extends XmppActivity {
} else {
contactJidTv.setText(contact.getJid());
}
- accountJidTv.setText(getString(R.string.using_account,contact.getAccount().getJid()));
+ accountJidTv.setText(getString(R.string.using_account, contact
+ .getAccount().getJid()));
UIHelper.prepareContactBadge(this, badge, contact,
getApplicationContext());
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index 40739387..24ef9a6f 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -222,7 +222,8 @@ public class ConversationActivity extends XmppActivity implements
ab.setDisplayHomeAsUpEnabled(true);
ab.setHomeButtonEnabled(true);
if (getSelectedConversation().getMode() == Conversation.MODE_SINGLE
- || ConversationActivity.this.useSubjectToIdentifyConference()) {
+ || ConversationActivity.this
+ .useSubjectToIdentifyConference()) {
ab.setTitle(getSelectedConversation().getName());
} else {
ab.setTitle(getSelectedConversation().getContactJid()
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index 4835636d..0e71801b 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -72,8 +72,7 @@ public class ConversationFragment extends Fragment {
private boolean messagesLoaded = false;
private IntentSender askForPassphraseIntent = null;
-
-
+
private ConcurrentLinkedQueue<Message> mEncryptedMessages = new ConcurrentLinkedQueue<Message>();
private boolean mDecryptJobRunning = false;
@@ -505,8 +504,8 @@ public class ConversationFragment extends Fragment {
private void decryptNext() {
Message next = this.mEncryptedMessages.peek();
PgpEngine engine = activity.xmppConnectionService.getPgpEngine();
-
- if (next!=null && engine != null && !mDecryptJobRunning) {
+
+ if (next != null && engine != null && !mDecryptJobRunning) {
mDecryptJobRunning = true;
engine.decrypt(next, new UiCallback<Message>() {
@@ -535,7 +534,7 @@ public class ConversationFragment extends Fragment {
});
}
}
-
+
private void messageSent() {
int size = this.messageList.size();
messagesView.setSelection(size - 1);
diff --git a/src/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
index afe9e06e..5b5b0608 100644
--- a/src/eu/siacs/conversations/ui/ManageAccountActivity.java
+++ b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
@@ -70,7 +70,8 @@ public class ManageAccountActivity extends XmppActivity {
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
- ManageAccountActivity.this.getMenuInflater().inflate(R.menu.manageaccounts_context, menu);
+ ManageAccountActivity.this.getMenuInflater().inflate(
+ R.menu.manageaccounts_context, menu);
AdapterView.AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
this.selectedAccount = accountList.get(acmi.position);
if (this.selectedAccount.isOptionSet(Account.OPTION_DISABLED)) {
@@ -187,7 +188,8 @@ public class ManageAccountActivity extends XmppActivity {
}
private void deleteAccount(final Account account) {
- AlertDialog.Builder builder = new AlertDialog.Builder(ManageAccountActivity.this);
+ AlertDialog.Builder builder = new AlertDialog.Builder(
+ ManageAccountActivity.this);
builder.setTitle(getString(R.string.mgmt_account_are_you_sure));
builder.setIconAttribute(android.R.attr.alertDialogIcon);
builder.setMessage(getString(R.string.mgmt_account_delete_confirm_text));
diff --git a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
index f74856b0..6943a85c 100644
--- a/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
+++ b/src/eu/siacs/conversations/ui/adapter/ConversationAdapter.java
@@ -5,6 +5,7 @@ import java.util.List;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Conversation;
+import eu.siacs.conversations.entities.Downloadable;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.ui.ConversationActivity;
import eu.siacs.conversations.ui.XmppActivity;
@@ -37,11 +38,11 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
view = (View) inflater.inflate(R.layout.conversation_list_row,
parent, false);
}
- Conversation conv = getItem(position);
+ Conversation conversation = getItem(position);
if (this.activity instanceof ConversationActivity) {
ConversationActivity activity = (ConversationActivity) this.activity;
if (!activity.isConversationsOverviewHideable()) {
- if (conv == activity.getSelectedConversation()) {
+ if (conversation == activity.getSelectedConversation()) {
view.setBackgroundColor(activity
.getSecondaryBackgroundColor());
} else {
@@ -53,65 +54,76 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
}
TextView convName = (TextView) view
.findViewById(R.id.conversation_name);
- if (conv.getMode() == Conversation.MODE_SINGLE
+ if (conversation.getMode() == Conversation.MODE_SINGLE
|| activity.useSubjectToIdentifyConference()) {
- convName.setText(conv.getName());
+ convName.setText(conversation.getName());
} else {
- convName.setText(conv.getContactJid().split("/")[0]);
+ convName.setText(conversation.getContactJid().split("/")[0]);
}
- TextView convLastMsg = (TextView) view
+ TextView mLastMessage = (TextView) view
.findViewById(R.id.conversation_lastmsg);
+ TextView mTimestamp = (TextView) view
+ .findViewById(R.id.conversation_lastupdate);
ImageView imagePreview = (ImageView) view
.findViewById(R.id.conversation_lastimage);
- Message latestMessage = conv.getLatestMessage();
+ Message message = conversation.getLatestMessage();
- if (latestMessage.getType() == Message.TYPE_TEXT
- || latestMessage.getType() == Message.TYPE_PRIVATE) {
- if ((latestMessage.getEncryption() != Message.ENCRYPTION_PGP)
- && (latestMessage.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) {
- String body = Config.PARSE_EMOTICONS ? UIHelper
- .transformAsciiEmoticons(latestMessage.getBody())
- : latestMessage.getBody();
- convLastMsg.setText(body);
- } else {
- convLastMsg.setText(R.string.encrypted_message_received);
- }
- convLastMsg.setVisibility(View.VISIBLE);
- imagePreview.setVisibility(View.GONE);
- } else if (latestMessage.getType() == Message.TYPE_IMAGE) {
- if (latestMessage.getStatus() >= Message.STATUS_RECEIVED) {
- convLastMsg.setVisibility(View.GONE);
- imagePreview.setVisibility(View.VISIBLE);
- activity.loadBitmap(latestMessage, imagePreview);
- } else {
- convLastMsg.setVisibility(View.VISIBLE);
+ if (!conversation.isRead()) {
+ convName.setTypeface(null, Typeface.BOLD);
+ } else {
+ convName.setTypeface(null, Typeface.NORMAL);
+ }
+
+ if (message.getType() == Message.TYPE_IMAGE
+ || message.getDownloadable() != null) {
+ Downloadable d = message.getDownloadable();
+ if (d != null) {
+ mLastMessage.setVisibility(View.VISIBLE);
imagePreview.setVisibility(View.GONE);
- if (latestMessage.getStatus() == Message.STATUS_RECEIVED_OFFER) {
- convLastMsg.setText(R.string.image_offered_for_download);
- } else if (latestMessage.getStatus() == Message.STATUS_RECEIVING) {
- convLastMsg.setText(R.string.receiving_image);
+ if (conversation.isRead()) {
+ mLastMessage.setTypeface(null, Typeface.ITALIC);
+ } else {
+ mLastMessage.setTypeface(null, Typeface.BOLD_ITALIC);
+ }
+ if (d.getStatus() == Downloadable.STATUS_CHECKING) {
+ mLastMessage.setText(R.string.checking_image);
+ } else if (d.getStatus() == Downloadable.STATUS_DOWNLOADING) {
+ mLastMessage.setText(R.string.receiving_image);
+ } else if (d.getStatus() == Downloadable.STATUS_OFFER) {
+ mLastMessage.setText(R.string.image_offered_for_download);
} else {
- convLastMsg.setText("");
+ mLastMessage.setText("");
}
+ } else {
+ mLastMessage.setVisibility(View.GONE);
+ imagePreview.setVisibility(View.VISIBLE);
+ activity.loadBitmap(message, imagePreview);
}
- }
-
- if (!conv.isRead()) {
- convName.setTypeface(null, Typeface.BOLD);
- convLastMsg.setTypeface(null, Typeface.BOLD);
} else {
- convName.setTypeface(null, Typeface.NORMAL);
- convLastMsg.setTypeface(null, Typeface.NORMAL);
+ if ((message.getEncryption() != Message.ENCRYPTION_PGP)
+ && (message.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED)) {
+ String body = Config.PARSE_EMOTICONS ? UIHelper
+ .transformAsciiEmoticons(message.getBody()) : message
+ .getBody();
+ mLastMessage.setText(body);
+ } else {
+ mLastMessage.setText(R.string.encrypted_message_received);
+ }
+ if (!conversation.isRead()) {
+ mLastMessage.setTypeface(null, Typeface.BOLD);
+ } else {
+ mLastMessage.setTypeface(null, Typeface.NORMAL);
+ }
+ mLastMessage.setVisibility(View.VISIBLE);
+ imagePreview.setVisibility(View.GONE);
}
-
- ((TextView) view.findViewById(R.id.conversation_lastupdate))
- .setText(UIHelper.readableTimeDifference(getContext(), conv
- .getLatestMessage().getTimeSent()));
+ mTimestamp.setText(UIHelper.readableTimeDifference(getContext(),
+ conversation.getLatestMessage().getTimeSent()));
ImageView profilePicture = (ImageView) view
.findViewById(R.id.conversation_image);
- profilePicture.setImageBitmap(conv.getImage(activity, 56));
+ profilePicture.setImageBitmap(conversation.getImage(activity, 56));
return view;
}
diff --git a/src/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java b/src/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java
index 2b8ee048..143dfda1 100644
--- a/src/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java
+++ b/src/eu/siacs/conversations/ui/adapter/KnownHostsAdapter.java
@@ -47,11 +47,11 @@ public class KnownHostsAdapter extends ArrayAdapter<String> {
@Override
protected void publishResults(CharSequence constraint,
FilterResults results) {
- ArrayList filteredList = (ArrayList)results.values;
+ ArrayList filteredList = (ArrayList) results.values;
if (results != null && results.count > 0) {
clear();
for (Object c : filteredList) {
- add((String)c);
+ add((String) c);
}
notifyDataSetChanged();
}
diff --git a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index b09f97fc..efb07292 100644
--- a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -138,10 +138,6 @@ public class MessageAdapter extends ArrayAdapter<Message> {
info = getContext().getString(R.string.send_rejected);
error = true;
break;
- case Message.STATUS_RECEPTION_FAILED:
- info = getContext().getString(R.string.reception_failed);
- error = true;
- break;
default:
if (multiReceived) {
Contact contact = message.getContact();
@@ -230,19 +226,10 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.messageBody.setVisibility(View.VISIBLE);
if (message.getBody() != null) {
if (message.getType() != Message.TYPE_PRIVATE) {
- if (message.getType() == Message.TYPE_IMAGE) {
- String orign = message.getImageParams().origin;
- if (orign!=null) {
- viewHolder.messageBody.setText(orign);
- } else {
- viewHolder.messageBody.setText(message.getBody());
- }
- } else {
- String body = Config.PARSE_EMOTICONS ? UIHelper
- .transformAsciiEmoticons(message.getMergedBody())
- : message.getMergedBody();
- viewHolder.messageBody.setText(body);
- }
+ String body = Config.PARSE_EMOTICONS ? UIHelper
+ .transformAsciiEmoticons(message.getMergedBody())
+ : message.getMergedBody();
+ viewHolder.messageBody.setText(body);
} else {
String privateMarker;
if (message.getStatus() <= Message.STATUS_RECEIVED) {
@@ -347,6 +334,8 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.contact_picture = (ImageView) view
.findViewById(R.id.message_photo);
viewHolder.contact_picture.setImageBitmap(getSelfBitmap());
+ viewHolder.download_button = (Button) view
+ .findViewById(R.id.download_button);
viewHolder.indicator = (ImageView) view
.findViewById(R.id.security_indicator);
viewHolder.image = (ImageView) view
@@ -366,15 +355,11 @@ public class MessageAdapter extends ArrayAdapter<Message> {
.findViewById(R.id.message_box);
viewHolder.contact_picture = (ImageView) view
.findViewById(R.id.message_photo);
-
viewHolder.download_button = (Button) view
.findViewById(R.id.download_button);
-
if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
-
viewHolder.contact_picture.setImageBitmap(mBitmapCache.get(
item.getConversation().getContact(), getContext()));
-
}
viewHolder.indicator = (ImageView) view
.findViewById(R.id.security_indicator);
@@ -483,14 +468,15 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
}
- if (item.getType() == Message.TYPE_IMAGE) {
- if (item.getStatus() == Message.STATUS_RECEIVING) {
+ if (item.getType() == Message.TYPE_IMAGE
+ || item.getDownloadable() != null) {
+ Downloadable d = item.getDownloadable();
+ if (d != null && d.getStatus() == Downloadable.STATUS_DOWNLOADING) {
displayInfoMessage(viewHolder, R.string.receiving_image);
- } else if (item.getStatus() == Message.STATUS_RECEIVED_CHECKING) {
+ } else if (d != null
+ && d.getStatus() == Downloadable.STATUS_CHECKING) {
displayInfoMessage(viewHolder, R.string.checking_image);
- } else if (item.getStatus() == Message.STATUS_RECEPTION_FAILED) {
- displayTextMessage(viewHolder, item);
- } else if (item.getStatus() == Message.STATUS_RECEIVED_OFFER) {
+ } else if (d != null && d.getStatus() == Downloadable.STATUS_OFFER) {
viewHolder.image.setVisibility(View.GONE);
viewHolder.messageBody.setVisibility(View.GONE);
viewHolder.download_button.setVisibility(View.VISIBLE);
@@ -499,11 +485,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
@Override
public void onClick(View v) {
- if (!startDonwloadable(item)) {
- activity.xmppConnectionService.markMessage(
- item,
- Message.STATUS_RECEPTION_FAILED);
- }
+ startDonwloadable(item);
}
});
} else if ((item.getEncryption() == Message.ENCRYPTION_DECRYPTED)