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

Commit 034e40b

Browse files
kunall17niftynei
authored andcommitted
Added Checks to chatBox's editText's for blank value.
Also it checks if the entered stream exist's or not.
1 parent d37694d commit 034e40b

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,41 @@ public void onClick(View v) {
444444

445445
private void sendMessage() {
446446

447+
if (isCurrentModeStream()) {
448+
if (TextUtils.isEmpty(streamActv.getText().toString())) {
449+
streamActv.setError(getString(R.string.stream_error));
450+
streamActv.requestFocus();
451+
return;
452+
} else {
453+
try {
454+
Cursor streamCursor = makeStreamCursor(streamActv.getText().toString());
455+
if (streamCursor.getCount() == 0) {
456+
streamActv.setError(getString(R.string.stream_not_exists));
457+
streamActv.requestFocus();
458+
return;
459+
}
460+
} catch (SQLException e) {
461+
Log.e("SQLException", "SQL not correct", e);
462+
}
463+
}
464+
if (TextUtils.isEmpty(topicActv.getText().toString())) {
465+
topicActv.setError(getString(R.string.subject_error));
466+
topicActv.requestFocus();
467+
return;
468+
}
469+
} else {
470+
if (TextUtils.isEmpty(topicActv.getText().toString())) {
471+
topicActv.setError(getString(R.string.person_error));
472+
topicActv.requestFocus();
473+
return;
474+
}
475+
}
476+
477+
if (TextUtils.isEmpty(messageEt.getText().toString())) {
478+
messageEt.setError(getString(R.string.no_message_error));
479+
messageEt.requestFocus();
480+
return;
481+
}
447482
MessageType messageType = (isCurrentModeStream()) ? MessageType.STREAM_MESSAGE : MessageType.PRIVATE_MESSAGE;
448483
Message msg = new Message(app);
449484
msg.setSender(app.getYou());

app/src/main/res/values/strings.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
<string name="hint_stream">Stream</string>
5656
<string name="message_sent">Message Sent!</string>
5757
<string name="message_error">Error sending Message</string>
58+
<string name="stream_error">No Stream specified.</string>
59+
<string name="stream_not_exists">Stream Does not Exists.</string>
60+
<string name="subject_error">No Subject specified.</string>
61+
<string name="person_error">No Person specified.</string>
62+
<string name="no_message_error">No Message Written.</string>
5863

5964

6065
<string name="tap_message">Tap on a message to send reply</string>

0 commit comments

Comments
 (0)