From 67847d90dae066d44d70599a67339a292f16c963 Mon Sep 17 00:00:00 2001 From: Grishka Date: Wed, 1 May 2024 17:38:22 +0300 Subject: [PATCH 1/7] Fix #832 --- mastodon/src/main/res/layout/sheet_photo_viewer_info.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/mastodon/src/main/res/layout/sheet_photo_viewer_info.xml b/mastodon/src/main/res/layout/sheet_photo_viewer_info.xml index b588e173..560f85d6 100644 --- a/mastodon/src/main/res/layout/sheet_photo_viewer_info.xml +++ b/mastodon/src/main/res/layout/sheet_photo_viewer_info.xml @@ -141,6 +141,7 @@ android:layout_marginHorizontal="16dp" android:textAppearance="@style/m3_body_large" android:textColor="?colorM3OnSurface" + android:textIsSelectable="true" tools:text="A cute black cat"/> From 0e868f0be0124202b9269e3f32cea9a501cc3762 Mon Sep 17 00:00:00 2001 From: Grishka Date: Wed, 1 May 2024 17:39:56 +0300 Subject: [PATCH 2/7] English proper nouns are a mess --- mastodon/src/main/res/values/strings.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mastodon/src/main/res/values/strings.xml b/mastodon/src/main/res/values/strings.xml index 4ad2692b..069e370f 100644 --- a/mastodon/src/main/res/values/strings.xml +++ b/mastodon/src/main/res/values/strings.xml @@ -314,7 +314,7 @@ This server does not accept new registrations. Copied to clipboard Bookmark - Remove Bookmark + Remove bookmark Bookmarks Your favorites Welcome back @@ -751,8 +751,8 @@ Fewer algorithmic fanfares Only your followers Everyone mentioned in the post - View Boosts - View Favorites - Undo Boost - Undo Favorite + View boosts + View favorites + Undo boost + Undo favorite \ No newline at end of file From c7b8cc72fc81a5640357b1bd69627b514a73bd2a Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Wed, 1 May 2024 23:14:08 +0200 Subject: [PATCH 3/7] Display more user-friendly error messages Instead of displaying the Java exception, this change displays a more user-friendly message for some common network-related issues. Fixes mastodon/mastodon-android#667 --- .../android/api/MastodonErrorResponse.java | 23 +++++++++++++++++-- mastodon/src/main/res/values/strings.xml | 5 ++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/MastodonErrorResponse.java b/mastodon/src/main/java/org/joinmastodon/android/api/MastodonErrorResponse.java index 9dfbfdc8..70b21d6d 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/MastodonErrorResponse.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/MastodonErrorResponse.java @@ -5,31 +5,50 @@ import android.view.View; import android.widget.TextView; import android.widget.Toast; +import com.google.gson.JsonIOException; +import com.google.gson.JsonSyntaxException; + import org.joinmastodon.android.R; +import java.net.SocketTimeoutException; +import java.net.UnknownHostException; + import me.grishka.appkit.api.ErrorResponse; public class MastodonErrorResponse extends ErrorResponse{ public final String error; public final int httpStatus; public final Throwable underlyingException; + public final int messageResource; public MastodonErrorResponse(String error, int httpStatus, Throwable exception){ this.error=error; this.httpStatus=httpStatus; this.underlyingException=exception; + + if(exception instanceof UnknownHostException){ + this.messageResource=R.string.could_not_reach_server; + }else if(exception instanceof SocketTimeoutException){ + this.messageResource=R.string.connection_timed_out; + }else if(exception instanceof JsonSyntaxException || exception instanceof JsonIOException || httpStatus>=500){ + this.messageResource=R.string.server_error; + }else if(httpStatus == 404){ + this.messageResource=R.string.not_found; + }else{ + this.messageResource=R.string.unknown_error; + } } @Override public void bindErrorView(View view){ TextView text=view.findViewById(R.id.error_text); - text.setText(error); + text.setText(view.getContext().getString(messageResource, error)); } @Override public void showToast(Context context){ if(context==null) return; - Toast.makeText(context, error, Toast.LENGTH_SHORT).show(); + Toast.makeText(context, context.getString(messageResource, error), Toast.LENGTH_SHORT).show(); } } diff --git a/mastodon/src/main/res/values/strings.xml b/mastodon/src/main/res/values/strings.xml index 069e370f..b36247e1 100644 --- a/mastodon/src/main/res/values/strings.xml +++ b/mastodon/src/main/res/values/strings.xml @@ -755,4 +755,9 @@ View favorites Undo boost Undo favorite + Could not reach the server. Make sure you\'re connected to the internet and try again. + Connection timed out. Make sure you\'re connected to the internet and try again. + There may be a problem with your instance or your internet. Make sure you have access to the internet and try again. + Not found. It probably doesn\'t exist anymore. + Unknown error: %s \ No newline at end of file From 4a1b1e19e8e2f42699f2199ed69a8fe8b5ab8f95 Mon Sep 17 00:00:00 2001 From: Grishka Date: Sat, 4 May 2024 21:20:20 +0300 Subject: [PATCH 4/7] Fix #834 --- .../android/ui/displayitems/MediaGridStatusDisplayItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/MediaGridStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/MediaGridStatusDisplayItem.java index e21d557e..e3e3d7fe 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/MediaGridStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/MediaGridStatusDisplayItem.java @@ -173,7 +173,7 @@ public class MediaGridStatusDisplayItem extends StatusDisplayItem{ } controllers.add(c); - if (item.status.translation != null){ + if (item.status.translation!=null && item.status.translation.mediaAttachments!=null){ if(item.status.translationState==Status.TranslationState.SHOWN){ if(!item.translatedAttachments.containsKey(att.id)){ Optional translatedAttachment=Arrays.stream(item.status.translation.mediaAttachments).filter(mediaAttachment->mediaAttachment.id.equals(att.id)).findFirst(); From bc78c61009d4a2eadf74ca077933fa56a027017a Mon Sep 17 00:00:00 2001 From: Grishka Date: Mon, 6 May 2024 12:56:56 +0300 Subject: [PATCH 5/7] Fix #835 --- .../settings/SettingsServerAboutFragment.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerAboutFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerAboutFragment.java index cd464289..307dfd83 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerAboutFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsServerAboutFragment.java @@ -100,15 +100,19 @@ public class SettingsServerAboutFragment extends LoaderFragment{ scroller.setClipToPadding(false); scroller.addView(scrollingLayout); - FixedAspectRatioImageView banner=new FixedAspectRatioImageView(getActivity()); - banner.setAspectRatio(1.914893617f); - banner.setScaleType(ImageView.ScaleType.CENTER_CROP); - banner.setOutlineProvider(OutlineProviders.bottomRoundedRect(16)); - banner.setClipToOutline(true); - ViewImageLoader.loadWithoutAnimation(banner, getResources().getDrawable(R.drawable.image_placeholder, getActivity().getTheme()), new UrlImageLoaderRequest(instance.thumbnail)); - LinearLayout.LayoutParams blp=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - blp.bottomMargin=V.dp(24); - scrollingLayout.addView(banner, blp); + if(!TextUtils.isEmpty(instance.thumbnail)){ + FixedAspectRatioImageView banner=new FixedAspectRatioImageView(getActivity()); + banner.setAspectRatio(1.914893617f); + banner.setScaleType(ImageView.ScaleType.CENTER_CROP); + banner.setOutlineProvider(OutlineProviders.bottomRoundedRect(16)); + banner.setClipToOutline(true); + ViewImageLoader.loadWithoutAnimation(banner, getResources().getDrawable(R.drawable.image_placeholder, getActivity().getTheme()), new UrlImageLoaderRequest(instance.thumbnail)); + LinearLayout.LayoutParams blp=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + blp.bottomMargin=V.dp(24); + scrollingLayout.addView(banner, blp); + }else{ + scrollingLayout.setPadding(0, V.dp(24), 0, 0); + } boolean needDivider=false; if(instance.contactAccount!=null){ From 97e16b9f736949402fa3bf0bf2a0e2c3052370ac Mon Sep 17 00:00:00 2001 From: Grishka Date: Tue, 7 May 2024 23:04:43 +0300 Subject: [PATCH 6/7] Use `image_matrix_limit` from instance configuration if available --- .../ui/viewcontrollers/ComposeMediaViewController.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeMediaViewController.java b/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeMediaViewController.java index 94170fd6..e3930971 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeMediaViewController.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/viewcontrollers/ComposeMediaViewController.java @@ -313,7 +313,12 @@ public class ComposeMediaViewController{ int maxSize=0; String contentType=fragment.getActivity().getContentResolver().getType(attachment.uri); if(contentType!=null && contentType.startsWith("image/")){ - maxSize=2_073_600; // TODO get this from instance configuration when it gets added there + Instance instance=fragment.instance; + if(instance.configuration!=null && instance.configuration.mediaAttachments!=null && instance.configuration.mediaAttachments.imageMatrixLimit>0){ + maxSize=instance.configuration.mediaAttachments.imageMatrixLimit; + }else{ + maxSize=2_073_600; + } } attachment.progressBar.setProgress(0); attachment.speedTracker.reset(); From 629e65edbad246f4c90dca20e20b9ff4f957bec8 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 13 May 2024 00:08:18 +0200 Subject: [PATCH 7/7] Update error messages and remove the unknown error text --- .../android/api/MastodonErrorResponse.java | 20 +++++++++++++++---- mastodon/src/main/res/values/strings.xml | 9 ++++----- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/MastodonErrorResponse.java b/mastodon/src/main/java/org/joinmastodon/android/api/MastodonErrorResponse.java index 70b21d6d..f7d69066 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/MastodonErrorResponse.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/MastodonErrorResponse.java @@ -32,23 +32,35 @@ public class MastodonErrorResponse extends ErrorResponse{ this.messageResource=R.string.connection_timed_out; }else if(exception instanceof JsonSyntaxException || exception instanceof JsonIOException || httpStatus>=500){ this.messageResource=R.string.server_error; - }else if(httpStatus == 404){ + }else if(httpStatus==404){ this.messageResource=R.string.not_found; }else{ - this.messageResource=R.string.unknown_error; + this.messageResource=0; } } @Override public void bindErrorView(View view){ TextView text=view.findViewById(R.id.error_text); - text.setText(view.getContext().getString(messageResource, error)); + String message; + if(messageResource>0){ + message=view.getContext().getString(messageResource, error); + }else{ + message=error; + } + text.setText(message); } @Override public void showToast(Context context){ if(context==null) return; - Toast.makeText(context, context.getString(messageResource, error), Toast.LENGTH_SHORT).show(); + String message; + if(messageResource>0){ + message=context.getString(messageResource, error); + }else{ + message=error; + } + Toast.makeText(context, message, Toast.LENGTH_SHORT).show(); } } diff --git a/mastodon/src/main/res/values/strings.xml b/mastodon/src/main/res/values/strings.xml index b36247e1..5f3886ff 100644 --- a/mastodon/src/main/res/values/strings.xml +++ b/mastodon/src/main/res/values/strings.xml @@ -755,9 +755,8 @@ View favorites Undo boost Undo favorite - Could not reach the server. Make sure you\'re connected to the internet and try again. - Connection timed out. Make sure you\'re connected to the internet and try again. - There may be a problem with your instance or your internet. Make sure you have access to the internet and try again. - Not found. It probably doesn\'t exist anymore. - Unknown error: %s + Couldn’t reach the server. Check your connection and try again? + The request timed out. Check your connection and try again? + Something went wrong talking with your server. It’s probably not your fault. Try again? + It could’ve been deleted, or maybe it never existed at all. \ No newline at end of file