increase max height

This commit is contained in:
sk 2023-04-07 18:42:18 +02:00
parent 41a70a353c
commit df93a1a845
7 changed files with 19 additions and 12 deletions

View File

@ -93,6 +93,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> 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<T extends DisplayItemsParent> 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();

View File

@ -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) {

View File

@ -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");
};

View File

@ -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<getChildCount();i++){

View File

@ -11,7 +11,7 @@
android:layout_height="250dp"
android:layout_gravity="center_horizontal"
android:foreground="?android:selectableItemBackground"
android:maxWidth="400dp">
android:maxWidth="@dimen/layout_max_width">
<ImageView
android:id="@+id/photo"
android:layout_width="match_parent"

View File

@ -14,7 +14,7 @@
<org.joinmastodon.android.ui.views.MaxWidthFrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxWidth="400dp">
android:maxWidth="@dimen/layout_max_width">
<ImageView
android:id="@+id/photo"

View File

@ -2,4 +2,5 @@
<resources>
<dimen name="text_max_height">220dp</dimen>
<dimen name="text_collapsed_height">150dp</dimen>
<dimen name="layout_max_width">450dp</dimen>
</resources>