@@ -240,7 +240,7 @@ public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
240
240
Markwon postBodyMarkwon = MarkdownUtils .createFullRedditMarkwon (this ,
241
241
miscPlugin , emoteCloseBracketInlineProcessor , emotePlugin , imageAndGifPlugin , parentTextColor ,
242
242
parentSpoilerBackgroundColor , null );
243
- CustomMarkwonAdapter markwonAdapter = MarkdownUtils .createCustomTablesAdapter (imageAndGifEntry );
243
+ CustomMarkwonAdapter markwonAdapter = MarkdownUtils .createCustomTablesAndImagesAdapter (imageAndGifEntry );
244
244
markwonAdapter .setOnLongClickListener (view -> {
245
245
Utils .hideKeyboard (CommentActivity .this );
246
246
CopyTextBottomSheetFragment .show (getSupportFragmentManager (),
@@ -282,24 +282,25 @@ public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
282
282
}
283
283
284
284
MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter (
285
- mCustomThemeWrapper , new MarkdownBottomBarRecyclerViewAdapter .ItemClickListener () {
286
- @ Override
287
- public void onClick (int item ) {
288
- MarkdownBottomBarRecyclerViewAdapter .bindEditTextWithItemClickListener (
289
- CommentActivity .this , binding .commentCommentEditText , item );
290
- }
285
+ mCustomThemeWrapper , true ,
286
+ new MarkdownBottomBarRecyclerViewAdapter .ItemClickListener () {
287
+ @ Override
288
+ public void onClick (int item ) {
289
+ MarkdownBottomBarRecyclerViewAdapter .bindEditTextWithItemClickListener (
290
+ CommentActivity .this , binding .commentCommentEditText , item );
291
+ }
291
292
292
- @ Override
293
- public void onUploadImage () {
294
- Utils .hideKeyboard (CommentActivity .this );
295
- UploadedImagesBottomSheetFragment fragment = new UploadedImagesBottomSheetFragment ();
296
- Bundle arguments = new Bundle ();
297
- arguments .putParcelableArrayList (UploadedImagesBottomSheetFragment .EXTRA_UPLOADED_IMAGES ,
298
- uploadedImages );
299
- fragment .setArguments (arguments );
300
- fragment .show (getSupportFragmentManager (), fragment .getTag ());
301
- }
302
- });
293
+ @ Override
294
+ public void onUploadImage () {
295
+ Utils .hideKeyboard (CommentActivity .this );
296
+ UploadedImagesBottomSheetFragment fragment = new UploadedImagesBottomSheetFragment ();
297
+ Bundle arguments = new Bundle ();
298
+ arguments .putParcelableArrayList (UploadedImagesBottomSheetFragment .EXTRA_UPLOADED_IMAGES ,
299
+ uploadedImages );
300
+ fragment .setArguments (arguments );
301
+ fragment .show (getSupportFragmentManager (), fragment .getTag ());
302
+ }
303
+ });
303
304
304
305
binding .commentMarkdownBottomBarRecyclerView .setLayoutManager (new LinearLayoutManagerBugFixed (this ,
305
306
LinearLayoutManagerBugFixed .HORIZONTAL , false ));
@@ -402,7 +403,7 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
402
403
return true ;
403
404
} else if (itemId == R .id .action_preview_comment_activity ) {
404
405
Intent intent = new Intent (this , FullMarkdownActivity .class );
405
- intent .putExtra (FullMarkdownActivity .EXTRA_COMMENT_MARKDOWN , binding .commentCommentEditText .getText ().toString ());
406
+ intent .putExtra (FullMarkdownActivity .EXTRA_MARKDOWN , binding .commentCommentEditText .getText ().toString ());
406
407
intent .putExtra (FullMarkdownActivity .EXTRA_SUBMIT_POST , true );
407
408
startActivityForResult (intent , MARKDOWN_PREVIEW_REQUEST_CODE );
408
409
} else if (itemId == R .id .action_send_comment_activity ) {
@@ -436,8 +437,8 @@ public void sendComment(@Nullable MenuItem item) {
436
437
.connectionPool (new ConnectionPool (0 , 1 , TimeUnit .NANOSECONDS ))
437
438
.build ())
438
439
.build ();
439
- SendComment .sendComment (mExecutor , new Handler (), binding .commentCommentEditText .getText ().toString (),
440
- parentFullname , parentDepth , newAuthenticatorOauthRetrofit , selectedAccount ,
440
+ SendComment .sendComment (this , mExecutor , new Handler (), binding .commentCommentEditText .getText ().toString (),
441
+ parentFullname , parentDepth , uploadedImages , newAuthenticatorOauthRetrofit , selectedAccount ,
441
442
new SendComment .SendCommentListener () {
442
443
@ Override
443
444
public void sendCommentSuccess (Comment comment ) {
@@ -466,7 +467,7 @@ public void sendCommentFailed(@Nullable String errorMessage) {
466
467
item .getIcon ().setAlpha (255 );
467
468
}
468
469
469
- if (errorMessage == null || ! errorMessage .equals ( "" )) {
470
+ if (errorMessage == null || errorMessage .isEmpty ( )) {
470
471
Snackbar .make (binding .commentCoordinatorLayout , R .string .send_comment_failed , Snackbar .LENGTH_SHORT ).show ();
471
472
} else {
472
473
Snackbar .make (binding .commentCoordinatorLayout , errorMessage , Snackbar .LENGTH_SHORT ).show ();
@@ -557,7 +558,7 @@ public void uploadImage() {
557
558
public void captureImage () {
558
559
Intent pictureIntent = new Intent (MediaStore .ACTION_IMAGE_CAPTURE );
559
560
try {
560
- capturedImageUri = FileProvider .getUriForFile (this , "ml.docilealligator.infinityforreddit .provider" ,
561
+ capturedImageUri = FileProvider .getUriForFile (this , getPackageName () + " .provider" ,
561
562
File .createTempFile ("captured_image" , ".jpg" , getExternalFilesDir (Environment .DIRECTORY_PICTURES )));
562
563
pictureIntent .putExtra (MediaStore .EXTRA_OUTPUT , capturedImageUri );
563
564
startActivityForResult (pictureIntent , CAPTURE_IMAGE_REQUEST_CODE );
@@ -572,9 +573,16 @@ public void captureImage() {
572
573
public void insertImageUrl (UploadedImage uploadedImage ) {
573
574
int start = Math .max (binding .commentCommentEditText .getSelectionStart (), 0 );
574
575
int end = Math .max (binding .commentCommentEditText .getSelectionEnd (), 0 );
575
- binding .commentCommentEditText .getText ().replace (Math .min (start , end ), Math .max (start , end ),
576
- "[" + uploadedImage .imageName + "](" + uploadedImage .imageUrl + ")" ,
577
- 0 , "[]()" .length () + uploadedImage .imageName .length () + uploadedImage .imageUrl .length ());
576
+ int realStart = Math .min (start , end );
577
+ if (realStart > 0 && binding .commentCommentEditText .getText ().toString ().charAt (realStart - 1 ) != '\n' ) {
578
+ binding .commentCommentEditText .getText ().replace (realStart , Math .max (start , end ),
579
+ "\n \n " ,
580
+ 0 , "\n ![]()\n " .length () + uploadedImage .imageUrlOrKey .length ());
581
+ } else {
582
+ binding .commentCommentEditText .getText ().replace (realStart , Math .max (start , end ),
583
+ "\n " ,
584
+ 0 , "![]()\n " .length () + uploadedImage .imageUrlOrKey .length ());
585
+ }
578
586
}
579
587
580
588
@ Override
0 commit comments