diff options
author | Thialfihar <thi@thialfihar.org> | 2015-06-26 11:08:26 +0200 |
---|---|---|
committer | Thialfihar <thi@thialfihar.org> | 2015-07-21 20:50:32 +0200 |
commit | 13983be7998ea28cc4b8882e1b45eff5ca4986a6 (patch) | |
tree | 58cd1963fb4b7106ca7e81ed1c6c19e5217e9e79 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util | |
parent | 58cb6bb4b70795213f9609682c68d0025e0bab56 (diff) | |
download | open-keychain-13983be7998ea28cc4b8882e1b45eff5ca4986a6.tar.gz open-keychain-13983be7998ea28cc4b8882e1b45eff5ca4986a6.tar.bz2 open-keychain-13983be7998ea28cc4b8882e1b45eff5ca4986a6.zip |
Make header text and tertiary text color themeable
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/FormattingUtils.java | 8 | ||||
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Highlighter.java | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/FormattingUtils.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/FormattingUtils.java index eb5c3df45..902a7ec56 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/FormattingUtils.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/FormattingUtils.java @@ -18,9 +18,11 @@ package org.sufficientlysecure.keychain.ui.util; import android.content.Context; +import android.content.res.Resources.Theme; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.style.StrikethroughSpan; +import android.util.TypedValue; public class FormattingUtils { @@ -32,4 +34,10 @@ public class FormattingUtils { return (int) ((px / context.getResources().getDisplayMetrics().density) + 0.5f); } + public static int getColorFromAttr(Context context, int attr) { + TypedValue typedValue = new TypedValue(); + Theme theme = context.getTheme(); + theme.resolveAttribute(attr, typedValue, true); + return typedValue.data; + } } 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 22c5315a9..ac34d5526 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,12 +18,11 @@ 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; +import org.sufficientlysecure.keychain.ui.util.FormattingUtils; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -47,10 +46,7 @@ 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; + int colorEmphasis = FormattingUtils.getColorFromAttr(mContext, R.attr.colorEmphasis); while (matcher.find()) { highlight.setSpan( |