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

Commit 56e33de

Browse files
jainkuniyatimabbott
authored andcommitted
Hide keyboard on narrowing to searched stream/PM.
1 parent 32c2196 commit 56e33de

File tree

1 file changed

+45
-21
lines changed

1 file changed

+45
-21
lines changed

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

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -329,17 +329,7 @@ protected void onCreate(Bundle savedInstanceState) {
329329
@Override
330330
public void onClick(View v) {
331331
//set default people list
332-
try {
333-
peopleAdapter.changeCursor(getPeopleCursorGenerator().call());
334-
} catch (Exception e) {
335-
ZLog.logException(e);
336-
}
337-
//set search editText text empty
338-
etSearchPeople.setText("");
339-
//hide soft keyboard
340-
hideSoftKeyBoard();
341-
//remove focus
342-
etSearchPeople.clearFocus();
332+
resetPeopleSearch();
343333
}
344334
});
345335
etSearchStream = (EditText)findViewById(R.id.stream_drawer_search);
@@ -349,16 +339,7 @@ public void onClick(View v) {
349339
@Override
350340
public void onClick(View v) {
351341
//set default stream list
352-
try {
353-
streamsDrawerAdapter.changeCursor(getSteamCursorGenerator().call());
354-
} catch (Exception e) {
355-
ZLog.logException(e);
356-
}
357-
etSearchStream.setText("");
358-
//hide soft keyboard
359-
hideSoftKeyBoard();
360-
//remove focus
361-
etSearchStream.clearFocus();
342+
resetStreamSearch();
362343
}
363344
});
364345
app.setZulipActivity(this);
@@ -398,6 +379,7 @@ public void onDrawerOpened(View drawerView) {
398379
@Override
399380
public void onItemClick(AdapterView<?> parent, View view,
400381
int position, long id) {
382+
resetPeopleSearch();
401383
if (id == allPeopleId) {
402384
doNarrow(new NarrowFilterAllPMs(app.getYou()));
403385
} else {
@@ -544,6 +526,28 @@ public Cursor runQuery(CharSequence charSequence) {
544526
}
545527
}
546528

529+
/**
530+
* Change peopleAdapter cursor to default
531+
* Clear text of etSearchPeople
532+
* Remove focus of etSearchPeople
533+
*/
534+
private void resetPeopleSearch() {
535+
try {
536+
peopleAdapter.changeCursor(getPeopleCursorGenerator().call());
537+
} catch (Exception e) {
538+
ZLog.logException(e);
539+
}
540+
//set search editText text empty
541+
etSearchPeople.setText("");
542+
//hide soft keyboard
543+
hideSoftKeyBoard();
544+
//remove focus
545+
etSearchPeople.clearFocus();
546+
}
547+
548+
/**
549+
* Hide soft keyboard
550+
*/
547551
private void hideSoftKeyBoard() {
548552
// Check if no view has focus:
549553
View view = this.getCurrentFocus();
@@ -1026,6 +1030,7 @@ public boolean onChildClick(ExpandableListView parent, View v, int groupPosition
10261030

10271031
@Override
10281032
public boolean onGroupClick(ExpandableListView expandableListView, View view, int position, long l) {
1033+
resetStreamSearch();
10291034
String streamName = ((TextView) view.findViewById(R.id.name)).getText().toString();
10301035
doNarrow(new NarrowFilterStream(streamName, null));
10311036
drawerLayout.openDrawer(GravityCompat.START);
@@ -1054,6 +1059,7 @@ public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
10541059
view.setOnClickListener(new View.OnClickListener() {
10551060
@Override
10561061
public void onClick(View v) {
1062+
resetStreamSearch();
10571063
onNarrow(new NarrowFilterStream(streamName, null));
10581064
onNarrowFillSendBoxStream(streamName, "", false);
10591065
}
@@ -1099,6 +1105,24 @@ public void onClick(View v) {
10991105
streamsDrawer.setAdapter(streamsDrawerAdapter);
11001106
}
11011107

1108+
/**
1109+
* Change streamsDrawerAdapter cursor to default
1110+
* Clear text of etSearchStream
1111+
* Remove focus of etSearchStream
1112+
*/
1113+
private void resetStreamSearch() {
1114+
try {
1115+
streamsDrawerAdapter.changeCursor(getSteamCursorGenerator().call());
1116+
} catch (Exception e) {
1117+
ZLog.logException(e);
1118+
}
1119+
etSearchStream.setText("");
1120+
//hide soft keyboard
1121+
hideSoftKeyBoard();
1122+
//remove focus
1123+
etSearchStream.clearFocus();
1124+
}
1125+
11021126
/**
11031127
* Initiates the streams Drawer if the streams in the drawer is 0.
11041128
*/

0 commit comments

Comments
 (0)