summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorThomas <tschneider.ac@gmail.com>2023-12-19 10:42:36 +0100
committerThomas <tschneider.ac@gmail.com>2023-12-19 10:42:36 +0100
commitdade64750d7d8c067dd4803131436dd806508b8b (patch)
tree317f24148ad983c6f6d5e206771604fc25bc8524 /app
parent0064db72a194d3c63c5119567a4551b23be56432 (diff)
Allow to underline clickable elements
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java18
-rw-r--r--app/src/main/res/values/strings.xml2
-rw-r--r--app/src/main/res/xml/pref_timelines.xml7
3 files changed, 23 insertions, 4 deletions
diff --git a/app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java b/app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java
index 6f65eaa69..c9918a702 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/helper/SpannableHelper.java
@@ -104,6 +104,7 @@ public class SpannableHelper {
public static final String CLICKABLE_SPAN = "CLICKABLE_SPAN";
private static int linkColor;
+ private static boolean underlineLinks;
public static Spannable convert(Context context, String text,
Status status, Account account, Announcement announcement,
@@ -115,6 +116,7 @@ public class SpannableHelper {
int currentNightMode = context.getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK;
boolean customLight = sharedpreferences.getBoolean(context.getString(R.string.SET_CUSTOMIZE_LIGHT_COLORS), false);
boolean customDark = sharedpreferences.getBoolean(context.getString(R.string.SET_CUSTOMIZE_DARK_COLORS), false);
+ underlineLinks = sharedpreferences.getBoolean(context.getString(R.string.SET_UNDERLINE_CLICKABLE), false);
int link_color;
if (currentNightMode == Configuration.UI_MODE_NIGHT_NO && customLight) {
link_color = sharedpreferences.getInt(context.getString(R.string.SET_LIGHT_LINK), -1);
@@ -309,7 +311,9 @@ public class SpannableHelper {
@Override
public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds);
- ds.setUnderlineText(status != null && status.underlined);
+ if(!underlineLinks) {
+ ds.setUnderlineText(status != null && status.underlined);
+ }
if (linkColor != -1) {
ds.setColor(linkColor);
}
@@ -599,7 +603,9 @@ public class SpannableHelper {
@Override
public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds);
- ds.setUnderlineText(status != null && status.underlined);
+ if(!underlineLinks) {
+ ds.setUnderlineText(status != null && status.underlined);
+ }
if (linkColor != -1) {
ds.setColor(linkColor);
}
@@ -744,7 +750,9 @@ public class SpannableHelper {
@Override
public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds);
- ds.setUnderlineText(status != null && status.underlined);
+ if(!underlineLinks) {
+ ds.setUnderlineText(status != null && status.underlined);
+ }
if (linkColor != -1) {
ds.setColor(linkColor);
}
@@ -891,7 +899,9 @@ public class SpannableHelper {
@Override
public void updateDrawState(@NonNull TextPaint ds) {
super.updateDrawState(ds);
- ds.setUnderlineText(false);
+ if(!underlineLinks) {
+ ds.setUnderlineText(false);
+ }
if (linkColor != -1) {
ds.setColor(linkColor);
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index abf0f150f..97644ed22 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1189,6 +1189,7 @@
<string name="SET_BOOST_ORIGINAL_DATE" translatable="false">SET_BOOST_ORIGINAL_DATE</string>
<string name="SET_MARKDOWN_SUPPORT" translatable="false">SET_MARKDOWN_SUPPORT</string>
<string name="SET_TRUNCATE_LINKS" translatable="false">SET_TRUNCATE_LINKS</string>
+ <string name="SET_UNDERLINE_CLICKABLE" translatable="false">SET_UNDERLINE_CLICKABLE</string>
<string name="SET_TRUNCATE_LINKS_MAX" translatable="false">SET_TRUNCATE_LINKS_MAX</string>
<string name="SET_HIDE_SINGLE_MEDIA_WITH_CARD" translatable="false">SET_HIDE_SINGLE_MEDIA_WITH_CARD</string>
@@ -1991,6 +1992,7 @@
<string name="toot_error_no_media_description">There are missing media descriptions</string>
<string name="truncate_links">Truncate links</string>
+ <string name="underline_links">Underlines clickable elements</string>
<string name="truncate_links_max">Max chars in links</string>
diff --git a/app/src/main/res/xml/pref_timelines.xml b/app/src/main/res/xml/pref_timelines.xml
index 4143933b4..c59d8b788 100644
--- a/app/src/main/res/xml/pref_timelines.xml
+++ b/app/src/main/res/xml/pref_timelines.xml
@@ -64,6 +64,13 @@
app:singleLineTitle="false"
app:title="@string/truncate_links" />
+ <SwitchPreferenceCompat
+ android:defaultValue="false"
+ app:iconSpaceReserved="false"
+ app:key="@string/SET_UNDERLINE_CLICKABLE"
+ app:singleLineTitle="false"
+ app:title="@string/underline_links" />
+
<androidx.preference.SeekBarPreference
android:defaultValue="30"
android:max="150"