mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-27 19:22:15 -05:00
don't show opt-out of battery optimization dialog when push is enabled
This commit is contained in:
parent
86fff5839a
commit
e6a9829dd2
@ -1353,7 +1353,9 @@ public class ConversationActivity extends XmppActivity
|
||||
}
|
||||
|
||||
private void openBatteryOptimizationDialogIfNeeded() {
|
||||
if (showBatteryOptimizationWarning() && getPreferences().getBoolean("show_battery_optimization", true)) {
|
||||
if (hasAccountWithoutPush()
|
||||
&& isOptimizingBattery()
|
||||
&& getPreferences().getBoolean("show_battery_optimization", true)) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.battery_optimizations_enabled);
|
||||
builder.setMessage(R.string.battery_optimizations_enabled_dialog);
|
||||
@ -1378,6 +1380,16 @@ public class ConversationActivity extends XmppActivity
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasAccountWithoutPush() {
|
||||
for(Account account : xmppConnectionService.getAccounts()) {
|
||||
if (account.getStatus() != Account.State.DISABLED
|
||||
&& !xmppConnectionService.getPushManagementService().available(account)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void attachLocationToConversation(Conversation conversation, Uri uri) {
|
||||
if (conversation == null) {
|
||||
return;
|
||||
|
@ -641,11 +641,12 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
||||
this.mRegisterNew.setChecked(false);
|
||||
}
|
||||
if (this.mAccount.isOnlineAndConnected() && !this.mFetchingAvatar) {
|
||||
Features features = this.mAccount.getXmppConnection().getFeatures();
|
||||
this.mStats.setVisibility(View.VISIBLE);
|
||||
this.mBatteryOptimizations.setVisibility(showBatteryOptimizationWarning() ? View.VISIBLE : View.GONE);
|
||||
boolean showOptimizingWarning = !xmppConnectionService.getPushManagementService().available(mAccount) && isOptimizingBattery();
|
||||
this.mBatteryOptimizations.setVisibility(showOptimizingWarning ? View.VISIBLE : View.GONE);
|
||||
this.mSessionEst.setText(UIHelper.readableTimeDifferenceFull(this, this.mAccount.getXmppConnection()
|
||||
.getLastSessionEstablished()));
|
||||
Features features = this.mAccount.getXmppConnection().getFeatures();
|
||||
if (features.rosterVersioning()) {
|
||||
this.mServerInfoRosterVersion.setText(R.string.server_info_available);
|
||||
} else {
|
||||
|
@ -391,7 +391,7 @@ public abstract class XmppActivity extends Activity {
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
}
|
||||
|
||||
protected boolean showBatteryOptimizationWarning() {
|
||||
protected boolean isOptimizingBattery() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
|
||||
return !pm.isIgnoringBatteryOptimizations(getPackageName());
|
||||
|
Loading…
Reference in New Issue
Block a user