From 7fc9603cb4b9054ab10c45cc022b3da65825897d Mon Sep 17 00:00:00 2001 From: Vavassor Date: Sat, 8 Jul 2017 15:44:08 -0400 Subject: [PATCH] Adds envelope icon indicator to direct messages on timelines, so they can be differentiated from private statuses. --- .../tusky/adapter/StatusViewHolder.java | 16 ++++++++++++---- app/src/main/res/drawable/reblog_direct_dark.xml | 10 ++++++++++ .../main/res/drawable/reblog_direct_light.xml | 10 ++++++++++ app/src/main/res/values/attrs.xml | 1 + app/src/main/res/values/styles.xml | 2 ++ 5 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/drawable/reblog_direct_dark.xml create mode 100644 app/src/main/res/drawable/reblog_direct_light.xml diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusViewHolder.java index 9646e4f2..49a3c17f 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusViewHolder.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusViewHolder.java @@ -19,6 +19,7 @@ import android.content.Context; import android.graphics.drawable.Drawable; import android.preference.PreferenceManager; import android.support.annotation.DrawableRes; +import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; @@ -173,7 +174,7 @@ class StatusViewHolder extends RecyclerView.ViewHolder { } /** This should only be called after setReblogged, in order to override the tint correctly. */ - private void setRebloggingEnabled(boolean enabled) { + private void setRebloggingEnabled(boolean enabled, Status.Visibility visibility) { reblogButton.setEnabled(enabled); if (enabled) { @@ -182,8 +183,14 @@ class StatusViewHolder extends RecyclerView.ViewHolder { reblogButton.setInactiveImage(inactiveId); reblogButton.setActiveImage(R.drawable.reblog_active); } else { - int disabledId = ThemeUtils.getDrawableId(reblogButton.getContext(), - R.attr.status_reblog_disabled_drawable, R.drawable.reblog_disabled_dark); + int disabledId; + if (visibility == Status.Visibility.DIRECT) { + disabledId = ThemeUtils.getDrawableId(reblogButton.getContext(), + R.attr.status_reblog_direct_drawable, R.drawable.reblog_direct_dark); + } else { + disabledId = ThemeUtils.getDrawableId(reblogButton.getContext(), + R.attr.status_reblog_disabled_drawable, R.drawable.reblog_disabled_dark); + } reblogButton.setInactiveImage(disabledId); reblogButton.setActiveImage(disabledId); } @@ -266,6 +273,7 @@ class StatusViewHolder extends RecyclerView.ViewHolder { } } + @NonNull private static String getLabelTypeText(Context context, Status.MediaAttachment.Type type) { switch (type) { default: @@ -468,7 +476,7 @@ class StatusViewHolder extends RecyclerView.ViewHolder { } setupButtons(listener, realStatus.account.id); - setRebloggingEnabled(status.rebloggingAllowed()); + setRebloggingEnabled(status.rebloggingAllowed(), status.getVisibility()); if (realStatus.spoilerText.isEmpty()) { hideSpoilerText(); } else { diff --git a/app/src/main/res/drawable/reblog_direct_dark.xml b/app/src/main/res/drawable/reblog_direct_dark.xml new file mode 100644 index 00000000..83312584 --- /dev/null +++ b/app/src/main/res/drawable/reblog_direct_dark.xml @@ -0,0 +1,10 @@ + + + + diff --git a/app/src/main/res/drawable/reblog_direct_light.xml b/app/src/main/res/drawable/reblog_direct_light.xml new file mode 100644 index 00000000..472c5847 --- /dev/null +++ b/app/src/main/res/drawable/reblog_direct_light.xml @@ -0,0 +1,10 @@ + + + + diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml index eb53dc4a..02b83853 100644 --- a/app/src/main/res/values/attrs.xml +++ b/app/src/main/res/values/attrs.xml @@ -18,6 +18,7 @@ + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index db9e5071..0b6dff58 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -48,6 +48,7 @@ @style/AppTheme.ImageButton.Dark @drawable/reblog_inactive_dark @drawable/reblog_disabled_dark + @drawable/reblog_direct_dark @drawable/favourite_active_dark @drawable/favourite_inactive_dark @drawable/toggle_small @@ -125,6 +126,7 @@ @style/AppTheme.ImageButton.Light @drawable/reblog_inactive_light @drawable/reblog_disabled_light + @drawable/reblog_direct_light @drawable/favourite_active_light @drawable/favourite_inactive_light @drawable/toggle_small_light