From 407844378f1fc97dcccde32a256e7c1d66bdac45 Mon Sep 17 00:00:00 2001 From: Jacocococo Date: Wed, 21 Aug 2024 22:15:55 +0200 Subject: [PATCH] Revert some changes specifically for Iceshrimp.NET --- .../android/api/StatusInteractionController.java | 6 +++--- .../org/joinmastodon/android/fragments/ComposeFragment.java | 2 +- .../org/joinmastodon/android/fragments/HasAccountID.java | 4 ++++ .../org/joinmastodon/android/fragments/ProfileFragment.java | 2 +- .../fragments/settings/SettingsBehaviorFragment.java | 2 +- .../main/java/org/joinmastodon/android/model/Instance.java | 4 ++++ .../ui/displayitems/EmojiReactionsStatusDisplayItem.java | 6 +++--- 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/StatusInteractionController.java b/mastodon/src/main/java/org/joinmastodon/android/api/StatusInteractionController.java index 72e457a31..14765a481 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/StatusInteractionController.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/StatusInteractionController.java @@ -64,7 +64,7 @@ public class StatusInteractionController{ result.favouritesCount = Math.max(0, status.favouritesCount + (favorited ? 1 : -1)); cb.accept(result); if(updateCounters) E.post(new StatusCountersUpdatedEvent(result)); - if(instance.isIceshrimp()) E.post(new EmojiReactionsUpdatedEvent(status.id, result.reactions, false, null)); + if(instance.isIceshrimpJs()) E.post(new EmojiReactionsUpdatedEvent(status.id, result.reactions, false, null)); } @Override @@ -74,7 +74,7 @@ public class StatusInteractionController{ status.favourited=!favorited; cb.accept(status); if(updateCounters) E.post(new StatusCountersUpdatedEvent(status)); - if(instance.isIceshrimp()) E.post(new EmojiReactionsUpdatedEvent(status.id, status.reactions, false, null)); + if(instance.isIceshrimpJs()) E.post(new EmojiReactionsUpdatedEvent(status.id, status.reactions, false, null)); } }) .exec(accountID); @@ -86,7 +86,7 @@ public class StatusInteractionController{ return; String defaultReactionEmojiRaw=instance.configuration.reactions.defaultReaction; - if(!instance.isIceshrimp() || defaultReactionEmojiRaw==null) + if(!instance.isIceshrimpJs() || defaultReactionEmojiRaw==null) return; boolean reactionIsCustom=defaultReactionEmojiRaw.startsWith(":"); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index bf5281a2e..71527154c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -830,7 +830,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr publishButton=wrap.findViewById(R.id.publish_btn); languageButton=wrap.findViewById(R.id.language_btn); - if(instance.isIceshrimp()) + if(instance.isIceshrimpJs()) languageButton.setVisibility(View.GONE); else { languageButton.setOnClickListener(v->showLanguageAlert()); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HasAccountID.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HasAccountID.java index d66e7f4c9..d8f84e565 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HasAccountID.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HasAccountID.java @@ -26,6 +26,10 @@ public interface HasAccountID { return getInstance().map(Instance::isIceshrimp).orElse(false); } + default boolean isInstanceIceshrimpJs() { + return getInstance().map(Instance::isIceshrimpJs).orElse(false); + } + default Optional getInstance() { return getSession().getInstance(); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java index e1a0d3f78..1cb01244c 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -1020,7 +1020,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList else hidePrivateNote(); invalidateOptionsMenu(); actionButton.setVisibility(View.VISIBLE); - notifyButton.setVisibility(relationship.following && !isInstanceIceshrimp() ? View.VISIBLE : View.GONE); + notifyButton.setVisibility(relationship.following && !isInstanceIceshrimpJs() ? View.VISIBLE : View.GONE); UiUtils.setRelationshipToActionButtonM3(relationship, actionButton); actionProgress.setIndeterminateTintList(actionButton.getTextColors()); notifyProgress.setIndeterminateTintList(notifyButton.getTextColors()); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsBehaviorFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsBehaviorFragment.java index 1c75b2793..52993acf1 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsBehaviorFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsBehaviorFragment.java @@ -61,7 +61,7 @@ public class SettingsBehaviorFragment extends BaseSettingsFragment impleme showRepliesItem=new CheckableListItem<>(R.string.sk_settings_show_replies, 0, CheckableListItem.Style.SWITCH, lp.showReplies, R.drawable.ic_fluent_arrow_reply_24_regular, i->toggleCheckableItem(showRepliesItem)) )); - if(!isInstanceIceshrimp()) items.add( + if(!isInstanceIceshrimpJs()) items.add( 0, languageItem=new ListItem<>(getString(R.string.default_post_language), postLanguage!=null ? postLanguage.getDisplayName(getContext()) : null, R.drawable.ic_fluent_local_language_24_regular, this::onDefaultLanguageClick) ); diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/Instance.java b/mastodon/src/main/java/org/joinmastodon/android/model/Instance.java index 345ff9c16..be0e2aa15 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/Instance.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/Instance.java @@ -156,6 +156,10 @@ public class Instance extends BaseModel{ return version.contains("compatible; Iceshrimp"); } + public boolean isIceshrimpJs() { + return version.contains("compatible; Iceshrimp "); // Iceshrimp.NET will not have a space immediately after + } + public boolean hasFeature(Feature feature) { Optional> pleromaFeatures = Optional.ofNullable(pleroma) .map(p -> p.metadata) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java index 0f819f48e..b93fa638a 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java @@ -295,7 +295,7 @@ public class EmojiReactionsStatusDisplayItem extends StatusDisplayItem { finalExisting.add(me); adapter.notifyItemChanged(item.status.reactions.indexOf(finalExisting)); } - if(instance.isIceshrimp() && status!=null){ + if(instance.isIceshrimpJs() && status!=null){ item.parentFragment.onFavoriteChanged(status, getItemID()); E.post(new StatusCountersUpdatedEvent(status)); } @@ -510,7 +510,7 @@ public class EmojiReactionsStatusDisplayItem extends StatusDisplayItem { btn.setCompoundDrawablesRelative(item.first.placeholder, null, null, null); } btn.setSelected(reaction.me); - if(parent.parentFragment.isInstanceIceshrimp() && reaction.name.contains("@")){ + if(parent.parentFragment.isInstanceIceshrimpJs() && reaction.name.contains("@")){ btn.setEnabled(false); btn.setClickable(false); btn.setLongClickable(true); @@ -552,7 +552,7 @@ public class EmojiReactionsStatusDisplayItem extends StatusDisplayItem { if(instance.configuration!=null && instance.configuration.reactions!=null && instance.configuration.reactions.maxReactions!=0){ adapter.parentHolder.updateMeReactionCount(deleting); } - if(instance.isIceshrimp() && status!=null){ + if(instance.isIceshrimpJs() && status!=null){ parent.parentFragment.onFavoriteChanged(status, adapter.parentHolder.getItemID()); E.post(new StatusCountersUpdatedEvent(status)); }