Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit 3ef5e8d

Browse files
committed
On cancelling search remove edittext focus and hide keyboard
1 parent 132aa23 commit 3ef5e8d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

app/src/main/java/com/zulip/android/activities/ZulipActivity.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,10 @@ public void onClick(View v) {
334334
}
335335
//set search editText text empty
336336
etSearchPeople.setText("");
337+
//hide soft keyboard
338+
hideSoftKeyBoard();
339+
//remove focus
340+
etSearchPeople.clearFocus();
337341
}
338342
});
339343
etSearchStream = (EditText)findViewById(R.id.stream_drawer_search);
@@ -349,6 +353,10 @@ public void onClick(View v) {
349353
ZLog.logException(e);
350354
}
351355
etSearchStream.setText("");
356+
//hide soft keyboard
357+
hideSoftKeyBoard();
358+
//remove focus
359+
etSearchStream.clearFocus();
352360
}
353361
});
354362
app.setZulipActivity(this);
@@ -534,6 +542,15 @@ public Cursor runQuery(CharSequence charSequence) {
534542
}
535543
}
536544

545+
private void hideSoftKeyBoard() {
546+
// Check if no view has focus:
547+
View view = this.getCurrentFocus();
548+
if (view != null) {
549+
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
550+
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
551+
}
552+
}
553+
537554
private void onTextChangeOfStreamSearchEditText() {
538555
etSearchStream.addTextChangedListener(new TextWatcher() {
539556
@Override

0 commit comments

Comments
 (0)