Skip to content

Commit 99d5420

Browse files
Merge remote-tracking branch 'origin/snackbar-for-recent-search-deletions' into snackbar-for-recent-search-deletions
2 parents 4012d14 + f1e8dc6 commit 99d5420

File tree

61 files changed

+3828
-2892
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3828
-2892
lines changed

app/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ android {
88
applicationId "ml.docilealligator.infinityforreddit"
99
minSdk 21
1010
targetSdk 33
11-
versionCode 162
12-
versionName "7.0.2"
11+
versionCode 163
12+
versionName "7.1.0-beta1"
1313
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1414
javaCompileOptions {
1515
annotationProcessorOptions {
@@ -99,7 +99,7 @@ dependencies {
9999
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
100100
implementation "com.squareup.retrofit2:converter-scalars:$retrofitVersion"
101101
implementation "com.squareup.retrofit2:adapter-guava:$retrofitVersion"
102-
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
102+
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
103103

104104
// Dependency injection
105105
def daggerVersion = '2.40.5'
@@ -111,7 +111,7 @@ dependencies {
111111
def butterknifeVersion = "10.2.3"
112112
implementation "com.jakewharton:butterknife:$butterknifeVersion"
113113
annotationProcessor "com.jakewharton:butterknife-compiler:$butterknifeVersion"
114-
compileOnly 'com.android.databinding:viewbinding:7.3.1'
114+
compileOnly 'com.android.databinding:viewbinding:8.3.1'
115115

116116
// Events
117117
def eventbusVersion = "3.3.1"
@@ -135,7 +135,7 @@ dependencies {
135135
implementation 'net.lingala.zip4j:zip4j:2.11.2'
136136

137137
// IO functionality
138-
implementation 'commons-io:commons-io:2.5'
138+
implementation 'commons-io:commons-io:2.13.0'
139139

140140
// Crash reporting
141141
implementation 'com.github.FunkyMuse:Crashy:1.2.0'
@@ -144,7 +144,7 @@ dependencies {
144144
/**** User Interface (frontend) ****/
145145

146146
//Image loading
147-
def glideVersion = "4.12.0"
147+
def glideVersion = "4.16.0"
148148
implementation "com.github.bumptech.glide:glide:$glideVersion"
149149
annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
150150
implementation 'jp.wasabeef:glide-transformations:4.3.0'

app/src/main/java/ml/docilealligator/infinityforreddit/PollPayload.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class PollPayload {
1414
public String flairId;
1515
@SerializedName("flair_text")
1616
public String flairText;
17+
@SerializedName("raw_rtjson")
18+
public String richTextJSON;
1719
@SerializedName("post_to_twitter")
1820
public boolean postToTwitter = false;
1921
@SerializedName("sendreplies")
@@ -26,12 +28,14 @@ public class PollPayload {
2628
public String subredditName;
2729
@SerializedName("submit_type")
2830
public String submitType;
31+
public String text;
2932
public String title;
3033
@SerializedName("validate_on_submit")
3134
public boolean validateOnSubmit = true;
3235

3336
public PollPayload(String subredditName, String title, String[] options, int duration, boolean isNsfw,
34-
boolean isSpoiler, Flair flair, boolean sendReplies, String submitType) {
37+
boolean isSpoiler, Flair flair, boolean sendReplies,
38+
String submitType) {
3539
this.subredditName = subredditName;
3640
this.title = title;
3741
this.options = options;
@@ -45,4 +49,23 @@ public PollPayload(String subredditName, String title, String[] options, int dur
4549
this.sendReplies = sendReplies;
4650
this.submitType = submitType;
4751
}
52+
53+
public PollPayload(String subredditName, String title, String[] options, int duration, boolean isNsfw,
54+
boolean isSpoiler, Flair flair, String richTextJSON, String text, boolean sendReplies,
55+
String submitType) {
56+
this.subredditName = subredditName;
57+
this.title = title;
58+
this.options = options;
59+
this.duration = duration;
60+
this.isNsfw = isNsfw;
61+
this.isSpoiler = isSpoiler;
62+
if (flair != null) {
63+
flairId = flair.getId();
64+
flairText = flair.getText();
65+
}
66+
this.richTextJSON = richTextJSON;
67+
this.text = text;
68+
this.sendReplies = sendReplies;
69+
this.submitType = submitType;
70+
}
4871
}

app/src/main/java/ml/docilealligator/infinityforreddit/RedditGalleryPayload.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class RedditGalleryPayload {
1717
@SerializedName("show_error_list")
1818
public boolean showErrorList = true;
1919
public String title;
20+
public String text;
2021
@SerializedName("spoiler")
2122
public boolean isSpoiler;
2223
@SerializedName("nsfw")
@@ -36,11 +37,12 @@ public class RedditGalleryPayload {
3637
public String flairText;
3738
public ArrayList<Item> items;
3839

39-
public RedditGalleryPayload(String subredditName, String submitType, String title,
40+
public RedditGalleryPayload(String subredditName, String submitType, String title, String text,
4041
boolean isSpoiler, boolean isNSFW, boolean sendReplies, Flair flair, ArrayList<Item> items) {
4142
this.subredditName = subredditName;
4243
this.submitType = submitType;
4344
this.title = title;
45+
this.text = text;
4446
this.isSpoiler = isSpoiler;
4547
this.isNSFW = isNSFW;
4648
this.sendReplies = sendReplies;

app/src/main/java/ml/docilealligator/infinityforreddit/UploadedImage.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,26 @@
55

66
public class UploadedImage implements Parcelable {
77
public String imageName;
8-
public String imageUrl;
8+
public String imageUrlOrKey;
9+
private String caption = "";
910

10-
public UploadedImage(String imageName, String imageUrl) {
11+
public UploadedImage(String imageName, String imageUrlOrKey) {
1112
this.imageName = imageName;
12-
this.imageUrl = imageUrl;
13+
this.imageUrlOrKey = imageUrlOrKey;
1314
}
1415

1516
protected UploadedImage(Parcel in) {
1617
imageName = in.readString();
17-
imageUrl = in.readString();
18+
imageUrlOrKey = in.readString();
19+
caption = in.readString();
20+
}
21+
22+
public String getCaption() {
23+
return caption == null ? "" : caption;
24+
}
25+
26+
public void setCaption(String caption) {
27+
this.caption = caption == null ? "" : caption;
1828
}
1929

2030
public static final Creator<UploadedImage> CREATOR = new Creator<UploadedImage>() {
@@ -37,6 +47,7 @@ public int describeContents() {
3747
@Override
3848
public void writeToParcel(Parcel parcel, int i) {
3949
parcel.writeString(imageName);
40-
parcel.writeString(imageUrl);
50+
parcel.writeString(imageUrlOrKey);
51+
parcel.writeString(caption);
4152
}
4253
}

app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
240240
Markwon postBodyMarkwon = MarkdownUtils.createFullRedditMarkwon(this,
241241
miscPlugin, emoteCloseBracketInlineProcessor, emotePlugin, imageAndGifPlugin, parentTextColor,
242242
parentSpoilerBackgroundColor, null);
243-
CustomMarkwonAdapter markwonAdapter = MarkdownUtils.createCustomTablesAdapter(imageAndGifEntry);
243+
CustomMarkwonAdapter markwonAdapter = MarkdownUtils.createCustomTablesAndImagesAdapter(imageAndGifEntry);
244244
markwonAdapter.setOnLongClickListener(view -> {
245245
Utils.hideKeyboard(CommentActivity.this);
246246
CopyTextBottomSheetFragment.show(getSupportFragmentManager(),
@@ -282,24 +282,25 @@ public void configureTheme(@NonNull MarkwonTheme.Builder builder) {
282282
}
283283

284284
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+
}
291292

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+
});
303304

304305
binding.commentMarkdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManagerBugFixed(this,
305306
LinearLayoutManagerBugFixed.HORIZONTAL, false));
@@ -402,7 +403,7 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
402403
return true;
403404
} else if (itemId == R.id.action_preview_comment_activity) {
404405
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());
406407
intent.putExtra(FullMarkdownActivity.EXTRA_SUBMIT_POST, true);
407408
startActivityForResult(intent, MARKDOWN_PREVIEW_REQUEST_CODE);
408409
} else if (itemId == R.id.action_send_comment_activity) {
@@ -436,8 +437,8 @@ public void sendComment(@Nullable MenuItem item) {
436437
.connectionPool(new ConnectionPool(0, 1, TimeUnit.NANOSECONDS))
437438
.build())
438439
.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,
441442
new SendComment.SendCommentListener() {
442443
@Override
443444
public void sendCommentSuccess(Comment comment) {
@@ -466,7 +467,7 @@ public void sendCommentFailed(@Nullable String errorMessage) {
466467
item.getIcon().setAlpha(255);
467468
}
468469

469-
if (errorMessage == null || !errorMessage.equals("")) {
470+
if (errorMessage == null || errorMessage.isEmpty()) {
470471
Snackbar.make(binding.commentCoordinatorLayout, R.string.send_comment_failed, Snackbar.LENGTH_SHORT).show();
471472
} else {
472473
Snackbar.make(binding.commentCoordinatorLayout, errorMessage, Snackbar.LENGTH_SHORT).show();
@@ -557,7 +558,7 @@ public void uploadImage() {
557558
public void captureImage() {
558559
Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
559560
try {
560-
capturedImageUri = FileProvider.getUriForFile(this, "ml.docilealligator.infinityforreddit.provider",
561+
capturedImageUri = FileProvider.getUriForFile(this, getPackageName() + ".provider",
561562
File.createTempFile("captured_image", ".jpg", getExternalFilesDir(Environment.DIRECTORY_PICTURES)));
562563
pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, capturedImageUri);
563564
startActivityForResult(pictureIntent, CAPTURE_IMAGE_REQUEST_CODE);
@@ -572,9 +573,16 @@ public void captureImage() {
572573
public void insertImageUrl(UploadedImage uploadedImage) {
573574
int start = Math.max(binding.commentCommentEditText.getSelectionStart(), 0);
574575
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![](" + uploadedImage.imageUrlOrKey + ")\n",
580+
0, "\n![]()\n".length() + uploadedImage.imageUrlOrKey.length());
581+
} else {
582+
binding.commentCommentEditText.getText().replace(realStart, Math.max(start, end),
583+
"![](" + uploadedImage.imageUrlOrKey + ")\n",
584+
0, "![]()\n".length() + uploadedImage.imageUrlOrKey.length());
585+
}
578586
}
579587

580588
@Override

0 commit comments

Comments
 (0)