aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2015-10-23 22:20:54 +0200
committersteckbrief <steckbrief@chefmail.de>2015-10-23 22:20:54 +0200
commit7aed735df28984e76486f23d17d02981b268930e (patch)
treeff419b6ac84ff52bf58b8a45b3f1dafc7b0673bf /src/main
parent57cfcefd527195b67b3d96cde921f0f598690946 (diff)
Fixes FS#47: WiFi only setting in unencrypted chats bug fixed, typo in values for the setting fixed, preferences involved in the decision for auto downloading image links moved to global Utility Class
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ConversationsPlusApplication.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java15
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/crypto/PgpEngine.java5
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/http/HttpDownloadConnection.java3
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java7
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/AbstractConnectionManager.java4
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java5
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnection.java6
-rw-r--r--src/main/java/de/tzur/conversations/Settings.java14
-rw-r--r--src/main/res/values-de/strings.xml2
-rw-r--r--src/main/res/values/strings.xml4
11 files changed, 39 insertions, 30 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusApplication.java b/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusApplication.java
index 5c669650..9ec39de8 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusApplication.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusApplication.java
@@ -25,6 +25,10 @@ public class ConversationsPlusApplication extends Application {
ConversationsPlusPreferences.init(PreferenceManager.getDefaultSharedPreferences(getAppContext()));
}
+ public static ConversationsPlusApplication getInstance() {
+ return ConversationsPlusApplication.instance;
+ }
+
/**
* Returns the application's context.
* @return Context the application's context
diff --git a/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java b/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java
index 788aed41..b20cfb8f 100644
--- a/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java
+++ b/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java
@@ -13,6 +13,21 @@ public class ConversationsPlusPreferences extends Settings {
private static ConversationsPlusPreferences instance;
private final SharedPreferences sharedPreferences;
+ /**
+ * Whether automatic downloads should only be done when connected to Wifi or not.
+ * @return
+ */
+ public static boolean autoDownloadFileWLAN() {
+ return getBoolean("auto_download_file_wlan", true);
+ }
+ /**
+ * Whether image-links should be downloaded or not.
+ * @return
+ */
+ public static boolean autoDownloadFileLink() {
+ return getBoolean("auto_download_file_link", true);
+ }
+
public static boolean showDynamicTags() {
return getBoolean("show_dynamic_tags", false);
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/crypto/PgpEngine.java b/src/main/java/de/thedevstack/conversationsplus/crypto/PgpEngine.java
index 49c8db54..531aca32 100644
--- a/src/main/java/de/thedevstack/conversationsplus/crypto/PgpEngine.java
+++ b/src/main/java/de/thedevstack/conversationsplus/crypto/PgpEngine.java
@@ -13,6 +13,7 @@ import org.openintents.openpgp.OpenPgpSignatureResult;
import org.openintents.openpgp.util.OpenPgpApi;
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback;
+import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
import de.tzur.conversations.Settings;
import de.thedevstack.conversationsplus.R;
import de.thedevstack.conversationsplus.entities.Account;
@@ -61,9 +62,9 @@ public class PgpEngine {
final HttpConnectionManager manager = mXmppConnectionService.getHttpConnectionManager();
if (message.trusted()
&& message.treatAsDownloadable() != Message.Decision.NEVER
- && Settings.DOWNLOAD_IMAGE_LINKS
+ && ConversationsPlusPreferences.autoDownloadFileLink()
&& mXmppConnectionService.isDownloadAllowedInConnection()
- && manager.getAutoAcceptFileSize() > 0) {
+ && ConversationsPlusPreferences.autoAcceptFileSize() > 0) {
manager.createNewDownloadConnection(message);
}
callback.success(message);
diff --git a/src/main/java/de/thedevstack/conversationsplus/http/HttpDownloadConnection.java b/src/main/java/de/thedevstack/conversationsplus/http/HttpDownloadConnection.java
index 834539d5..b7f3cc67 100644
--- a/src/main/java/de/thedevstack/conversationsplus/http/HttpDownloadConnection.java
+++ b/src/main/java/de/thedevstack/conversationsplus/http/HttpDownloadConnection.java
@@ -17,6 +17,7 @@ import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLHandshakeException;
import de.thedevstack.conversationsplus.Config;
+import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
import de.thedevstack.conversationsplus.R;
import de.thedevstack.conversationsplus.entities.Transferable;
import de.thedevstack.conversationsplus.entities.DownloadableFile;
@@ -150,7 +151,7 @@ public class HttpDownloadConnection implements Transferable {
return;
}
file.setExpectedSize(size);
- if (size != -1 && size <= mHttpConnectionManager.getAutoAcceptFileSize()) {
+ if (size != -1 && size <= ConversationsPlusPreferences.autoAcceptFileSize()) {
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 2969a18d..aa04df2b 100644
--- a/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java
+++ b/src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java
@@ -23,6 +23,7 @@ import de.thedevstack.conversationsplus.xmpp.chatstate.ChatState;
import de.thedevstack.conversationsplus.xmpp.jid.Jid;
import de.thedevstack.conversationsplus.xmpp.pep.Avatar;
import de.thedevstack.conversationsplus.xmpp.stanzas.MessagePacket;
+import de.tzur.conversations.Settings;
public class MessageParser extends AbstractParser implements
OnMessagePacketReceived {
@@ -368,7 +369,11 @@ public class MessageParser extends AbstractParser implements
mXmppConnectionService.databaseBackend.createMessage(message);
}
final HttpConnectionManager manager = this.mXmppConnectionService.getHttpConnectionManager();
- if (message.trusted() && message.treatAsDownloadable() != Message.Decision.NEVER && manager.getAutoAcceptFileSize() > 0) {
+ if (message.trusted()
+ && message.treatAsDownloadable() != Message.Decision.NEVER
+ && ConversationsPlusPreferences.autoAcceptFileSize() > 0
+ && ConversationsPlusPreferences.autoDownloadFileLink()
+ && mXmppConnectionService.isDownloadAllowedInConnection()) {
manager.createNewDownloadConnection(message);
} else if (!message.isRead()) {
mXmppConnectionService.getNotificationService().push(message);
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/AbstractConnectionManager.java b/src/main/java/de/thedevstack/conversationsplus/services/AbstractConnectionManager.java
index 00c78348..6936c635 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/AbstractConnectionManager.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/AbstractConnectionManager.java
@@ -12,8 +12,4 @@ public class AbstractConnectionManager {
public XmppConnectionService getXmppConnectionService() {
return this.mXmppConnectionService;
}
-
- public long getAutoAcceptFileSize() {
- return ConversationsPlusPreferences.autoAcceptFileSize();
- }
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java b/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java
index 212bc76a..25d6a389 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java
@@ -47,6 +47,7 @@ import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import de.duenndns.ssl.MemorizingTrustManager;
+import de.thedevstack.conversationsplus.ConversationsPlusApplication;
import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
import de.tzur.conversations.Settings;
import de.thedevstack.conversationsplus.Config;
@@ -578,7 +579,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
* check whether we are allowed to download at the moment
*/
public boolean isDownloadAllowedInConnection() {
- if (Settings.DOWNLOAD_ONLY_WLAN) {
+ if (ConversationsPlusPreferences.autoDownloadFileWLAN()) {
return isWifiConnected();
}
return true;
@@ -588,7 +589,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
* check whether wifi is connected
*/
public boolean isWifiConnected() {
- ConnectivityManager cm = (ConnectivityManager) getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
+ ConnectivityManager cm = (ConnectivityManager) ConversationsPlusApplication.getInstance().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo niWifi = cm.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
return niWifi.isConnected();
}
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 7b7aefee..e3dcbe6c 100644
--- a/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnection.java
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnection.java
@@ -13,6 +13,7 @@ import android.net.Uri;
import android.os.SystemClock;
import android.util.Log;
import de.thedevstack.conversationsplus.Config;
+import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
import de.thedevstack.conversationsplus.entities.Account;
import de.thedevstack.conversationsplus.entities.Conversation;
import de.thedevstack.conversationsplus.entities.Transferable;
@@ -319,7 +320,7 @@ public class JingleConnection implements Transferable {
message.setBody(Long.toString(size));
conversation.add(message);
mXmppConnectionService.updateConversationUi();
- if (size <= this.mJingleConnectionManager.getAutoAcceptFileSize()
+ if (size <= ConversationsPlusPreferences.autoAcceptFileSize()
&& mXmppConnectionService.isDownloadAllowedInConnection()) {
Log.d(Config.LOGTAG, "auto accepting file from "
+ packet.getFrom());
@@ -331,8 +332,7 @@ public class JingleConnection implements Transferable {
"not auto accepting new file offer with size: "
+ size
+ " allowed size:"
- + this.mJingleConnectionManager
- .getAutoAcceptFileSize());
+ + ConversationsPlusPreferences.autoAcceptFileSize());
this.mXmppConnectionService.getNotificationService()
.push(message);
}
diff --git a/src/main/java/de/tzur/conversations/Settings.java b/src/main/java/de/tzur/conversations/Settings.java
index 23eb3ee4..ffdce86d 100644
--- a/src/main/java/de/tzur/conversations/Settings.java
+++ b/src/main/java/de/tzur/conversations/Settings.java
@@ -40,12 +40,6 @@ public abstract class Settings {
case "led_notify_color":
Settings.LED_COLOR = preferences.getInt(name, Settings.LED_COLOR);
break;
- case "auto_download_file_wlan":
- Settings.DOWNLOAD_ONLY_WLAN = preferences.getBoolean(name, Settings.DOWNLOAD_ONLY_WLAN);
- break;
- case "auto_download_file_link":
- Settings.DOWNLOAD_IMAGE_LINKS = preferences.getBoolean(name, Settings.DOWNLOAD_IMAGE_LINKS);
- break;
case "confirm_messages_list":
int iPref = Settings.CONFIRM_MESSAGE_RECEIVED && Settings.CONFIRM_MESSAGE_READ ? 2 : Settings.CONFIRM_MESSAGE_RECEIVED ? 1 : 0;
try {
@@ -72,14 +66,6 @@ public abstract class Settings {
*/
public static int LED_COLOR = 0xffffffff;
/**
- * Boolean if image-links should be downloaded or not.
- */
- public static boolean DOWNLOAD_IMAGE_LINKS = true;
- /**
- * Boolean if automatic downloads should be done only jif connected to WLAN.
- */
- public static boolean DOWNLOAD_ONLY_WLAN = true;
- /**
* Boolean if confirm received messages
*/
public static boolean CONFIRM_MESSAGE_RECEIVED = true;
diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml
index 16ed5239..5bd93fa8 100644
--- a/src/main/res/values-de/strings.xml
+++ b/src/main/res/values-de/strings.xml
@@ -102,7 +102,7 @@
<string name="pref_accept_files_size">Größe</string>
<string name="pref_accept_files_size_summary">Dateien, die kleiner sind als …, automatisch annehmen</string>
<string name="pref_accept_files_download">nur WLAN</string>
- <string name="pref_accept_files_download_summary">Automatisches Herunterladen und Akzpetieren von Dateien nur im WLAN</string>
+ <string name="pref_accept_files_download_summary">Automatisches Herunterladen und Akzeptieren von Dateien nur im WLAN</string>
<string name="pref_accept_files_download_link">Bilder-Links</string>
<string name="pref_accept_files_download_link_summary">Bilder-Links automatisch herunterladen</string>
<string name="pref_notification_settings">Benachrichtigungen</string>
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index b3786b35..d44dd76a 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -103,8 +103,8 @@
<string name="pref_accept_files_summary">Settings for accepting and automatically downloading files</string>
<string name="pref_accept_files_size">Size</string>
<string name="pref_accept_files_size_summary">Automatically accept files smaller than…</string>
- <string name="pref_accept_files_download">WLAN only</string>
- <string name="pref_accept_files_download_summary">Download and accept files automatically only when using WLAN</string>
+ <string name="pref_accept_files_download">Wi-Fi only</string>
+ <string name="pref_accept_files_download_summary">Download and accept files automatically only when using Wi-Fi</string>
<string name="pref_accept_files_download_link">Image links</string>
<string name="pref_accept_files_download_link_summary">Automatically download image links</string>
<string name="pref_notification_settings">Notification Settings</string>