From b51ce43d36aad7633ac504b952be65a05116e20e Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 20 Mar 2016 17:24:15 +0100 Subject: don't show v\omemo keys as such if not enabled --- .../java/eu/siacs/conversations/ui/ContactDetailsActivity.java | 2 +- src/main/java/eu/siacs/conversations/ui/XmppActivity.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java index 4165b4be..e4fc59fa 100644 --- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -456,7 +456,7 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd private void onOmemoKeyClicked(Account account, String fingerprint) { final XmppAxolotlSession.Trust trust = account.getAxolotlService().getFingerprintTrust(fingerprint); - if (trust != null && trust == XmppAxolotlSession.Trust.TRUSTED_X509) { + if (Config.X509_VERIFICATION && trust != null && trust == XmppAxolotlSession.Trust.TRUSTED_X509) { X509Certificate x509Certificate = account.getAxolotlService().getFingerprintCertificate(fingerprint); if (x509Certificate != null) { showCertificateInformationDialog(CryptoHelper.extractCertificateInformation(x509Certificate)); diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index c7bf738c..fe3a3031 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -737,14 +737,15 @@ public abstract class XmppActivity extends Activity { view.setOnLongClickListener(purge); key.setOnLongClickListener(purge); keyType.setOnLongClickListener(purge); - boolean x509 = trust == XmppAxolotlSession.Trust.TRUSTED_X509 || trust == XmppAxolotlSession.Trust.INACTIVE_TRUSTED_X509; + boolean x509 = Config.X509_VERIFICATION + && (trust == XmppAxolotlSession.Trust.TRUSTED_X509 || trust == XmppAxolotlSession.Trust.INACTIVE_TRUSTED_X509); switch (trust) { case UNTRUSTED: case TRUSTED: case TRUSTED_X509: trustToggle.setChecked(trust.trusted(), false); - trustToggle.setEnabled(trust != XmppAxolotlSession.Trust.TRUSTED_X509); - if (trust == XmppAxolotlSession.Trust.TRUSTED_X509) { + trustToggle.setEnabled(!Config.X509_VERIFICATION || trust != XmppAxolotlSession.Trust.TRUSTED_X509); + if (Config.X509_VERIFICATION && trust == XmppAxolotlSession.Trust.TRUSTED_X509) { trustToggle.setOnClickListener(null); } key.setTextColor(getPrimaryTextColor()); -- cgit v1.2.3 From 7df24407dcbe6b19af7996cc0752531958c133d2 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 20 Mar 2016 17:24:41 +0100 Subject: be more careful to avoid creating multiple connections --- .../eu/siacs/conversations/services/XmppConnectionService.java | 1 + src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index ecf5504b..99f2e09a 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2578,6 +2578,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } Thread thread = new Thread(connection); connection.setInteractive(interactive); + connection.prepareNewConnection(); thread.start(); scheduleWakeUpCall(Config.CONNECT_DISCO_TIMEOUT, account.getUuid().hashCode()); } else { diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 72996e4b..fd0e355d 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -219,12 +219,16 @@ public class XmppConnection implements Runnable { } } + public void prepareNewConnection() { + this.lastConnect = SystemClock.elapsedRealtime(); + this.lastPingSent = SystemClock.elapsedRealtime(); + this.lastDiscoStarted = Long.MAX_VALUE; + this.changeStatus(Account.State.CONNECTING); + } + protected void connect() { Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": connecting"); features.encryptionEnabled = false; - lastConnect = SystemClock.elapsedRealtime(); - lastPingSent = SystemClock.elapsedRealtime(); - lastDiscoStarted = Long.MAX_VALUE; this.attempt++; switch (account.getJid().getDomainpart()) { case "chat.facebook.com": -- cgit v1.2.3 From ac09011690e2edacb2a0b2bfeb2b33b5943d2e68 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 20 Mar 2016 17:25:16 +0100 Subject: be less strict when sharing EXTRA_TEXT intents --- src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java index 4ec43c27..ae722081 100644 --- a/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ShareWithActivity.java @@ -187,7 +187,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer if (Intent.ACTION_SEND.equals(action)) { final String text = intent.getStringExtra(Intent.EXTRA_TEXT); final Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM); - if (type != null && uri != null && text == null) { + if (type != null && uri != null && (text == null || !type.equals("text/plain"))) { this.share.uris.clear(); this.share.uris.add(uri); this.share.image = type.startsWith("image/") || isImage(uri); -- cgit v1.2.3 From 135c8567a566e2c12f98a578dcd606dfdf2b06bb Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 20 Mar 2016 17:33:42 +0100 Subject: show room nick for /me command in sent muc messages. fixes #1773 --- src/main/java/eu/siacs/conversations/utils/UIHelper.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java index 8cae8117..add3d80c 100644 --- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java @@ -225,9 +225,10 @@ public class UIHelper { } public static String getMessageDisplayName(final Message message) { + final Conversation conversation = message.getConversation(); if (message.getStatus() == Message.STATUS_RECEIVED) { final Contact contact = message.getContact(); - if (message.getConversation().getMode() == Conversation.MODE_MULTI) { + if (conversation.getMode() == Conversation.MODE_MULTI) { if (contact != null) { return contact.getDisplayName(); } else { @@ -237,10 +238,10 @@ public class UIHelper { return contact != null ? contact.getDisplayName() : ""; } } else { - if (message.getConversation().getMode() == Conversation.MODE_MULTI) { - return getDisplayedMucCounterpart(message.getConversation().getJid()); + if (conversation.getMode() == Conversation.MODE_MULTI) { + return conversation.getMucOptions().getSelf().getName(); } else { - final Jid jid = message.getConversation().getAccount().getJid(); + final Jid jid = conversation.getAccount().getJid(); return jid.hasLocalpart() ? jid.getLocalpart() : jid.toDomainJid().toString(); } } -- cgit v1.2.3 From 6ba90ec43c59496fa69ceef51e4b945e61874517 Mon Sep 17 00:00:00 2001 From: licaon-kter Date: Tue, 22 Mar 2016 11:54:45 +0200 Subject: Typo `attempt` --- .../java/eu/siacs/conversations/services/XmppConnectionService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 99f2e09a..2159e92e 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -665,7 +665,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } private void resetAllAttemptCounts(boolean reallyAll) { - Log.d(Config.LOGTAG, "resetting all attepmt counts"); + Log.d(Config.LOGTAG, "resetting all attempt counts"); for (Account account : accounts) { if (account.hasErrorStatus() || reallyAll) { final XmppConnection connection = account.getXmppConnection(); -- cgit v1.2.3 From 564113669e214bab604bb760aa4105e280845b33 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 23 Mar 2016 12:04:23 +0100 Subject: update build deps --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index bbd0fea6..ee0da247 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ dependencies { compile project(':libs:MemorizingTrustManager') compile 'org.sufficientlysecure:openpgp-api:10.0' compile 'com.soundcloud.android:android-crop:1.0.1@aar' - compile 'com.android.support:support-v13:23.1.1' + compile 'com.android.support:support-v13:23.2.0' compile 'org.bouncycastle:bcprov-jdk15on:1.52' compile 'org.bouncycastle:bcmail-jdk15on:1.52' compile 'org.jitsi:org.otr4j:0.22' @@ -48,7 +48,7 @@ dependencies { compile 'com.kyleduo.switchbutton:library:1.2.8' compile 'org.whispersystems:axolotl-android:1.3.4' compile 'com.makeramen:roundedimageview:2.2.0' - playstoreCompile 'com.google.android.gms:play-services-gcm:8.3.0' + playstoreCompile 'com.google.android.gms:play-services-gcm:8.4.0' } android { -- cgit v1.2.3 From 281cb6504683ae2b8b957e18ff3f7f7f94941777 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 23 Mar 2016 12:20:09 +0100 Subject: only add image files to media scanner --- .../eu/siacs/conversations/crypto/PgpEngine.java | 4 +--- .../siacs/conversations/generator/IqGenerator.java | 1 - .../conversations/http/HttpDownloadConnection.java | 4 +--- .../conversations/http/HttpUploadConnection.java | 4 +--- .../conversations/persistance/FileBackend.java | 22 ++++++++++++++++++++++ .../xmpp/jingle/JingleConnection.java | 4 +--- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java b/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java index 0afcb9e1..c05cf2ee 100644 --- a/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java +++ b/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java @@ -106,9 +106,7 @@ public class PgpEngine { PgpEngine.this.mXmppConnectionService .updateMessage(message); inputFile.delete(); - Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); - intent.setData(Uri.fromFile(outputFile)); - mXmppConnectionService.sendBroadcast(intent); + mXmppConnectionService.getFileBackend().addImageFileToMedia(outputFile); callback.success(message); return; case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: diff --git a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java index a3b0f650..b7911ef7 100644 --- a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java +++ b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java @@ -25,7 +25,6 @@ import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.utils.Xmlns; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xmpp.forms.Data; -import eu.siacs.conversations.xmpp.forms.Field; import eu.siacs.conversations.xmpp.jid.Jid; import eu.siacs.conversations.xmpp.pep.Avatar; import eu.siacs.conversations.xmpp.stanzas.IqPacket; diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java index 84a44715..161a73f6 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java @@ -129,9 +129,7 @@ public class HttpDownloadConnection implements Transferable { } private void finish() { - Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); - intent.setData(Uri.fromFile(file)); - mXmppConnectionService.sendBroadcast(intent); + mXmppConnectionService.getFileBackend().addImageFileToMedia(file); message.setTransferable(null); mHttpConnectionManager.finishConnection(this); if (message.getEncryption() == Message.ENCRYPTION_PGP) { diff --git a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java index 1e4b9102..4d880ffc 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java @@ -196,9 +196,7 @@ public class HttpUploadConnection implements Transferable { mGetUrl = new URL(mGetUrl.toString() + "#" + CryptoHelper.bytesToHex(key)); } mXmppConnectionService.getFileBackend().updateFileParams(message, mGetUrl); - Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); - intent.setData(Uri.fromFile(file)); - mXmppConnectionService.sendBroadcast(intent); + mXmppConnectionService.getFileBackend().addImageFileToMedia(file); message.setTransferable(null); message.setCounterpart(message.getConversation().getJid().toBareJid()); if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) { diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 4bdf080c..8aa4f064 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -1,5 +1,6 @@ package eu.siacs.conversations.persistance; +import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -50,6 +51,27 @@ public class FileBackend { this.mXmppConnectionService = service; } + private void createNoMedia() { + final File nomedia = new File(getConversationsFileDirectory()+".nomedia"); + if (!nomedia.exists()) { + try { + nomedia.createNewFile(); + } catch (Exception e) { + Log.d(Config.LOGTAG, "could not create nomedia file"); + } + } + } + + public void addImageFileToMedia(File file) { + if (file.getAbsolutePath().startsWith(getConversationsImageDirectory())) { + Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); + intent.setData(Uri.fromFile(file)); + mXmppConnectionService.sendBroadcast(intent); + } else { + createNoMedia(); + } + } + public DownloadableFile getFile(Message message) { return getFile(message, true); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index dcb13c23..2f8b9841 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -111,9 +111,7 @@ public class JingleConnection implements Transferable { } Log.d(Config.LOGTAG,"successfully transmitted file:" + file.getAbsolutePath()+" ("+file.getSha1Sum()+")"); if (message.getEncryption() != Message.ENCRYPTION_PGP) { - Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); - intent.setData(Uri.fromFile(file)); - mXmppConnectionService.sendBroadcast(intent); + mXmppConnectionService.getFileBackend().addImageFileToMedia(file); } else { account.getPgpDecryptionService().add(message); } -- cgit v1.2.3 From a9b66e3ea588a0e9e621d10ad15c9456b0312b60 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 23 Mar 2016 19:23:22 +0100 Subject: allow to delete attachments. fixes #1539 --- .../eu/siacs/conversations/crypto/PgpEngine.java | 3 +- .../conversations/http/HttpDownloadConnection.java | 10 ++----- .../conversations/http/HttpUploadConnection.java | 7 +---- .../conversations/persistance/FileBackend.java | 14 ++++++++-- .../conversations/ui/ConversationFragment.java | 32 +++++++++++++++++----- .../xmpp/jingle/JingleConnection.java | 5 +--- src/main/res/menu/message_context.xml | 5 +++- src/main/res/values/strings.xml | 1 + 8 files changed, 46 insertions(+), 31 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java b/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java index c05cf2ee..7ca5bea0 100644 --- a/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java +++ b/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java @@ -2,7 +2,6 @@ package eu.siacs.conversations.crypto; import android.app.PendingIntent; import android.content.Intent; -import android.net.Uri; import org.openintents.openpgp.OpenPgpSignatureResult; import org.openintents.openpgp.util.OpenPgpApi; @@ -106,7 +105,7 @@ public class PgpEngine { PgpEngine.this.mXmppConnectionService .updateMessage(message); inputFile.delete(); - mXmppConnectionService.getFileBackend().addImageFileToMedia(outputFile); + mXmppConnectionService.getFileBackend().updateMediaScanner(outputFile); callback.success(message); return; case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java index 161a73f6..d23cb71a 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java @@ -1,7 +1,5 @@ package eu.siacs.conversations.http; -import android.content.Intent; -import android.net.Uri; import android.os.PowerManager; import android.util.Log; @@ -10,12 +8,8 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; -import java.net.InetAddress; -import java.net.InetSocketAddress; import java.net.MalformedURLException; -import java.net.Proxy; import java.net.URL; -import java.util.Arrays; import java.util.concurrent.CancellationException; import javax.net.ssl.HttpsURLConnection; @@ -94,7 +88,7 @@ public class HttpDownloadConnection implements Transferable { } else { extension = lastPart; } - message.setRelativeFilePath(message.getUuid()+"."+extension); + message.setRelativeFilePath(message.getUuid() + "." + extension); this.file = mXmppConnectionService.getFileBackend().getFile(message, false); String reference = mUrl.getRef(); if (reference != null && reference.length() == 96) { @@ -129,7 +123,7 @@ public class HttpDownloadConnection implements Transferable { } private void finish() { - mXmppConnectionService.getFileBackend().addImageFileToMedia(file); + mXmppConnectionService.getFileBackend().updateMediaScanner(file); message.setTransferable(null); mHttpConnectionManager.finishConnection(this); if (message.getEncryption() == Message.ENCRYPTION_PGP) { diff --git a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java index 4d880ffc..e337509b 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpUploadConnection.java @@ -1,8 +1,6 @@ package eu.siacs.conversations.http; import android.app.PendingIntent; -import android.content.Intent; -import android.net.Uri; import android.os.PowerManager; import android.util.Log; import android.util.Pair; @@ -12,10 +10,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; -import java.net.InetAddress; -import java.net.InetSocketAddress; import java.net.MalformedURLException; -import java.net.Proxy; import java.net.URL; import javax.net.ssl.HttpsURLConnection; @@ -196,7 +191,7 @@ public class HttpUploadConnection implements Transferable { mGetUrl = new URL(mGetUrl.toString() + "#" + CryptoHelper.bytesToHex(key)); } mXmppConnectionService.getFileBackend().updateFileParams(message, mGetUrl); - mXmppConnectionService.getFileBackend().addImageFileToMedia(file); + mXmppConnectionService.getFileBackend().updateMediaScanner(file); message.setTransferable(null); message.setCounterpart(message.getConversation().getJid().toBareJid()); if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) { diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 8aa4f064..18c195f1 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -27,7 +27,6 @@ import java.security.DigestOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; -import java.util.Arrays; import java.util.Date; import java.util.Locale; @@ -35,7 +34,6 @@ import eu.siacs.conversations.Config; import eu.siacs.conversations.R; import eu.siacs.conversations.entities.DownloadableFile; import eu.siacs.conversations.entities.Message; -import eu.siacs.conversations.entities.Transferable; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.utils.CryptoHelper; import eu.siacs.conversations.utils.ExifHelper; @@ -62,7 +60,7 @@ public class FileBackend { } } - public void addImageFileToMedia(File file) { + public void updateMediaScanner(File file) { if (file.getAbsolutePath().startsWith(getConversationsImageDirectory())) { Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); intent.setData(Uri.fromFile(file)); @@ -72,6 +70,16 @@ public class FileBackend { } } + public boolean deleteFile(Message message) { + File file = getFile(message); + if (file.delete()) { + updateMediaScanner(file); + return true; + } else { + return false; + } + } + public DownloadableFile getFile(Message message) { return getFile(message, true); } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 1665090c..679e2a03 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -527,6 +527,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa relevantForCorrection = relevantForCorrection.next(); } if (m.getType() != Message.TYPE_STATUS) { + final boolean treatAsFile = m.getType() != Message.TYPE_TEXT + && m.getType() != Message.TYPE_PRIVATE + && t == null; activity.getMenuInflater().inflate(R.menu.message_context, menu); menu.setHeaderTitle(R.string.message_options); MenuItem copyText = menu.findItem(R.id.copy_text); @@ -537,8 +540,8 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa MenuItem copyUrl = menu.findItem(R.id.copy_url); MenuItem downloadFile = menu.findItem(R.id.download_file); MenuItem cancelTransmission = menu.findItem(R.id.cancel_transmission); - if ((m.getType() == Message.TYPE_TEXT || m.getType() == Message.TYPE_PRIVATE) - && t == null + MenuItem deleteFile = menu.findItem(R.id.delete_file); + if (!treatAsFile && !GeoHelper.isGeoUri(m.getBody()) && m.treatAsDownloadable() != Message.Decision.MUST) { copyText.setVisible(true); @@ -550,10 +553,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa && relevantForCorrection.isLastCorrectableMessage()) { correctMessage.setVisible(true); } - if ((m.getType() != Message.TYPE_TEXT - && m.getType() != Message.TYPE_PRIVATE - && t == null) - || (GeoHelper.isGeoUri(m.getBody()))) { + if (treatAsFile || (GeoHelper.isGeoUri(m.getBody()))) { shareWith.setVisible(true); } if (m.getStatus() == Message.STATUS_SEND_FAILED) { @@ -575,6 +575,10 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa || m.getStatus() == Message.STATUS_OFFERED))) { cancelTransmission.setVisible(true); } + if (treatAsFile) { + deleteFile.setVisible(true); + deleteFile.setTitle(activity.getString(R.string.delete_x_file,UIHelper.getFileDescriptionString(activity, m))); + } } } @@ -605,6 +609,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa case R.id.retry_decryption: retryDecryption(selectedMessage); return true; + case R.id.delete_file: + deleteFile(selectedMessage); + return true; default: return super.onContextItemSelected(item); } @@ -643,12 +650,22 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } } + private void deleteFile(Message message) { + if (activity.xmppConnectionService.getFileBackend().deleteFile(message)) { + message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED)); + activity.updateConversationList(); + updateMessages(); + } + } + private void resendMessage(Message message) { if (message.getType() == Message.TYPE_FILE || message.getType() == Message.TYPE_IMAGE) { DownloadableFile file = activity.xmppConnectionService.getFileBackend().getFile(message); if (!file.exists()) { Toast.makeText(activity, R.string.file_deleted, Toast.LENGTH_SHORT).show(); message.setTransferable(new TransferablePlaceholder(Transferable.STATUS_DELETED)); + activity.updateConversationList(); + updateMessages(); return; } } @@ -690,7 +707,8 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa private void retryDecryption(Message message) { message.setEncryption(Message.ENCRYPTION_PGP); - activity.xmppConnectionService.updateConversationUi(); + activity.updateConversationList(); + updateMessages(); conversation.getAccount().getPgpDecryptionService().add(message); } diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index 2f8b9841..e3eec647 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -1,7 +1,5 @@ package eu.siacs.conversations.xmpp.jingle; -import android.content.Intent; -import android.net.Uri; import android.util.Log; import android.util.Pair; @@ -9,7 +7,6 @@ import java.io.FileNotFoundException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -111,7 +108,7 @@ public class JingleConnection implements Transferable { } Log.d(Config.LOGTAG,"successfully transmitted file:" + file.getAbsolutePath()+" ("+file.getSha1Sum()+")"); if (message.getEncryption() != Message.ENCRYPTION_PGP) { - mXmppConnectionService.getFileBackend().addImageFileToMedia(file); + mXmppConnectionService.getFileBackend().updateMediaScanner(file); } else { account.getPgpDecryptionService().add(message); } diff --git a/src/main/res/menu/message_context.xml b/src/main/res/menu/message_context.xml index 4096297c..bc8acede 100644 --- a/src/main/res/menu/message_context.xml +++ b/src/main/res/menu/message_context.xml @@ -33,5 +33,8 @@ android:id="@+id/cancel_transmission" android:title="@string/cancel_transmission" android:visible="false"/> - + \ No newline at end of file diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 70883507..082c10b9 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -385,6 +385,7 @@ Choose file Receiving %1$s (%2$d%% completed) Download %s + Delete %s file Open %s sending (%1$d%% completed) -- cgit v1.2.3 From 46be514b4db1cb8c17037ac6cd307078e4794a12 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 23 Mar 2016 19:24:54 +0100 Subject: version bump to 1.11.2 and changelog --- CHANGELOG.md | 5 +++++ build.gradle | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a6bb27e..b9b3881c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ###Changelog +####Version 1.11.2 +* only add image files to media scanner +* allow to delete files +* various bug fixes + ####Version 1.11.1 * fixed some bugs when sharing files with Conversations diff --git a/build.gradle b/build.gradle index ee0da247..d190dd09 100644 --- a/build.gradle +++ b/build.gradle @@ -58,8 +58,8 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 23 - versionCode 133 - versionName "1.11.1" + versionCode 134 + versionName "1.11.2" archivesBaseName += "-$versionName" applicationId "eu.siacs.conversations" } -- cgit v1.2.3