reply line below avatar
This commit is contained in:
parent
bad72985cb
commit
584700225c
|
@ -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))
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<Emoji> emojis, @DrawableRes int icon, StatusPrivacy visibility, @Nullable View.OnClickListener handleClick){
|
||||
public ReblogOrReplyLineStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, CharSequence text, List<Emoji> 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<ReblogOrReplyLineStatusDisplayItem> 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<Build.VERSION_CODES.N)
|
||||
UiUtils.fixCompoundDrawableTintOnAndroid6(text);
|
||||
ViewGroup.MarginLayoutParams params = new ViewGroup.MarginLayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params.bottomMargin = V.dp(item.isLastLine ? -12 : -18);
|
||||
params.leftMargin = V.dp(13) * item.lineNo;
|
||||
frame.setLayoutParams(params);
|
||||
params.bottomMargin = item.belowHeader ? V.dp(-6) : V.dp(-12);
|
||||
params.topMargin = item.belowHeader ? V.dp(-6) : 0;
|
||||
text.setTextAppearance(item.belowHeader ? R.style.m3_label_large : R.style.m3_title_small);
|
||||
text.setCompoundDrawableTintList(text.getTextColors());
|
||||
itemView.setLayoutParams(params);
|
||||
itemView.setPadding(itemView.getPaddingLeft(), itemView.getPaddingTop(), itemView.getPaddingRight(), item.needBottomPadding ? V.dp(16) : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.text.TextUtils;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.joinmastodon.android.GlobalUserPreferences;
|
||||
import org.joinmastodon.android.R;
|
||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||
|
@ -133,6 +134,7 @@ public abstract class StatusDisplayItem{
|
|||
)));
|
||||
}
|
||||
|
||||
ReblogOrReplyLineStatusDisplayItem replyLine = null;
|
||||
if(statusForContent.inReplyToAccountId!=null){
|
||||
Account account = knownAccounts.get(statusForContent.inReplyToAccountId);
|
||||
View.OnClickListener handleClick = account == null ? null : i -> {
|
||||
|
@ -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<Attachment> imageAttachments=statusForContent.mediaAttachments.stream().filter(att->att.type.isImage()).collect(Collectors.toList());
|
||||
|
|
|
@ -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"/>
|
||||
|
||||
<RelativeLayout
|
||||
|
@ -125,6 +125,23 @@
|
|||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/reply_text_below"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="-6dp"
|
||||
android:layout_marginBottom="-6dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:paddingTop="16dp"
|
||||
android:paddingBottom="6dp"
|
||||
android:textAppearance="@style/m3_title_small"
|
||||
android:drawableStart="@drawable/ic_fluent_arrow_reply_20_filled"
|
||||
android:drawableTint="?android:textColorSecondary"
|
||||
android:drawablePadding="6dp"
|
||||
android:singleLine="true"
|
||||
android:text="@string/sk_in_reply"
|
||||
android:ellipsize="end"/>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/toot_text_wrap"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -263,4 +263,5 @@
|
|||
<string name="sk_followed_as">Followed from %s</string>
|
||||
<string name="sk_settings_hide_fab">Auto-hide Compose button</string>
|
||||
<string name="sk_in_reply">In reply</string>
|
||||
<string name="sk_reply_line_below_avatar">“In reply to” line below avatar</string>
|
||||
</resources>
|
Loading…
Reference in New Issue