aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java16
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java40
-rw-r--r--src/main/res/values/strings.xml4
-rw-r--r--src/main/res/xml/preferences.xml20
4 files changed, 73 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java b/src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java
index 9228d0055..f888d8fd0 100644
--- a/src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java
+++ b/src/main/java/de/pixart/messenger/services/AbstractConnectionManager.java
@@ -3,6 +3,7 @@ package de.pixart.messenger.services;
import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.net.ConnectivityManager;
import android.os.Build;
import android.os.PowerManager;
import android.util.Log;
@@ -45,9 +46,18 @@ public class AbstractConnectionManager {
}
public long getAutoAcceptFileSize() {
- String config = this.mXmppConnectionService.getPreferences().getString(
- "auto_accept_file_size", "1048576");
- try {
+ String config = "0";
+ if (mXmppConnectionService.isWIFI()) {
+ config = this.mXmppConnectionService.getPreferences().getString(
+ "auto_accept_file_size_wifi", "10485760");
+ } else if (mXmppConnectionService.isMobile()) {
+ config = this.mXmppConnectionService.getPreferences().getString(
+ "auto_accept_file_size_mobile", "262144");
+ } else if (mXmppConnectionService.isMobileRoaming()) {
+ config = this.mXmppConnectionService.getPreferences().getString(
+ "auto_accept_file_size_roaming", "1");
+ }
+ try {
return Long.parseLong(config);
} catch (NumberFormatException e) {
return 1048576;
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 153c1c269..16ebd8c11 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -896,6 +896,46 @@ public class XmppConnectionService extends Service {
return activeNetwork != null && activeNetwork.isConnected();
}
+ public boolean isWIFI() {
+ ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+ if (activeNetwork != null) { // connected to the internet
+ if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isMobile() {
+ ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+ if (activeNetwork != null) { // connected to the internet
+ if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
+ if (!activeNetwork.isRoaming()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public boolean isMobileRoaming() {
+ ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+ if (activeNetwork != null) { // connected to the internet
+ if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
+ if (activeNetwork.isRoaming()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
@SuppressLint("TrulyRandom")
@Override
public void onCreate() {
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 322f9e7a0..f56ed4df1 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -100,7 +100,9 @@
<string name="pref_general">General</string>
<string name="pref_xmpp_resource">XMPP resource</string>
<string name="pref_xmpp_resource_summary">The name this client identifies itself with</string>
- <string name="pref_accept_files">Accept files</string>
+ <string name="pref_accept_files_wifi">Accept files in WiFi connections</string>
+ <string name="pref_accept_files_mobile">Accept files in mobile connections</string>
+ <string name="pref_accept_files_mobileroaming">Accept files in mobile roaming connections</string>
<string name="pref_accept_files_summary">Automatically accept files smaller than…</string>
<string name="pref_attachments">Attachments</string>
<string name="pref_return_to_previous">Quick Sharing</string>
diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml
index 8c0ca30cd..a3f15ba1a 100644
--- a/src/main/res/xml/preferences.xml
+++ b/src/main/res/xml/preferences.xml
@@ -88,12 +88,26 @@
android:key="attachments"
android:title="@string/pref_attachments">
<ListPreference
- android:defaultValue="1048576"
+ android:defaultValue="10485760"
android:entries="@array/filesizes"
android:entryValues="@array/filesizes_values"
- android:key="auto_accept_file_size"
+ android:key="auto_accept_file_size_wifi"
android:summary="@string/pref_accept_files_summary"
- android:title="@string/pref_accept_files" />
+ android:title="@string/pref_accept_files_wifi" />
+ <ListPreference
+ android:defaultValue="262144"
+ android:entries="@array/filesizes"
+ android:entryValues="@array/filesizes_values"
+ android:key="auto_accept_file_size_mobile"
+ android:summary="@string/pref_accept_files_summary"
+ android:title="@string/pref_accept_files_mobile" />
+ <ListPreference
+ android:defaultValue="1"
+ android:entries="@array/filesizes"
+ android:entryValues="@array/filesizes_values"
+ android:key="auto_accept_file_size_roaming"
+ android:summary="@string/pref_accept_files_summary"
+ android:title="@string/pref_accept_files_mobileroaming" />
<ListPreference
android:defaultValue="auto"
android:entries="@array/picture_compression_entries"