Merge branch 'master' into donations

# Conflicts:
#	mastodon/src/main/res/values/strings.xml
This commit is contained in:
Grishka 2024-05-21 20:08:43 +03:00
commit 2dae00800e
6 changed files with 63 additions and 18 deletions

View File

@ -5,31 +5,62 @@ import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
import org.joinmastodon.android.R; import org.joinmastodon.android.R;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import me.grishka.appkit.api.ErrorResponse; import me.grishka.appkit.api.ErrorResponse;
public class MastodonErrorResponse extends ErrorResponse{ public class MastodonErrorResponse extends ErrorResponse{
public final String error; public final String error;
public final int httpStatus; public final int httpStatus;
public final Throwable underlyingException; public final Throwable underlyingException;
public final int messageResource;
public MastodonErrorResponse(String error, int httpStatus, Throwable exception){ public MastodonErrorResponse(String error, int httpStatus, Throwable exception){
this.error=error; this.error=error;
this.httpStatus=httpStatus; this.httpStatus=httpStatus;
this.underlyingException=exception; 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=0;
}
} }
@Override @Override
public void bindErrorView(View view){ public void bindErrorView(View view){
TextView text=view.findViewById(R.id.error_text); TextView text=view.findViewById(R.id.error_text);
text.setText(error); String message;
if(messageResource>0){
message=view.getContext().getString(messageResource, error);
}else{
message=error;
}
text.setText(message);
} }
@Override @Override
public void showToast(Context context){ public void showToast(Context context){
if(context==null) if(context==null)
return; return;
Toast.makeText(context, 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();
} }
} }

View File

@ -100,6 +100,7 @@ public class SettingsServerAboutFragment extends LoaderFragment{
scroller.setClipToPadding(false); scroller.setClipToPadding(false);
scroller.addView(scrollingLayout); scroller.addView(scrollingLayout);
if(!TextUtils.isEmpty(instance.thumbnail)){
FixedAspectRatioImageView banner=new FixedAspectRatioImageView(getActivity()); FixedAspectRatioImageView banner=new FixedAspectRatioImageView(getActivity());
banner.setAspectRatio(1.914893617f); banner.setAspectRatio(1.914893617f);
banner.setScaleType(ImageView.ScaleType.CENTER_CROP); banner.setScaleType(ImageView.ScaleType.CENTER_CROP);
@ -109,6 +110,9 @@ public class SettingsServerAboutFragment extends LoaderFragment{
LinearLayout.LayoutParams blp=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams blp=new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
blp.bottomMargin=V.dp(24); blp.bottomMargin=V.dp(24);
scrollingLayout.addView(banner, blp); scrollingLayout.addView(banner, blp);
}else{
scrollingLayout.setPadding(0, V.dp(24), 0, 0);
}
boolean needDivider=false; boolean needDivider=false;
if(instance.contactAccount!=null){ if(instance.contactAccount!=null){

View File

@ -173,7 +173,7 @@ public class MediaGridStatusDisplayItem extends StatusDisplayItem{
} }
controllers.add(c); 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.status.translationState==Status.TranslationState.SHOWN){
if(!item.translatedAttachments.containsKey(att.id)){ if(!item.translatedAttachments.containsKey(att.id)){
Optional<Translation.MediaAttachment> translatedAttachment=Arrays.stream(item.status.translation.mediaAttachments).filter(mediaAttachment->mediaAttachment.id.equals(att.id)).findFirst(); Optional<Translation.MediaAttachment> translatedAttachment=Arrays.stream(item.status.translation.mediaAttachments).filter(mediaAttachment->mediaAttachment.id.equals(att.id)).findFirst();

View File

@ -313,7 +313,12 @@ public class ComposeMediaViewController{
int maxSize=0; int maxSize=0;
String contentType=fragment.getActivity().getContentResolver().getType(attachment.uri); String contentType=fragment.getActivity().getContentResolver().getType(attachment.uri);
if(contentType!=null && contentType.startsWith("image/")){ 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.progressBar.setProgress(0);
attachment.speedTracker.reset(); attachment.speedTracker.reset();

View File

@ -141,6 +141,7 @@
android:layout_marginHorizontal="16dp" android:layout_marginHorizontal="16dp"
android:textAppearance="@style/m3_body_large" android:textAppearance="@style/m3_body_large"
android:textColor="?colorM3OnSurface" android:textColor="?colorM3OnSurface"
android:textIsSelectable="true"
tools:text="A cute black cat"/> tools:text="A cute black cat"/>
</LinearLayout> </LinearLayout>

View File

@ -314,7 +314,7 @@
<string name="instance_signup_closed">This server does not accept new registrations.</string> <string name="instance_signup_closed">This server does not accept new registrations.</string>
<string name="text_copied">Copied to clipboard</string> <string name="text_copied">Copied to clipboard</string>
<string name="add_bookmark">Bookmark</string> <string name="add_bookmark">Bookmark</string>
<string name="remove_bookmark">Remove Bookmark</string> <string name="remove_bookmark">Remove bookmark</string>
<string name="bookmarks">Bookmarks</string> <string name="bookmarks">Bookmarks</string>
<string name="your_favorites">Your favorites</string> <string name="your_favorites">Your favorites</string>
<string name="login_title">Welcome back</string> <string name="login_title">Welcome back</string>
@ -751,10 +751,14 @@
<string name="visibility_subtitle_unlisted">Fewer algorithmic fanfares</string> <string name="visibility_subtitle_unlisted">Fewer algorithmic fanfares</string>
<string name="visibility_subtitle_followers">Only your followers</string> <string name="visibility_subtitle_followers">Only your followers</string>
<string name="visibility_subtitle_private">Everyone mentioned in the post</string> <string name="visibility_subtitle_private">Everyone mentioned in the post</string>
<string name="view_boosts">View Boosts</string> <string name="view_boosts">View boosts</string>
<string name="view_favorites">View Favorites</string> <string name="view_favorites">View favorites</string>
<string name="undo_reblog">Undo Boost</string> <string name="undo_reblog">Undo boost</string>
<string name="undo_favorite">Undo Favorite</string> <string name="undo_favorite">Undo favorite</string>
<string name="could_not_reach_server">Couldnt reach the server. Check your connection and try again?</string>
<string name="connection_timed_out">The request timed out. Check your connection and try again?</string>
<string name="server_error">Something went wrong talking with your server. Its probably not your fault. Try again?</string>
<string name="not_found">It couldve been deleted, or maybe it never existed at all.</string>
<string name="dismiss">Dismiss</string> <string name="dismiss">Dismiss</string>
<string name="donation_once">Just once</string> <string name="donation_once">Just once</string>
<string name="donation_monthly">Monthly</string> <string name="donation_monthly">Monthly</string>