This repository was archived by the owner on Jul 25, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +35
-11
lines changed Expand file tree Collapse file tree 3 files changed +35
-11
lines changed Original file line number Diff line number Diff line change @@ -1255,16 +1255,17 @@ private void sendMessage() {
1255
1255
streamActv .requestFocus ();
1256
1256
return ;
1257
1257
} else {
1258
- try {
1259
- Cursor streamCursor = makeStreamCursor (streamActv .getText ().toString ());
1260
- if (streamCursor .getCount () == 0 ) {
1261
- streamActv .setError (getString (R .string .stream_not_exists ));
1262
- streamActv .requestFocus ();
1263
- return ;
1264
- }
1265
- } catch (SQLException e ) {
1266
- ZLog .logException (e );
1267
- Log .e ("SQLException" , "SQL not correct" , e );
1258
+ Stream stream = Stream .streamCheckBeforeMessageSend (app , streamActv .getText ().toString ());
1259
+ //check whether stream exists or not
1260
+ if (stream == null ) {
1261
+ streamActv .setError (getString (R .string .stream_not_exists ));
1262
+ streamActv .requestFocus ();
1263
+ return ;
1264
+ }// check whether user is subscribed or not
1265
+ else if (!stream .isSubscribed ()) {
1266
+ Toast .makeText (ZulipActivity .this , getString (R .string .message_not_subscribed )
1267
+ + " " + streamActv .getText ().toString () + " " + getString (R .string .keyword_stream ), Toast .LENGTH_SHORT ).show ();
1268
+ return ;
1268
1269
}
1269
1270
}
1270
1271
if (TextUtils .isEmpty (topicActv .getText ().toString ())) {
Original file line number Diff line number Diff line change 13
13
import com .j256 .ormlite .stmt .SelectArg ;
14
14
import com .j256 .ormlite .table .DatabaseTable ;
15
15
import com .zulip .android .ZulipApp ;
16
+ import com .zulip .android .util .ZLog ;
16
17
17
18
import org .apache .commons .lang .builder .EqualsBuilder ;
18
19
import org .apache .commons .lang .builder .HashCodeBuilder ;
@@ -190,4 +191,24 @@ public int getId() {
190
191
return id ;
191
192
}
192
193
193
- }
194
+ /**
195
+ * Checks stream name is valid or not
196
+ * @param app ZulipApp
197
+ * @param streamName Checks this stream name is valid or not
198
+ * @return null if stream does not exist else cursor
199
+ */
200
+ public static Stream streamCheckBeforeMessageSend (ZulipApp app , CharSequence streamName ) {
201
+ if (streamName == null ) {
202
+ return null ;
203
+ }
204
+ try {
205
+ return app .getDao (Stream .class )
206
+ .queryBuilder ().where ()
207
+ .eq (Stream .NAME_FIELD , new SelectArg (Stream .NAME_FIELD , streamName )).queryForFirst ();
208
+ } catch (SQLException e ) {
209
+ ZLog .logException (e );
210
+ }
211
+ return null ;
212
+ }
213
+
214
+ }
Original file line number Diff line number Diff line change 116
116
<string name =" camera_content_desp" >take photo</string >
117
117
<string name =" menu_one_day_before" >One Day Before</string >
118
118
<string name =" enter_date" >Enter Date</string >
119
+ <string name =" message_not_subscribed" >Not subscribed to</string >
120
+ <string name =" keyword_stream" >stream</string >
119
121
</resources >
You can’t perform that action at this time.
0 commit comments