From 60fc9852986f05f7110f912818f594751b06eafe Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Wed, 24 Oct 2018 13:54:42 +0200 Subject: [PATCH] do not show up navigation in start conversation screen if called with view intent --- src/main/AndroidManifest.xml | 2 +- .../conversations/ui/StartConversationActivity.java | 11 ++++++----- .../eu/siacs/conversations/ui/UriHandlerActivity.java | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml index 9c3b36cfb..f3789099d 100644 --- a/src/main/AndroidManifest.xml +++ b/src/main/AndroidManifest.xml @@ -110,7 +110,7 @@ android:windowSoftInputMode="stateAlwaysHidden"/> + android:label="@string/app_name"> diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index 07b3dfbdc..b66e6f25f 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -26,10 +26,7 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.AlertDialog; import android.support.v7.widget.Toolbar; import android.text.Editable; -import android.text.SpannableString; -import android.text.Spanned; import android.text.TextWatcher; -import android.text.style.TypefaceSpan; import android.util.Log; import android.util.Pair; import android.view.ContextMenu; @@ -101,6 +98,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne private EditText mSearchEditText; private AtomicBoolean mRequestedContactsPermission = new AtomicBoolean(false); private boolean mHideOfflineContacts = false; + private boolean createdByViewIntent = false; private MenuItem.OnActionExpandListener mOnActionExpandListener = new MenuItem.OnActionExpandListener() { @Override @@ -305,6 +303,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne if (savedInstanceState == null) { intent = getIntent(); } else { + createdByViewIntent = savedInstanceState.getBoolean("created_by_view_intent", false); final String search = savedInstanceState.getString("search"); if (search != null) { mInitialSearchValue.push(search); @@ -314,6 +313,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne if (isViewIntent(intent)) { pendingViewIntent.push(intent); + createdByViewIntent = true; setIntent(createLauncherIntent(this)); } else if (startSearching && mInitialSearchValue.peek() == null) { mInitialSearchValue.push(""); @@ -324,6 +324,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne public void onSaveInstanceState(Bundle savedInstanceState) { Intent pendingIntent = pendingViewIntent.peek(); savedInstanceState.putParcelable("intent", pendingIntent != null ? pendingIntent : getIntent()); + savedInstanceState.putBoolean("created_by_view_intent",createdByViewIntent); if (mMenuSearchView != null && mMenuSearchView.isActionViewExpanded()) { savedInstanceState.putString("search", mSearchEditText != null ? mSearchEditText.getText().toString() : null); } @@ -712,7 +713,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne if (actionBar == null) { return; } - boolean openConversations = !xmppConnectionService.isConversationsListEmpty(null); + boolean openConversations = !createdByViewIntent && !xmppConnectionService.isConversationsListEmpty(null); actionBar.setDisplayHomeAsUpEnabled(openConversations); actionBar.setDisplayHomeAsUpEnabled(openConversations); @@ -926,7 +927,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne } private void navigateBack() { - if (xmppConnectionService != null && !xmppConnectionService.isConversationsListEmpty(null)) { + if (!createdByViewIntent && xmppConnectionService != null && !xmppConnectionService.isConversationsListEmpty(null)) { Intent intent = new Intent(this, ConversationsActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); diff --git a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java index fd4cf9bab..d2f44ffb2 100644 --- a/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/UriHandlerActivity.java @@ -117,6 +117,7 @@ public class UriHandlerActivity extends AppCompatActivity { intent.putExtra("body", body); } else { intent = new Intent(this, StartConversationActivity.class); + intent.setAction(Intent.ACTION_VIEW); intent.setData(uri); intent.putExtra("account", accounts.get(0).toEscapedString()); }