mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 01:32:17 -05:00
don't automatically download files and avatars when datasaver is on
This commit is contained in:
parent
3d5940cb76
commit
caafd03130
@ -183,7 +183,9 @@ public class HttpDownloadConnection implements Transferable {
|
||||
return;
|
||||
}
|
||||
file.setExpectedSize(size);
|
||||
if (mHttpConnectionManager.hasStoragePermission() && size <= mHttpConnectionManager.getAutoAcceptFileSize()) {
|
||||
if (mHttpConnectionManager.hasStoragePermission()
|
||||
&& size <= mHttpConnectionManager.getAutoAcceptFileSize()
|
||||
&& mXmppConnectionService.isDataSaverDisabled()) {
|
||||
HttpDownloadConnection.this.acceptedAutomatically = true;
|
||||
new Thread(new FileDownloader(interactive)).start();
|
||||
} else {
|
||||
|
@ -238,7 +238,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||
mXmppConnectionService.updateConversationUi();
|
||||
mXmppConnectionService.updateRosterUi();
|
||||
}
|
||||
} else {
|
||||
} else if (mXmppConnectionService.isDataSaverDisabled()) {
|
||||
mXmppConnectionService.fetchAvatar(account, avatar);
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class PresenceParser extends AbstractParser implements
|
||||
if (user.setAvatar(avatar)) {
|
||||
mXmppConnectionService.getAvatarService().clear(user);
|
||||
}
|
||||
} else {
|
||||
} else if (mXmppConnectionService.isDataSaverDisabled()) {
|
||||
mXmppConnectionService.fetchAvatar(mucOptions.getAccount(), avatar);
|
||||
}
|
||||
}
|
||||
@ -192,7 +192,7 @@ public class PresenceParser extends AbstractParser implements
|
||||
mXmppConnectionService.updateConversationUi();
|
||||
mXmppConnectionService.updateRosterUi();
|
||||
}
|
||||
} else {
|
||||
} else if (mXmppConnectionService.isDataSaverDisabled()){
|
||||
mXmppConnectionService.fetchAvatar(account, avatar);
|
||||
}
|
||||
}
|
||||
|
@ -697,6 +697,16 @@ public class XmppConnectionService extends Service {
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
public boolean isDataSaverDisabled() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
|
||||
return !connectivityManager.isActiveNetworkMetered()
|
||||
|| connectivityManager.getRestrictBackgroundStatus() == ConnectivityManager.RESTRICT_BACKGROUND_STATUS_DISABLED;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void directReply(Conversation conversation, String body) {
|
||||
Message message = new Message(conversation,body,conversation.getNextEncryption());
|
||||
message.markUnread();
|
||||
|
@ -389,7 +389,8 @@ public class JingleConnection implements Transferable {
|
||||
conversation.add(message);
|
||||
mXmppConnectionService.updateConversationUi();
|
||||
if (mJingleConnectionManager.hasStoragePermission()
|
||||
&& size < this.mJingleConnectionManager.getAutoAcceptFileSize()) {
|
||||
&& size < this.mJingleConnectionManager.getAutoAcceptFileSize()
|
||||
&& mXmppConnectionService.isDataSaverDisabled()) {
|
||||
Log.d(Config.LOGTAG, "auto accepting file from "+ packet.getFrom());
|
||||
this.acceptedAutomatically = true;
|
||||
this.sendAccept();
|
||||
|
Loading…
Reference in New Issue
Block a user