diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index ce645c5c5..d66b63f04 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -44,6 +44,7 @@ public class GlobalUserPreferences{ public static boolean collapseLongPosts; public static boolean spectatorMode; public static boolean autoHideFab; + public static boolean replyLineBelowHeader; public static String publishButtonText; public static ThemePreference theme; public static ColorPreference color; @@ -93,6 +94,7 @@ public class GlobalUserPreferences{ collapseLongPosts=prefs.getBoolean("collapseLongPosts", true); spectatorMode=prefs.getBoolean("spectatorMode", false); autoHideFab=prefs.getBoolean("autoHideFab", true); + replyLineBelowHeader=prefs.getBoolean("replyLineBelowHeader", true); publishButtonText=prefs.getString("publishButtonText", ""); theme=ThemePreference.values()[prefs.getInt("theme", 0)]; recentLanguages=fromJson(prefs.getString("recentLanguages", null), recentLanguagesType, new HashMap<>()); @@ -136,6 +138,7 @@ public class GlobalUserPreferences{ .putBoolean("autoHideFab", autoHideFab) .putString("publishButtonText", publishButtonText) .putBoolean("bottomEncoding", bottomEncoding) + .putBoolean("replyLineBelowHeader", replyLineBelowHeader) .putInt("theme", theme.ordinal()) .putString("color", color.name()) .putString("recentLanguages", gson.toJson(recentLanguages)) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index db7ee5596..a27f9c73c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -333,7 +333,9 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr scheduleTimeBtn=view.findViewById(R.id.scheduled_time_btn); sensitiveIcon=view.findViewById(R.id.sensitive_icon); sensitiveItem=view.findViewById(R.id.sensitive_item); - replyText=view.findViewById(R.id.reply_text); + replyText=view.findViewById(GlobalUserPreferences.replyLineBelowHeader ? R.id.reply_text_below : R.id.reply_text); + view.findViewById(GlobalUserPreferences.replyLineBelowHeader ? R.id.reply_text : R.id.reply_text_below) + .setVisibility(View.GONE); if (isPhotoPickerAvailable()) { PopupMenu attachPopup = new PopupMenu(getContext(), mediaBtn); 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 34e7a522f..d7f299143 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -253,6 +253,10 @@ public class SettingsFragment extends MastodonToolbarFragment{ GlobalUserPreferences.save(); needAppRestart=true; })); + items.add(new SwitchItem(R.string.sk_reply_line_below_avatar, R.drawable.ic_fluent_arrow_reply_24_regular, GlobalUserPreferences.replyLineBelowHeader, i->{ + GlobalUserPreferences.replyLineBelowHeader=i.checked; + GlobalUserPreferences.save(); + })); items.add(new SwitchItem(R.string.sk_settings_translate_only_opened, R.drawable.ic_fluent_translate_24_regular, GlobalUserPreferences.translateButtonOpenedOnly, i->{ GlobalUserPreferences.translateButtonOpenedOnly=i.checked; GlobalUserPreferences.save(); 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 4d3022a46..71973c466 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 @@ -38,10 +38,9 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{ private int iconEnd; private CustomEmojiHelper emojiHelper=new CustomEmojiHelper(); private View.OnClickListener handleClick; - private boolean isLastLine = true; - private int lineNo = 0; + boolean belowHeader, needBottomPadding; - public ReblogOrReplyLineStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, CharSequence text, List emojis, @DrawableRes int icon, StatusPrivacy visibility, @Nullable View.OnClickListener handleClick){ + public ReblogOrReplyLineStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, CharSequence text, List emojis, @DrawableRes int icon, StatusPrivacy visibility, @Nullable View.OnClickListener handleClick) { super(parentID, parentFragment); SpannableStringBuilder ssb=new SpannableStringBuilder(text); HtmlParser.parseCustomEmoji(ssb, emojis); @@ -54,14 +53,6 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{ updateVisibility(visibility); } - public void setIsLastLine(boolean isLastLine) { - this.isLastLine = isLastLine; - } - - public void setLineNo(int lineNo) { - this.lineNo = lineNo; - } - public void updateVisibility(StatusPrivacy visibility) { this.visibility = visibility; this.iconEnd = visibility != null ? switch (visibility) { @@ -89,12 +80,10 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{ public static class Holder extends StatusDisplayItem.Holder implements ImageLoaderViewHolder{ private final TextView text; - private final View frame; public Holder(Activity activity, ViewGroup parent){ super(activity, R.layout.display_item_reblog_or_reply_line, parent); text=findViewById(R.id.text); - frame=findViewById(R.id.frame); } @Override @@ -116,9 +105,12 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{ if(Build.VERSION.SDK_INT { @@ -140,28 +142,28 @@ public abstract class StatusDisplayItem{ Nav.go(fragment.getActivity(), ProfileFragment.class, args); }; String text = account != null ? fragment.getString(R.string.in_reply_to, account.displayName) : fragment.getString(R.string.sk_in_reply); - items.add(new ReblogOrReplyLineStatusDisplayItem( + replyLine = new ReblogOrReplyLineStatusDisplayItem( parentID, fragment, text, account == null ? List.of() : account.emojis, R.drawable.ic_fluent_arrow_reply_20_filled, null, handleClick - )); + ); } - int l = 0; - ReblogOrReplyLineStatusDisplayItem lastLine = null; - for (StatusDisplayItem item : items) { - if (item instanceof ReblogOrReplyLineStatusDisplayItem line) { - line.setLineNo(l); - line.setIsLastLine(false); - lastLine = line; - l++; - } + if (replyLine != null && !GlobalUserPreferences.replyLineBelowHeader) { + items.add(replyLine); } - if (lastLine != null) lastLine.setIsLastLine(true); HeaderStatusDisplayItem header; items.add(header=new HeaderStatusDisplayItem(parentID, statusForContent.account, statusForContent.createdAt, fragment, accountID, statusForContent, null, notification, scheduledStatus)); + + if (replyLine != null && GlobalUserPreferences.replyLineBelowHeader) { + replyLine.belowHeader = true; + items.add(replyLine); + } + if(!TextUtils.isEmpty(statusForContent.content)) items.add(new TextStatusDisplayItem(parentID, HtmlParser.parse(statusForContent.content, statusForContent.emojis, statusForContent.mentions, statusForContent.tags, accountID), fragment, statusForContent, disableTranslate)); + else if (GlobalUserPreferences.replyLineBelowHeader && replyLine != null) + replyLine.needBottomPadding=true; else header.needBottomPadding=true; List imageAttachments=statusForContent.mediaAttachments.stream().filter(att->att.type.isImage()).collect(Collectors.toList()); diff --git a/mastodon/src/main/res/layout/fragment_compose.xml b/mastodon/src/main/res/layout/fragment_compose.xml index 80426d5a5..56f797dc6 100644 --- a/mastodon/src/main/res/layout/fragment_compose.xml +++ b/mastodon/src/main/res/layout/fragment_compose.xml @@ -64,10 +64,10 @@ android:paddingBottom="6dp" android:textAppearance="@style/m3_title_small" android:drawableStart="@drawable/ic_fluent_arrow_reply_20_filled" - tools:drawableEnd="@drawable/ic_fluent_earth_20_regular" android:drawableTint="?android:textColorSecondary" android:drawablePadding="6dp" android:singleLine="true" + android:text="@string/sk_in_reply" android:ellipsize="end"/> + + Followed from %s Auto-hide Compose button In reply + “In reply to” line below avatar \ No newline at end of file