Better handling of muted users and conversations, add option Hide muted users like in PleromaFE
This commit is contained in:
parent
6f91e1f9ff
commit
7ccb9ac5d2
|
@ -129,7 +129,7 @@ class PreferencesActivity : BaseActivity(), SharedPreferences.OnSharedPreference
|
||||||
|
|
||||||
}
|
}
|
||||||
"statusTextSize", "absoluteTimeView", "showBotOverlay", "animateGifAvatars",
|
"statusTextSize", "absoluteTimeView", "showBotOverlay", "animateGifAvatars",
|
||||||
"useBlurhash", "showCardsInTimelines", "confirmReblogs" -> {
|
"useBlurhash", "showCardsInTimelines", "confirmReblogs", "hideMutedUsers" -> {
|
||||||
restartActivitiesOnExit = true
|
restartActivitiesOnExit = true
|
||||||
}
|
}
|
||||||
"language" -> {
|
"language" -> {
|
||||||
|
|
|
@ -262,7 +262,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
switch (concrete.getType()) {
|
switch (concrete.getType()) {
|
||||||
case MENTION:
|
case MENTION:
|
||||||
case POLL: {
|
case POLL: {
|
||||||
if(concrete.getStatusViewData() != null && concrete.getStatusViewData().isThreadMuted())
|
if(concrete.getStatusViewData() != null && concrete.getStatusViewData().isMuted())
|
||||||
return VIEW_TYPE_MUTED_STATUS;
|
return VIEW_TYPE_MUTED_STATUS;
|
||||||
return VIEW_TYPE_STATUS;
|
return VIEW_TYPE_STATUS;
|
||||||
}
|
}
|
||||||
|
@ -493,13 +493,13 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
if(icon != null) {
|
if(icon != null) {
|
||||||
icon.setColorFilter(ContextCompat.getColor(context,
|
icon.setColorFilter(ContextCompat.getColor(context,
|
||||||
R.color.tusky_green), PorterDuff.Mode.SRC_ATOP);
|
R.color.tusky_green), PorterDuff.Mode.SRC_ATOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
String format = context.getString(R.string.notification_emoji_format);
|
String format = context.getString(R.string.notification_emoji_format);
|
||||||
String emojiCode = notificationViewData.getEmoji();
|
String emojiCode = notificationViewData.getEmoji();
|
||||||
wholeMessage = String.format(format, displayName, emojiCode);
|
wholeMessage = String.format(format, displayName, emojiCode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
message.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
|
message.setCompoundDrawablesWithIntrinsicBounds(icon, null, null, null);
|
||||||
final SpannableStringBuilder str = new SpannableStringBuilder(wholeMessage);
|
final SpannableStringBuilder str = new SpannableStringBuilder(wholeMessage);
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class StatusViewHolder extends StatusBaseViewHolder {
|
||||||
statusInfo.setOnClickListener(v -> listener.onOpenReblog(getAdapterPosition()));
|
statusInfo.setOnClickListener(v -> listener.onOpenReblog(getAdapterPosition()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(status.isThreadMutedOnBackend()) {
|
if(status.isUserMuted() || status.isThreadMuted()) {
|
||||||
toggleVisibility.setVisibility(View.VISIBLE);
|
toggleVisibility.setVisibility(View.VISIBLE);
|
||||||
toggleVisibility.setOnClickListener(v -> listener.onMute(getAdapterPosition(), true));
|
toggleVisibility.setOnClickListener(v -> listener.onMute(getAdapterPosition(), true));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -111,7 +111,7 @@ public final class TimelineAdapter extends RecyclerView.Adapter {
|
||||||
holder.setup(statusListener, ((StatusViewData.Placeholder) status).isLoading());
|
holder.setup(statusListener, ((StatusViewData.Placeholder) status).isLoading());
|
||||||
} else if (status instanceof StatusViewData.Concrete) {
|
} else if (status instanceof StatusViewData.Concrete) {
|
||||||
StatusViewData.Concrete concrete = (StatusViewData.Concrete)status;
|
StatusViewData.Concrete concrete = (StatusViewData.Concrete)status;
|
||||||
if(concrete.isThreadMuted()) {
|
if(concrete.isMuted()) {
|
||||||
MutedStatusViewHolder holder = (MutedStatusViewHolder) viewHolder;
|
MutedStatusViewHolder holder = (MutedStatusViewHolder) viewHolder;
|
||||||
holder.setupWithStatus(concrete, statusListener, statusDisplayOptions,
|
holder.setupWithStatus(concrete, statusListener, statusDisplayOptions,
|
||||||
payloads != null && !payloads.isEmpty() ? payloads.get(0) : null);
|
payloads != null && !payloads.isEmpty() ? payloads.get(0) : null);
|
||||||
|
@ -134,7 +134,7 @@ public final class TimelineAdapter extends RecyclerView.Adapter {
|
||||||
return VIEW_TYPE_PLACEHOLDER;
|
return VIEW_TYPE_PLACEHOLDER;
|
||||||
} else {
|
} else {
|
||||||
StatusViewData.Concrete concrete = (StatusViewData.Concrete)dataSource.getItemAt(position);
|
StatusViewData.Concrete concrete = (StatusViewData.Concrete)dataSource.getItemAt(position);
|
||||||
if(concrete.isThreadMuted()) {
|
if(concrete.isMuted()) {
|
||||||
return VIEW_TYPE_STATUS_MUTED;
|
return VIEW_TYPE_STATUS_MUTED;
|
||||||
} else {
|
} else {
|
||||||
return VIEW_TYPE_STATUS;
|
return VIEW_TYPE_STATUS;
|
||||||
|
|
|
@ -126,6 +126,10 @@ data class Status(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isMuted(): Boolean {
|
||||||
|
return muted
|
||||||
|
}
|
||||||
|
|
||||||
fun isUserMuted(): Boolean {
|
fun isUserMuted(): Boolean {
|
||||||
return muted && !isThreadMuted()
|
return muted && !isThreadMuted()
|
||||||
}
|
}
|
||||||
|
|
|
@ -626,7 +626,7 @@ public class NotificationsFragment extends SFragment implements
|
||||||
(NotificationViewData.Concrete) notifications.getPairedItem(position);
|
(NotificationViewData.Concrete) notifications.getPairedItem(position);
|
||||||
StatusViewData.Concrete statusViewData =
|
StatusViewData.Concrete statusViewData =
|
||||||
new StatusViewData.Builder(old.getStatusViewData())
|
new StatusViewData.Builder(old.getStatusViewData())
|
||||||
.setThreadMuted(isMuted)
|
.setMuted(isMuted)
|
||||||
.createStatusViewData();
|
.createStatusViewData();
|
||||||
NotificationViewData notificationViewData = new NotificationViewData.Concrete(old.getType(),
|
NotificationViewData notificationViewData = new NotificationViewData.Concrete(old.getType(),
|
||||||
old.getId(), old.getAccount(), statusViewData, old.isExpanded(), old.getEmoji());
|
old.getId(), old.getAccount(), statusViewData, old.isExpanded(), old.getEmoji());
|
||||||
|
@ -641,7 +641,7 @@ public class NotificationsFragment extends SFragment implements
|
||||||
|
|
||||||
StatusViewData.Builder viewDataBuilder = new StatusViewData.Builder(viewdata.getStatusViewData());
|
StatusViewData.Builder viewDataBuilder = new StatusViewData.Builder(viewdata.getStatusViewData());
|
||||||
viewDataBuilder.setThreadMuted(muted);
|
viewDataBuilder.setThreadMuted(muted);
|
||||||
viewDataBuilder.setThreadMutedOnBackend(muted);
|
viewDataBuilder.setMuted(muted);
|
||||||
|
|
||||||
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
|
NotificationViewData.Concrete newViewData = new NotificationViewData.Concrete(
|
||||||
viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
|
viewdata.getType(), viewdata.getId(), viewdata.getAccount(),
|
||||||
|
|
|
@ -675,7 +675,7 @@ public class TimelineFragment extends SFragment implements
|
||||||
public void onMute(int position, boolean isMuted) {
|
public void onMute(int position, boolean isMuted) {
|
||||||
StatusViewData.Concrete statusViewData =
|
StatusViewData.Concrete statusViewData =
|
||||||
new StatusViewData.Builder((StatusViewData.Concrete)statuses.getPairedItem(position))
|
new StatusViewData.Builder((StatusViewData.Concrete)statuses.getPairedItem(position))
|
||||||
.setThreadMuted(isMuted)
|
.setMuted(isMuted)
|
||||||
.createStatusViewData();
|
.createStatusViewData();
|
||||||
statuses.setPairedItem(position, statusViewData);
|
statuses.setPairedItem(position, statusViewData);
|
||||||
updateAdapter();
|
updateAdapter();
|
||||||
|
@ -685,8 +685,8 @@ public class TimelineFragment extends SFragment implements
|
||||||
status.setThreadMuted(muted);
|
status.setThreadMuted(muted);
|
||||||
|
|
||||||
StatusViewData.Builder statusViewData = new StatusViewData.Builder((StatusViewData.Concrete)statuses.getPairedItem(position));
|
StatusViewData.Builder statusViewData = new StatusViewData.Builder((StatusViewData.Concrete)statuses.getPairedItem(position));
|
||||||
|
statusViewData.setMuted(muted);
|
||||||
statusViewData.setThreadMuted(muted);
|
statusViewData.setThreadMuted(muted);
|
||||||
statusViewData.setThreadMutedOnBackend(muted);
|
|
||||||
|
|
||||||
statuses.setPairedItem(position, statusViewData.createStatusViewData());
|
statuses.setPairedItem(position, statusViewData.createStatusViewData());
|
||||||
}
|
}
|
||||||
|
@ -993,7 +993,8 @@ public class TimelineFragment extends SFragment implements
|
||||||
private Call<List<Status>> getFetchCallByTimelineType(Kind kind, String tagOrId, String fromId,
|
private Call<List<Status>> getFetchCallByTimelineType(Kind kind, String tagOrId, String fromId,
|
||||||
String uptoId) {
|
String uptoId) {
|
||||||
MastodonApi api = mastodonApi;
|
MastodonApi api = mastodonApi;
|
||||||
boolean withMuted = true; // TODO: configurable
|
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
||||||
|
boolean withMuted = !preferences.getBoolean("hideMutedUsers", false);
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
default:
|
default:
|
||||||
case HOME:
|
case HOME:
|
||||||
|
|
|
@ -65,9 +65,9 @@ public final class ViewDataUtils {
|
||||||
.setPoll(visibleStatus.getPoll())
|
.setPoll(visibleStatus.getPoll())
|
||||||
.setCard(visibleStatus.getCard())
|
.setCard(visibleStatus.getCard())
|
||||||
.setIsBot(visibleStatus.getAccount().getBot())
|
.setIsBot(visibleStatus.getAccount().getBot())
|
||||||
|
.setMuted(visibleStatus.isMuted())
|
||||||
.setUserMuted(visibleStatus.isUserMuted())
|
.setUserMuted(visibleStatus.isUserMuted())
|
||||||
.setThreadMuted(visibleStatus.isThreadMuted())
|
.setThreadMuted(visibleStatus.isThreadMuted())
|
||||||
.setThreadMutedOnBackend(visibleStatus.isThreadMuted())
|
|
||||||
.setConversationId(visibleStatus.getConversationId())
|
.setConversationId(visibleStatus.getConversationId())
|
||||||
.setEmojiReactions(visibleStatus.getEmojiReactions())
|
.setEmojiReactions(visibleStatus.getEmojiReactions())
|
||||||
.createStatusViewData();
|
.createStatusViewData();
|
||||||
|
|
|
@ -92,9 +92,9 @@ public abstract class StatusViewData {
|
||||||
@Nullable
|
@Nullable
|
||||||
private final PollViewData poll;
|
private final PollViewData poll;
|
||||||
private final boolean isBot;
|
private final boolean isBot;
|
||||||
private final boolean isThreadMuted; /* toggle for showing thread */
|
private final boolean isMuted; /* user toggle */
|
||||||
private final boolean isUserMuted;
|
private final boolean isThreadMuted; /* thread_muted state got from backend */
|
||||||
private final boolean isThreadMutedOnBackend; /* thread_muted state got from backend */
|
private final boolean isUserMuted; /* muted state got from backend */
|
||||||
private final int conversationId;
|
private final int conversationId;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final List<EmojiReaction> emojiReactions;
|
private final List<EmojiReaction> emojiReactions;
|
||||||
|
@ -106,8 +106,8 @@ public abstract class StatusViewData {
|
||||||
Date createdAt, int reblogsCount, int favouritesCount, @Nullable String inReplyToId,
|
Date createdAt, int reblogsCount, int favouritesCount, @Nullable String inReplyToId,
|
||||||
@Nullable Status.Mention[] mentions, String senderId, boolean rebloggingEnabled,
|
@Nullable Status.Mention[] mentions, String senderId, boolean rebloggingEnabled,
|
||||||
Status.Application application, List<Emoji> statusEmojis, List<Emoji> accountEmojis, @Nullable Card card,
|
Status.Application application, List<Emoji> statusEmojis, List<Emoji> accountEmojis, @Nullable Card card,
|
||||||
boolean isCollapsible, boolean isCollapsed, @Nullable PollViewData poll, boolean isBot, boolean isThreadMuted,
|
boolean isCollapsible, boolean isCollapsed, @Nullable PollViewData poll, boolean isBot, boolean isMuted, boolean isThreadMuted,
|
||||||
boolean isUserMuted, boolean isThreadMutedOnBackend, int conversationId, @Nullable List<EmojiReaction> emojiReactions) {
|
boolean isUserMuted, int conversationId, @Nullable List<EmojiReaction> emojiReactions) {
|
||||||
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) {
|
||||||
|
@ -147,8 +147,8 @@ public abstract class StatusViewData {
|
||||||
this.isCollapsed = isCollapsed;
|
this.isCollapsed = isCollapsed;
|
||||||
this.poll = poll;
|
this.poll = poll;
|
||||||
this.isBot = isBot;
|
this.isBot = isBot;
|
||||||
|
this.isMuted = isMuted;
|
||||||
this.isThreadMuted = isThreadMuted;
|
this.isThreadMuted = isThreadMuted;
|
||||||
this.isThreadMutedOnBackend = isThreadMutedOnBackend;
|
|
||||||
this.isUserMuted = isUserMuted;
|
this.isUserMuted = isUserMuted;
|
||||||
this.conversationId = conversationId;
|
this.conversationId = conversationId;
|
||||||
this.emojiReactions = emojiReactions;
|
this.emojiReactions = emojiReactions;
|
||||||
|
@ -304,12 +304,12 @@ public abstract class StatusViewData {
|
||||||
return isThreadMuted;
|
return isThreadMuted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isThreadMutedOnBackend() {
|
public boolean isMuted() {
|
||||||
return isThreadMutedOnBackend;
|
return isMuted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUserMuted() {
|
public boolean isUserMuted() {
|
||||||
return isUserMuted;
|
return isUserMuted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -351,9 +351,9 @@ public abstract class StatusViewData {
|
||||||
Objects.equals(card, concrete.card) &&
|
Objects.equals(card, concrete.card) &&
|
||||||
Objects.equals(poll, concrete.poll) &&
|
Objects.equals(poll, concrete.poll) &&
|
||||||
isCollapsed == concrete.isCollapsed &&
|
isCollapsed == concrete.isCollapsed &&
|
||||||
|
isMuted == concrete.isMuted &&
|
||||||
isThreadMuted == concrete.isThreadMuted &&
|
isThreadMuted == concrete.isThreadMuted &&
|
||||||
isUserMuted == concrete.isUserMuted &&
|
isUserMuted == concrete.isUserMuted &&
|
||||||
isThreadMutedOnBackend == concrete.isThreadMutedOnBackend &&
|
|
||||||
conversationId == concrete.conversationId &&
|
conversationId == concrete.conversationId &&
|
||||||
Objects.equals(emojiReactions, concrete.emojiReactions);
|
Objects.equals(emojiReactions, concrete.emojiReactions);
|
||||||
}
|
}
|
||||||
|
@ -462,8 +462,8 @@ public abstract class StatusViewData {
|
||||||
private boolean isCollapsed; /** Whether the status is shown partially or fully */
|
private boolean isCollapsed; /** Whether the status is shown partially or fully */
|
||||||
private PollViewData poll;
|
private PollViewData poll;
|
||||||
private boolean isBot;
|
private boolean isBot;
|
||||||
|
private boolean isMuted;
|
||||||
private boolean isThreadMuted;
|
private boolean isThreadMuted;
|
||||||
private boolean isThreadMutedOnBackend;
|
|
||||||
private boolean isUserMuted;
|
private boolean isUserMuted;
|
||||||
private int conversationId;
|
private int conversationId;
|
||||||
private List<EmojiReaction> emojiReactions;
|
private List<EmojiReaction> emojiReactions;
|
||||||
|
@ -503,9 +503,9 @@ public abstract class StatusViewData {
|
||||||
isCollapsed = viewData.isCollapsed();
|
isCollapsed = viewData.isCollapsed();
|
||||||
poll = viewData.poll;
|
poll = viewData.poll;
|
||||||
isBot = viewData.isBot();
|
isBot = viewData.isBot();
|
||||||
|
isMuted = viewData.isMuted;
|
||||||
isThreadMuted = viewData.isThreadMuted;
|
isThreadMuted = viewData.isThreadMuted;
|
||||||
isUserMuted = viewData.isUserMuted;
|
isUserMuted = viewData.isUserMuted;
|
||||||
isThreadMutedOnBackend = viewData.isThreadMutedOnBackend;
|
|
||||||
emojiReactions = viewData.emojiReactions;
|
emojiReactions = viewData.emojiReactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,27 +677,27 @@ public abstract class StatusViewData {
|
||||||
this.poll = PollViewDataKt.toViewData(poll);
|
this.poll = PollViewDataKt.toViewData(poll);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder setMuted(Boolean isMuted) {
|
||||||
|
this.isMuted = isMuted;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder setUserMuted(Boolean isUserMuted) {
|
public Builder setUserMuted(Boolean isUserMuted) {
|
||||||
this.isUserMuted = isUserMuted;
|
this.isUserMuted = isUserMuted;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setThreadMuted(Boolean isThreadMuted) {
|
public Builder setThreadMuted(Boolean isThreadMuted) {
|
||||||
this.isThreadMuted = isThreadMuted;
|
this.isThreadMuted = isThreadMuted;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setThreadMutedOnBackend(Boolean isThreadMutedOnBackend) {
|
|
||||||
this.isThreadMutedOnBackend = isThreadMutedOnBackend;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder setConversationId(int conversationId) {
|
public Builder setConversationId(int conversationId) {
|
||||||
this.conversationId = conversationId;
|
this.conversationId = conversationId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setEmojiReactions(List<EmojiReaction> emojiReactions) {
|
public Builder setEmojiReactions(List<EmojiReaction> emojiReactions) {
|
||||||
this.emojiReactions = emojiReactions;
|
this.emojiReactions = emojiReactions;
|
||||||
return this;
|
return this;
|
||||||
|
@ -712,8 +712,8 @@ public abstract class StatusViewData {
|
||||||
visibility, attachments, rebloggedByUsername, rebloggedAvatar, isSensitive, isExpanded,
|
visibility, attachments, rebloggedByUsername, rebloggedAvatar, isSensitive, isExpanded,
|
||||||
isShowingContent, userFullName, nickname, avatar, createdAt, reblogsCount,
|
isShowingContent, userFullName, nickname, avatar, createdAt, reblogsCount,
|
||||||
favouritesCount, inReplyToId, mentions, senderId, rebloggingEnabled, application,
|
favouritesCount, inReplyToId, mentions, senderId, rebloggingEnabled, application,
|
||||||
statusEmojis, accountEmojis, card, isCollapsible, isCollapsed, poll, isBot, isThreadMuted,
|
statusEmojis, accountEmojis, card, isCollapsible, isCollapsed, poll, isBot, isMuted, isThreadMuted,
|
||||||
isUserMuted, isThreadMutedOnBackend, conversationId, emojiReactions);
|
isUserMuted, conversationId, emojiReactions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,5 +23,6 @@
|
||||||
<string name="notification_emoji_description">Notifications about new emoji reactions</string>
|
<string name="notification_emoji_description">Notifications about new emoji reactions</string>
|
||||||
|
|
||||||
<string name="pref_title_notification_filter_emoji">my posts are reacted with emojis</string>
|
<string name="pref_title_notification_filter_emoji">my posts are reacted with emojis</string>
|
||||||
|
<string name="pref_title_hide_muted_users">Hide muted users</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,12 @@
|
||||||
android:title="@string/pref_title_confirm_reblogs"
|
android:title="@string/pref_title_confirm_reblogs"
|
||||||
app:singleLineTitle="false" />
|
app:singleLineTitle="false" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="hideMutedUsers"
|
||||||
|
android:title="@string/pref_title_hide_muted_users"
|
||||||
|
app:singleLineTitle="false" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/pref_title_browser_settings">
|
<PreferenceCategory android:title="@string/pref_title_browser_settings">
|
||||||
|
|
Loading…
Reference in New Issue