fixed some regressions introduced in toolbar migration

This commit is contained in:
Daniel Gultsch 2018-03-18 09:31:37 +01:00
parent f2885575ba
commit 82ba4ce4fc
2 changed files with 55 additions and 33 deletions

View file

@ -83,6 +83,7 @@ import eu.siacs.conversations.ui.adapter.ListItemAdapter;
import eu.siacs.conversations.ui.interfaces.OnBackendConnected;
import eu.siacs.conversations.ui.service.EmojiService;
import eu.siacs.conversations.ui.util.DelayedHintHelper;
import eu.siacs.conversations.ui.util.PendingItem;
import eu.siacs.conversations.utils.XmppUri;
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
import eu.siacs.conversations.xmpp.XmppConnection;
@ -110,8 +111,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;
@ -133,8 +139,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
@ -173,7 +178,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>() {
@ -511,14 +517,24 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
switchToConversation(conversation, body, false);
}
@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);
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);
@ -527,10 +543,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);
}
@ -775,7 +792,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;
}

View file

@ -1,35 +1,40 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/color_background_secondary"
tools:context="eu.siacs.conversations.ui.AboutActivity"
android:orientation="vertical">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/color_background_secondary"
android:orientation="vertical"
tools:context="eu.siacs.conversations.ui.AboutActivity">
<include layout="@layout/toolbar" />
<include layout="@layout/toolbar"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin">
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:fontFamily="monospace"
android:linksClickable="true"
android:padding="@dimen/card_padding_regular"
android:text="@string/pref_about_message"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:typeface="monospace"/>
</android.support.v7.widget.CardView>
android:layout_marginBottom="@dimen/activity_vertical_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_vertical_margin">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:fontFamily="monospace"
android:linksClickable="true"
android:padding="@dimen/card_padding_regular"
android:text="@string/pref_about_message"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:typeface="monospace"/>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
</LinearLayout>