added message option to download images

This commit is contained in:
iNPUTmice 2014-10-24 19:30:03 +02:00
parent 1ea8feaf24
commit 8fb8985412
3 changed files with 18 additions and 3 deletions

View File

@ -13,5 +13,8 @@
<item <item
android:id="@+id/send_again" android:id="@+id/send_again"
android:title="@string/send_again"/> android:title="@string/send_again"/>
<item
android:id="@+id/download_image"
android:title="@string/download_image"/>
</menu> </menu>

View File

@ -355,6 +355,7 @@ public class ConversationFragment extends Fragment {
MenuItem shareImage = menu.findItem(R.id.share_image); MenuItem shareImage = menu.findItem(R.id.share_image);
MenuItem sendAgain = menu.findItem(R.id.send_again); MenuItem sendAgain = menu.findItem(R.id.send_again);
MenuItem copyUrl = menu.findItem(R.id.copy_url); MenuItem copyUrl = menu.findItem(R.id.copy_url);
MenuItem downloadImage = menu.findItem(R.id.download_image);
if (this.selectedMessage.getType() != Message.TYPE_TEXT if (this.selectedMessage.getType() != Message.TYPE_TEXT
|| this.selectedMessage.getDownloadable() != null) { || this.selectedMessage.getDownloadable() != null) {
copyText.setVisible(false); copyText.setVisible(false);
@ -372,6 +373,12 @@ public class ConversationFragment extends Fragment {
|| this.selectedMessage.getImageParams().url == null) { || this.selectedMessage.getImageParams().url == null) {
copyUrl.setVisible(false); copyUrl.setVisible(false);
} }
if (this.selectedMessage.getType() != Message.TYPE_TEXT
|| this.selectedMessage.getDownloadable() != null
|| !this.selectedMessage.bodyContainsDownloadable()) {
downloadImage.setVisible(false);
}
} }
} }
@ -390,6 +397,8 @@ public class ConversationFragment extends Fragment {
case R.id.copy_url: case R.id.copy_url:
copyUrl(selectedMessage); copyUrl(selectedMessage);
return true; return true;
case R.id.download_image:
downloadImage(selectedMessage);
default: default:
return super.onContextItemSelected(item); return super.onContextItemSelected(item);
} }
@ -427,6 +436,11 @@ public class ConversationFragment extends Fragment {
} }
} }
private void downloadImage(Message message) {
activity.xmppConnectionService.getHttpConnectionManager()
.createNewConnection(message);
}
protected void privateMessageWith(String counterpart) { protected void privateMessageWith(String counterpart) {
this.mEditMessage.setText(""); this.mEditMessage.setText("");
this.conversation.setNextPresence(counterpart); this.conversation.setNextPresence(counterpart);

View File

@ -1,8 +1,6 @@
package eu.siacs.conversations.ui; package eu.siacs.conversations.ui;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable; import android.text.Editable;