aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorChristian S <christian@pix-art.de>2016-03-13 12:07:28 +0100
committerChristian S <christian@pix-art.de>2016-03-13 12:07:28 +0100
commitecbf5f6459584fdd694ded4ffc650b685381548e (patch)
tree4d17928512dff1b60dd9de0343bf6992dd41aab4 /src/main/java
parent73907600fa340eb51b9d297e94cdbdca981e0d2b (diff)
parent817d344521835622a625c8263141dc1148fff451 (diff)
Merge branch 'siacs/master' into development
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java4
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java14
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java15
-rw-r--r--src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java5
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java2
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java4
6 files changed, 36 insertions, 8 deletions
diff --git a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
index b975a0017..2ce737968 100644
--- a/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
+++ b/src/main/java/eu/siacs/conversations/persistance/DatabaseBackend.java
@@ -415,8 +415,10 @@ public class DatabaseBackend extends SQLiteOpenHelper {
Cursor cursor = db.query(ServiceDiscoveryResult.TABLENAME, null,
ServiceDiscoveryResult.HASH + "=? AND " + ServiceDiscoveryResult.VER + "=?",
selectionArgs, null, null, null);
- if (cursor.getCount() == 0)
+ if (cursor.getCount() == 0) {
+ cursor.close();
return null;
+ }
cursor.moveToFirst();
ServiceDiscoveryResult result = null;
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 14f6ac3f4..e45ffd432 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -1444,7 +1444,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);
@@ -1469,6 +1471,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;
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index 02c09a5f2..3a889bacf 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -777,6 +777,17 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
}
}
+ private OnClickListener mEnableAccountListener = new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ final Account account = conversation == null ? null : conversation.getAccount();
+ if (account != null) {
+ account.setOption(Account.OPTION_DISABLED, false);
+ activity.xmppConnectionService.updateAccount(account);
+ }
+ }
+ };
+
private OnClickListener mUnblockClickListener = new OnClickListener() {
@Override
public void onClick(final View v) {
@@ -822,7 +833,9 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
final Account account = conversation.getAccount();
final Contact contact = conversation.getContact();
final int mode = conversation.getMode();
- if (conversation.isBlocked()) {
+ if (account.getStatus() == Account.State.DISABLED) {
+ showSnackbar(R.string.this_account_is_disabled, R.string.enable, this.mEnableAccountListener);
+ } else if (conversation.isBlocked()) {
showSnackbar(R.string.contact_blocked, R.string.unblock, this.mUnblockClickListener);
} else if (!contact.showInRoster() && contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
showSnackbar(R.string.contact_added_you, R.string.add_back, this.mAddBackClickListener);
diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
index b05e4e44a..10c6b685d 100644
--- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java
@@ -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 {
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index 3c109967b..1114560ba 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -394,7 +394,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());
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index dc6021284..ee67a5f95 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -915,11 +915,11 @@ public class XmppConnection implements Runnable {
sendPostBindInitialization();
}
} else {
- Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure");
+ Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure. (no jid)");
disconnect(true);
}
} else {
- Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure");
+ Log.d(Config.LOGTAG, account.getJid() + ": disconnecting because of bind failure ("+packet.toString());
disconnect(true);
}
}