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

Commit 8449ec5

Browse files
jainkuniyatimabbott
authored andcommitted
Populate chatbox when narrowed to stream/pm.
Show it when user narrowed to stream/topic/pm from drawer. Fills the fields in the chatbox. This saves the time in composing message. Fixes #330.
1 parent 273ed60 commit 8449ec5

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,9 @@ public void onItemClick(int viewId, int position) {
116116
case R.id.displayRecipient: //StreamTV
117117
MessageHeaderParent messageHeaderParent = (MessageHeaderParent) getItem(position);
118118
if (messageHeaderParent.getMessageType() == MessageType.PRIVATE_MESSAGE) {
119-
narrowListener.onNarrow(new NarrowFilterPM(
120-
Arrays.asList(messageHeaderParent.getRecipients((ZulipApp.get())))));
119+
Person[] recipientArray = messageHeaderParent.getRecipients(zulipApp);
120+
narrowListener.onNarrow(new NarrowFilterPM(Arrays.asList(recipientArray)));
121+
narrowListener.onNarrowFillSendBoxPrivate(recipientArray,false);
121122
} else {
122123

123124
narrowListener.onNarrow(new NarrowFilterStream(Stream.getByName(zulipApp, messageHeaderParent.getStream()), null));
@@ -128,7 +129,7 @@ public void onItemClick(int viewId, int position) {
128129
MessageHeaderParent messageParent = (MessageHeaderParent) getItem(position);
129130
if (messageParent.getMessageType() == MessageType.STREAM_MESSAGE) {
130131
narrowListener.onNarrow(new NarrowFilterStream(Stream.getByName(zulipApp, messageParent.getStream()), messageParent.getSubject()));
131-
narrowListener.onNarrowFillSendBoxStream(messageParent.getStream(), "", false);
132+
narrowListener.onNarrowFillSendBoxStream(messageParent.getStream(), messageParent.getSubject(), false);
132133
} else {
133134
Person[] recipentArray = messageParent.getRecipients(zulipApp);
134135
narrowListener.onNarrow(new NarrowFilterPM(Arrays.asList(recipentArray)));

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,9 @@ public void onItemClick(AdapterView<?> parent, View view,
396396
if (id == allPeopleId) {
397397
doNarrow(new NarrowFilterAllPMs(app.getYou()));
398398
} else {
399-
narrow_pm_with(Person.getById(app, (int) id));
399+
Person person = Person.getById(app, (int) id);
400+
narrowPMWith(person);
401+
switchToPrivate();
400402
}
401403
}
402404
});
@@ -569,6 +571,7 @@ public void onBackStackChanged() {
569571
if (narrowedList == null) {
570572
calendar = Calendar.getInstance();
571573
menu.getItem(2).getSubMenu().getItem(0).setTitle(R.string.menu_today);
574+
switchToStream();
572575
checkForChatBoxFocusRequest();
573576
} else if (narrowedList.filter instanceof NarrowFilterByDate) {
574577
menu.getItem(2).getSubMenu().getItem(0).setTitle(R.string.menu_one_day_before);
@@ -578,7 +581,7 @@ public void onBackStackChanged() {
578581
}
579582

580583
private void checkForChatBoxFocusRequest() {
581-
if (TextUtils.isEmpty(streamActv.getText().toString())) {
584+
if (TextUtils.isEmpty(streamActv.getText().toString()) && isCurrentModeStream()) {
582585
streamActv.requestFocus();
583586
} else if (TextUtils.isEmpty(topicActv.getText().toString())) {
584587
topicActv.requestFocus();
@@ -1083,6 +1086,7 @@ private void displayChatBox(boolean show) {
10831086
showView(chatBox);
10841087
} else {
10851088
hideView(chatBox);
1089+
hideSoftKeyBoard();
10861090
}
10871091
}
10881092

@@ -1203,6 +1207,7 @@ public boolean onGroupClick(ExpandableListView expandableListView, View view, in
12031207
}
12041208
expandableListView.expandGroup(position);
12051209
previousClick = position;
1210+
onNarrowFillSendBoxStream(streamName, "", false);
12061211
return true;
12071212
}
12081213
});
@@ -1743,8 +1748,9 @@ protected void narrow(final Stream stream) {
17431748
doNarrow(new NarrowFilterStream(stream, null));
17441749
}
17451750

1746-
private void narrow_pm_with(final Person person) {
17471751
doNarrow(new NarrowFilterPM(Arrays.asList(app.getYou(), person)));
1752+
private void narrowPMWith(final Person person) {
1753+
onNarrowFillSendBoxPrivate(new Person[]{person},false);
17481754
}
17491755

17501756
@TargetApi(Build.VERSION_CODES.HONEYCOMB)

0 commit comments

Comments
 (0)