From 9a76aff8f906468a75d34deed90d9afd605bce66 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 26 Feb 2018 12:03:17 +0100 Subject: [PATCH] skip background connect when changing theme --- .../eu/siacs/conversations/ui/ConversationActivity.java | 6 +++++- src/main/java/eu/siacs/conversations/ui/XmppActivity.java | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index d7c2e4074..6be671e02 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -396,7 +396,8 @@ public class ConversationActivity extends XmppActivity implements OnConversation @Override public void onSaveInstanceState(Bundle savedInstanceState) { - savedInstanceState.putParcelable("intent", getIntent()); + Intent pendingIntent = pendingViewIntent.pop(); + savedInstanceState.putParcelable("intent", pendingIntent == null ? pendingIntent : getIntent()); super.onSaveInstanceState(savedInstanceState); } @@ -404,7 +405,10 @@ public class ConversationActivity extends XmppActivity implements OnConversation protected void onStart() { final int theme = findTheme(); if (this.mTheme != theme) { + this.mSkipBackgroundBinding = true; recreate(); + } else { + this.mSkipBackgroundBinding = false; } mRedirectInProcess.set(false); super.onStart(); diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index 997df6422..d03a449e3 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -40,6 +40,7 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.text.InputType; import android.util.DisplayMetrics; +import android.util.Log; import android.view.MenuItem; import android.view.View; import android.view.inputmethod.InputMethodManager; @@ -145,6 +146,7 @@ public abstract class XmppActivity extends AppCompatActivity { } }; + public boolean mSkipBackgroundBinding = false; public static boolean cancelPotentialWork(Message message, ImageView imageView) { final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView); @@ -205,7 +207,11 @@ public abstract class XmppActivity extends AppCompatActivity { protected void onStart() { super.onStart(); if (!xmppConnectionServiceBound) { - connectToBackend(); + if (this.mSkipBackgroundBinding) { + Log.d(Config.LOGTAG,"skipping background binding"); + } else { + connectToBackend(); + } } else { if (!registeredListeners) { this.registerListeners();