@@ -153,7 +153,8 @@ public void run() {
153153 // Find the bottom comment input
154154 bottomCommentInput = findViewById (R .id .bottomCommentInput );
155155 if (bottomCommentInput != null ) {
156- // Set up for live chat use
156+ // Use bottom comment input for live chat
157+ commentForm = null ; // We'll use bottomCommentInput instead
157158 } else {
158159 // Fallback for layouts without bottom input
159160 commentForm = new CommentFormView (context );
@@ -167,11 +168,21 @@ public void run() {
167168 backPressedCallback = new OnBackPressedCallback (true ) {
168169 @ Override
169170 public void handleOnBackPressed () {
170- // Check if we have text in the form
171- if (!commentForm .isTextEmpty ()) {
171+ // Check if we have text in either input method
172+ boolean hasText = false ;
173+ RenderableComment parentComment = null ;
174+
175+ if (bottomCommentInput != null ) {
176+ hasText = !bottomCommentInput .isTextEmpty ();
177+ parentComment = bottomCommentInput .getParentComment ();
178+ } else if (commentForm != null ) {
179+ hasText = !commentForm .isTextEmpty ();
180+ parentComment = commentForm .getParentComment ();
181+ }
182+
183+ if (hasText ) {
172184 // Show confirmation dialog - different message for reply vs new comment
173185 String title , message ;
174- RenderableComment parentComment = commentForm .getParentComment ();
175186
176187 if (parentComment != null ) {
177188 title = getContext ().getString (R .string .cancel_reply_title );
@@ -186,13 +197,22 @@ public void handleOnBackPressed() {
186197 .setMessage (message )
187198 .setPositiveButton (android .R .string .yes , (dialog , which ) -> {
188199 // Proceed with cancellation
189- commentForm .resetReplyState ();
200+ if (bottomCommentInput != null ) {
201+ bottomCommentInput .clearText ();
202+ bottomCommentInput .clearReplyState ();
203+ } else if (commentForm != null ) {
204+ commentForm .resetReplyState ();
205+ }
190206 })
191207 .setNegativeButton (android .R .string .no , null )
192208 .show ();
193209 } else {
194210 // Text is empty, no need for confirmation
195- commentForm .resetReplyState ();
211+ if (bottomCommentInput != null ) {
212+ bottomCommentInput .clearReplyState ();
213+ } else if (commentForm != null ) {
214+ commentForm .resetReplyState ();
215+ }
196216 }
197217 }
198218 };
@@ -284,30 +304,45 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
284304 }
285305 });
286306
287- // Setup form listeners
288- commentForm .setOnCommentSubmitListener ((commentText , parentId ) -> {
289- postComment (commentText , parentId );
290- });
307+ // Setup form listeners based on which input method is available
308+ if (bottomCommentInput != null ) {
309+ // Setup bottom comment input for live chat
310+ bottomCommentInput .setCurrentUser (sdk .getCurrentUser ());
311+ bottomCommentInput .setSDK (sdk );
312+
313+ bottomCommentInput .setOnCommentSubmitListener ((commentText , parentId ) -> {
314+ postComment (commentText , parentId );
315+ });
316+
317+ bottomCommentInput .setOnReplyStateChangeListener ((isReplying , parentComment ) -> {
318+ // Handle reply state changes if needed
319+ });
320+ } else if (commentForm != null ) {
321+ // Setup traditional comment form as fallback
322+ commentForm .setOnCommentSubmitListener ((commentText , parentId ) -> {
323+ postComment (commentText , parentId );
324+ });
291325
292- commentForm .setOnCancelReplyListener (() -> {
293- // Get the parent comment
294- RenderableComment parentComment = commentForm .getParentComment ();
295- if (parentComment != null && !commentForm .isTextEmpty ()) {
296- // Show confirmation dialog
297- new android .app .AlertDialog .Builder (getContext ())
298- .setTitle (R .string .cancel_reply_title )
299- .setMessage (R .string .cancel_reply_confirm )
300- .setPositiveButton (android .R .string .yes , (dialog , which ) -> {
301- // Proceed with cancellation
302- commentForm .resetReplyState ();
303- })
304- .setNegativeButton (android .R .string .no , null )
305- .show ();
306- } else {
307- // Just reset the form if there's no text
308- commentForm .resetReplyState ();
309- }
310- });
326+ commentForm .setOnCancelReplyListener (() -> {
327+ // Get the parent comment
328+ RenderableComment parentComment = commentForm .getParentComment ();
329+ if (parentComment != null && !commentForm .isTextEmpty ()) {
330+ // Show confirmation dialog
331+ new android .app .AlertDialog .Builder (getContext ())
332+ .setTitle (R .string .cancel_reply_title )
333+ .setMessage (R .string .cancel_reply_confirm )
334+ .setPositiveButton (android .R .string .yes , (dialog , which ) -> {
335+ // Proceed with cancellation
336+ commentForm .resetReplyState ();
337+ })
338+ .setNegativeButton (android .R .string .no , null )
339+ .show ();
340+ } else {
341+ // Just reset the form if there's no text
342+ commentForm .resetReplyState ();
343+ }
344+ });
345+ }
311346
312347 // For chat view, we primarily use infinite scrolling, but keep pagination
313348 // buttons just in case
@@ -321,8 +356,13 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
321356
322357 // Handle reply requests from comments
323358 adapter .setRequestingReplyListener ((commentToReplyTo ) -> {
324- // Show form in reply mode
325- commentForm .setReplyingTo (commentToReplyTo );
359+ // Set reply mode on the appropriate input method
360+ if (bottomCommentInput != null ) {
361+ bottomCommentInput .setReplyingTo (commentToReplyTo );
362+ bottomCommentInput .requestInputFocus ();
363+ } else if (commentForm != null ) {
364+ commentForm .setReplyingTo (commentToReplyTo );
365+ }
326366
327367 // Scroll to the comment being replied to
328368 int pos = adapter .getPositionForComment (commentToReplyTo );
@@ -344,8 +384,11 @@ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
344384 sendResults .call (new ArrayList <>());
345385 });
346386
347- // Set SDK on comment form for mentions functionality
348- commentForm .setSDK (sdk );
387+ // Set SDK on the appropriate input method for mentions functionality
388+ if (commentForm != null ) {
389+ commentForm .setSDK (sdk );
390+ }
391+ // Note: bottomCommentInput SDK is already set above
349392 }
350393
351394 private void setupVoteHandlers () {
@@ -901,8 +944,12 @@ public boolean onSuccess(GetCommentsResponseWithPresencePublicComment response)
901944 }
902945 }
903946
904- // Initialize the form with current user info
905- commentForm .setCurrentUser (sdk .getCurrentUser ());
947+ // Initialize the input with current user info
948+ if (bottomCommentInput != null ) {
949+ bottomCommentInput .setCurrentUser (sdk .getCurrentUser ());
950+ } else if (commentForm != null ) {
951+ commentForm .setCurrentUser (sdk .getCurrentUser ());
952+ }
906953 });
907954 return CONSUME ;
908955 }
@@ -927,13 +974,24 @@ public void scrollToBottom() {
927974 * @param parentId Parent comment ID for replies (null for top-level comments)
928975 */
929976 public void postComment (String commentText , String parentId ) {
930- commentForm .setSubmitting (true );
977+ // Set submitting state on the appropriate input method
978+ if (bottomCommentInput != null ) {
979+ bottomCommentInput .setSubmitting (true );
980+ } else if (commentForm != null ) {
981+ commentForm .setSubmitting (true );
982+ }
931983
932984 sdk .postComment (commentText , parentId , new FCCallback <PublicComment >() {
933985 @ Override
934986 public boolean onFailure (APIError error ) {
935987 getHandler ().post (() -> {
936- commentForm .setSubmitting (false );
988+ // Reset submitting state
989+ if (bottomCommentInput != null ) {
990+ bottomCommentInput .setSubmitting (false );
991+ } else if (commentForm != null ) {
992+ commentForm .setSubmitting (false );
993+ }
994+
937995 // Check for translated error message
938996 String errorMessage ;
939997 if (error .getTranslatedError () != null && !error .getTranslatedError ().isEmpty ()) {
@@ -944,17 +1002,29 @@ public boolean onFailure(APIError error) {
9441002 errorMessage = getContext ().getString (R .string .error_posting_comment );
9451003 }
9461004
947- commentForm .showError (errorMessage );
1005+ // Show error on the appropriate input method
1006+ if (bottomCommentInput != null ) {
1007+ bottomCommentInput .showError (errorMessage );
1008+ } else if (commentForm != null ) {
1009+ commentForm .showError (errorMessage );
1010+ }
9481011 });
9491012 return CONSUME ;
9501013 }
9511014
9521015 @ Override
9531016 public boolean onSuccess (PublicComment comment ) {
9541017 getHandler ().post (() -> {
955- commentForm .setSubmitting (false );
956- commentForm .clearText ();
957- commentForm .resetReplyState ();
1018+ // Reset state on the appropriate input method
1019+ if (bottomCommentInput != null ) {
1020+ bottomCommentInput .setSubmitting (false );
1021+ bottomCommentInput .clearText ();
1022+ bottomCommentInput .clearReplyState ();
1023+ } else if (commentForm != null ) {
1024+ commentForm .setSubmitting (false );
1025+ commentForm .clearText ();
1026+ commentForm .resetReplyState ();
1027+ }
9581028
9591029 // Show a toast message to confirm successful posting
9601030 android .widget .Toast .makeText (
0 commit comments