From 0e96e23cfa91861e894a9ecfefbabaacc49669d8 Mon Sep 17 00:00:00 2001 From: Jacocococo Date: Thu, 15 Feb 2024 00:06:08 +0100 Subject: [PATCH] Hide language selector on Iceshrimp --- .../android/fragments/ComposeFragment.java | 20 +++++++++++-------- .../android/fragments/HasAccountID.java | 4 ++++ .../settings/SettingsBehaviorFragment.java | 6 +++++- 3 files changed, 21 insertions(+), 9 deletions(-) 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 0764b7d7a..492678c26 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -829,14 +829,18 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr publishButton=wrap.findViewById(R.id.publish_btn); languageButton=wrap.findViewById(R.id.language_btn); - languageButton.setOnClickListener(v->showLanguageAlert()); - languageButton.setOnLongClickListener(v->{ - if(!getLocalPrefs().bottomEncoding){ - getLocalPrefs().bottomEncoding=true; - getLocalPrefs().save(); - } - return false; - }); + if(instance.isIceshrimp()) + languageButton.setVisibility(View.GONE); + else { + languageButton.setOnClickListener(v->showLanguageAlert()); + languageButton.setOnLongClickListener(v->{ + if(!getLocalPrefs().bottomEncoding){ + getLocalPrefs().bottomEncoding=true; + getLocalPrefs().save(); + } + return false; + }); + } publishButton.post(()->publishButton.setMinimumWidth(publishButton.getWidth())); publishButton.setOnClickListener(v->{ 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 9934b2e17..d66e7f4c9 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HasAccountID.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HasAccountID.java @@ -22,6 +22,10 @@ public interface HasAccountID { return getInstance().map(Instance::isPixelfed).orElse(false); } + default boolean isInstanceIceshrimp() { + return getInstance().map(Instance::isIceshrimp).orElse(false); + } + default Optional getInstance() { return getSession().getInstance(); } 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 62c32d8fb..1c75b2793 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 @@ -45,7 +45,6 @@ public class SettingsBehaviorFragment extends BaseSettingsFragment impleme languageResolver.from(s.preferences.postingDefaultLanguage).orElse(null); List> items = new ArrayList<>(List.of( - 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), altTextItem=new CheckableListItem<>(R.string.settings_alt_text_reminders, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.altTextReminders, R.drawable.ic_fluent_image_alt_text_24_regular, i->toggleCheckableItem(altTextItem)), playGifsItem=new CheckableListItem<>(R.string.settings_gif, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.playGifs, R.drawable.ic_fluent_gif_24_regular, i->toggleCheckableItem(playGifsItem)), overlayMediaItem=new CheckableListItem<>(R.string.sk_settings_continues_playback, R.string.sk_settings_continues_playback_summary, CheckableListItem.Style.SWITCH, GlobalUserPreferences.overlayMedia, R.drawable.ic_fluent_play_circle_hint_24_regular, i->toggleCheckableItem(overlayMediaItem)), @@ -62,6 +61,11 @@ 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( + 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) + ); + if(isInstanceAkkoma()) items.add( replyVisibilityItem=new ListItem<>(R.string.sk_settings_reply_visibility, getReplyVisibilityString(), R.drawable.ic_fluent_chat_24_regular, this::onReplyVisibilityClick) );