Skip to content

Commit 0bc6a47

Browse files
committed
3.13.0 the attachment update
updated kotlin things
1 parent be11598 commit 0bc6a47

File tree

14 files changed

+84
-38
lines changed

14 files changed

+84
-38
lines changed

Awful.apk/build.gradle

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
buildscript {
2-
ext.kotlin_version = '1.9.21'
2+
ext.kotlin_version = '2.2.21'
33

44
dependencies {
5-
classpath 'com.android.tools.build:gradle:8.13.0'
5+
classpath 'com.android.tools.build:gradle:8.13.1'
66
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
77
}
88
}
@@ -15,7 +15,7 @@ plugins {
1515

1616
android {
1717
namespace "com.ferg.awfulapp"
18-
compileSdk 36
18+
compileSdk = 36
1919

2020
buildFeatures {
2121
viewBinding = true
@@ -141,9 +141,8 @@ dependencies {
141141
testImplementation 'org.hamcrest:hamcrest-library:3.0'
142142
implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
143143

144-
implementation "androidx.core:core:1.17.0"
144+
implementation "androidx.core:core-ktx:1.17.0"
145145
implementation 'androidx.core:core-google-shortcuts:1.1.0'
146146

147147
// updating this might cause the status and navigation bar to become blue, test for this
148-
implementation 'androidx.core:core-splashscreen:1.0.0-alpha02'
149-
}
148+
implementation 'androidx.core:core-splashscreen:1.0.0-alpha02'}

Awful.apk/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
-->
88
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
99
package="com.ferg.awfulapp"
10-
android:versionCode="31204"
11-
android:versionName="3.12.4"
10+
android:versionCode="31300"
11+
android:versionName="3.13.0"
1212
android:installLocation="auto">
1313
<supports-screens
1414
android:smallScreens="true"

Awful.apk/src/main/assets/changelog.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
<!-- See the Changelog code for the expected structure of this document -->
66

77
<main>
8+
<section>
9+
<h2>3.13.0</h2>
10+
<ul>
11+
<li>Raised attachment limit to 2MB to match forums. Where will this end??</li>
12+
<li>Now showing attachment file name if present. Hope you named that file well or remember what "1000016741.png" was</li>
13+
<li>Removed option to add attachments on edits, added option to remove attachments on edits. I think this balances it out.</li>
14+
<li>Fixed file permissions for adding attachments when posting new threads. Someone surely must be doing that, right?</li>
15+
</ul>
16+
</section>
817
<section>
918
<h2>3.12.4</h2>
1019
<ul>

Awful.apk/src/main/java/com/ferg/awfulapp/PostReplyFragment.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ public class PostReplyFragment extends AwfulFragment {
131131
private boolean saveRequired = true;
132132
@Nullable
133133
private Intent attachmentData;
134+
private boolean removeAttachment = false;
134135

135136
// async stuff
136137
private ContentResolver mContentResolver;
@@ -300,6 +301,9 @@ public void success(ContentValues result) {
300301
messageComposer.setText(null, false);
301302
}
302303
}
304+
if (result.containsKey(AwfulMessage.REPLY_ATTACHMENT)) {
305+
mFileAttachment = result.getAsString(AwfulMessage.REPLY_ATTACHMENT);
306+
}
303307
// set any options and update the menu
304308
postSignature = getCheckedAndRemove(REPLY_SIGNATURE, result);
305309
disableEmotes = getCheckedAndRemove(REPLY_DISABLE_SMILIES, result);
@@ -581,6 +585,8 @@ private ContentValues prepareCV() {
581585
}
582586
if (!TextUtils.isEmpty(mFileAttachment)) {
583587
cv.put(AwfulMessage.REPLY_ATTACHMENT, mFileAttachment);
588+
} else if(mReplyType == TYPE_EDIT && removeAttachment) {
589+
cv.put(AwfulMessage.REPLY_ATTACHMENT_ACTION, Constants.DELETE);
584590
}
585591
if (postSignature) {
586592
cv.put(REPLY_SIGNATURE, Constants.YES);
@@ -755,13 +761,16 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
755761

756762
MenuItem attach = menu.findItem(R.id.add_attachment);
757763
if (attach != null && getPrefs() != null) {
758-
attach.setEnabled(getPrefs().hasPlatinum);
759-
attach.setVisible(getPrefs().hasPlatinum);
764+
attach.setEnabled(getPrefs().hasPlatinum && mReplyType != TYPE_EDIT);
765+
attach.setVisible(getPrefs().hasPlatinum && mReplyType != TYPE_EDIT);
760766
}
761767
MenuItem remove = menu.findItem(R.id.remove_attachment);
762-
if (remove != null && getPrefs() != null) {
763-
remove.setEnabled((getPrefs().hasPlatinum && this.mFileAttachment != null));
764-
remove.setVisible(getPrefs().hasPlatinum && this.mFileAttachment != null);
768+
if (remove != null && getPrefs() != null && this.mFileAttachment != null) {
769+
remove.setEnabled(getPrefs().hasPlatinum);
770+
remove.setVisible(getPrefs().hasPlatinum);
771+
String[] filepath = this.mFileAttachment.split("/");
772+
String filename = filepath[filepath.length-1];
773+
remove.setTitle("Remove " + filename);
765774
}
766775
MenuItem disableEmoticons = menu.findItem(R.id.disableEmots);
767776
if (disableEmoticons != null) {
@@ -789,6 +798,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
789798
break;
790799
case R.id.remove_attachment:
791800
this.mFileAttachment = null;
801+
if (mReplyType == TYPE_EDIT) {
802+
removeAttachment = true;
803+
}
792804
Toast removeToast = Toast.makeText(getAwfulActivity(), getAwfulActivity().getResources().getText(R.string.file_removed), Toast.LENGTH_SHORT);
793805
removeToast.show();
794806
invalidateOptionsMenu();

Awful.apk/src/main/java/com/ferg/awfulapp/PostThreadFragment.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,15 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
217217
int permissionCheck = ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_EXTERNAL_STORAGE);
218218
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
219219
this.attachmentData = data;
220-
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, Constants.AWFUL_PERMISSION_READ_EXTERNAL_STORAGE);
221-
} else {
222-
addAttachment(data);
220+
if (AwfulUtils.isTiramisu33()) {
221+
requestPermissions(new String[]{Manifest.permission.READ_MEDIA_IMAGES}, Constants.AWFUL_PERMISSION_READ_MEDIA_IMAGES);
222+
} else {
223+
requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, Constants.AWFUL_PERMISSION_READ_EXTERNAL_STORAGE);
224+
}
225+
return;
223226
}
224-
} else {
225-
addAttachment(data);
226227
}
228+
addAttachment(data);
227229
}
228230
}
229231
}
@@ -233,6 +235,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
233235
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
234236
switch (requestCode) {
235237
case Constants.AWFUL_PERMISSION_READ_EXTERNAL_STORAGE:
238+
case Constants.AWFUL_PERMISSION_READ_MEDIA_IMAGES:
236239
// If request is cancelled, the result arrays are empty.
237240
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
238241
addAttachment();
@@ -698,9 +701,12 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
698701
attach.setVisible(getPrefs().hasPlatinum);
699702
}
700703
MenuItem remove = menu.findItem(R.id.remove_attachment);
701-
if (remove != null && getPrefs() != null) {
702-
remove.setEnabled((getPrefs().hasPlatinum && this.mFileAttachment != null));
703-
remove.setVisible(getPrefs().hasPlatinum && this.mFileAttachment != null);
704+
if (remove != null && getPrefs() != null && this.mFileAttachment != null) {
705+
remove.setEnabled(getPrefs().hasPlatinum);
706+
remove.setVisible(getPrefs().hasPlatinum);
707+
String[] filepath = this.mFileAttachment.split("/");
708+
String filename = filepath[filepath.length-1];
709+
remove.setTitle("Remove " + filename);
704710
}
705711
MenuItem disableEmoticons = menu.findItem(R.id.disableEmots);
706712
if (disableEmoticons != null) {

Awful.apk/src/main/java/com/ferg/awfulapp/constants/Constants.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public class Constants {
100100
public static final String PARAM_SUBMIT = "submit";
101101
public static final String PARAM_PREVIEW = "preview";
102102
public static final String PARAM_PARSEURL = "parseurl";
103+
public static final String PARAM_ATTACHMENT_ACTION = "attachmentaction";
103104

104105
public static final String USERLIST_IGNORE = "ignore";
105106
public static final String USERLIST_BUDDY = "buddy";
@@ -161,7 +162,7 @@ public class Constants {
161162
public static final int PRIVATE_MESSAGE_SENT_FOLDER = -1;
162163

163164
// attachments
164-
public static final int ATTACHMENT_MAX_BYTES = 1024 * 1024;
165+
public static final int ATTACHMENT_MAX_BYTES = 1024 * 1024 * 2;
165166
public static final int ATTACHMENT_MAX_WIDTH = 4096;
166167
public static final int ATTACHMENT_MAX_HEIGHT = 4096;
167168

@@ -195,8 +196,10 @@ public class Constants {
195196
public static final String PREVIEW_POST = "Preview Post";
196197

197198
public static final String YES = "yes";//heh
199+
public static final String DELETE = "delete";//heh
198200

199-
//NOT FOR NETWORK USE
201+
202+
//NOT FOR NETWORK USE
200203
public static final String FORUM_PAGE = "forum_page";
201204
//NOT FOR NETWORK USE
202205
public static final String THREAD_PAGE = "thread_page";

Awful.apk/src/main/java/com/ferg/awfulapp/forums/UpdateTask.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ internal abstract class UpdateTask(protected val context: Context, private val t
272272

273273
private fun StringBuilder.appendPadded(message: String, pad: Int) {
274274
repeat(pad) { append('-') }
275-
appendln(message)
275+
this.appendLine(message)
276276
}
277277

278278
companion object {

Awful.apk/src/main/java/com/ferg/awfulapp/reply/Reply.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,15 @@ public static final ContentValues processEdit(Document response, int threadId, i
8989
edit.put(AwfulMessage.ID, threadId);
9090
edit.put(AwfulMessage.TYPE, AwfulMessage.TYPE_EDIT);
9191
edit.put(AwfulMessage.REPLY_CONTENT, getMessageContent(response));
92+
edit.put(AwfulMessage.REPLY_ATTACHMENT, getAttachment(response));
9293
edit.put(AwfulPost.FORM_BOOKMARK, getBookmarkOption(response));
9394
edit.put(AwfulPost.FORM_SIGNATURE, getSignatureOption(response));
9495
edit.put(AwfulPost.FORM_DISABLE_SMILIES, getDisableEmotesOption(response));
9596
edit.put(AwfulPost.REPLY_ORIGINAL_CONTENT, edit.getAsString(AwfulMessage.REPLY_CONTENT));
9697
edit.put(AwfulPost.EDIT_POST_ID, postId);
9798
return edit;
9899
}
99-
100+
100101
public static final String getMessageContent(Document data) throws AwfulError{
101102
try{
102103
Element formContent = data.getElementsByAttributeValue("name", "message").first();
@@ -106,6 +107,18 @@ public static final String getMessageContent(Document data) throws AwfulError{
106107
}
107108
}
108109

110+
public static String getAttachment(Document data) throws AwfulError{
111+
try{
112+
Element attachmentAction = data.getElementsByAttributeValue("name", "attachmentaction").first();
113+
if (attachmentAction != null){
114+
return attachmentAction.nextElementSibling().text();
115+
}
116+
return null;
117+
} catch (Exception e){
118+
throw new AwfulError("Failed to load quote");
119+
}
120+
}
121+
109122
public static final String getBookmarkOption(Document data){
110123
Element formBookmark = data.getElementsByAttributeValue("name", "bookmark").first();
111124
if(formBookmark.hasAttr("checked")){

Awful.apk/src/main/java/com/ferg/awfulapp/search/SearchFragment.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ import com.google.android.material.snackbar.Snackbar
6767
import com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayoutDirection
6868
import org.apache.commons.lang3.ArrayUtils
6969
import timber.log.Timber
70+
import java.util.Locale.getDefault
7071

7172
class SearchFragment : AwfulFragment(), com.orangegangsters.github.swipyrefreshlayout.library.SwipyRefreshLayout.OnRefreshListener {
7273

@@ -145,7 +146,8 @@ class SearchFragment : AwfulFragment(), com.orangegangsters.github.swipyrefreshl
145146
private fun search() {
146147
mDialog = ProgressDialog.show(activity, getString(R.string.search_forums_active_dialog_title), getString(R.string.search_forums_active_dialog_message), true, false)
147148
val searchForumsPrimitive = ArrayUtils.toPrimitive(searchForums.toTypedArray())
148-
NetworkUtils.queueRequest(SearchRequest(this.requireContext(), mSearchQuery.text.toString().toLowerCase(), searchForumsPrimitive)
149+
NetworkUtils.queueRequest(SearchRequest(this.requireContext(),
150+
mSearchQuery.text.toString().lowercase(getDefault()), searchForumsPrimitive)
149151
.build(null, object : AwfulRequest.AwfulResultCallback<AwfulSearchResult> {
150152
override fun success(result: AwfulSearchResult) {
151153
removeLoadingDialog()

Awful.apk/src/main/java/com/ferg/awfulapp/task/SendEditRequest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class SendEditRequest(context: Context, reply: ContentValues)
2626
}
2727
listOf(AwfulMessage.REPLY_SIGNATURE, AwfulMessage.REPLY_DISABLE_SMILIES)
2828
.forEach { key -> if (reply.containsKey(key)) add(key, YES) }
29-
reply.getAsString(AwfulMessage.REPLY_ATTACHMENT)?.let { filePath ->
30-
attachFile(PARAM_ATTACHMENT, filePath)
29+
if (reply.getAsString(AwfulMessage.REPLY_ATTACHMENT_ACTION).equals("delete", ignoreCase = true)) {
30+
add(PARAM_ATTACHMENT_ACTION, DELETE)
3131
}
3232
}
3333
}

0 commit comments

Comments
 (0)