aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/services
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-02-09 16:24:32 +0100
committerChristian Schneppe <christian@pix-art.de>2017-02-09 16:24:32 +0100
commit9e63ebae836f64163ac1a9b5c4d772b576112131 (patch)
tree7b1be6beecc87689eb85fd8337add36176d1de4d /src/main/java/de/pixart/messenger/services
parent49fb5e29cd931a504bd414c3398cb0e39fa17da6 (diff)
resend failed uploads automatically if filesize smaller than configured AutoAcceptFilesize
Diffstat (limited to 'src/main/java/de/pixart/messenger/services')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 729079f2a..5065d4242 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -173,6 +173,8 @@ public class XmppConnectionService extends Service {
private WakeLock wakeLock;
private long mLastActivity = 0;
private NotificationManager mNotifyManager;
+ AbstractConnectionManager mAbstractConnectionManager;
+
private ContentObserver contactObserver = new ContentObserver(null) {
@Override
public void onChange(boolean selfChange) {
@@ -345,6 +347,7 @@ public class XmppConnectionService extends Service {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": couldn't start OTR with " + conversation.getContact().getJid() + " when needed");
}
sendUnsentMessages(conversation);
+ resendFailedFileMessages(conversation);
}
}
for (Conversation conversation : account.pendingConferenceLeaves) {
@@ -1404,6 +1407,36 @@ public class XmppConnectionService extends Service {
});
}
+ private long AcceptFileSize() {
+ String config = "0";
+ SharedPreferences sharedPref = getPreferences();
+ if (isWIFI()) {
+ config = sharedPref.getString("auto_accept_file_size_wifi", "10485760");
+ } else if (isMobile() && !isMobileRoaming()) {
+ config = sharedPref.getString("auto_accept_file_size_mobile", "262144");
+ } else if (isMobile() && isMobileRoaming()) {
+ config = sharedPref.getString("auto_accept_file_size_roaming", "1");
+ }
+
+ try {
+ return Long.parseLong(config);
+ } catch (NumberFormatException e) {
+ return 1048576;
+ }
+ }
+
+ private void resendFailedFileMessages(final Conversation conversation) {
+ conversation.findFailedMessagesWithFiles(new Conversation.OnMessageFound() {
+
+ @Override
+ public void onMessageFound(Message message) {
+ if (AcceptFileSize() >= message.getFileParams().size) {
+ resendMessage(message, true);
+ }
+ }
+ });
+ }
+
public void resendMessage(final Message message, final boolean delay) {
sendMessage(message, true, delay);
}