aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlookshe <github@lookshe.org>2016-03-07 23:42:13 +0100
committerlookshe <github@lookshe.org>2016-03-07 23:42:13 +0100
commit5eda297b145558b4bcdbd0fb94f8a2675691971f (patch)
tree684e9c2b287566c4c1ec001889b82e34a5ca29b3
parentd620dcdc575ff1ce4cbdaf78e3182f3418e2142d (diff)
parentc8759af913b775645b5394eb3c1f08d8c5fe9238 (diff)
Merge branch 'trz/rebase' into trz/rename
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/crypto/PgpEngine.java1
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/http/HttpDownloadConnection.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java3
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/FileHelper.java42
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/utils/FileUtils.java5
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnection.java3
-rw-r--r--src/main/res/values-de/strings.xml2
-rw-r--r--src/main/res/xml/preferences.xml7
9 files changed, 49 insertions, 22 deletions
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/java/de/thedevstack/conversationsplus/crypto/PgpEngine.java b/src/main/java/de/thedevstack/conversationsplus/crypto/PgpEngine.java
index 8a5c6101..d01dc867 100644
--- a/src/main/java/de/thedevstack/conversationsplus/crypto/PgpEngine.java
+++ b/src/main/java/de/thedevstack/conversationsplus/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/de/thedevstack/conversationsplus/http/HttpDownloadConnection.java b/src/main/java/de/thedevstack/conversationsplus/http/HttpDownloadConnection.java
index 4381ed03..0462defd 100644
--- a/src/main/java/de/thedevstack/conversationsplus/http/HttpDownloadConnection.java
+++ b/src/main/java/de/thedevstack/conversationsplus/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/de/thedevstack/conversationsplus/parser/MessageParser.java b/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java
index fd89ad00..ee6ef8b6 100644
--- a/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java
+++ b/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java
@@ -443,8 +443,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/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;
@@ -12,15 +15,47 @@ 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
* @return the real path or <code>null</code>
*/
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/de/thedevstack/conversationsplus/utils/FileUtils.java b/src/main/java/de/thedevstack/conversationsplus/utils/FileUtils.java
index 2cf5679b..a8375dc0 100644
--- a/src/main/java/de/thedevstack/conversationsplus/utils/FileUtils.java
+++ b/src/main/java/de/thedevstack/conversationsplus/utils/FileUtils.java
@@ -1,6 +1,7 @@
package de.thedevstack.conversationsplus.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();
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnection.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnection.java
index c4ceeb4e..de5f3ab1 100644
--- a/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnection.java
+++ b/src/main/java/de/thedevstack/conversationsplus/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();
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 @@
<string name="pref_vibrate_summary">Vibrieren bei Erhalt einer neuen Nachricht</string>
<string name="pref_sound">Benachrichtigungston</string>
<string name="pref_sound_summary">Benachrichtigungston wiedergeben</string>
- <string name="pref_conference_notifications">Konferenz-Benachrichtigungen</string>
- <string name="pref_conference_notifications_summary">Benachrichtige mich bei jeder Konferenz-Nachricht und nicht nur, wenn ich angesprochen werde</string>
<string name="pref_notification_grace_period">Gnadenfrist</string>
<string name="pref_notification_grace_period_summary">Deaktiviere Benachrichtigungen für eine kurze Zeit nach Erhalt einer Nachricht, die von einem anderen deiner Clients kommt.</string>
<string name="pref_advanced_options">Erweiterte Optionen</string>
diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml
index 0d19ea5a..7dac445a 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"/>
-
- <CheckBoxPreference
- android:defaultValue="true"
- android:dependency="show_notification"
- android:key="always_notify_in_conference"
- android:summary="@string/pref_conference_notifications_summary"
- android:title="@string/pref_conference_notifications" />
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_ui_options">