diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index fa2d08f3e..6115c1120 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -95,7 +95,7 @@ public class GlobalUserPreferences{ collapseLongPosts=prefs.getBoolean("collapseLongPosts", true); spectatorMode=prefs.getBoolean("spectatorMode", false); autoHideFab=prefs.getBoolean("autoHideFab", true); - replyLineAboveHeader =prefs.getBoolean("replyLineAboveHeader", false); + replyLineAboveHeader=prefs.getBoolean("replyLineAboveHeader", true); compactReblogReplyLine=prefs.getBoolean("compactReblogReplyLine", true); publishButtonText=prefs.getString("publishButtonText", ""); theme=ThemePreference.values()[prefs.getInt("theme", 0)]; diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java index 6704813bc..487751cdc 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -260,10 +260,12 @@ public class SettingsFragment extends MastodonToolbarFragment{ compactReblogReplyLineItem.checked= GlobalUserPreferences.replyLineAboveHeader; if (list.findViewHolderForAdapterPosition(items.indexOf(compactReblogReplyLineItem)) instanceof SwitchViewHolder svh) svh.rebind(); GlobalUserPreferences.save(); + needAppRestart=true; })); items.add(compactReblogReplyLineItem=new SwitchItem(R.string.sk_compact_reblog_reply_line, R.drawable.ic_fluent_re_order_24_regular, GlobalUserPreferences.compactReblogReplyLine, i->{ GlobalUserPreferences.compactReblogReplyLine=i.checked; - GlobalUserPreferences.save();; + GlobalUserPreferences.save(); + needAppRestart=true; })); compactReblogReplyLineItem.enabled=GlobalUserPreferences.replyLineAboveHeader; items.add(new SwitchItem(R.string.sk_settings_translate_only_opened, R.drawable.ic_fluent_translate_24_regular, GlobalUserPreferences.translateButtonOpenedOnly, i->{ diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ReblogOrReplyLineStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ReblogOrReplyLineStatusDisplayItem.java index edb1b60d3..2e1b8a77f 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ReblogOrReplyLineStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/ReblogOrReplyLineStatusDisplayItem.java @@ -10,8 +10,10 @@ import android.text.SpannableStringBuilder; import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; +import android.widget.LinearLayout; import android.widget.TextView; +import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.R; import org.joinmastodon.android.fragments.BaseStatusListFragment; import org.joinmastodon.android.model.Emoji; @@ -39,7 +41,7 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{ private CustomEmojiHelper emojiHelper=new CustomEmojiHelper(); private View.OnClickListener handleClick; boolean belowHeader, needBottomPadding; - ReblogOrReplyLineStatusDisplayItem secondary; + ReblogOrReplyLineStatusDisplayItem extra; public ReblogOrReplyLineStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, CharSequence text, List emojis, @DrawableRes int icon, StatusPrivacy visibility, @Nullable View.OnClickListener handleClick) { super(parentID, parentFragment); @@ -80,14 +82,26 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{ } public static class Holder extends StatusDisplayItem.Holder implements ImageLoaderViewHolder{ - private final TextView text, secondaryText; - private final View secondaryWrap; + private final TextView text, extraText; + private final View separator; public Holder(Activity activity, ViewGroup parent){ super(activity, R.layout.display_item_reblog_or_reply_line, parent); text=findViewById(R.id.text); - secondaryText=findViewById(R.id.secondary_text); - secondaryWrap=findViewById(R.id.secondary_wrap); + extraText=findViewById(R.id.extra_text); + separator=findViewById(R.id.separator); + if (GlobalUserPreferences.replyLineAboveHeader && GlobalUserPreferences.compactReblogReplyLine) { + itemView.getViewTreeObserver().addOnPreDrawListener(() -> { + int orientation = ((LinearLayout) itemView).getOrientation(); + extraText.setPaddingRelative(extraText.getPaddingStart(), V.dp(16), extraText.getPaddingEnd(), extraText.getPaddingBottom()); + separator.setVisibility(View.GONE); + if (getItem() != null && getItem().extra != null) { + if (orientation == LinearLayout.VERTICAL) extraText.setPaddingRelative(extraText.getPaddingStart(), 0, extraText.getPaddingEnd(), extraText.getPaddingBottom()); + else separator.setVisibility(View.VISIBLE); + } + return true; + }); + } } private void bindLine(ReblogOrReplyLineStatusDisplayItem item, TextView text) { @@ -114,8 +128,9 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{ @Override public void onBind(ReblogOrReplyLineStatusDisplayItem item){ bindLine(item, text); - if (item.secondary != null) bindLine(item.secondary, secondaryText); - secondaryWrap.setVisibility(item.secondary == null ? View.GONE : View.VISIBLE); + if (item.extra != null) bindLine(item.extra, extraText); + extraText.setVisibility(item.extra == null ? View.GONE : View.VISIBLE); + separator.setVisibility(item.extra == null ? View.GONE : View.VISIBLE); ViewGroup.MarginLayoutParams params = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.bottomMargin = item.belowHeader ? V.dp(-6) : V.dp(-12); params.topMargin = item.belowHeader ? V.dp(-6) : 0; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java index 19b30ceb0..3e3bb3bf0 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/StatusDisplayItem.java @@ -162,7 +162,7 @@ public abstract class StatusDisplayItem{ .findFirst(); if (primaryLine.isPresent() && GlobalUserPreferences.compactReblogReplyLine) { - primaryLine.get().secondary = replyLine; + primaryLine.get().extra = replyLine; } else { items.add(replyLine); } diff --git a/mastodon/src/main/res/layout/display_item_reblog_or_reply_line.xml b/mastodon/src/main/res/layout/display_item_reblog_or_reply_line.xml index f3de28551..2138522c0 100644 --- a/mastodon/src/main/res/layout/display_item_reblog_or_reply_line.xml +++ b/mastodon/src/main/res/layout/display_item_reblog_or_reply_line.xml @@ -1,16 +1,17 @@ - - + android:layout_marginHorizontal="6dp" + android:paddingTop="16dp" + android:paddingHorizontal="1dp" + android:textAppearance="@style/m3_title_small" + android:gravity="center_horizontal" + android:importantForAccessibility="no" + android:includeFontPadding="false" + android:text="@string/sk_separator" /> - - - - - + \ No newline at end of file