From 026292122d15947365d745beb0307bb79d4f5e3b Mon Sep 17 00:00:00 2001 From: kyori19 Date: Wed, 7 Nov 2018 02:10:07 +0900 Subject: [PATCH] Do not show "Pin" in "more" menu of direct status. (#909) --- .../com/keylesspalace/tusky/entity/Status.kt | 4 +++ .../tusky/fragment/SFragment.java | 26 ++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt index 94636774..a21b47fc 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt @@ -102,6 +102,10 @@ data class Status( return (visibility != Visibility.DIRECT && visibility != Visibility.UNKNOWN) } + fun isPinned(): Boolean { + return pinned ?: false + } + override fun equals(other: Any?): Boolean { if (this === other) return true if (other == null || javaClass != other.javaClass) return false diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java index d6bf1b86..8178c32d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/SFragment.java @@ -153,15 +153,21 @@ public abstract class SFragment extends BaseFragment { } else { popup.inflate(R.menu.status_more_for_user); Menu menu = popup.getMenu(); - if (status.getVisibility() == Status.Visibility.PRIVATE) { - boolean reblogged = status.getReblogged(); - if (status.getReblog() != null) reblogged = status.getReblog().getReblogged(); - menu.findItem(R.id.status_reblog_private).setVisible(!reblogged); - menu.findItem(R.id.status_unreblog_private).setVisible(reblogged); - } else { - final String textId = - getString(status.getPinned() ? R.string.unpin_action : R.string.pin_action); - menu.add(0, R.id.pin, 1, textId); + switch (status.getVisibility()) { + case PUBLIC: + case UNLISTED: { + final String textId = + getString(status.isPinned() ? R.string.unpin_action : R.string.pin_action); + menu.add(0, R.id.pin, 1, textId); + break; + } + case PRIVATE: { + boolean reblogged = status.getReblogged(); + if (status.getReblog() != null) reblogged = status.getReblog().getReblogged(); + menu.findItem(R.id.status_reblog_private).setVisible(!reblogged); + menu.findItem(R.id.status_unreblog_private).setVisible(reblogged); + break; + } } } popup.setOnMenuItemClickListener(item -> { @@ -219,7 +225,7 @@ public abstract class SFragment extends BaseFragment { return true; } case R.id.pin: { - timelineCases().pin(status, !status.getPinned()); + timelineCases().pin(status, !status.isPinned()); return true; } }