improve compact reply/reblog header
This commit is contained in:
parent
938ae97cac
commit
499ac8f727
5 changed files with 54 additions and 41 deletions
|
@ -95,7 +95,7 @@ public class GlobalUserPreferences{
|
||||||
collapseLongPosts=prefs.getBoolean("collapseLongPosts", true);
|
collapseLongPosts=prefs.getBoolean("collapseLongPosts", true);
|
||||||
spectatorMode=prefs.getBoolean("spectatorMode", false);
|
spectatorMode=prefs.getBoolean("spectatorMode", false);
|
||||||
autoHideFab=prefs.getBoolean("autoHideFab", true);
|
autoHideFab=prefs.getBoolean("autoHideFab", true);
|
||||||
replyLineAboveHeader =prefs.getBoolean("replyLineAboveHeader", false);
|
replyLineAboveHeader=prefs.getBoolean("replyLineAboveHeader", true);
|
||||||
compactReblogReplyLine=prefs.getBoolean("compactReblogReplyLine", true);
|
compactReblogReplyLine=prefs.getBoolean("compactReblogReplyLine", true);
|
||||||
publishButtonText=prefs.getString("publishButtonText", "");
|
publishButtonText=prefs.getString("publishButtonText", "");
|
||||||
theme=ThemePreference.values()[prefs.getInt("theme", 0)];
|
theme=ThemePreference.values()[prefs.getInt("theme", 0)];
|
||||||
|
|
|
@ -260,10 +260,12 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
||||||
compactReblogReplyLineItem.checked= GlobalUserPreferences.replyLineAboveHeader;
|
compactReblogReplyLineItem.checked= GlobalUserPreferences.replyLineAboveHeader;
|
||||||
if (list.findViewHolderForAdapterPosition(items.indexOf(compactReblogReplyLineItem)) instanceof SwitchViewHolder svh) svh.rebind();
|
if (list.findViewHolderForAdapterPosition(items.indexOf(compactReblogReplyLineItem)) instanceof SwitchViewHolder svh) svh.rebind();
|
||||||
GlobalUserPreferences.save();
|
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->{
|
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.compactReblogReplyLine=i.checked;
|
||||||
GlobalUserPreferences.save();;
|
GlobalUserPreferences.save();
|
||||||
|
needAppRestart=true;
|
||||||
}));
|
}));
|
||||||
compactReblogReplyLineItem.enabled=GlobalUserPreferences.replyLineAboveHeader;
|
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->{
|
items.add(new SwitchItem(R.string.sk_settings_translate_only_opened, R.drawable.ic_fluent_translate_24_regular, GlobalUserPreferences.translateButtonOpenedOnly, i->{
|
||||||
|
|
|
@ -10,8 +10,10 @@ import android.text.SpannableStringBuilder;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import org.joinmastodon.android.GlobalUserPreferences;
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||||
import org.joinmastodon.android.model.Emoji;
|
import org.joinmastodon.android.model.Emoji;
|
||||||
|
@ -39,7 +41,7 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{
|
||||||
private CustomEmojiHelper emojiHelper=new CustomEmojiHelper();
|
private CustomEmojiHelper emojiHelper=new CustomEmojiHelper();
|
||||||
private View.OnClickListener handleClick;
|
private View.OnClickListener handleClick;
|
||||||
boolean belowHeader, needBottomPadding;
|
boolean belowHeader, needBottomPadding;
|
||||||
ReblogOrReplyLineStatusDisplayItem secondary;
|
ReblogOrReplyLineStatusDisplayItem extra;
|
||||||
|
|
||||||
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);
|
super(parentID, parentFragment);
|
||||||
|
@ -80,14 +82,26 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Holder extends StatusDisplayItem.Holder<ReblogOrReplyLineStatusDisplayItem> implements ImageLoaderViewHolder{
|
public static class Holder extends StatusDisplayItem.Holder<ReblogOrReplyLineStatusDisplayItem> implements ImageLoaderViewHolder{
|
||||||
private final TextView text, secondaryText;
|
private final TextView text, extraText;
|
||||||
private final View secondaryWrap;
|
private final View separator;
|
||||||
|
|
||||||
public Holder(Activity activity, ViewGroup parent){
|
public Holder(Activity activity, ViewGroup parent){
|
||||||
super(activity, R.layout.display_item_reblog_or_reply_line, parent);
|
super(activity, R.layout.display_item_reblog_or_reply_line, parent);
|
||||||
text=findViewById(R.id.text);
|
text=findViewById(R.id.text);
|
||||||
secondaryText=findViewById(R.id.secondary_text);
|
extraText=findViewById(R.id.extra_text);
|
||||||
secondaryWrap=findViewById(R.id.secondary_wrap);
|
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) {
|
private void bindLine(ReblogOrReplyLineStatusDisplayItem item, TextView text) {
|
||||||
|
@ -114,8 +128,9 @@ public class ReblogOrReplyLineStatusDisplayItem extends StatusDisplayItem{
|
||||||
@Override
|
@Override
|
||||||
public void onBind(ReblogOrReplyLineStatusDisplayItem item){
|
public void onBind(ReblogOrReplyLineStatusDisplayItem item){
|
||||||
bindLine(item, text);
|
bindLine(item, text);
|
||||||
if (item.secondary != null) bindLine(item.secondary, secondaryText);
|
if (item.extra != null) bindLine(item.extra, extraText);
|
||||||
secondaryWrap.setVisibility(item.secondary == null ? View.GONE : View.VISIBLE);
|
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);
|
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.bottomMargin = item.belowHeader ? V.dp(-6) : V.dp(-12);
|
||||||
params.topMargin = item.belowHeader ? V.dp(-6) : 0;
|
params.topMargin = item.belowHeader ? V.dp(-6) : 0;
|
||||||
|
|
|
@ -162,7 +162,7 @@ public abstract class StatusDisplayItem{
|
||||||
.findFirst();
|
.findFirst();
|
||||||
|
|
||||||
if (primaryLine.isPresent() && GlobalUserPreferences.compactReblogReplyLine) {
|
if (primaryLine.isPresent() && GlobalUserPreferences.compactReblogReplyLine) {
|
||||||
primaryLine.get().secondary = replyLine;
|
primaryLine.get().extra = replyLine;
|
||||||
} else {
|
} else {
|
||||||
items.add(replyLine);
|
items.add(replyLine);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<org.joinmastodon.android.ui.views.AutoOrientationLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<org.joinmastodon.android.ui.views.AutoOrientationLinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="horizontal"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="16dp"
|
android:paddingHorizontal="16dp"
|
||||||
android:paddingHorizontal="10dp"
|
|
||||||
android:layout_marginBottom="-12dp">
|
android:layout_marginBottom="-12dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text"
|
android:id="@+id/text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="6dp"
|
android:paddingTop="16dp"
|
||||||
android:paddingBottom="6dp"
|
android:paddingBottom="6dp"
|
||||||
android:textAppearance="@style/m3_title_small"
|
android:textAppearance="@style/m3_title_small"
|
||||||
android:drawableStart="@drawable/ic_fluent_arrow_repeat_all_20_filled"
|
android:drawableStart="@drawable/ic_fluent_arrow_repeat_all_20_filled"
|
||||||
|
@ -19,16 +20,12 @@
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="end"/>
|
android:ellipsize="end"/>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/secondary_wrap"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
android:id="@+id/separator"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="6dp"
|
android:layout_marginHorizontal="6dp"
|
||||||
|
android:paddingTop="16dp"
|
||||||
android:paddingHorizontal="1dp"
|
android:paddingHorizontal="1dp"
|
||||||
android:textAppearance="@style/m3_title_small"
|
android:textAppearance="@style/m3_title_small"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
|
@ -37,9 +34,10 @@
|
||||||
android:text="@string/sk_separator" />
|
android:text="@string/sk_separator" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/secondary_text"
|
android:id="@+id/extra_text"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="16dp"
|
||||||
android:paddingBottom="6dp"
|
android:paddingBottom="6dp"
|
||||||
android:textAppearance="@style/m3_title_small"
|
android:textAppearance="@style/m3_title_small"
|
||||||
android:drawableStart="@drawable/ic_fluent_arrow_reply_20_filled"
|
android:drawableStart="@drawable/ic_fluent_arrow_reply_20_filled"
|
||||||
|
@ -48,6 +46,4 @@
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:ellipsize="end"/>
|
android:ellipsize="end"/>
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</org.joinmastodon.android.ui.views.AutoOrientationLinearLayout>
|
</org.joinmastodon.android.ui.views.AutoOrientationLinearLayout>
|
Loading…
Add table
Reference in a new issue