From 349a1115a6d305c2fed7d8bab61b28af07e8d947 Mon Sep 17 00:00:00 2001 From: sk Date: Tue, 24 Jan 2023 12:40:23 +0100 Subject: [PATCH] add indicator for direct and local-only posts --- .../fragments/NotificationsListFragment.java | 2 +- .../fragments/StatusEditHistoryFragment.java | 3 ++- .../org/joinmastodon/android/model/Status.java | 1 + .../ui/displayitems/HeaderStatusDisplayItem.java | 16 ++++++++++++++-- .../PollFooterStatusDisplayItem.java | 5 +++-- .../src/main/res/layout/display_item_header.xml | 12 ++++++------ mastodon/src/main/res/values/strings_sk.xml | 3 +++ 7 files changed, 30 insertions(+), 12 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java index c7e2beeb6..fab315de8 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java @@ -80,7 +80,7 @@ public class NotificationsListFragment extends BaseStatusListFragment getString(R.string.poll_ended); case UPDATE -> getString(R.string.sk_post_edited); }; - HeaderStatusDisplayItem titleItem=extraText!=null ? new HeaderStatusDisplayItem(n.id, n.account, n.createdAt, this, accountID, null, extraText, n, null) : null; + HeaderStatusDisplayItem titleItem=extraText!=null ? new HeaderStatusDisplayItem(n.id, n.account, n.createdAt, this, accountID, n.status, extraText, n, null) : null; if(n.status!=null){ ArrayList items=StatusDisplayItem.buildItems(this, n.status, accountID, n, knownAccounts, titleItem!=null, titleItem==null, n); if(titleItem!=null){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusEditHistoryFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusEditHistoryFragment.java index 37649f7af..d8491b474 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusEditHistoryFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusEditHistoryFragment.java @@ -139,7 +139,8 @@ public class StatusEditHistoryFragment extends StatusListFragment{ action=getString(R.string.edit_multiple_changed); } } - items.add(0, new ReblogOrReplyLineStatusDisplayItem(s.id, this, action+" · "+date, Collections.emptyList(), 0, null, null)); + String sep = getString(R.string.sk_separator); + items.add(0, new ReblogOrReplyLineStatusDisplayItem(s.id, this, action+" "+sep+" "+date, Collections.emptyList(), 0, null, null)); } return items; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/Status.java b/mastodon/src/main/java/org/joinmastodon/android/model/Status.java index 1ccc858d4..c835c7fcd 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/Status.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/Status.java @@ -50,6 +50,7 @@ public class Status extends BaseModel implements DisplayItemsParent{ public Card card; public String language; public String text; + public boolean localOnly; public boolean favourited; public boolean reblogged; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java index baeab1681..fb03cbce8 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java @@ -9,7 +9,6 @@ import android.os.Build; import android.os.Bundle; import android.text.SpannableStringBuilder; import android.text.TextUtils; -import android.util.TypedValue; import android.view.Menu; import android.view.MenuItem; import android.view.SubMenu; @@ -43,6 +42,7 @@ import org.joinmastodon.android.model.Notification; import org.joinmastodon.android.model.Relationship; import org.joinmastodon.android.model.ScheduledStatus; import org.joinmastodon.android.model.Status; +import org.joinmastodon.android.model.StatusPrivacy; import org.joinmastodon.android.ui.text.HtmlParser; import org.joinmastodon.android.ui.utils.CustomEmojiHelper; import org.joinmastodon.android.ui.utils.UiUtils; @@ -52,6 +52,7 @@ import java.time.Instant; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; @@ -318,7 +319,18 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ } itemView.setPadding(itemView.getPaddingLeft(), itemView.getPaddingTop(), itemView.getPaddingRight(), item.needBottomPadding ? V.dp(16) : 0); if(TextUtils.isEmpty(item.extraText)){ - extraText.setVisibility(View.GONE); + List extraParts = new ArrayList<>(); + if (item.status != null && item.status.localOnly) + extraParts.add(item.parentFragment.getString(R.string.sk_inline_local_only)); + if (item.status != null && item.status.visibility.equals(StatusPrivacy.DIRECT)) + extraParts.add(item.parentFragment.getString(R.string.sk_inline_direct)); + if (!extraParts.isEmpty()) { + String sep = item.parentFragment.getString(R.string.sk_separator); + extraText.setText(String.join(" " + sep + " ", extraParts)); + extraText.setVisibility(View.VISIBLE); + } else { + extraText.setVisibility(View.GONE); + } }else{ extraText.setVisibility(View.VISIBLE); extraText.setText(item.extraText); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollFooterStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollFooterStatusDisplayItem.java index e4221cf9f..ed73e4b44 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollFooterStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/PollFooterStatusDisplayItem.java @@ -39,10 +39,11 @@ public class PollFooterStatusDisplayItem extends StatusDisplayItem{ @Override public void onBind(PollFooterStatusDisplayItem item){ String text=item.parentFragment.getResources().getQuantityString(R.plurals.x_voters, item.poll.votersCount, item.poll.votersCount); + String sep=item.parentFragment.getString(R.string.sk_separator); if(item.poll.expiresAt!=null && !item.poll.isExpired()){ - text+=" · "+UiUtils.formatTimeLeft(itemView.getContext(), item.poll.expiresAt); + text+=" "+sep+" "+UiUtils.formatTimeLeft(itemView.getContext(), item.poll.expiresAt); }else if(item.poll.isExpired()){ - text+=" · "+item.parentFragment.getString(R.string.poll_closed); + text+=" "+sep+" "+item.parentFragment.getString(R.string.poll_closed); } this.text.setText(text); button.setVisibility(item.poll.isExpired() || item.poll.voted || (!item.poll.multiple && !GlobalUserPreferences.voteButtonForSingleChoice) ? View.GONE : View.VISIBLE); diff --git a/mastodon/src/main/res/layout/display_item_header.xml b/mastodon/src/main/res/layout/display_item_header.xml index 441a3a3c0..c494cb460 100644 --- a/mastodon/src/main/res/layout/display_item_header.xml +++ b/mastodon/src/main/res/layout/display_item_header.xml @@ -18,7 +18,7 @@ android:layout_height="36dp" android:layout_alignParentTop="true" android:layout_alignParentEnd="true" - android:layout_marginTop="-6dp" + android:layout_marginTop="-5dp" android:layout_marginEnd="-9.9dp" android:background="?android:actionBarItemBackground" android:contentDescription="@string/more_options" @@ -30,7 +30,7 @@ android:id="@+id/delete_notification" android:layout_width="36dp" android:layout_height="36dp" - android:layout_marginTop="-6dp" + android:layout_marginTop="-5dp" android:layout_toStartOf="@id/more" android:visibility="gone" android:background="?android:actionBarItemBackground" @@ -43,7 +43,7 @@ android:id="@+id/visibility" android:layout_width="36dp" android:layout_height="36dp" - android:layout_marginTop="-6dp" + android:layout_marginTop="-5dp" android:layout_toStartOf="@id/delete_notification" android:background="?android:actionBarItemBackground" android:scaleType="center" @@ -54,7 +54,7 @@ android:id="@+id/unread_indicator" android:layout_width="36dp" android:layout_height="36dp" - android:layout_marginTop="-6dp" + android:layout_marginTop="-5dp" android:layout_toStartOf="@id/visibility" android:visibility="gone" android:tint="?android:colorAccent" @@ -93,7 +93,7 @@ android:id="@+id/extra_text" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="8dp" + android:layout_marginStart="8sp" android:ellipsize="end" android:fontFamily="sans-serif" android:singleLine="true" @@ -130,7 +130,7 @@ android:layout_marginLeft="4sp" android:layout_marginRight="4sp" android:importantForAccessibility="no" - android:text="·" + android:text="@string/sk_separator" android:textAppearance="@style/m3_title_small" /> Indicator for missing alt texts Enable pre-releases “Show new posts” button + local-only + direct + · \ No newline at end of file