From 58cb6bb4b70795213f9609682c68d0025e0bab56 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Thu, 25 Jun 2015 19:24:02 +0200 Subject: Start moving colors into themes Using attrs instead of fixed colors it will be possible to style everything and also dynamically grab the color where needed in code. This is done with colorEmphasis as an initial test. Also remove several unused colors. --- .../org/sufficientlysecure/keychain/ui/util/Highlighter.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Highlighter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Highlighter.java index 69338aa3e..22c5315a9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Highlighter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Highlighter.java @@ -18,8 +18,10 @@ package org.sufficientlysecure.keychain.ui.util; import android.content.Context; +import android.content.res.Resources.Theme; import android.text.Spannable; import android.text.style.ForegroundColorSpan; +import android.util.TypedValue; import org.sufficientlysecure.keychain.R; @@ -44,9 +46,15 @@ public class Highlighter { Pattern pattern = Pattern.compile("(?i)(" + mQuery.trim().replaceAll("\\s+", "|") + ")"); Matcher matcher = pattern.matcher(text); + + TypedValue typedValue = new TypedValue(); + Theme theme = mContext.getTheme(); + theme.resolveAttribute(R.attr.colorEmphasis, typedValue, true); + int colorEmphasis = typedValue.data; + while (matcher.find()) { highlight.setSpan( - new ForegroundColorSpan(mContext.getResources().getColor(R.color.emphasis)), + new ForegroundColorSpan(colorEmphasis), matcher.start(), matcher.end(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); -- cgit v1.2.3