Improvements for Pleroma/Akkoma (#445)
* Reply Visibility on Plemora * Sort statuses in thread * Get default visibility and language from account if preferences fail * Fix for Mentions tab in notifications on Pleroma * Mark status as sensitive if not already when spoilertext is present * Integrating Pleroma quoting for new posts * move string to strings_sk * use null instead of empty string * change string * fix crash due to null value * update string --------- Co-authored-by: sk <sk22@mailbox.org>
This commit is contained in:
parent
ffb7cc5c18
commit
132b672441
13 changed files with 185 additions and 40 deletions
|
@ -63,7 +63,12 @@ public class GlobalUserPreferences{
|
|||
private final static Type recentEmojisType = new TypeToken<Map<String, Integer>>() {}.getType();
|
||||
public static Map<String, Integer> recentEmojis;
|
||||
|
||||
private static SharedPreferences getPrefs(){
|
||||
/**
|
||||
* Pleroma
|
||||
*/
|
||||
public static String replyVisibility;
|
||||
|
||||
private static SharedPreferences getPrefs(){
|
||||
return MastodonApp.context.getSharedPreferences("global", Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
|
@ -113,6 +118,7 @@ public class GlobalUserPreferences{
|
|||
pinnedTimelines=fromJson(prefs.getString("pinnedTimelines", null), pinnedTimelinesType, new HashMap<>());
|
||||
accountsWithLocalOnlySupport=prefs.getStringSet("accountsWithLocalOnlySupport", new HashSet<>());
|
||||
accountsInGlitchMode=prefs.getStringSet("accountsInGlitchMode", new HashSet<>());
|
||||
replyVisibility=prefs.getString("replyVisibility", null);
|
||||
|
||||
try {
|
||||
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S){
|
||||
|
@ -165,6 +171,7 @@ public class GlobalUserPreferences{
|
|||
.putString("recentEmojis", gson.toJson(recentEmojis))
|
||||
.putStringSet("accountsWithLocalOnlySupport", accountsWithLocalOnlySupport)
|
||||
.putStringSet("accountsInGlitchMode", accountsInGlitchMode)
|
||||
.putString("replyVisibility", replyVisibility)
|
||||
.apply();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,11 @@ import org.joinmastodon.android.BuildConfig;
|
|||
import org.joinmastodon.android.MastodonApp;
|
||||
import org.joinmastodon.android.api.requests.notifications.GetNotifications;
|
||||
import org.joinmastodon.android.api.requests.timelines.GetHomeTimeline;
|
||||
import org.joinmastodon.android.api.session.AccountSession;
|
||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||
import org.joinmastodon.android.model.CacheablePaginatedResponse;
|
||||
import org.joinmastodon.android.model.Filter;
|
||||
import org.joinmastodon.android.model.Instance;
|
||||
import org.joinmastodon.android.model.Notification;
|
||||
import org.joinmastodon.android.model.PaginatedResponse;
|
||||
import org.joinmastodon.android.model.SearchResult;
|
||||
|
@ -130,7 +132,8 @@ public class CacheController{
|
|||
cancelDelayedClose();
|
||||
databaseThread.postRunnable(()->{
|
||||
try{
|
||||
List<Filter> filters=AccountSessionManager.getInstance().getAccount(accountID).wordFilters.stream().filter(f->f.context.contains(Filter.FilterContext.NOTIFICATIONS)).collect(Collectors.toList());
|
||||
AccountSession accountSession=AccountSessionManager.getInstance().getAccount(accountID);
|
||||
List<Filter> filters=accountSession.wordFilters.stream().filter(f->f.context.contains(Filter.FilterContext.NOTIFICATIONS)).collect(Collectors.toList());
|
||||
if(!forceReload){
|
||||
SQLiteDatabase db=getOrOpenDatabase();
|
||||
String table=onlyPosts ? "notifications_posts" : onlyMentions ? "notifications_mentions" : "notifications_all";
|
||||
|
@ -160,7 +163,8 @@ public class CacheController{
|
|||
Log.w(TAG, "getNotifications: corrupted notification object in database", x);
|
||||
}
|
||||
}
|
||||
new GetNotifications(maxID, count, onlyPosts ? EnumSet.of(Notification.Type.STATUS) : onlyMentions ? EnumSet.of(Notification.Type.MENTION): EnumSet.allOf(Notification.Type.class))
|
||||
Instance instance=AccountSessionManager.getInstance().getInstanceInfo(accountSession.domain);
|
||||
new GetNotifications(maxID, count, onlyPosts ? EnumSet.of(Notification.Type.STATUS) : onlyMentions ? EnumSet.of(Notification.Type.MENTION): EnumSet.allOf(Notification.Type.class), instance.pleroma != null)
|
||||
.setCallback(new Callback<>(){
|
||||
@Override
|
||||
public void onSuccess(List<Notification> result){
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.joinmastodon.android.api.requests.notifications;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import org.joinmastodon.android.api.ApiUtils;
|
||||
|
@ -11,18 +10,24 @@ import java.util.EnumSet;
|
|||
import java.util.List;
|
||||
|
||||
public class GetNotifications extends MastodonAPIRequest<List<Notification>>{
|
||||
public GetNotifications(String maxID, int limit, EnumSet<Notification.Type> includeTypes){
|
||||
public GetNotifications(String maxID, int limit, EnumSet<Notification.Type> includeTypes, boolean isPleromaInstance){
|
||||
super(HttpMethod.GET, "/notifications", new TypeToken<>(){});
|
||||
if(maxID!=null)
|
||||
addQueryParameter("max_id", maxID);
|
||||
if(limit>0)
|
||||
addQueryParameter("limit", ""+limit);
|
||||
if(includeTypes!=null){
|
||||
for(String type:ApiUtils.enumSetToStrings(includeTypes, Notification.Type.class)){
|
||||
addQueryParameter("types[]", type);
|
||||
}
|
||||
for(String type:ApiUtils.enumSetToStrings(EnumSet.complementOf(includeTypes), Notification.Type.class)){
|
||||
addQueryParameter("exclude_types[]", type);
|
||||
if(!isPleromaInstance) {
|
||||
for(String type:ApiUtils.enumSetToStrings(includeTypes, Notification.Type.class)){
|
||||
addQueryParameter("types[]", type);
|
||||
}
|
||||
for(String type:ApiUtils.enumSetToStrings(EnumSet.complementOf(includeTypes), Notification.Type.class)){
|
||||
addQueryParameter("exclude_types[]", type);
|
||||
}
|
||||
}else{
|
||||
for(String type:ApiUtils.enumSetToStrings(includeTypes, Notification.Type.class)){
|
||||
addQueryParameter("include_types[]", type);
|
||||
}
|
||||
}
|
||||
}
|
||||
removeUnsupportedItems=true;
|
||||
|
|
|
@ -45,6 +45,8 @@ public class CreateStatus extends MastodonAPIRequest<Status>{
|
|||
public Instant scheduledAt;
|
||||
public String language;
|
||||
|
||||
public String quoteId;
|
||||
|
||||
public static class Poll{
|
||||
public ArrayList<String> options=new ArrayList<>();
|
||||
public int expiresIn;
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.joinmastodon.android.api.requests.timelines;
|
|||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import org.joinmastodon.android.GlobalUserPreferences;
|
||||
import org.joinmastodon.android.api.MastodonAPIRequest;
|
||||
import org.joinmastodon.android.model.Status;
|
||||
|
||||
|
@ -18,5 +19,7 @@ public class GetHomeTimeline extends MastodonAPIRequest<List<Status>>{
|
|||
addQueryParameter("since_id", sinceID);
|
||||
if(limit>0)
|
||||
addQueryParameter("limit", ""+limit);
|
||||
if(GlobalUserPreferences.replyVisibility != null)
|
||||
addQueryParameter("reply_visibility", GlobalUserPreferences.replyVisibility);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,6 +283,12 @@ public class AccountSessionManager{
|
|||
public void onSuccess(Account result){
|
||||
session.self=result;
|
||||
session.infoLastUpdated=System.currentTimeMillis();
|
||||
if(session.preferences != null && session.preferences.postingDefaultVisibility != null){
|
||||
session.preferences.postingDefaultVisibility = result.source.privacy;
|
||||
}
|
||||
if(session.preferences != null && session.preferences.postingDefaultLanguage != null){
|
||||
session.preferences.postingDefaultLanguage = result.source.language;
|
||||
}
|
||||
writeAccountsFile();
|
||||
}
|
||||
|
||||
|
@ -302,7 +308,14 @@ public class AccountSessionManager{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorResponse error) {}
|
||||
public void onError(ErrorResponse error) {
|
||||
Preferences preferences = new Preferences();
|
||||
if(session.self != null){
|
||||
preferences.postingDefaultVisibility = session.self.source.privacy;
|
||||
preferences.postingDefaultLanguage = session.self.source.language;
|
||||
}
|
||||
session.preferences = preferences;
|
||||
}
|
||||
}).exec(session.getID());
|
||||
}
|
||||
|
||||
|
|
|
@ -207,6 +207,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||
private List<EmojiCategory> customEmojis;
|
||||
private CustomEmojiPopupKeyboard emojiKeyboard;
|
||||
private Status replyTo;
|
||||
private Status quote;
|
||||
private String initialText;
|
||||
private String uuid;
|
||||
private int pollDuration=24*3600;
|
||||
|
@ -259,6 +260,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||
editingStatus=Parcels.unwrap(getArguments().getParcelable("editStatus"));
|
||||
if(getArguments().containsKey("replyTo"))
|
||||
replyTo=Parcels.unwrap(getArguments().getParcelable("replyTo"));
|
||||
if(getArguments().containsKey("quote"))
|
||||
quote=Parcels.unwrap(getArguments().getParcelable("quote"));
|
||||
if(instance==null){
|
||||
Nav.finish(this);
|
||||
return;
|
||||
|
@ -628,7 +631,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||
}
|
||||
});
|
||||
spoilerEdit.addTextChangedListener(new SimpleTextWatcher(e->updateCharCounter()));
|
||||
if(replyTo!=null){
|
||||
if(replyTo!=null || quote!=null){
|
||||
Status status = quote!=null ? quote : replyTo;
|
||||
View replyWrap = view.findViewById(R.id.reply_wrap);
|
||||
scrollView.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
|
||||
int scrollHeight = scrollView.getHeight();
|
||||
|
@ -654,13 +658,13 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||
originalPost.setOnClickListener(v->{
|
||||
Bundle args=new Bundle();
|
||||
args.putString("account", accountID);
|
||||
args.putParcelable("status", Parcels.wrap(replyTo));
|
||||
args.putParcelable("status", Parcels.wrap(status));
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
Nav.go(getActivity(), ThreadFragment.class, args);
|
||||
});
|
||||
|
||||
ImageView avatar = view.findViewById(R.id.avatar);
|
||||
ViewImageLoader.load(avatar, null, new UrlImageLoaderRequest(replyTo.account.avatar));
|
||||
ViewImageLoader.load(avatar, null, new UrlImageLoaderRequest(status.account.avatar));
|
||||
ViewOutlineProvider roundCornersOutline=new ViewOutlineProvider(){
|
||||
@Override
|
||||
public void getOutline(View view, Outline outline){
|
||||
|
@ -672,15 +676,15 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||
avatar.setOnClickListener(v->{
|
||||
Bundle args=new Bundle();
|
||||
args.putString("account", accountID);
|
||||
args.putParcelable("profileAccount", Parcels.wrap(replyTo.account));
|
||||
args.putParcelable("profileAccount", Parcels.wrap(status.account));
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
Nav.go(getActivity(), ProfileFragment.class, args);
|
||||
});
|
||||
|
||||
((TextView) view.findViewById(R.id.name)).setText(replyTo.account.displayName);
|
||||
((TextView) view.findViewById(R.id.username)).setText(replyTo.account.getDisplayUsername());
|
||||
((TextView) view.findViewById(R.id.name)).setText(status.account.displayName);
|
||||
((TextView) view.findViewById(R.id.username)).setText(status.account.getDisplayUsername());
|
||||
view.findViewById(R.id.visibility).setVisibility(View.GONE);
|
||||
Drawable visibilityIcon = getActivity().getDrawable(switch(replyTo.visibility){
|
||||
Drawable visibilityIcon = getActivity().getDrawable(switch(status.visibility){
|
||||
case PUBLIC -> R.drawable.ic_fluent_earth_20_regular;
|
||||
case UNLISTED -> R.drawable.ic_fluent_lock_open_20_regular;
|
||||
case PRIVATE -> R.drawable.ic_fluent_lock_closed_20_filled;
|
||||
|
@ -691,27 +695,27 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||
moreBtn.setImageDrawable(visibilityIcon);
|
||||
moreBtn.setBackground(null);
|
||||
TextView timestamp = view.findViewById(R.id.timestamp);
|
||||
if (replyTo.editedAt==null) timestamp.setText(UiUtils.formatRelativeTimestamp(getContext(), replyTo.createdAt));
|
||||
else timestamp.setText(getString(R.string.edited_timestamp, UiUtils.formatRelativeTimestamp(getContext(), replyTo.editedAt)));
|
||||
if (replyTo.spoilerText != null && !replyTo.spoilerText.isBlank()) {
|
||||
if (status.editedAt==null) timestamp.setText(UiUtils.formatRelativeTimestamp(getContext(), status.createdAt));
|
||||
else timestamp.setText(getString(R.string.edited_timestamp, UiUtils.formatRelativeTimestamp(getContext(), status.editedAt)));
|
||||
if (status.spoilerText != null && !status.spoilerText.isBlank()) {
|
||||
view.findViewById(R.id.spoiler_header).setVisibility(View.VISIBLE);
|
||||
((TextView) view.findViewById(R.id.spoiler_title_inline)).setText(replyTo.spoilerText);
|
||||
((TextView) view.findViewById(R.id.spoiler_title_inline)).setText(status.spoilerText);
|
||||
}
|
||||
|
||||
SpannableStringBuilder content = HtmlParser.parse(replyTo.content, replyTo.emojis, replyTo.mentions, replyTo.tags, accountID);
|
||||
SpannableStringBuilder content = HtmlParser.parse(status.content, status.emojis, status.mentions, status.tags, accountID);
|
||||
LinkedTextView text = view.findViewById(R.id.text);
|
||||
if (content.length() > 0) text.setText(content);
|
||||
else view.findViewById(R.id.display_item_text).setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, V.dp(16)));
|
||||
|
||||
replyText.setText(getString(R.string.in_reply_to, replyTo.account.displayName));
|
||||
int visibilityNameRes = switch (replyTo.visibility) {
|
||||
replyText.setText(getString(quote!=null? R.string.sk_quoting_user : R.string.in_reply_to, status.account.displayName));
|
||||
int visibilityNameRes = switch (status.visibility) {
|
||||
case PUBLIC -> R.string.visibility_public;
|
||||
case UNLISTED -> R.string.sk_visibility_unlisted;
|
||||
case PRIVATE -> R.string.visibility_followers_only;
|
||||
case DIRECT -> R.string.visibility_private;
|
||||
case LOCAL -> R.string.sk_local_only;
|
||||
};
|
||||
replyText.setContentDescription(getString(R.string.in_reply_to, replyTo.account.displayName) + ". " + getString(R.string.post_visibility) + ": " + getString(visibilityNameRes));
|
||||
replyText.setContentDescription(getString(R.string.in_reply_to, status.account.displayName) + ". " + getString(R.string.post_visibility) + ": " + getString(visibilityNameRes));
|
||||
replyText.setOnClickListener(v->{
|
||||
scrollView.smoothScrollTo(0, 0);
|
||||
});
|
||||
|
@ -722,9 +726,9 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||
|
||||
ArrayList<String> mentions=new ArrayList<>();
|
||||
String ownID=AccountSessionManager.getInstance().getAccount(accountID).self.id;
|
||||
if(!replyTo.account.id.equals(ownID))
|
||||
mentions.add('@'+replyTo.account.acct);
|
||||
for(Mention mention:replyTo.mentions){
|
||||
if(!status.account.id.equals(ownID))
|
||||
mentions.add('@'+status.account.acct);
|
||||
for(Mention mention:status.mentions){
|
||||
if(mention.id.equals(ownID))
|
||||
continue;
|
||||
String m='@'+mention.acct;
|
||||
|
@ -737,17 +741,17 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||
ignoreSelectionChanges=true;
|
||||
mainEditText.setSelection(mainEditText.length());
|
||||
ignoreSelectionChanges=false;
|
||||
if(!TextUtils.isEmpty(replyTo.spoilerText)){
|
||||
if(!TextUtils.isEmpty(status.spoilerText)){
|
||||
hasSpoiler=true;
|
||||
spoilerEdit.setVisibility(View.VISIBLE);
|
||||
if(GlobalUserPreferences.prefixRepliesWithRe && !replyTo.spoilerText.startsWith("re: ")){
|
||||
spoilerEdit.setText("re: " + replyTo.spoilerText);
|
||||
if(GlobalUserPreferences.prefixRepliesWithRe && !status.spoilerText.startsWith("re: ")){
|
||||
spoilerEdit.setText("re: " + status.spoilerText);
|
||||
}else{
|
||||
spoilerEdit.setText(replyTo.spoilerText);
|
||||
spoilerEdit.setText(status.spoilerText);
|
||||
}
|
||||
spoilerBtn.setSelected(true);
|
||||
}
|
||||
if (replyTo.language != null && !replyTo.language.isEmpty()) updateLanguage(replyTo.language);
|
||||
if (status.language != null && !status.language.isEmpty()) updateLanguage(status.language);
|
||||
}
|
||||
}else if (editingStatus==null || editingStatus.inReplyToId==null){
|
||||
// TODO: remove workaround after https://github.com/mastodon/mastodon-android/issues/341 gets fixed
|
||||
|
@ -1140,6 +1144,9 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
|
|||
if(hasSpoiler && spoilerEdit.length()>0){
|
||||
req.spoilerText=spoilerEdit.getText().toString();
|
||||
}
|
||||
if(quote != null){
|
||||
req.quoteId=quote.id;
|
||||
}
|
||||
if(uuid==null)
|
||||
uuid=UUID.randomUUID().toString();
|
||||
|
||||
|
|
|
@ -242,6 +242,22 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||
GlobalUserPreferences.showReplies=i.checked;
|
||||
GlobalUserPreferences.save();
|
||||
}));
|
||||
if (instance.pleroma != null) {
|
||||
items.add(new ButtonItem(R.string.sk_settings_reply_visibility, R.drawable.ic_fluent_chat_24_regular, b->{
|
||||
PopupMenu popupMenu=new PopupMenu(getActivity(), b, Gravity.CENTER_HORIZONTAL);
|
||||
popupMenu.inflate(R.menu.reply_visibility);
|
||||
popupMenu.setOnMenuItemClickListener(item -> this.onReplyVisibilityChanged(item, b));
|
||||
b.setOnTouchListener(popupMenu.getDragToOpenListener());
|
||||
b.setOnClickListener(v->popupMenu.show());
|
||||
b.setText(GlobalUserPreferences.replyVisibility == null ?
|
||||
R.string.sk_settings_reply_visibility_all :
|
||||
switch(GlobalUserPreferences.replyVisibility){
|
||||
case "following" -> R.string.sk_settings_reply_visibility_following;
|
||||
case "self" -> R.string.sk_settings_reply_visibility_self;
|
||||
default -> R.string.sk_settings_reply_visibility_all;
|
||||
});
|
||||
}));
|
||||
}
|
||||
items.add(new SwitchItem(R.string.sk_settings_show_boosts, R.drawable.ic_fluent_arrow_repeat_all_24_regular, GlobalUserPreferences.showBoosts, i->{
|
||||
GlobalUserPreferences.showBoosts=i.checked;
|
||||
GlobalUserPreferences.save();
|
||||
|
@ -525,6 +541,25 @@ public class SettingsFragment extends MastodonToolbarFragment{
|
|||
}
|
||||
}
|
||||
|
||||
private boolean onReplyVisibilityChanged(MenuItem item, Button btn){
|
||||
String pref = null;
|
||||
int id = item.getItemId();
|
||||
|
||||
if (id == R.id.reply_visibility_following) pref = "following";
|
||||
else if (id == R.id.reply_visibility_self) pref = "self";
|
||||
|
||||
GlobalUserPreferences.replyVisibility=pref;
|
||||
GlobalUserPreferences.save();
|
||||
btn.setText(GlobalUserPreferences.replyVisibility == null ?
|
||||
R.string.sk_settings_reply_visibility_all :
|
||||
switch(GlobalUserPreferences.replyVisibility){
|
||||
case "following" -> R.string.sk_settings_reply_visibility_following;
|
||||
case "self" -> R.string.sk_settings_reply_visibility_self;
|
||||
default -> R.string.sk_settings_reply_visibility_all;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
private void restartActivityToApplyNewTheme(){
|
||||
// Calling activity.recreate() causes a black screen for like half a second.
|
||||
// So, let's take a screenshot and overlay it on top to create the illusion of a smoother transition.
|
||||
|
|
|
@ -6,9 +6,12 @@ import android.view.View;
|
|||
import org.joinmastodon.android.DomainManager;
|
||||
import org.joinmastodon.android.R;
|
||||
import org.joinmastodon.android.api.requests.statuses.GetStatusContext;
|
||||
import org.joinmastodon.android.api.session.AccountSession;
|
||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||
import org.joinmastodon.android.events.StatusCreatedEvent;
|
||||
import org.joinmastodon.android.model.Account;
|
||||
import org.joinmastodon.android.model.Filter;
|
||||
import org.joinmastodon.android.model.Instance;
|
||||
import org.joinmastodon.android.model.Status;
|
||||
import org.joinmastodon.android.model.StatusContext;
|
||||
import org.joinmastodon.android.ui.displayitems.ExtendedFooterStatusDisplayItem;
|
||||
|
@ -20,6 +23,7 @@ import org.joinmastodon.android.ui.utils.UiUtils;
|
|||
import org.joinmastodon.android.utils.StatusFilterPredicate;
|
||||
import org.parceler.Parcels;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -76,6 +80,30 @@ public class ThreadFragment extends StatusListFragment implements DomainDisplay{
|
|||
data.add(mainStatus);
|
||||
onAppendItems(Collections.singletonList(mainStatus));
|
||||
}
|
||||
AccountSession account=AccountSessionManager.getInstance().getAccount(accountID);
|
||||
Instance instance=AccountSessionManager.getInstance().getInstanceInfo(account.domain);
|
||||
if(instance.pleroma != null){
|
||||
List<String> threadIds=new ArrayList<>();
|
||||
threadIds.add(mainStatus.id);
|
||||
for(Status s:result.descendants){
|
||||
if(threadIds.contains(s.inReplyToId)){
|
||||
threadIds.add(s.id);
|
||||
}
|
||||
}
|
||||
threadIds.add(mainStatus.inReplyToId);
|
||||
for(int i=result.ancestors.size()-1; i >= 0; i--){
|
||||
Status s=result.ancestors.get(i);
|
||||
if(s.inReplyToId != null && threadIds.contains(s.id)){
|
||||
threadIds.add(s.inReplyToId);
|
||||
}
|
||||
}
|
||||
|
||||
result.ancestors=result.ancestors.stream().filter(s -> threadIds.contains(s.id)).collect(Collectors.toList());
|
||||
result.descendants=getDescendantsOrdered(mainStatus.id,
|
||||
result.descendants.stream()
|
||||
.filter(s -> threadIds.contains(s.id))
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
result.descendants=filterStatuses(result.descendants);
|
||||
result.ancestors=filterStatuses(result.ancestors);
|
||||
if(footerProgress!=null)
|
||||
|
@ -98,6 +126,24 @@ public class ThreadFragment extends StatusListFragment implements DomainDisplay{
|
|||
.exec(accountID);
|
||||
}
|
||||
|
||||
private List<Status> getDescendantsOrdered(String id, List<Status> statuses){
|
||||
List<Status> out=new ArrayList<>();
|
||||
for(Status s:getDirectDescendants(id, statuses)){
|
||||
out.add(s);
|
||||
getDirectDescendants(s.id, statuses).forEach(d ->{
|
||||
out.add(d);
|
||||
out.addAll(getDescendantsOrdered(d.id, statuses));
|
||||
});
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private List<Status> getDirectDescendants(String id, List<Status> statuses){
|
||||
return statuses.stream()
|
||||
.filter(s -> s.inReplyToId.equals(id))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<Status> filterStatuses(List<Status> statuses){
|
||||
StatusFilterPredicate statusFilterPredicate=new StatusFilterPredicate(accountID,Filter.FilterContext.THREAD);
|
||||
return statuses.stream()
|
||||
|
|
|
@ -58,6 +58,8 @@ public class Status extends BaseModel implements DisplayItemsParent, Searchable{
|
|||
public boolean bookmarked;
|
||||
public boolean pinned;
|
||||
|
||||
public Status quote;
|
||||
|
||||
public transient boolean filterRevealed;
|
||||
public transient boolean spoilerRevealed;
|
||||
public transient boolean textExpanded, textExpandable;
|
||||
|
@ -67,6 +69,9 @@ public class Status extends BaseModel implements DisplayItemsParent, Searchable{
|
|||
|
||||
@Override
|
||||
public void postprocess() throws ObjectValidationException{
|
||||
if(spoilerText!=null && !spoilerText.isEmpty() && !sensitive)
|
||||
sensitive=true;
|
||||
|
||||
super.postprocess();
|
||||
if(application!=null)
|
||||
application.postprocess();
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.joinmastodon.android.api.session.AccountSession;
|
|||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||
import org.joinmastodon.android.fragments.BaseStatusListFragment;
|
||||
import org.joinmastodon.android.fragments.ComposeFragment;
|
||||
import org.joinmastodon.android.model.Instance;
|
||||
import org.joinmastodon.android.model.Status;
|
||||
import org.joinmastodon.android.model.StatusPrivacy;
|
||||
import org.joinmastodon.android.ui.M3AlertDialogBuilder;
|
||||
|
@ -319,12 +320,18 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
|
|||
v.startAnimation(opacityIn);
|
||||
Bundle args=new Bundle();
|
||||
args.putString("account", item.accountID);
|
||||
StringBuilder prefilledText = new StringBuilder().append("\n\n");
|
||||
String ownID = AccountSessionManager.getInstance().getAccount(item.accountID).self.id;
|
||||
if (!item.status.account.id.equals(ownID)) prefilledText.append('@').append(item.status.account.acct).append(' ');
|
||||
prefilledText.append(item.status.url);
|
||||
args.putString("prefilledText", prefilledText.toString());
|
||||
args.putInt("selectionStart", 0);
|
||||
AccountSession accountSession=AccountSessionManager.getInstance().getAccount(item.accountID);
|
||||
Instance instance=AccountSessionManager.getInstance().getInstanceInfo(accountSession.domain);
|
||||
if(instance.pleroma == null){
|
||||
StringBuilder prefilledText = new StringBuilder().append("\n\n");
|
||||
String ownID = AccountSessionManager.getInstance().getAccount(item.accountID).self.id;
|
||||
if (!item.status.account.id.equals(ownID)) prefilledText.append('@').append(item.status.account.acct).append(' ');
|
||||
prefilledText.append(item.status.url);
|
||||
args.putString("prefilledText", prefilledText.toString());
|
||||
args.putInt("selectionStart", 0);
|
||||
}else{
|
||||
args.putParcelable("quote", Parcels.wrap(item.status));
|
||||
}
|
||||
Nav.go(item.parentFragment.getActivity(), ComposeFragment.class, args);
|
||||
});
|
||||
|
||||
|
|
6
mastodon/src/main/res/menu/reply_visibility.xml
Normal file
6
mastodon/src/main/res/menu/reply_visibility.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@+id/reply_visibility_all" android:title="@string/sk_settings_reply_visibility_all"/>
|
||||
<item android:id="@+id/reply_visibility_following" android:title="@string/sk_settings_reply_visibility_following"/>
|
||||
<item android:id="@+id/reply_visibility_self" android:title="@string/sk_settings_reply_visibility_self"/>
|
||||
</menu>
|
|
@ -16,6 +16,11 @@
|
|||
<string name="sk_image_description">Image description</string>
|
||||
<string name="sk_visibility_unlisted">Unlisted</string>
|
||||
<string name="sk_settings_show_replies">Show replies</string>
|
||||
<string name="sk_quoting_user">Quoting %s</string>
|
||||
<string name="sk_settings_reply_visibility">Reply visibility</string>
|
||||
<string name="sk_settings_reply_visibility_all">All replies</string>
|
||||
<string name="sk_settings_reply_visibility_following">Replies to my follows</string>
|
||||
<string name="sk_settings_reply_visibility_self">Replies to me</string>
|
||||
<string name="sk_settings_show_boosts">Show boosts</string>
|
||||
<string name="sk_settings_load_new_posts">Automatically load new posts</string>
|
||||
<string name="sk_settings_show_interaction_counts">Show interaction counts</string>
|
||||
|
|
Loading…
Add table
Reference in a new issue