From e9b5793cefd6fd8a24a6bf710493c9bc1800850f Mon Sep 17 00:00:00 2001 From: lookshe Date: Mon, 7 Mar 2016 23:35:35 +0100 Subject: Finally fixes FS#142 --- .../conversationsplus/ConversationsPlusPreferences.java | 4 ---- src/main/res/values-de/strings.xml | 2 -- src/main/res/xml/preferences.xml | 7 ------- 3 files changed, 13 deletions(-) (limited to 'src/main') diff --git a/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java b/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java index 20eca48a..dda4208c 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java +++ b/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java @@ -133,10 +133,6 @@ public class ConversationsPlusPreferences extends Settings { return getString("notification_ringtone", null); } - public static boolean alwaysNotifyInConference() { - return getBoolean("always_notify_in_conference", false); - } - public static boolean showNotification() { return getBoolean("show_notification", true); } diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml index f91bf1dd..87cacb45 100644 --- a/src/main/res/values-de/strings.xml +++ b/src/main/res/values-de/strings.xml @@ -115,8 +115,6 @@ Vibrieren bei Erhalt einer neuen Nachricht Benachrichtigungston Benachrichtigungston wiedergeben - Konferenz-Benachrichtigungen - Benachrichtige mich bei jeder Konferenz-Nachricht und nicht nur, wenn ich angesprochen werde Gnadenfrist Deaktiviere Benachrichtigungen für eine kurze Zeit nach Erhalt einer Nachricht, die von einem anderen deiner Clients kommt. Erweiterte Optionen diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 622e772c..e468cd27 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -133,13 +133,6 @@ android:title="@string/pref_led_notification_color" app:supportsAlpha="true" android:summary="@string/pref_led_notification_color_summary"/> - - -- cgit v1.2.3 From 6578ecfe0e79c1d00d2282e05e28d5a4c950b687 Mon Sep 17 00:00:00 2001 From: lookshe Date: Mon, 7 Mar 2016 23:37:51 +0100 Subject: corrected getRealPathFromUri --- .../conversationsplus/utils/FileHelper.java | 42 ++++++++++++++++++++-- .../eu/siacs/conversations/utils/FileUtils.java | 5 +-- 2 files changed, 43 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/java/de/thedevstack/conversationsplus/utils/FileHelper.java b/src/main/java/de/thedevstack/conversationsplus/utils/FileHelper.java index 3384b54e..9772b03f 100644 --- a/src/main/java/de/thedevstack/conversationsplus/utils/FileHelper.java +++ b/src/main/java/de/thedevstack/conversationsplus/utils/FileHelper.java @@ -1,7 +1,10 @@ package de.thedevstack.conversationsplus.utils; +import android.annotation.TargetApi; +import android.content.ContentResolver; import android.database.Cursor; import android.net.Uri; +import android.provider.DocumentsContract; import android.provider.MediaStore; import de.thedevstack.conversationsplus.ConversationsPlusApplication; @@ -11,6 +14,38 @@ import de.thedevstack.conversationsplus.ConversationsPlusApplication; */ public final class FileHelper { + /** + * taken from: http://stackoverflow.com/a/29164361 + * @param uri + * @return + */ + @TargetApi(19) + private static String getRealPathFromUriLollipop(Uri uri) { + String path = null; + + String wholeID = DocumentsContract.getDocumentId(uri); + + // Split at colon, use second item in the array + String id = wholeID.split(":")[1]; + + String[] column = { MediaStore.Images.Media.DATA }; + + // where id is equal to + String sel = MediaStore.Images.Media._ID + "=?"; + + Cursor cursor = ConversationsPlusApplication.getInstance().getContentResolver(). + query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, + column, sel, new String[]{ id }, null); + + int columnIndex = cursor.getColumnIndex(column[0]); + + if (cursor.moveToFirst()) { + path = cursor.getString(columnIndex); + } + cursor.close(); + return path; + } + /** * Get the real path from an Uri. * @param uri the uri to convert to the real path @@ -18,9 +53,9 @@ public final class FileHelper { */ public static String getRealPathFromUri(Uri uri) { String path = null; - if (uri.getScheme().equals("file")) { + if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())) { return uri.getPath(); - } else if (uri.toString().startsWith("content://media/")) { + } else if (ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) { String[] projection = {MediaStore.MediaColumns.DATA}; Cursor metaCursor = ConversationsPlusApplication.getInstance().getContentResolver().query(uri, projection, null, null, null); @@ -34,6 +69,9 @@ public final class FileHelper { } } } + if (path == null) { + path = getRealPathFromUriLollipop(uri); + } return path; } diff --git a/src/main/java/eu/siacs/conversations/utils/FileUtils.java b/src/main/java/eu/siacs/conversations/utils/FileUtils.java index ad8b8640..c5d0c3b0 100644 --- a/src/main/java/eu/siacs/conversations/utils/FileUtils.java +++ b/src/main/java/eu/siacs/conversations/utils/FileUtils.java @@ -1,6 +1,7 @@ package eu.siacs.conversations.utils; import android.annotation.SuppressLint; +import android.content.ContentResolver; import android.content.ContentUris; import android.content.Context; import android.database.Cursor; @@ -76,11 +77,11 @@ public class FileUtils { } } // MediaStore (and general) - else if ("content".equalsIgnoreCase(uri.getScheme())) { + else if (ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) { return getDataColumn(context, uri, null, null); } // File - else if ("file".equalsIgnoreCase(uri.getScheme())) { + else if (ContentResolver.SCHEME_FILE.equals(uri.getScheme())) { return uri.getPath(); } -- cgit v1.2.3 From c8759af913b775645b5394eb3c1f08d8c5fe9238 Mon Sep 17 00:00:00 2001 From: lookshe Date: Mon, 7 Mar 2016 23:39:41 +0100 Subject: Fixes FS#151 - Missing button on image-links --- src/main/java/eu/siacs/conversations/crypto/PgpEngine.java | 1 - src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java | 4 +++- src/main/java/eu/siacs/conversations/parser/MessageParser.java | 3 +-- .../java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) (limited to 'src/main') diff --git a/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java b/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java index d9464f8c..0e79ea2c 100644 --- a/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java +++ b/src/main/java/eu/siacs/conversations/crypto/PgpEngine.java @@ -64,7 +64,6 @@ public class PgpEngine { if (message.trusted() && message.treatAsDownloadable() != Message.Decision.NEVER && ConversationsPlusPreferences.autoDownloadFileLink() - && mXmppConnectionService.isDownloadAllowedInConnection() && ConversationsPlusPreferences.autoAcceptFileSize() > 0) { manager.createNewDownloadConnection(message); } diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java index 1470d250..b47ff96c 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java @@ -184,7 +184,9 @@ public class HttpDownloadConnection implements Transferable { return; } file.setExpectedSize(size); - if (size != -1 && size <= ConversationsPlusPreferences.autoAcceptFileSize()) { + if (size != -1 + && size <= ConversationsPlusPreferences.autoAcceptFileSize() + && mXmppConnectionService.isDownloadAllowedInConnection()) { HttpDownloadConnection.this.acceptedAutomatically = true; new Thread(new FileDownloader(interactive)).start(); } else { diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java index 34f24f6f..ca821ce2 100644 --- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java +++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java @@ -444,8 +444,7 @@ public class MessageParser extends AbstractParser implements if (message.trusted() && message.treatAsDownloadable() != Message.Decision.NEVER && ConversationsPlusPreferences.autoAcceptFileSize() > 0 - && ConversationsPlusPreferences.autoDownloadFileLink() - && mXmppConnectionService.isDownloadAllowedInConnection()) { + && ConversationsPlusPreferences.autoDownloadFileLink()) { manager.createNewDownloadConnection(message); } else { if (query == null) { 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 052f59c6..26e6d44d 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -366,7 +366,8 @@ public class JingleConnection implements Transferable { conversation.add(message); mXmppConnectionService.updateConversationUi(); if (mJingleConnectionManager.hasStoragePermission() - && size < ConversationsPlusPreferences.autoAcceptFileSize()) { + && size <= ConversationsPlusPreferences.autoAcceptFileSize() + && mXmppConnectionService.isDownloadAllowedInConnection()) { Logging.d(Config.LOGTAG, "auto accepting file from "+ packet.getFrom()); this.acceptedAutomatically = true; this.sendAccept(); -- cgit v1.2.3