From df93a1a845e75156aaa34cafb06974c20b69c1a2 Mon Sep 17 00:00:00 2001 From: sk Date: Fri, 7 Apr 2023 18:42:18 +0200 Subject: [PATCH] increase max height --- .../android/fragments/BaseStatusListFragment.java | 3 ++- .../org/joinmastodon/android/ui/utils/UiUtils.java | 5 +++++ .../android/ui/views/ComposeMediaLayout.java | 7 ++++--- .../android/ui/views/MediaGridLayout.java | 11 +++++------ .../src/main/res/layout/display_item_link_card.xml | 2 +- .../main/res/layout/fragment_image_description.xml | 2 +- mastodon/src/main/res/values/dimens.xml | 1 + 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java index 6d6389236..7202d7af5 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -93,6 +93,7 @@ public abstract class BaseStatusListFragment exten @Override public void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); + UiUtils.loadMaxWidth(getContext()); if(GlobalUserPreferences.disableMarquee){ setTitleMarqueeEnabled(false); setSubtitleMarqueeEnabled(false); @@ -758,7 +759,7 @@ public abstract class BaseStatusListFragment exten if(!imgHolder.getItem().status.spoilerRevealed){ if(TextUtils.isEmpty(imgHolder.getItem().status.spoilerText)){ int listWidth=getListWidthForMediaLayout(); - int width=Math.min(listWidth, V.dp(MediaGridLayout.MAX_WIDTH)); + int width=Math.min(listWidth, UiUtils.MAX_WIDTH); if(currentMediaHiddenLayoutsWidth!=width) rebuildMediaHiddenLayouts(width-V.dp(32)); c.save(); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java index 975fef86e..090e0b06b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java @@ -137,10 +137,15 @@ public class UiUtils { private static Handler mainHandler = new Handler(Looper.getMainLooper()); private static final DateTimeFormatter DATE_FORMATTER_SHORT_WITH_YEAR = DateTimeFormatter.ofPattern("d MMM uuuu"), DATE_FORMATTER_SHORT = DateTimeFormatter.ofPattern("d MMM"); public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.SHORT); + public static int MAX_WIDTH; private UiUtils() { } + public static void loadMaxWidth(Context ctx) { + if (MAX_WIDTH == 0) MAX_WIDTH = (int) ctx.getResources().getDimension(R.dimen.layout_max_width); + } + public static void launchWebBrowser(Context context, String url) { try { if (GlobalUserPreferences.useCustomTabs) { diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/views/ComposeMediaLayout.java b/mastodon/src/main/java/org/joinmastodon/android/ui/views/ComposeMediaLayout.java index 383bd0cdb..f435cca48 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/views/ComposeMediaLayout.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/views/ComposeMediaLayout.java @@ -3,13 +3,13 @@ package org.joinmastodon.android.ui.views; import android.annotation.SuppressLint; import android.content.Context; import android.util.AttributeSet; -import android.view.View; import android.view.ViewGroup; +import org.joinmastodon.android.ui.utils.UiUtils; + import me.grishka.appkit.utils.V; public class ComposeMediaLayout extends ViewGroup{ - private static final int MAX_WIDTH_DP=400; private static final int GAP_DP=8; private static final float ASPECT_RATIO=0.5625f; @@ -23,6 +23,7 @@ public class ComposeMediaLayout extends ViewGroup{ public ComposeMediaLayout(Context context, AttributeSet attrs, int defStyle){ super(context, attrs, defStyle); + UiUtils.loadMaxWidth(context); } @Override @@ -30,7 +31,7 @@ public class ComposeMediaLayout extends ViewGroup{ int mode=MeasureSpec.getMode(widthMeasureSpec); @SuppressLint("SwitchIntDef") int width=switch(mode){ - case MeasureSpec.AT_MOST -> Math.min(V.dp(MAX_WIDTH_DP), MeasureSpec.getSize(widthMeasureSpec)); + case MeasureSpec.AT_MOST -> Math.min(UiUtils.MAX_WIDTH, MeasureSpec.getSize(widthMeasureSpec)); case MeasureSpec.EXACTLY -> MeasureSpec.getSize(widthMeasureSpec); default -> throw new IllegalArgumentException("unsupported measure mode"); }; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/views/MediaGridLayout.java b/mastodon/src/main/java/org/joinmastodon/android/ui/views/MediaGridLayout.java index 80ddbaaa6..d4ca3e547 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/views/MediaGridLayout.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/views/MediaGridLayout.java @@ -6,13 +6,13 @@ import android.view.View; import android.view.ViewGroup; import org.joinmastodon.android.ui.PhotoLayoutHelper; +import org.joinmastodon.android.ui.utils.UiUtils; import me.grishka.appkit.utils.V; public class MediaGridLayout extends ViewGroup{ private static final String TAG="MediaGridLayout"; - public static final int MAX_WIDTH=400; // dp private static final int GAP=1; // dp private PhotoLayoutHelper.TiledLayoutResult tiledLayout; private int[] columnStarts=new int[10], columnEnds=new int[10], rowStarts=new int[10], rowEnds=new int[10]; @@ -27,7 +27,7 @@ public class MediaGridLayout extends ViewGroup{ public MediaGridLayout(Context context, AttributeSet attrs, int defStyle){ super(context, attrs, defStyle); - + UiUtils.loadMaxWidth(context); } @Override @@ -36,7 +36,7 @@ public class MediaGridLayout extends ViewGroup{ setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), 0); return; } - int width=Math.min(V.dp(MAX_WIDTH), MeasureSpec.getSize(widthMeasureSpec)); + int width=Math.min(UiUtils.MAX_WIDTH, MeasureSpec.getSize(widthMeasureSpec)); int height=Math.round(width*(tiledLayout.height/(float)PhotoLayoutHelper.MAX_WIDTH)); int offset=0; @@ -74,10 +74,9 @@ public class MediaGridLayout extends ViewGroup{ if(tiledLayout==null) return; - int maxWidth=V.dp(MAX_WIDTH); int xOffset=0; - if(r-l>maxWidth){ - xOffset=(r-l)/2-maxWidth/2; + if(r-l>UiUtils.MAX_WIDTH){ + xOffset=(r-l)/2-UiUtils.MAX_WIDTH/2; } for(int i=0;i + android:maxWidth="@dimen/layout_max_width"> + android:maxWidth="@dimen/layout_max_width"> 220dp 150dp + 450dp \ No newline at end of file