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

Commit 802f45d

Browse files
kunall17niftynei
authored andcommitted
Hide keyboard on Narrow
1 parent 0d6ecc5 commit 802f45d

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,30 +196,30 @@ public boolean onContextItemSelected(MenuItem item) {
196196
Message message = (Message) adapter.getItem(adapter.getContextMenuItemSelectedPosition());
197197
switch (item.getItemId()) {
198198
case R.id.reply_to_stream:
199-
((NarrowListener) getActivity()).onNarrowFillSendBox(message);
199+
((NarrowListener) getActivity()).onNarrowFillSendBox(message, true);
200200
return true;
201201
case R.id.reply_to_private:
202-
((NarrowListener) getActivity()).onNarrowFillSendBox(message);
202+
((NarrowListener) getActivity()).onNarrowFillSendBox(message, true);
203203
return true;
204204
case R.id.reply_to_sender:
205-
((NarrowListener) getActivity()).onNarrowFillSendBox(message);
205+
((NarrowListener) getActivity()).onNarrowFillSendBox(message, true);
206206
return true;
207207
case R.id.narrow_to_private:
208208
if (getActivity() instanceof NarrowListener) {
209209
((NarrowListener) getActivity()).onNarrow(new NarrowFilterPM(Arrays.asList(message.getRecipients(app))));
210-
((NarrowListener) getActivity()).onNarrowFillSendBox(message);
210+
((NarrowListener) getActivity()).onNarrowFillSendBox(message, false);
211211
}
212212
return true;
213213
case R.id.narrow_to_stream:
214214
if (getActivity() instanceof NarrowListener) {
215215
((NarrowListener) getActivity()).onNarrow(new NarrowFilterStream(message.getStream(), null));
216-
((NarrowListener) getActivity()).onNarrowFillSendBox(message);
216+
((NarrowListener) getActivity()).onNarrowFillSendBox(message, false);
217217
}
218218
return true;
219219
case R.id.narrow_to_subject:
220220
if (getActivity() instanceof NarrowListener) {
221221
((NarrowListener) getActivity()).onNarrow(new NarrowFilterStream(message.getStream(), message.getSubject()));
222-
((NarrowListener) getActivity()).onNarrowFillSendBox(message);
222+
((NarrowListener) getActivity()).onNarrowFillSendBox(message, false);
223223
}
224224
return true;
225225
case R.id.copy_message:

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,18 @@ public void onItemClick(int viewId, int position) {
8989
} else {
9090

9191
narrowListener.onNarrow(new NarrowFilterStream(Stream.getByName(zulipApp, messageHeaderParent.getStream()), ""));
92-
narrowListener.onNarrowFillSendBoxStream(messageHeaderParent.getStream(), "");
92+
narrowListener.onNarrowFillSendBoxStream(messageHeaderParent.getStream(), "", false);
9393
}
9494
break;
9595

9696
case R.id.instance: //Topic
9797
MessageHeaderParent messageParent = (MessageHeaderParent) getItem(position);
9898
narrowListener.onNarrow(new NarrowFilterStream(Stream.getByName(zulipApp, messageParent.getStream()), messageParent.getSubject()));
99-
narrowListener.onNarrowFillSendBoxStream(messageParent.getStream(), "");
99+
narrowListener.onNarrowFillSendBoxStream(messageParent.getStream(), "", false);
100100
break;
101101
case R.id.contentView: //Main message
102102
Message message = (Message) getItem(position);
103-
narrowListener.onNarrowFillSendBox(message);
103+
narrowListener.onNarrowFillSendBox(message, false);
104104
break;
105105

106106
case R.id.messageTile:

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ public boolean onChildClick(ExpandableListView parent, View v, int groupPosition
651651
String streamName = ((Cursor) streamsDrawer.getExpandableListAdapter().getGroup(groupPosition)).getString(1);
652652
String subjectName = ((TextView) v).getText().toString();
653653
onNarrow(new NarrowFilterStream(streamName, subjectName));
654-
onNarrowFillSendBoxStream(streamName, subjectName);
654+
onNarrowFillSendBoxStream(streamName, subjectName, false);
655655
break;
656656
default:
657657
return false;
@@ -693,7 +693,7 @@ public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
693693
@Override
694694
public void onClick(View v) {
695695
onNarrow(new NarrowFilterStream(streamName, null));
696-
onNarrowFillSendBoxStream(streamName, "");
696+
onNarrowFillSendBoxStream(streamName, "", false);
697697
}
698698
});
699699
return true;
@@ -1111,7 +1111,7 @@ public void doNarrow(NarrowFilter filter) {
11111111
}
11121112

11131113
@Override
1114-
public void onNarrowFillSendBox(Message message) {
1114+
public void onNarrowFillSendBox(Message message, boolean openSoftKeyboard) {
11151115
displayChatBox(true);
11161116
displayFAB(false);
11171117
if (message.getType() == MessageType.PRIVATE_MESSAGE) {
@@ -1127,10 +1127,12 @@ public void onNarrowFillSendBox(Message message) {
11271127
}
11281128
else messageEt.requestFocus();
11291129
}
1130-
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
1130+
if (openSoftKeyboard) {
1131+
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
1132+
}
11311133
}
11321134

1133-
public void onNarrowFillSendBoxStream(String stream, String subject) {
1135+
public void onNarrowFillSendBoxStream(String stream, String subject, boolean openSoftKeyboard) {
11341136
displayChatBox(true);
11351137
displayFAB(false);
11361138
switchToStream();
@@ -1139,8 +1141,9 @@ public void onNarrowFillSendBoxStream(String stream, String subject) {
11391141
if ("".equals(subject)) {
11401142
topicActv.requestFocus();
11411143
} else messageEt.requestFocus();
1142-
1143-
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
1144+
if (openSoftKeyboard) {
1145+
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
1146+
}
11441147
}
11451148

11461149
public void onNarrow(NarrowFilter narrowFilter) {

app/src/main/java/com/zulip/android/filters/NarrowListener.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
*/
88
public interface NarrowListener {
99
void onNarrow(NarrowFilter narrowFilter);
10-
void onNarrowFillSendBox(Message message);
11-
void onNarrowFillSendBoxStream(String stream, String message);
10+
void onNarrowFillSendBox(Message message, boolean openSoftKeyboard);
11+
void onNarrowFillSendBoxStream(String stream, String message, boolean openSoftKeyboard);
1212
}

0 commit comments

Comments
 (0)