add placeholder textColorLink resolving code to color webview links

This commit is contained in:
Andrew Dolgov 2012-02-01 09:57:07 +03:00
parent 8443d8702a
commit 2791bc46e9
2 changed files with 28 additions and 2 deletions

View File

@ -15,6 +15,7 @@ import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -101,13 +102,25 @@ public class ArticleFragment extends Fragment {
ws.setSupportZoom(true);
ws.setBuiltInZoomControls(true);
TypedValue tv = new TypedValue();
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
cssOverride = "body { background : black; color : #e0e0e0}\na:link {color: #00aae0;} \na:visited { color: #aaaae0;}\n";
getActivity().getTheme().resolveAttribute(android.R.attr.textColorLink, tv, true);
cssOverride = "body { background : black; color : #e0e0e0}";
view.setBackgroundColor(android.R.color.black);
web.setBackgroundColor(android.R.color.black);
} else {
getActivity().getTheme().resolveAttribute(android.R.attr.textColorLinkInverse, tv, true);
cssOverride = "";
}
int linkColor = tv.data;
String hexColor = String.format("#%06X", (0xFFFFFF & linkColor));
cssOverride += " a:link {color: "+hexColor+";} a:visited { color: "+hexColor+";}";
String articleContent = m_article.content != null ? m_article.content : "";
Document doc = Jsoup.parse(articleContent);

View File

@ -17,6 +17,7 @@ import android.provider.BaseColumns;
import android.support.v4.app.Fragment;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -106,12 +107,24 @@ public class OfflineArticleFragment extends Fragment {
ws.setSupportZoom(true);
ws.setBuiltInZoomControls(true);
TypedValue tv = new TypedValue();
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
cssOverride = "body { background : black; color : #e0e0e0}\n";
getActivity().getTheme().resolveAttribute(android.R.attr.textColorLink, tv, true);
cssOverride = "body { background : black; color : #e0e0e0}";
view.setBackgroundColor(android.R.color.black);
web.setBackgroundColor(android.R.color.black);
} else {
getActivity().getTheme().resolveAttribute(android.R.attr.textColorLinkInverse, tv, true);
cssOverride = "";
}
int linkColor = tv.data;
String hexColor = String.format("#%06X", (0xFFFFFF & linkColor));
cssOverride += " a:link {color: "+hexColor+";} a:visited { color: "+hexColor+";}";
String articleContent = m_cursor.getString(m_cursor.getColumnIndex("content"));
Document doc = Jsoup.parse(articleContent);