@@ -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 SetStatusPinned extends MastodonAPIRequest<Status>{
|
||||
public SetStatusPinned(String id, boolean pinned){
|
||||
super(HttpMethod.POST, "/statuses/"+id+"/"+(pinned ? "pin" : "unpin"), Status.class);
|
||||
setRequestBody(new Object());
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class Status extends BaseModel implements DisplayItemsParent{
|
||||
public boolean reblogged;
|
||||
public boolean muted;
|
||||
public boolean bookmarked;
|
||||
public boolean pinned;
|
||||
public Boolean pinned;
|
||||
|
||||
public transient boolean spoilerRevealed;
|
||||
public transient boolean hasGapAfter;
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.joinmastodon.android.GlobalUserPreferences;
|
||||
import org.joinmastodon.android.R;
|
||||
import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships;
|
||||
import org.joinmastodon.android.api.requests.statuses.GetStatusSourceText;
|
||||
import org.joinmastodon.android.api.requests.statuses.SetStatusPinned;
|
||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||
import org.joinmastodon.android.fragments.AddAccountToListsFragment;
|
||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||
@@ -36,6 +37,7 @@ import org.joinmastodon.android.model.Attachment;
|
||||
import org.joinmastodon.android.model.Relationship;
|
||||
import org.joinmastodon.android.model.Status;
|
||||
import org.joinmastodon.android.ui.OutlineProviders;
|
||||
import org.joinmastodon.android.ui.Snackbar;
|
||||
import org.joinmastodon.android.ui.text.HtmlParser;
|
||||
import org.joinmastodon.android.ui.utils.CustomEmojiHelper;
|
||||
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||
@@ -208,6 +210,24 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
||||
}else if(id==R.id.copy_link){
|
||||
activity.getSystemService(ClipboardManager.class).setPrimaryClip(ClipData.newPlainText(null, item.status.url));
|
||||
UiUtils.maybeShowTextCopiedToast(activity);
|
||||
}else if(id==R.id.pin){
|
||||
new SetStatusPinned(item.status.id, !item.status.pinned)
|
||||
.setCallback(new Callback<>(){
|
||||
@Override
|
||||
public void onSuccess(Status result){
|
||||
item.status.pinned=!item.status.pinned;
|
||||
new Snackbar.Builder(activity)
|
||||
.setText(item.status.pinned ? R.string.post_pinned : R.string.post_unpinned)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorResponse error){
|
||||
error.showToast(activity);
|
||||
}
|
||||
})
|
||||
.wrapProgress(activity, R.string.loading, true)
|
||||
.exec(item.accountID);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
@@ -293,11 +313,17 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
||||
MenuItem report=menu.findItem(R.id.report);
|
||||
MenuItem follow=menu.findItem(R.id.follow);
|
||||
MenuItem bookmark=menu.findItem(R.id.bookmark);
|
||||
MenuItem pin=menu.findItem(R.id.pin);
|
||||
if(item.status!=null){
|
||||
bookmark.setVisible(true);
|
||||
bookmark.setTitle(item.status.bookmarked ? R.string.remove_bookmark : R.string.add_bookmark);
|
||||
pin.setVisible(item.status.pinned!=null);
|
||||
if(item.status.pinned!=null){
|
||||
pin.setTitle(item.status.pinned ? R.string.unpin_post : R.string.pin_post);
|
||||
}
|
||||
}else{
|
||||
bookmark.setVisible(false);
|
||||
pin.setVisible(false);
|
||||
}
|
||||
if(isOwnPost){
|
||||
mute.setVisible(false);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<group android:id="@+id/menu_group1">
|
||||
<item android:id="@+id/translate" android:title="@string/translate_post"/>
|
||||
<item android:id="@+id/pin" android:title="@string/pin_post"/>
|
||||
<item android:id="@+id/bookmark" android:title="@string/add_bookmark"/>
|
||||
<item android:id="@+id/share" android:title="@string/button_share"/>
|
||||
<item android:id="@+id/open_in_browser" android:title="@string/open_in_browser"/>
|
||||
|
||||
@@ -716,4 +716,8 @@
|
||||
<string name="tab_home">Home</string>
|
||||
<string name="tab_search">Explore</string>
|
||||
<string name="tab_profile">Profile</string>
|
||||
<string name="pin_post">Pin on profile</string>
|
||||
<string name="unpin_post">Unpin from profile</string>
|
||||
<string name="post_pinned">Post has been pinned</string>
|
||||
<string name="post_unpinned">Post has been unpinned</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user