Do not show "Pin" in "more" menu of direct status. (#909)

This commit is contained in:
kyori19 2018-11-07 02:10:07 +09:00 committed by Konrad Pozniak
parent d8d37bacd9
commit 026292122d
2 changed files with 20 additions and 10 deletions

View file

@ -102,6 +102,10 @@ data class Status(
return (visibility != Visibility.DIRECT && visibility != Visibility.UNKNOWN) return (visibility != Visibility.DIRECT && visibility != Visibility.UNKNOWN)
} }
fun isPinned(): Boolean {
return pinned ?: false
}
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true
if (other == null || javaClass != other.javaClass) return false if (other == null || javaClass != other.javaClass) return false

View file

@ -153,15 +153,21 @@ public abstract class SFragment extends BaseFragment {
} else { } else {
popup.inflate(R.menu.status_more_for_user); popup.inflate(R.menu.status_more_for_user);
Menu menu = popup.getMenu(); Menu menu = popup.getMenu();
if (status.getVisibility() == Status.Visibility.PRIVATE) { 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(); boolean reblogged = status.getReblogged();
if (status.getReblog() != null) reblogged = status.getReblog().getReblogged(); if (status.getReblog() != null) reblogged = status.getReblog().getReblogged();
menu.findItem(R.id.status_reblog_private).setVisible(!reblogged); menu.findItem(R.id.status_reblog_private).setVisible(!reblogged);
menu.findItem(R.id.status_unreblog_private).setVisible(reblogged); menu.findItem(R.id.status_unreblog_private).setVisible(reblogged);
} else { break;
final String textId = }
getString(status.getPinned() ? R.string.unpin_action : R.string.pin_action);
menu.add(0, R.id.pin, 1, textId);
} }
} }
popup.setOnMenuItemClickListener(item -> { popup.setOnMenuItemClickListener(item -> {
@ -219,7 +225,7 @@ public abstract class SFragment extends BaseFragment {
return true; return true;
} }
case R.id.pin: { case R.id.pin: {
timelineCases().pin(status, !status.getPinned()); timelineCases().pin(status, !status.isPinned());
return true; return true;
} }
} }