From b0f76739ba66af77cd673a330ad565a3e8faa064 Mon Sep 17 00:00:00 2001 From: sk Date: Sat, 19 Nov 2022 19:39:09 +0100 Subject: [PATCH] implement showing original visibility on reply closes #41 --- .../android/fragments/ComposeFragment.java | 19 +++++++++++++++++++ .../drawable/ic_fluent_earth_20_regular.xml | 3 +++ .../ic_fluent_people_checkmark_20_regular.xml | 3 +++ .../ic_fluent_people_community_20_regular.xml | 3 +++ .../src/main/res/layout/fragment_compose.xml | 1 + mastodon/src/main/res/values/strings.xml | 1 + 6 files changed, 30 insertions(+) create mode 100644 mastodon/src/main/res/drawable/ic_fluent_earth_20_regular.xml create mode 100644 mastodon/src/main/res/drawable/ic_fluent_people_checkmark_20_regular.xml create mode 100644 mastodon/src/main/res/drawable/ic_fluent_people_community_20_regular.xml 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 58748aba9..7bc7375d0 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -13,6 +13,7 @@ import android.graphics.Outline; import android.graphics.PixelFormat; import android.graphics.RenderEffect; import android.graphics.Shader; +import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.icu.text.BreakIterator; import android.media.MediaMetadataRetriever; @@ -492,6 +493,24 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr spoilerEdit.addTextChangedListener(new SimpleTextWatcher(e->updateCharCounter())); if(replyTo!=null){ replyText.setText(getString(R.string.in_reply_to, replyTo.account.displayName)); + int visibilityNameRes = switch (statusVisibility) { + case PUBLIC -> R.string.visibility_public; + case UNLISTED -> R.string.visibility_unlisted; + case PRIVATE -> R.string.visibility_followers_only; + case DIRECT -> R.string.visibility_private; + }; + replyText.setContentDescription(getString(R.string.in_reply_to, replyTo.account.displayName) + ". " + getString(R.string.post_visibility) + ": " + getString(visibilityNameRes)); + Drawable visibilityIcon = getActivity().getDrawable(switch(statusVisibility){ + case PUBLIC -> R.drawable.ic_fluent_earth_20_regular; + case UNLISTED -> R.drawable.ic_fluent_people_community_20_regular; + case PRIVATE -> R.drawable.ic_fluent_people_checkmark_20_regular; + case DIRECT -> R.drawable.ic_at_symbol; + }); + visibilityIcon.setBounds(0, 0, V.dp(20), V.dp(20)); + Drawable replyArrow = getActivity().getDrawable(R.drawable.ic_fluent_arrow_reply_20_filled); + replyArrow.setBounds(0, 0, V.dp(20), V.dp(20)); + replyText.setCompoundDrawables(replyArrow, null, visibilityIcon, null); + ArrayList mentions=new ArrayList<>(); String ownID=AccountSessionManager.getInstance().getAccount(accountID).self.id; if(!replyTo.account.id.equals(ownID)) diff --git a/mastodon/src/main/res/drawable/ic_fluent_earth_20_regular.xml b/mastodon/src/main/res/drawable/ic_fluent_earth_20_regular.xml new file mode 100644 index 000000000..2ddaeff4f --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_fluent_earth_20_regular.xml @@ -0,0 +1,3 @@ + + + diff --git a/mastodon/src/main/res/drawable/ic_fluent_people_checkmark_20_regular.xml b/mastodon/src/main/res/drawable/ic_fluent_people_checkmark_20_regular.xml new file mode 100644 index 000000000..ea9b43e28 --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_fluent_people_checkmark_20_regular.xml @@ -0,0 +1,3 @@ + + + diff --git a/mastodon/src/main/res/drawable/ic_fluent_people_community_20_regular.xml b/mastodon/src/main/res/drawable/ic_fluent_people_community_20_regular.xml new file mode 100644 index 000000000..93b9bebc8 --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_fluent_people_community_20_regular.xml @@ -0,0 +1,3 @@ + + + diff --git a/mastodon/src/main/res/layout/fragment_compose.xml b/mastodon/src/main/res/layout/fragment_compose.xml index b5074a02e..6f4777829 100644 --- a/mastodon/src/main/res/layout/fragment_compose.xml +++ b/mastodon/src/main/res/layout/fragment_compose.xml @@ -40,6 +40,7 @@ android:layout_marginTop="16dp" android:textAppearance="@style/m3_title_small" android:drawableStart="@drawable/ic_fluent_arrow_reply_20_filled" + android:drawableEnd="@drawable/ic_fluent_earth_20_regular" android:drawableTint="?android:textColorSecondary" android:drawablePadding="6dp" android:singleLine="true" diff --git a/mastodon/src/main/res/values/strings.xml b/mastodon/src/main/res/values/strings.xml index 7b5aa47c2..4dcefec81 100644 --- a/mastodon/src/main/res/values/strings.xml +++ b/mastodon/src/main/res/values/strings.xml @@ -216,6 +216,7 @@ Alt text describes your photos for people with low or no vision. Try to only include enough detail to understand the context. e.g. A dog looking around suspiciously with narrowed eyes at the camera. Public + Unlisted Followers only Only people I mention All