diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-04-11 21:49:55 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-04-11 21:49:55 +0200 |
commit | 0470d60018c2bbe8d75bbc5752db669b9c5501cf (patch) | |
tree | 61e6b45ab0e4191dd11e31c594278da6d21d026f /src/main/java/de/pixart | |
parent | 6ad24e40d04640da7508e25596e0f18f76232407 (diff) |
fixed some regressions introduced in toolbar migration
Diffstat (limited to 'src/main/java/de/pixart')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/StartConversationActivity.java | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java index 526d9275f..fdaa8d388 100644 --- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java @@ -72,6 +72,7 @@ import de.pixart.messenger.services.EmojiService; import de.pixart.messenger.services.XmppConnectionService.OnRosterUpdate; import de.pixart.messenger.ui.adapter.ListItemAdapter; import de.pixart.messenger.ui.interfaces.OnBackendConnected; +import de.pixart.messenger.ui.util.PendingItem; import de.pixart.messenger.utils.XmppUri; import de.pixart.messenger.xmpp.OnUpdateBlocklist; import de.pixart.messenger.xmpp.XmppConnection; @@ -101,8 +102,13 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU public boolean onMenuItemActionExpand(MenuItem item) { mSearchEditText.post(() -> { mSearchEditText.requestFocus(); + if (oneShotKeyboardSuppress.compareAndSet(true, false)) { + return; + } InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(mSearchEditText, InputMethodManager.SHOW_IMPLICIT); + if (imm != null) { + imm.showSoftInput(mSearchEditText, InputMethodManager.SHOW_IMPLICIT); + } }); return true; @@ -124,8 +130,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } @Override - public void beforeTextChanged(CharSequence s, int start, int count, - int after) { + public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override @@ -164,7 +169,8 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } } }; - private String mInitialJid; + private final PendingItem<String> mInitialSearchValue = new PendingItem<>(); + private final AtomicBoolean oneShotKeyboardSuppress = new AtomicBoolean(); private Pair<Integer, Intent> mPostponedActivityResult; private Toast mToast; private UiCallback<Conversation> mAdhocConferenceCallback = new UiCallback<Conversation>() { @@ -504,6 +510,17 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } @Override + public void invalidateOptionsMenu() { + boolean isExpanded = mMenuSearchView != null && mMenuSearchView.isActionViewExpanded(); + String text = mSearchEditText != null ? mSearchEditText.getText().toString() : ""; + if (isExpanded) { + mInitialSearchValue.push(text); + oneShotKeyboardSuppress.set(true); + } + super.invalidateOptionsMenu(); + } + + @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.start_conversation, menu); MenuItem menuHideOffline = menu.findItem(R.id.action_hide_offline); @@ -515,8 +532,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU } MenuItem joinGroupChat = menu.findItem(R.id.action_join_conference); MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code); - ActionBar bar = getSupportActionBar(); - joinGroupChat.setVisible(bar != null && binding.startConversationViewPager.getCurrentItem() == 1); + joinGroupChat.setVisible(binding.startConversationViewPager.getCurrentItem() == 1); qrCodeScanMenuItem.setVisible(isCameraFeatureAvailable()); menuHideOffline.setChecked(this.mHideOfflineContacts); mMenuSearchView = menu.findItem(R.id.action_search); @@ -525,10 +541,11 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU mSearchEditText = mSearchView.findViewById(R.id.search_field); mSearchEditText.addTextChangedListener(mSearchTextWatcher); mSearchEditText.setOnEditorActionListener(mSearchDone); - if (mInitialJid != null) { + String initialSearchValue = mInitialSearchValue.pop(); + if (initialSearchValue != null) { mMenuSearchView.expandActionView(); - mSearchEditText.append(mInitialJid); - filter(mInitialJid); + mSearchEditText.append(initialSearchValue); + filter(initialSearchValue); } return super.onCreateOptionsMenu(menu); } @@ -774,7 +791,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU mSearchEditText.append(invite.getJid().toString()); filter(invite.getJid().toString()); } else { - mInitialJid = invite.getJid().toString(); + mInitialSearchValue.push(invite.getJid().toString()); } return true; } |