diff options
| author | Bananeweizen <Bananeweizen@gmx.de> | 2013-05-30 10:18:47 -0700 |
|---|---|---|
| committer | Bananeweizen <Bananeweizen@gmx.de> | 2013-05-30 10:18:47 -0700 |
| commit | 559a9990f3b6c3969c9456f498d749e0b3afd20f (patch) | |
| tree | fc3a92195754afd8915ff30411cc8713349ef387 /main | |
| parent | 016a2b348ead0483be8d760c20bcd57e84c0f12b (diff) | |
| parent | cc7aa77b9827f463531718d5fe0ece970f590814 (diff) | |
| download | cgeo-559a9990f3b6c3969c9456f498d749e0b3afd20f.zip cgeo-559a9990f3b6c3969c9456f498d749e0b3afd20f.tar.gz cgeo-559a9990f3b6c3969c9456f498d749e0b3afd20f.tar.bz2 | |
Merge pull request #2805 from campbeb/fixColor
Fix #2804 - Cache detail text coloring fixes
Diffstat (limited to 'main')
| -rw-r--r-- | main/src/cgeo/geocaching/CacheDetailActivity.java | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index 33a6504..9b57f0d 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -137,7 +137,13 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc private static final int CONTEXT_MENU_WAYPOINT_DEFAULT_NAVIGATION = 1240; private static final int CONTEXT_MENU_WAYPOINT_RESET_ORIGINAL_CACHE_COORDINATES = 1241; - private static final Pattern DARK_COLOR_PATTERN = Pattern.compile(Pattern.quote("color=\"#") + "(0[0-9]){3}" + "\""); + private static final Pattern[] DARK_COLOR_PATTERNS = { + Pattern.compile("((?<!bg)color)=\"#" + "(0[0-9]){3}" + "\"", Pattern.CASE_INSENSITIVE), + Pattern.compile("((?<!bg)color)=\"" + "black" + "\"", Pattern.CASE_INSENSITIVE), + Pattern.compile("((?<!bg)color)=\"#" + "000080" + "\"", Pattern.CASE_INSENSITIVE) }; + private static final Pattern[] LIGHT_COLOR_PATTERNS = { + Pattern.compile("((?<!bg)color)=\"#" + "([F][6-9A-F]){3}" + "\"", Pattern.CASE_INSENSITIVE), + Pattern.compile("((?<!bg)color)=\"" + "white" + "\"", Pattern.CASE_INSENSITIVE) }; public static final String STATE_PAGE_INDEX = "cgeo.geocaching.pageIndex"; private Geocache cache; @@ -2015,7 +2021,7 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc if (StringUtils.isNotBlank(descriptionString)) { descriptionView.setText(description, TextView.BufferType.SPANNABLE); descriptionView.setMovementMethod(AnchorAwareLinkMovementMethod.getInstance()); - fixBlackTextColor(descriptionView, descriptionString); + fixTextColor(descriptionView, descriptionString); descriptionView.setVisibility(View.VISIBLE); registerForContextMenu(descriptionView); @@ -2046,23 +2052,35 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc } /** - * handle caches with black font color - * + * Handle caches with black font color in dark skin and white font color in light skin + * by changing background color of the view + * * @param view + * containing the text * @param text + * to be checked */ - private void fixBlackTextColor(final TextView view, final String text) { + private void fixTextColor(final TextView view, final String text) { + int backcolor; if (Settings.isLightSkin()) { - return; - } - int backcolor = color.black; - if (-1 != StringUtils.indexOfAny(text, new String[] { "color=\"black", "color=\"#000080\"" })) { - backcolor = color.darker_gray; - } - else { - MatcherWrapper matcher = new MatcherWrapper(DARK_COLOR_PATTERN, text); - if (matcher.find()) { - backcolor = color.darker_gray; + backcolor = color.white; + + for (Pattern pattern : LIGHT_COLOR_PATTERNS) { + final MatcherWrapper matcher = new MatcherWrapper(pattern, text); + if (matcher.find()) { + view.setBackgroundResource(color.darker_gray); + return; + } + } + } else { + backcolor = color.black; + + for (Pattern pattern : DARK_COLOR_PATTERNS) { + final MatcherWrapper matcher = new MatcherWrapper(pattern, text); + if (matcher.find()) { + view.setBackgroundResource(color.darker_gray); + return; + } } } view.setBackgroundResource(backcolor); |
