diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-11-14 12:31:57 +0100 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-11-15 15:34:12 +0100 |
commit | e7a70a46e0154740177dcdea7fad255dcd4067e9 (patch) | |
tree | 76594b4f495b8b415b47e1d4273c64f6e15f6f60 /src/main/java/eu/siacs/conversations/ui | |
parent | 16847a30c88246381a026bce9f2435be2bd77422 (diff) |
some mime and pgp fixes for file transfer
Diffstat (limited to '')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ConversationActivity.java | 24 | ||||
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java | 61 |
2 files changed, 40 insertions, 45 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 9859d424..7e28cc6c 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -15,7 +15,6 @@ import android.os.SystemClock; import android.provider.MediaStore; import android.support.v4.widget.SlidingPaneLayout; import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener; -import android.util.Log; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; @@ -32,7 +31,6 @@ import android.widget.Toast; import java.util.ArrayList; import java.util.List; -import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; @@ -80,7 +78,7 @@ public class ConversationActivity extends XmppActivity implements private ArrayAdapter<Conversation> listAdapter; - private Toast prepareImageToast; + private Toast prepareFileToast; public List<Conversation> getConversationList() { @@ -782,15 +780,19 @@ public class ConversationActivity extends XmppActivity implements } private void attachFileToConversation(Conversation conversation, Uri uri) { + prepareFileToast = Toast.makeText(getApplicationContext(), + getText(R.string.preparing_file), Toast.LENGTH_LONG); + prepareFileToast.show(); xmppConnectionService.attachFileToConversation(conversation,uri, new UiCallback<Message>() { @Override public void success(Message message) { + hidePrepareFileToast(); xmppConnectionService.sendMessage(message); } @Override public void error(int errorCode, Message message) { - + displayErrorDialog(errorCode); } @Override @@ -801,16 +803,16 @@ public class ConversationActivity extends XmppActivity implements } private void attachImageToConversation(Conversation conversation, Uri uri) { - prepareImageToast = Toast.makeText(getApplicationContext(), + prepareFileToast = Toast.makeText(getApplicationContext(), getText(R.string.preparing_image), Toast.LENGTH_LONG); - prepareImageToast.show(); + prepareFileToast.show(); xmppConnectionService.attachImageToConversation(conversation, uri, new UiCallback<Message>() { @Override public void userInputRequried(PendingIntent pi, Message object) { - hidePrepareImageToast(); + hidePrepareFileToast(); ConversationActivity.this.runIntent(pi, ConversationActivity.REQUEST_SEND_PGP_IMAGE); } @@ -822,19 +824,19 @@ public class ConversationActivity extends XmppActivity implements @Override public void error(int error, Message message) { - hidePrepareImageToast(); + hidePrepareFileToast(); displayErrorDialog(error); } }); } - private void hidePrepareImageToast() { - if (prepareImageToast != null) { + private void hidePrepareFileToast() { + if (prepareFileToast != null) { runOnUiThread(new Runnable() { @Override public void run() { - prepareImageToast.cancel(); + prepareFileToast.cancel(); } }); } diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java index 81eccacc..71795e98 100644 --- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java +++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java @@ -281,15 +281,16 @@ public class MessageAdapter extends ArrayAdapter<Message> { } private void displayOpenableMessage(ViewHolder viewHolder,final Message message) { + final DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message); viewHolder.image.setVisibility(View.GONE); viewHolder.messageBody.setVisibility(View.GONE); viewHolder.download_button.setVisibility(View.VISIBLE); - viewHolder.download_button.setText(activity.getString(R.string.open_file,activity.xmppConnectionService.getFileBackend().getFile(message).getMimeType())); + viewHolder.download_button.setText(activity.getString(R.string.open_file,file.getMimeType())); viewHolder.download_button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - openDonwloadable(message); + openDonwloadable(file); } }); viewHolder.download_button.setOnLongClickListener(openContextMenu); @@ -506,43 +507,35 @@ public class MessageAdapter extends ArrayAdapter<Message> { } else if (d.getStatus() == Downloadable.STATUS_FAILED) { displayInfoMessage(viewHolder, activity.getString(R.string.image_transmission_failed)); } - } else if (item.getType() == Message.TYPE_IMAGE) { - if (item.getEncryption() == Message.ENCRYPTION_PGP) { - displayInfoMessage(viewHolder,activity.getString(R.string.encrypted_message)); - } else if (item.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) { - displayDecryptionFailed(viewHolder); - } else { - displayImageMessage(viewHolder, item); - } - } else if (item.getType() == Message.TYPE_FILE) { + } else if (item.getType() == Message.TYPE_IMAGE && item.getEncryption() != Message.ENCRYPTION_PGP && item.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) { + displayImageMessage(viewHolder, item); + } else if (item.getType() == Message.TYPE_FILE && item.getEncryption() != Message.ENCRYPTION_PGP && item.getEncryption() != Message.ENCRYPTION_DECRYPTION_FAILED) { if (item.getImageParams().width > 0) { displayImageMessage(viewHolder,item); } else { displayOpenableMessage(viewHolder, item); } - } else { - if (item.getEncryption() == Message.ENCRYPTION_PGP) { - if (activity.hasPgp()) { - displayInfoMessage(viewHolder,activity.getString(R.string.encrypted_message)); - } else { - displayInfoMessage(viewHolder, - activity.getString(R.string.install_openkeychain)); - if (viewHolder != null) { - viewHolder.message_box - .setOnClickListener(new OnClickListener() { - - @Override - public void onClick(View v) { - activity.showInstallPgpDialog(); - } - }); - } - } - } else if (item.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) { - displayDecryptionFailed(viewHolder); + } else if (item.getEncryption() == Message.ENCRYPTION_PGP) { + if (activity.hasPgp()) { + displayInfoMessage(viewHolder,activity.getString(R.string.encrypted_message)); } else { - displayTextMessage(viewHolder, item); + displayInfoMessage(viewHolder, + activity.getString(R.string.install_openkeychain)); + if (viewHolder != null) { + viewHolder.message_box + .setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + activity.showInstallPgpDialog(); + } + }); + } } + } else if (item.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) { + displayDecryptionFailed(viewHolder); + } else { + displayTextMessage(viewHolder, item); } displayStatus(viewHolder, item); @@ -560,8 +553,8 @@ public class MessageAdapter extends ArrayAdapter<Message> { } } - public void openDonwloadable(Message message) { - DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message); + public void openDonwloadable(DownloadableFile file) { + Log.d(Config.LOGTAG,"file "+file.getAbsolutePath()); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), file.getMimeType()); getContext().startActivity(intent); |