Add conversation muting
This commit is contained in:
parent
3972ab207c
commit
ff7948ad83
|
@ -0,0 +1,11 @@
|
||||||
|
package org.joinmastodon.android.api.requests.statuses;
|
||||||
|
|
||||||
|
import org.joinmastodon.android.api.MastodonAPIRequest;
|
||||||
|
import org.joinmastodon.android.model.Status;
|
||||||
|
|
||||||
|
public class SetStatusConversationMuted extends MastodonAPIRequest<Status>{
|
||||||
|
public SetStatusConversationMuted(String id, boolean muted){
|
||||||
|
super(HttpMethod.POST, "/statuses/"+id+(muted ? "/mute" : "/unmute"), Status.class);
|
||||||
|
setRequestBody(new Object());
|
||||||
|
}
|
||||||
|
}
|
|
@ -58,7 +58,7 @@ public class Status extends BaseModel implements DisplayItemsParent{
|
||||||
|
|
||||||
public boolean favourited;
|
public boolean favourited;
|
||||||
public boolean reblogged;
|
public boolean reblogged;
|
||||||
public boolean muted;
|
public Boolean muted;
|
||||||
public boolean bookmarked;
|
public boolean bookmarked;
|
||||||
public Boolean pinned;
|
public Boolean pinned;
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,13 @@ import org.joinmastodon.android.GlobalUserPreferences;
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships;
|
import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships;
|
||||||
import org.joinmastodon.android.api.requests.statuses.GetStatusSourceText;
|
import org.joinmastodon.android.api.requests.statuses.GetStatusSourceText;
|
||||||
|
import org.joinmastodon.android.api.requests.statuses.SetStatusConversationMuted;
|
||||||
import org.joinmastodon.android.api.requests.statuses.SetStatusPinned;
|
import org.joinmastodon.android.api.requests.statuses.SetStatusPinned;
|
||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.joinmastodon.android.fragments.AddAccountToListsFragment;
|
import org.joinmastodon.android.fragments.AddAccountToListsFragment;
|
||||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||||
import org.joinmastodon.android.fragments.ComposeFragment;
|
import org.joinmastodon.android.fragments.ComposeFragment;
|
||||||
|
import org.joinmastodon.android.fragments.NotificationsListFragment;
|
||||||
import org.joinmastodon.android.fragments.ProfileFragment;
|
import org.joinmastodon.android.fragments.ProfileFragment;
|
||||||
import org.joinmastodon.android.fragments.report.ReportReasonChoiceFragment;
|
import org.joinmastodon.android.fragments.report.ReportReasonChoiceFragment;
|
||||||
import org.joinmastodon.android.model.Account;
|
import org.joinmastodon.android.model.Account;
|
||||||
|
@ -228,6 +230,22 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
||||||
})
|
})
|
||||||
.wrapProgress(activity, R.string.loading, true)
|
.wrapProgress(activity, R.string.loading, true)
|
||||||
.exec(item.accountID);
|
.exec(item.accountID);
|
||||||
|
}else if(id==R.id.mute_conversation){
|
||||||
|
new SetStatusConversationMuted(item.status.id, !item.status.muted)
|
||||||
|
.setCallback(new Callback<>(){
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Status result){
|
||||||
|
// TODO snackbar?
|
||||||
|
item.status.muted=result.muted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(ErrorResponse error){
|
||||||
|
error.showToast(activity);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.wrapProgress(activity, R.string.loading, true)
|
||||||
|
.exec(item.accountID);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
@ -314,6 +332,7 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
||||||
MenuItem follow=menu.findItem(R.id.follow);
|
MenuItem follow=menu.findItem(R.id.follow);
|
||||||
MenuItem bookmark=menu.findItem(R.id.bookmark);
|
MenuItem bookmark=menu.findItem(R.id.bookmark);
|
||||||
MenuItem pin=menu.findItem(R.id.pin);
|
MenuItem pin=menu.findItem(R.id.pin);
|
||||||
|
MenuItem muteConversation=menu.findItem(R.id.mute_conversation);
|
||||||
if(item.status!=null){
|
if(item.status!=null){
|
||||||
bookmark.setVisible(true);
|
bookmark.setVisible(true);
|
||||||
bookmark.setTitle(item.status.bookmarked ? R.string.remove_bookmark : R.string.add_bookmark);
|
bookmark.setTitle(item.status.bookmarked ? R.string.remove_bookmark : R.string.add_bookmark);
|
||||||
|
@ -340,6 +359,12 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
||||||
report.setTitle(item.parentFragment.getString(R.string.report_user, account.displayName));
|
report.setTitle(item.parentFragment.getString(R.string.report_user, account.displayName));
|
||||||
follow.setTitle(item.parentFragment.getString(relationship!=null && relationship.following ? R.string.unfollow_user : R.string.follow_user, account.displayName));
|
follow.setTitle(item.parentFragment.getString(relationship!=null && relationship.following ? R.string.unfollow_user : R.string.follow_user, account.displayName));
|
||||||
}
|
}
|
||||||
|
if(item.status.muted!=null){
|
||||||
|
muteConversation.setVisible(isOwnPost || item.parentFragment instanceof NotificationsListFragment);
|
||||||
|
muteConversation.setTitle(item.status.muted ? R.string.unmute_conversation : R.string.mute_conversation);
|
||||||
|
}else{
|
||||||
|
muteConversation.setVisible(false);
|
||||||
|
}
|
||||||
menu.findItem(R.id.add_to_list).setVisible(relationship!=null && relationship.following);
|
menu.findItem(R.id.add_to_list).setVisible(relationship!=null && relationship.following);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
<item android:id="@+id/copy_link" android:title="@string/fallback_menu_item_copy_link"/>
|
<item android:id="@+id/copy_link" android:title="@string/fallback_menu_item_copy_link"/>
|
||||||
<item android:id="@+id/edit" android:title="@string/edit"/>
|
<item android:id="@+id/edit" android:title="@string/edit"/>
|
||||||
<item android:id="@+id/delete" android:title="@string/delete"/>
|
<item android:id="@+id/delete" android:title="@string/delete"/>
|
||||||
|
<item android:id="@+id/mute_conversation" android:title="@string/mute_conversation"/>
|
||||||
</group>
|
</group>
|
||||||
<group android:id="@+id/menu_group2">
|
<group android:id="@+id/menu_group2">
|
||||||
<item android:id="@+id/add_to_list" android:title="@string/add_user_to_list"/>
|
<item android:id="@+id/add_to_list" android:title="@string/add_user_to_list"/>
|
||||||
|
|
|
@ -725,4 +725,6 @@
|
||||||
<string name="disable_new_post_notifications">Stop notifying me when %s posts</string>
|
<string name="disable_new_post_notifications">Stop notifying me when %s posts</string>
|
||||||
<string name="new_post_notifications_enabled">You’ll get notifications for new posts.</string>
|
<string name="new_post_notifications_enabled">You’ll get notifications for new posts.</string>
|
||||||
<string name="new_post_notifications_disabled">You’ll no longer get notifications for new posts.</string>
|
<string name="new_post_notifications_disabled">You’ll no longer get notifications for new posts.</string>
|
||||||
|
<string name="mute_conversation">Mute conversation</string>
|
||||||
|
<string name="unmute_conversation">Unmute conversation</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in New Issue