From 40a34b07de6db3c600f37a5a11306ab231357d56 Mon Sep 17 00:00:00 2001 From: sk Date: Mon, 9 Oct 2023 18:07:19 +0200 Subject: [PATCH] add option to disable underlined links closes sk22#847 --- .../android/GlobalUserPreferences.java | 41 +++++++++++-------- .../settings/SettingsDisplayFragment.java | 4 +- .../android/ui/text/LinkSpan.java | 3 +- .../ic_fluent_text_underline_24_regular.xml | 3 ++ mastodon/src/main/res/values/strings_sk.xml | 1 + 5 files changed, 34 insertions(+), 18 deletions(-) create mode 100644 mastodon/src/main/res/drawable/ic_fluent_text_underline_24_regular.xml diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index 1234cbd45..6cf2a98fb 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -58,6 +58,7 @@ public class GlobalUserPreferences{ public static boolean displayPronounsInTimelines, displayPronounsInThreads, displayPronounsInUserListings; public static boolean overlayMedia; public static boolean showSuicideHelp; + public static boolean underlinedLinks; private static SharedPreferences getPrefs(){ return MastodonApp.context.getSharedPreferences("global", Context.MODE_PRIVATE); @@ -118,6 +119,7 @@ public class GlobalUserPreferences{ displayPronounsInUserListings=prefs.getBoolean("displayPronounsInUserListings", true); overlayMedia=prefs.getBoolean("overlayMedia", false); showSuicideHelp=prefs.getBoolean("showSuicideHelp", true); + underlinedLinks=prefs.getBoolean("underlinedLinks", true); if (prefs.contains("prefixRepliesWithRe")) { prefixReplies = prefs.getBoolean("prefixRepliesWithRe", false) @@ -175,9 +177,31 @@ public class GlobalUserPreferences{ .putBoolean("displayPronounsInUserListings", displayPronounsInUserListings) .putBoolean("overlayMedia", overlayMedia) .putBoolean("showSuicideHelp", showSuicideHelp) + .putBoolean("underlinedLinks", underlinedLinks) .apply(); } + public enum ThemePreference{ + AUTO, + LIGHT, + DARK + } + + public enum AutoRevealMode { + NEVER, + THREADS, + DISCUSSIONS + } + + public enum PrefixRepliesMode { + NEVER, + ALWAYS, + TO_OTHERS + } + + + //region preferences migrations + private static void migrateToVersion102(){ Log.d(TAG, "Migrating preferences to version 102!! (copy current theme to local preferences)"); @@ -245,21 +269,6 @@ public class GlobalUserPreferences{ } } - public enum ThemePreference{ - AUTO, - LIGHT, - DARK - } + //endregion - public enum AutoRevealMode { - NEVER, - THREADS, - DISCUSSIONS - } - - public enum PrefixRepliesMode { - NEVER, - ALWAYS, - TO_OTHERS - } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDisplayFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDisplayFragment.java index 5c8352b22..097fbe3d3 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDisplayFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/settings/SettingsDisplayFragment.java @@ -38,7 +38,7 @@ public class SettingsDisplayFragment extends BaseSettingsFragment{ private CheckableListItem revealCWsItem, hideSensitiveMediaItem, interactionCountsItem, emojiInNamesItem; // MEGALODON - private CheckableListItem trueBlackModeItem, marqueeItem, disableSwipeItem, reduceMotionItem, altIndicatorItem, noAltIndicatorItem, collapsePostsItem, spectatorModeItem, hideFabItem, translateOpenedItem, disablePillItem, showNavigationLabelsItem, likeIconItem; + private CheckableListItem trueBlackModeItem, marqueeItem, disableSwipeItem, reduceMotionItem, altIndicatorItem, noAltIndicatorItem, collapsePostsItem, spectatorModeItem, hideFabItem, translateOpenedItem, disablePillItem, showNavigationLabelsItem, likeIconItem, underlinedLinksItem; private ListItem colorItem, publishTextItem, autoRevealCWsItem; private CheckableListItem pronounsInUserListingsItem, pronounsInTimelinesItem, pronounsInThreadsItem; @@ -70,6 +70,7 @@ public class SettingsDisplayFragment extends BaseSettingsFragment{ hideFabItem=new CheckableListItem<>(R.string.sk_settings_hide_fab, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.autoHideFab, R.drawable.ic_fluent_edit_24_regular, ()->toggleCheckableItem(hideFabItem)), translateOpenedItem=new CheckableListItem<>(R.string.sk_settings_translate_only_opened, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.translateButtonOpenedOnly, R.drawable.ic_fluent_translate_24_regular, ()->toggleCheckableItem(translateOpenedItem)), likeIconItem=new CheckableListItem<>(R.string.sk_settings_like_icon, 0, CheckableListItem.Style.SWITCH, lp.likeIcon, R.drawable.ic_fluent_heart_24_regular, ()->toggleCheckableItem(likeIconItem)), + underlinedLinksItem=new CheckableListItem<>(R.string.sk_settings_underlined_links, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.underlinedLinks, R.drawable.ic_fluent_text_underline_24_regular, ()->toggleCheckableItem(underlinedLinksItem)), disablePillItem=new CheckableListItem<>(R.string.sk_disable_pill_shaped_active_indicator, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.disableM3PillActiveIndicator, R.drawable.ic_fluent_pill_24_regular, ()->toggleCheckableItem(disablePillItem)), showNavigationLabelsItem=new CheckableListItem<>(R.string.sk_settings_show_labels_in_navigation_bar, 0, CheckableListItem.Style.SWITCH, GlobalUserPreferences.showNavigationLabels, R.drawable.ic_fluent_tag_24_regular, ()->toggleCheckableItem(showNavigationLabelsItem), true), pronounsInTimelinesItem=new CheckableListItem<>(R.string.sk_settings_display_pronouns_in_timelines, 0, CheckableListItem.Style.CHECKBOX, GlobalUserPreferences.displayPronounsInTimelines, 0, ()->toggleCheckableItem(pronounsInTimelinesItem)), @@ -116,6 +117,7 @@ public class SettingsDisplayFragment extends BaseSettingsFragment{ GlobalUserPreferences.spectatorMode=spectatorModeItem.checked; GlobalUserPreferences.autoHideFab=hideFabItem.checked; GlobalUserPreferences.translateButtonOpenedOnly=translateOpenedItem.checked; + GlobalUserPreferences.underlinedLinks=underlinedLinksItem.checked; GlobalUserPreferences.disableM3PillActiveIndicator=disablePillItem.checked; GlobalUserPreferences.showNavigationLabels=showNavigationLabelsItem.checked; GlobalUserPreferences.displayPronounsInTimelines=pronounsInTimelinesItem.checked; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/text/LinkSpan.java b/mastodon/src/main/java/org/joinmastodon/android/ui/text/LinkSpan.java index dc28bd7fb..66281119b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/text/LinkSpan.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/text/LinkSpan.java @@ -5,6 +5,7 @@ import android.text.TextPaint; import android.text.style.CharacterStyle; import android.view.View; +import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.model.Hashtag; import org.joinmastodon.android.ui.utils.UiUtils; @@ -34,7 +35,7 @@ public class LinkSpan extends CharacterStyle { @Override public void updateDrawState(TextPaint tp) { tp.setColor(color=tp.linkColor); - tp.setUnderlineText(true); + tp.setUnderlineText(GlobalUserPreferences.underlinedLinks); } public void onClick(Context context){ diff --git a/mastodon/src/main/res/drawable/ic_fluent_text_underline_24_regular.xml b/mastodon/src/main/res/drawable/ic_fluent_text_underline_24_regular.xml new file mode 100644 index 000000000..fab41cb2c --- /dev/null +++ b/mastodon/src/main/res/drawable/ic_fluent_text_underline_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 626784ccd..6a62111d3 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -408,4 +408,5 @@ Blocked accounts Use heart as favorite icon Recently used + Underlined links \ No newline at end of file