mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 20:57:25 +01:00
Remove file extension from uploaded image's file name after uploading an image. Send Toast and Snackbar messages when uploading an image.
This commit is contained in:
parent
f3d905c817
commit
bf127f6fe9
@ -433,6 +433,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
|
||||
}
|
||||
|
||||
private void uploadImageToReddit(Uri imageUri) {
|
||||
Toast.makeText(this, R.string.uploading_image, Toast.LENGTH_SHORT).show();
|
||||
Handler handler = new Handler();
|
||||
mExecutor.execute(() -> {
|
||||
try {
|
||||
@ -449,8 +450,9 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
|
||||
int start = Math.max(commentEditText.getSelectionStart(), 0);
|
||||
int end = Math.max(commentEditText.getSelectionEnd(), 0);
|
||||
commentEditText.getText().replace(Math.min(start, end), Math.max(start, end),
|
||||
"[" + imageUrlOrError + "](" + imageUrlOrError + ")",
|
||||
0, "[]()".length() + imageUrlOrError.length() + imageUrlOrError.length());
|
||||
"[" + fileName + "](" + imageUrlOrError + ")",
|
||||
0, "[]()".length() + fileName.length() + imageUrlOrError.length());
|
||||
Snackbar.make(coordinatorLayout, R.string.upload_image_success, Snackbar.LENGTH_LONG).show();
|
||||
} else {
|
||||
Toast.makeText(CommentActivity.this, R.string.upload_image_failed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
@ -497,7 +499,11 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
|
||||
if (cursor != null) {
|
||||
int nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
|
||||
cursor.moveToFirst();
|
||||
return cursor.getString(nameIndex);
|
||||
String fileName = cursor.getString(nameIndex);
|
||||
if(fileName != null && fileName.contains(".")) {
|
||||
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1121,6 +1121,8 @@
|
||||
<string name="uploaded_images">Uploaded Images</string>
|
||||
<string name="upload">Upload</string>
|
||||
<string name="capture">Capture</string>
|
||||
<string name="uploading_image">Uploading</string>
|
||||
<string name="upload_image_success">Upload image successfully. Click the image button again to see the uploaded images.</string>
|
||||
<string name="get_image_bitmap_failed">Unable to get the bitmap of the image</string>
|
||||
<string name="upload_image_failed">Unable to upload the image</string>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user