diff options
-rw-r--r-- | res/layout/headlines_row.xml | 7 | ||||
-rw-r--r-- | res/layout/headlines_row_selected.xml | 7 | ||||
-rw-r--r-- | res/layout/headlines_row_selected_unread.xml | 7 | ||||
-rw-r--r-- | res/layout/headlines_row_unread.xml | 7 | ||||
-rw-r--r-- | src/org/fox/ttrss/HeadlinesFragment.java | 57 |
5 files changed, 84 insertions, 1 deletions
diff --git a/res/layout/headlines_row.xml b/res/layout/headlines_row.xml index 8d3b4c26..326ff49c 100644 --- a/res/layout/headlines_row.xml +++ b/res/layout/headlines_row.xml @@ -84,6 +84,13 @@ android:textColor="?headlineExcerptTextColor"
android:textSize="13sp" />
+ <WebView
+ android:id="@+id/content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingTop="3dp"
+ android:visibility="gone" />
+
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/headlines_row_selected.xml b/res/layout/headlines_row_selected.xml index 9123e44e..0418d7b8 100644 --- a/res/layout/headlines_row_selected.xml +++ b/res/layout/headlines_row_selected.xml @@ -81,6 +81,13 @@ android:text="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
android:textColor="?headlineSelectedExcerptTextColor"
android:textSize="13sp" />
+
+ <WebView
+ android:id="@+id/content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingTop="3dp"
+ android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
diff --git a/res/layout/headlines_row_selected_unread.xml b/res/layout/headlines_row_selected_unread.xml index 0b7d7b84..abca9eaf 100644 --- a/res/layout/headlines_row_selected_unread.xml +++ b/res/layout/headlines_row_selected_unread.xml @@ -83,6 +83,13 @@ android:textColor="?headlineSelectedExcerptTextColor"
android:textSize="13sp" />
+ <WebView
+ android:id="@+id/content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingTop="3dp"
+ android:visibility="gone" />
+
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/headlines_row_unread.xml b/res/layout/headlines_row_unread.xml index 0fd5a836..b54f91d6 100644 --- a/res/layout/headlines_row_unread.xml +++ b/res/layout/headlines_row_unread.xml @@ -80,6 +80,13 @@ android:textColor="?headlineExcerptTextColor"
android:textSize="13sp" />
+ <WebView
+ android:id="@+id/content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingTop="3dp"
+ android:visibility="gone" />
+
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index b67012a6..60890b2f 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -1,5 +1,7 @@ package org.fox.ttrss; +import java.net.MalformedURLException; +import java.net.URL; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -30,6 +32,7 @@ import android.support.v4.app.Fragment; import android.support.v4.widget.SwipeRefreshLayout; import android.text.Html; import android.text.Html.ImageGetter; +import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; import android.view.ContextMenu; @@ -39,6 +42,8 @@ import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.webkit.WebSettings; +import android.webkit.WebView; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; import android.widget.AdapterView; @@ -75,6 +80,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, private HeadlinesEventListener m_listener; private OnlineActivity m_activity; private SwipeRefreshLayout m_swipeLayout; + private int m_maxImageSize = 0; private ImageGetter m_dummyGetter = new ImageGetter() { @@ -288,6 +294,12 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, m_searchQuery = (String) savedInstanceState.getCharSequence("searchQuery"); } + DisplayMetrics metrics = new DisplayMetrics(); + getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics); + m_maxImageSize = (int) (128 * metrics.density + 0.5); + + Log.d(TAG, "maxImageSize=" + m_maxImageSize); + View view = inflater.inflate(R.layout.headlines_fragment, container, false); m_swipeLayout = (SwipeRefreshLayout) view.findViewById(R.id.headlines_swipe_container); @@ -794,7 +806,50 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, te.setTextSize(TypedValue.COMPLEX_UNIT_SP, headlineFontSize); te.setText(excerpt); } - } + } + + WebView content = (WebView)v.findViewById(R.id.content); + + if (content != null) { + + content.setVisibility(View.VISIBLE); + if (te != null) te.setVisibility(View.GONE); + + String baseUrl = null; + + try { + URL url = new URL(article.link); + baseUrl = url.getProtocol() + "://" + url.getHost(); + } catch (MalformedURLException e) { + // + } + + TypedValue tv = new TypedValue(); + getActivity().getTheme().resolveAttribute(R.attr.linkColor, tv, true); + + String hexColor = String.format("#%06X", (0xFFFFFF & tv.data)); + + articleContent = "<html>" + + "<head>" + + "<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\">" + + "<meta name=\"viewport\" content=\"width=device-width, user-scalable=no\" />" + + "<style type=\"text/css\">" + + "body { padding : 0px; margin : 0px; line-height : 130%; }" + + "img { max-width : 100%; max-height : "+m_maxImageSize+"px; width : auto; height : auto; }" + + "table { width : 100%; }" + + "a:link {color: "+hexColor+";} a:visited { color: "+hexColor+";}" + + "</style>" + + "</head>" + + "<body>" + articleContent + "</body></html>"; + + WebSettings ws = content.getSettings(); + ws.setSupportZoom(false); + ws.setDefaultFontSize(headlineFontSize); + + content.loadDataWithBaseURL(baseUrl, articleContent, "text/html", "utf-8", null); + + + } String articleAuthor = article.author != null ? article.author : ""; |