Skip to content

Commit

Permalink
chats: hide calendar/users button when typing into searchbar (iOS off…
Browse files Browse the repository at this point in the history
…icial app behaviour, also fixes a bug)
  • Loading branch information
iTaysonLab committed Feb 5, 2021
1 parent d44b20e commit f4fddd5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java
Expand Up @@ -56,6 +56,7 @@
import android.text.style.ClickableSpan;
import android.text.style.ForegroundColorSpan;
import android.text.style.URLSpan;
import android.util.Log;
import android.util.LongSparseArray;
import android.util.Property;
import android.util.SparseArray;
Expand Down Expand Up @@ -2024,11 +2025,22 @@ public void onSearchPressed(EditText editText) {
@Override
public void onTextChanged(EditText editText) {
showMessagesSearchListView(false);

if (searchingForUser) {
mentionsAdapter.searchUsernameOrHashtag("@" + editText.getText().toString(), 0, messages, true);
} else if (searchingUserMessages == null && searchingChatMessages == null && searchUserButton != null && TextUtils.equals(editText.getText(), LocaleController.getString("SearchFrom", R.string.SearchFrom))) {
searchUserButton.callOnClick();
}

if (searchUserButton != null) {
if (editText.getText().length() > 0) {
searchUserButton.setVisibility(View.INVISIBLE);
searchCalendarButton.setVisibility(View.INVISIBLE);
} else {
searchUserButton.setVisibility(View.VISIBLE);
searchCalendarButton.setVisibility(View.VISIBLE);
}
}
}

@Override
Expand Down Expand Up @@ -6569,15 +6581,15 @@ protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, i
searchUserButton.setOnClickListener(view -> {
mentionLayoutManager.setReverseLayout(true);
mentionsAdapter.setSearchingMentions(true);
searchCalendarButton.setVisibility(View.GONE);
searchUserButton.setVisibility(View.GONE);
searchingForUser = true;
searchingUserMessages = null;
searchingChatMessages = null;
searchItem.setSearchFieldHint(LocaleController.getString("SearchMembers", R.string.SearchMembers));
searchItem.setSearchFieldCaption(LocaleController.getString("SearchFrom", R.string.SearchFrom));
AndroidUtilities.showKeyboard(searchItem.getSearchField());
searchItem.clearSearchText();
searchCalendarButton.setVisibility(View.GONE);
searchUserButton.setVisibility(View.GONE);
});
searchUserButton.setContentDescription(LocaleController.getString("AccDescrSearchByUser", R.string.AccDescrSearchByUser));
}
Expand Down

0 comments on commit f4fddd5

Please sign in to comment.