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() {
|
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);
|
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||||
builder.setTitle(R.string.battery_optimizations_enabled);
|
builder.setTitle(R.string.battery_optimizations_enabled);
|
||||||
builder.setMessage(R.string.battery_optimizations_enabled_dialog);
|
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) {
|
private void attachLocationToConversation(Conversation conversation, Uri uri) {
|
||||||
if (conversation == null) {
|
if (conversation == null) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -641,11 +641,12 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
|
||||||
this.mRegisterNew.setChecked(false);
|
this.mRegisterNew.setChecked(false);
|
||||||
}
|
}
|
||||||
if (this.mAccount.isOnlineAndConnected() && !this.mFetchingAvatar) {
|
if (this.mAccount.isOnlineAndConnected() && !this.mFetchingAvatar) {
|
||||||
|
Features features = this.mAccount.getXmppConnection().getFeatures();
|
||||||
this.mStats.setVisibility(View.VISIBLE);
|
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()
|
this.mSessionEst.setText(UIHelper.readableTimeDifferenceFull(this, this.mAccount.getXmppConnection()
|
||||||
.getLastSessionEstablished()));
|
.getLastSessionEstablished()));
|
||||||
Features features = this.mAccount.getXmppConnection().getFeatures();
|
|
||||||
if (features.rosterVersioning()) {
|
if (features.rosterVersioning()) {
|
||||||
this.mServerInfoRosterVersion.setText(R.string.server_info_available);
|
this.mServerInfoRosterVersion.setText(R.string.server_info_available);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -391,7 +391,7 @@ public abstract class XmppActivity extends Activity {
|
||||||
return super.onCreateOptionsMenu(menu);
|
return super.onCreateOptionsMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean showBatteryOptimizationWarning() {
|
protected boolean isOptimizingBattery() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
|
PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
|
||||||
return !pm.isIgnoringBatteryOptimizations(getPackageName());
|
return !pm.isIgnoringBatteryOptimizations(getPackageName());
|
||||||
|
|
Loading…
Reference in a new issue