diff --git a/app/src/main/java/com/keylesspalace/tusky/util/SpanUtils.kt b/app/src/main/java/com/keylesspalace/tusky/util/SpanUtils.kt index 0da64c1c..f89f5fea 100644 --- a/app/src/main/java/com/keylesspalace/tusky/util/SpanUtils.kt +++ b/app/src/main/java/com/keylesspalace/tusky/util/SpanUtils.kt @@ -1,7 +1,6 @@ package com.keylesspalace.tusky.util import android.content.Context -import android.graphics.drawable.Drawable import android.os.Build import android.text.Spannable import android.text.SpannableStringBuilder @@ -11,7 +10,6 @@ import android.text.style.DynamicDrawableSpan import android.text.style.ForegroundColorSpan import android.text.style.ImageSpan import android.text.style.URLSpan -import androidx.appcompat.content.res.AppCompatResources import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial import java.util.regex.Pattern @@ -97,34 +95,24 @@ fun highlightSpans(text: Spannable, colour: Int) { } /** - * Replaces text of the form [drawabale name] or [iconics name] with their spanned counterparts (ImageSpan). + * Replaces text of the form [iconics name] with their spanned counterparts (ImageSpan). */ fun addDrawables(text: CharSequence, color: Int, size: Int, context: Context): Spannable { val alignment = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) DynamicDrawableSpan.ALIGN_CENTER else DynamicDrawableSpan.ALIGN_BASELINE val builder = SpannableStringBuilder(text) - val pattern = Pattern.compile("\\[(drawable|iconics) ([0-9a-z_]+)\\]") + val pattern = Pattern.compile("\\[iconics ([0-9a-z_]+)\\]") val matcher = pattern.matcher(builder) while (matcher.find()) { - val resourceType = matcher.group(1) - val resourceName = matcher.group(2) + val resourceName = matcher.group(1) ?: continue - val drawable: Drawable? = when (resourceType) { - "iconics" -> IconicsDrawable(context, GoogleMaterial.getIcon(resourceName)) - else -> { - val drawableResourceId = context.resources.getIdentifier(resourceName, "drawable", context.packageName) - if (drawableResourceId != 0) AppCompatResources.getDrawable(context, drawableResourceId) else null - } - } + val drawable = IconicsDrawable(context, GoogleMaterial.getIcon(resourceName)) + drawable.setBounds(0, 0, size, size) + drawable.setTint(color) - if (drawable != null) { - drawable.setBounds(0, 0, size, size) - drawable.setTint(color) - - builder.setSpan(ImageSpan(drawable, alignment), matcher.start(), matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) - } + builder.setSpan(ImageSpan(drawable, alignment), matcher.start(), matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) } return builder diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 3e198dcf..d7c7c619 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -662,7 +662,7 @@ Trotzdem anzeigen Dies ist deine Startseite. Sie zeigt die neuesten Beiträge der Accounts, denen du folgst.\n\nUm andere Accounts zu finden, kannst du entweder andere Timelines lesen. - Zum Beispiel die Lokale Timeline deiner Instanz [drawable ic_local_24dp]. Oder du kannst nach ihrem Namen suchen + Zum Beispiel die Lokale Timeline deiner Instanz [iconics gmd_group]. Oder du kannst nach ihrem Namen suchen [iconics gmd_search]; suche z. B. nach Tusky, um unseren Mastodon-Account zu finden. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 48197ea1..e6526430 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -805,6 +805,6 @@ This is your home timeline. It shows the recent posts of the accounts you follow.\n\nTo explore accounts you can either discover them in one of the other timelines. - For example the local timeline of your instance [drawable ic_local_24dp]. Or you can search them + For example the local timeline of your instance [iconics gmd_group]. Or you can search them by name [iconics gmd_search]; for example search for Tusky to find our Mastodon account.