aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-07-04 14:57:30 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-07-04 14:57:30 +0000
commitbf127f6fe97c94d254bde2542730187e58d5294d (patch)
treec18cbb21da2b388c6a11797f7a30924dd34d1a72 /app/src/main/java
parentf3d905c817c29798755fca863775a90ce0b511e1 (diff)
downloadinfinity-for-reddit-bf127f6fe97c94d254bde2542730187e58d5294d.tar
infinity-for-reddit-bf127f6fe97c94d254bde2542730187e58d5294d.tar.gz
infinity-for-reddit-bf127f6fe97c94d254bde2542730187e58d5294d.tar.bz2
infinity-for-reddit-bf127f6fe97c94d254bde2542730187e58d5294d.tar.lz
infinity-for-reddit-bf127f6fe97c94d254bde2542730187e58d5294d.tar.xz
infinity-for-reddit-bf127f6fe97c94d254bde2542730187e58d5294d.tar.zst
infinity-for-reddit-bf127f6fe97c94d254bde2542730187e58d5294d.zip
Remove file extension from uploaded image's file name after uploading an image. Send Toast and Snackbar messages when uploading an image.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
index 93e4e2a8..2c3e10b6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
@@ -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;
}
}