diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index 05245ab05..77a174218 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -27,6 +27,7 @@ public class GlobalUserPreferences{ public static boolean disableSwipe; public static boolean voteButtonForSingleChoice; public static boolean enableDeleteNotifications; + public static boolean translateButtonOpenedOnly; public static String publishButtonText; public static ThemePreference theme; public static ColorPreference color; @@ -58,6 +59,7 @@ public class GlobalUserPreferences{ disableSwipe=prefs.getBoolean("disableSwipe", false); voteButtonForSingleChoice=prefs.getBoolean("voteButtonForSingleChoice", true); enableDeleteNotifications=prefs.getBoolean("enableDeleteNotifications", false); + translateButtonOpenedOnly=prefs.getBoolean("translateButtonOpenedOnly", false); publishButtonText=prefs.getString("publishButtonText", ""); theme=ThemePreference.values()[prefs.getInt("theme", 0)]; recentLanguages=fromJson(prefs.getString("recentLanguages", "{}"), recentLanguagesType, new HashMap<>()); @@ -84,6 +86,7 @@ public class GlobalUserPreferences{ .putBoolean("disableMarquee", disableMarquee) .putBoolean("disableSwipe", disableSwipe) .putBoolean("enableDeleteNotifications", enableDeleteNotifications) + .putBoolean("translateButtonOpenedOnly", translateButtonOpenedOnly) .putString("publishButtonText", publishButtonText) .putInt("theme", theme.ordinal()) .putString("color", color.name()) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java index c4df5bd06..8fd571956 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -182,6 +182,11 @@ public class SettingsFragment extends MastodonToolbarFragment{ GlobalUserPreferences.save(); needAppRestart=true; })); + items.add(new SwitchItem(R.string.sk_settings_hide_translate_in_timeline, R.drawable.ic_fluent_translate_24_regular, GlobalUserPreferences.translateButtonOpenedOnly, i->{ + GlobalUserPreferences.translateButtonOpenedOnly=i.checked; + GlobalUserPreferences.save(); + needAppRestart=true; + })); items.add(new HeaderItem(R.string.home_timeline)); items.add(new SwitchItem(R.string.sk_settings_show_replies, R.drawable.ic_fluent_chat_multiple_24_regular, GlobalUserPreferences.showReplies, i->{ diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java index 64772d025..8d31f9f20 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java @@ -12,6 +12,7 @@ import android.widget.LinearLayout; import android.widget.Button; import android.widget.TextView; +import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.R; import org.joinmastodon.android.api.requests.statuses.TranslateStatus; import org.joinmastodon.android.api.session.AccountSession; @@ -145,7 +146,9 @@ public class TextStatusDisplayItem extends StatusDisplayItem{ Instance instanceInfo = AccountSessionManager.getInstance().getInstanceInfo(item.session.domain); boolean translateEnabled = instanceInfo.v2 != null && instanceInfo.v2.configuration.translation != null && instanceInfo.v2.configuration.translation.enabled; - translateWrap.setVisibility(item.textSelectable && translateEnabled && + translateWrap.setVisibility( + (!GlobalUserPreferences.translateButtonOpenedOnly || item.textSelectable) && + translateEnabled && !item.status.visibility.isLessVisibleThan(StatusPrivacy.UNLISTED) && item.status.language != null && (item.session.preferences == null || !item.status.language.equalsIgnoreCase(item.session.preferences.postingDefaultLanguage)) diff --git a/mastodon/src/main/res/drawable/ic_fluent_translate_24_regular.xml b/mastodon/src/main/res/drawable/ic_fluent_translate_24_regular.xml new file mode 100644 index 000000000..bab48ab1e --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_fluent_translate_24_regular.xml @@ -0,0 +1,3 @@ + + + diff --git a/mastodon/src/main/res/values/strings_sk.xml b/mastodon/src/main/res/values/strings_sk.xml index fc5d07254..78af0fcb1 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -79,4 +79,5 @@ Enable deleting notifications Publish button text Customize Publish button text + Hide translate button in timeline