DescriptionFragment now works correctly with different themes
This commit is contained in:
parent
49974c776a
commit
349b5970f2
|
@ -2,7 +2,6 @@ package de.danoeh.antennapod.fragment;
|
|||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
|
||||
import android.R;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.res.TypedArray;
|
||||
|
@ -19,6 +18,8 @@ import android.webkit.WebView;
|
|||
import com.actionbarsherlock.app.SherlockFragment;
|
||||
|
||||
import de.danoeh.antennapod.AppConfig;
|
||||
import de.danoeh.antennapod.PodcastApp;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
import de.danoeh.antennapod.feed.FeedManager;
|
||||
|
@ -53,7 +54,9 @@ public class ItemDescriptionFragment extends SherlockFragment {
|
|||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Creating view");
|
||||
webvDescription = new WebView(getActivity());
|
||||
if (PodcastApp.getThemeResourceId() == R.style.Theme_AntennaPod_Dark) {
|
||||
webvDescription.setBackgroundColor(0);
|
||||
}
|
||||
webvDescription.getSettings().setUseWideViewPort(false);
|
||||
return webvDescription;
|
||||
}
|
||||
|
@ -154,8 +157,12 @@ public class ItemDescriptionFragment extends SherlockFragment {
|
|||
}
|
||||
}
|
||||
|
||||
/** Return the CSS style of the Webview.
|
||||
* @param textColor the default color to use for the text in the webview. This value is inserted directly into the CSS String.
|
||||
/**
|
||||
* Return the CSS style of the Webview.
|
||||
*
|
||||
* @param textColor
|
||||
* the default color to use for the text in the webview. This
|
||||
* value is inserted directly into the CSS String.
|
||||
* */
|
||||
private String getWebViewStyle(String textColor) {
|
||||
final String WEBVIEW_STYLE = "<head><style type=\"text/css\"> * { color: %s; font-family: Helvetica; line-height: 1.5em; font-size: 12pt; } a { font-style: normal; text-decoration: none; font-weight: normal; color: #00A8DF; }</style></head>";
|
||||
|
@ -205,16 +212,18 @@ public class ItemDescriptionFragment extends SherlockFragment {
|
|||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Loading Webview");
|
||||
data = "";
|
||||
if (contentEncodedRef == null
|
||||
&& descriptionRef != null) {
|
||||
if (contentEncodedRef == null && descriptionRef != null) {
|
||||
data = descriptionRef;
|
||||
} else {
|
||||
data = StringEscapeUtils.unescapeHtml4(contentEncodedRef);
|
||||
}
|
||||
|
||||
TypedArray res = getActivity().getTheme().obtainStyledAttributes(new int[] {android.R.attr.textColorPrimary});
|
||||
TypedArray res = getActivity().getTheme()
|
||||
.obtainStyledAttributes(
|
||||
new int[] { android.R.attr.textColorPrimary });
|
||||
int colorResource = res.getColor(0, 0);
|
||||
String colorString = String.format("#%06X", 0xFFFFFF & colorResource);
|
||||
String colorString = String.format("#%06X",
|
||||
0xFFFFFF & colorResource);
|
||||
Log.i(TAG, "text color: " + colorString);
|
||||
res.recycle();
|
||||
data = getWebViewStyle(colorString) + data;
|
||||
|
|
Loading…
Reference in New Issue