From 1fec72cf4ae441e6fd87d981412752abdd163690 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 30 Nov 2011 16:05:03 +0300 Subject: [PATCH] implement combined article display mode (closes #399) --- res/layout-port/headlines_row.xml | 7 + res/layout-port/headlines_row_selected.xml | 7 + res/layout-port/headlines_row_unread.xml | 7 + res/layout-xlarge/headlines_row.xml | 136 ++++++++++++----- res/layout-xlarge/headlines_row_selected.xml | 146 ++++++++++--------- res/layout-xlarge/headlines_row_unread.xml | 136 ++++++++++++----- res/layout/headlines_row.xml | 136 ++++++++++++----- res/layout/headlines_row_selected.xml | 146 ++++++++++--------- res/layout/headlines_row_unread.xml | 136 ++++++++++++----- res/values/strings.xml | 3 +- res/xml/preferences.xml | 1 + src/org/fox/ttrss/ArticleFragment.java | 2 - src/org/fox/ttrss/HeadlinesFragment.java | 65 +++++++-- 13 files changed, 635 insertions(+), 293 deletions(-) diff --git a/res/layout-port/headlines_row.xml b/res/layout-port/headlines_row.xml index 772184dd..a2c72d8d 100644 --- a/res/layout-port/headlines_row.xml +++ b/res/layout-port/headlines_row.xml @@ -32,6 +32,13 @@ android:textSize="16sp" > + + + + + + + + + - - - - - - - - - + + + + + + + android:layout_height="match_parent" + android:background="?headlineSeparatorNormal" + android:paddingRight="4dip" /> - - + + - - + + + + + + + + + + + + + + + + + + + + + + - - + + + + \ No newline at end of file diff --git a/res/layout-xlarge/headlines_row_selected.xml b/res/layout-xlarge/headlines_row_selected.xml index fa7e7ad0..a8d8d8bd 100644 --- a/res/layout-xlarge/headlines_row_selected.xml +++ b/res/layout-xlarge/headlines_row_selected.xml @@ -4,92 +4,106 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="?headlineSelectedBackground" - android:gravity="center_vertical" - android:orientation="horizontal" > - - - - - - + android:orientation="vertical" > + android:gravity="center_vertical" + android:orientation="horizontal" > - - + android:background="?headlineSeparatorSelected" + android:paddingRight="4dip" /> - - - - - - - - + android:focusable="false" + android:paddingLeft="6dip" + android:paddingRight="6dip" > + + + + + + + + + + + android:orientation="vertical" + android:padding="3dip" > - - + android:text="Jan 01" + android:textColor="#909090" + android:textSize="13sp" > + - - + android:gravity="center" + android:paddingRight="2sp" > + + + + + + + + + + \ No newline at end of file diff --git a/res/layout-xlarge/headlines_row_unread.xml b/res/layout-xlarge/headlines_row_unread.xml index e0aa00cf..65f4a5f4 100644 --- a/res/layout-xlarge/headlines_row_unread.xml +++ b/res/layout-xlarge/headlines_row_unread.xml @@ -1,47 +1,109 @@ - - - - - - - - - - - + + + + + android:layout_height="match_parent" + android:background="?headlineSeparatorUnread" + android:paddingRight="4dip" /> - - + + - - + + + + + + + + + + + + + + + + + + + + + + - - + + + + \ No newline at end of file diff --git a/res/layout/headlines_row.xml b/res/layout/headlines_row.xml index 4b66b747..8b51030d 100644 --- a/res/layout/headlines_row.xml +++ b/res/layout/headlines_row.xml @@ -1,45 +1,111 @@ - - - - - - - - - + + + + + + + android:layout_height="match_parent" + android:background="?headlineSeparatorNormal" + android:paddingRight="4dip" /> - - + + - - + + + + + + + + + + + + + + + + + + + + + + - - + + + + \ No newline at end of file diff --git a/res/layout/headlines_row_selected.xml b/res/layout/headlines_row_selected.xml index fa7e7ad0..a8d8d8bd 100644 --- a/res/layout/headlines_row_selected.xml +++ b/res/layout/headlines_row_selected.xml @@ -4,92 +4,106 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="?headlineSelectedBackground" - android:gravity="center_vertical" - android:orientation="horizontal" > - - - - - - + android:orientation="vertical" > + android:gravity="center_vertical" + android:orientation="horizontal" > - - + android:background="?headlineSeparatorSelected" + android:paddingRight="4dip" /> - - - - - - - - + android:focusable="false" + android:paddingLeft="6dip" + android:paddingRight="6dip" > + + + + + + + + + + + android:orientation="vertical" + android:padding="3dip" > - - + android:text="Jan 01" + android:textColor="#909090" + android:textSize="13sp" > + - - + android:gravity="center" + android:paddingRight="2sp" > + + + + + + + + + + \ No newline at end of file diff --git a/res/layout/headlines_row_unread.xml b/res/layout/headlines_row_unread.xml index e0aa00cf..65f4a5f4 100644 --- a/res/layout/headlines_row_unread.xml +++ b/res/layout/headlines_row_unread.xml @@ -1,47 +1,109 @@ - - - - - - - - - - - + + + + + android:layout_height="match_parent" + android:background="?headlineSeparatorUnread" + android:paddingRight="4dip" /> - - + + - - + + + + + + + + + + + + + + + + + + + + + + - - + + + + \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 82793a07..05e19f29 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -85,5 +85,6 @@ Error: API disabled for this user Error: unknown API error (see log) Error: username or password incorrect - + Displays articles inline, instead of a separate panel + Combined mode \ No newline at end of file diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml index 6c397f24..a4c24982 100644 --- a/res/xml/preferences.xml +++ b/res/xml/preferences.xml @@ -29,6 +29,7 @@ + diff --git a/src/org/fox/ttrss/ArticleFragment.java b/src/org/fox/ttrss/ArticleFragment.java index 636d47db..6a93967e 100644 --- a/src/org/fox/ttrss/ArticleFragment.java +++ b/src/org/fox/ttrss/ArticleFragment.java @@ -99,8 +99,6 @@ public class ArticleFragment extends Fragment implements OnClickListener { if (web != null) { - // this is ridiculous - // TODO white on black style for dark theme String content; String cssOverride = ""; diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index 243ee3cc..b1522fff 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -13,7 +13,10 @@ import org.jsoup.Jsoup; import android.app.Activity; import android.content.Context; +import android.content.SharedPreferences; +import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.v4.app.Fragment; import android.text.Html; import android.util.Log; @@ -23,6 +26,7 @@ import android.view.View; import android.view.ContextMenu.ContextMenuInfo; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.webkit.WebView; import android.widget.AbsListView; import android.widget.AbsListView.OnScrollListener; import android.widget.AdapterView; @@ -51,6 +55,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, private int m_activeArticleId; private boolean m_refreshInProgress = false; private boolean m_canLoadMore = false; + private boolean m_combinedMode = true; + + private SharedPreferences m_prefs; private ArticleListAdapter m_adapter; private ArticleList m_articles = new ArticleList(); @@ -88,7 +95,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, m_articles = savedInstanceState.getParcelable("articles"); m_activeArticleId = savedInstanceState.getInt("activeArticleId"); m_selectedArticles = savedInstanceState.getParcelable("selectedArticles"); - m_canLoadMore = savedInstanceState.getBoolean("canLoadMore"); + m_canLoadMore = savedInstanceState.getBoolean("canLoadMore"); + m_combinedMode = savedInstanceState.getBoolean("combinedMode"); } View view = inflater.inflate(R.layout.headlines_fragment, container, false); @@ -114,7 +122,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, public void onAttach(Activity activity) { super.onAttach(activity); m_feed = ((MainActivity)activity).getActiveFeed(); + m_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext()); m_articleOps = (ArticleOps) activity; + m_combinedMode = m_prefs.getBoolean("combined_mode", false); } @Override @@ -184,6 +194,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, out.putInt("activeArticleId", m_activeArticleId); out.putParcelable("selectedArticles", m_selectedArticles); out.putBoolean("canLoadMore", m_canLoadMore); + out.putBoolean("combinedMode", m_combinedMode); } public void setLoadingStatus(int status, boolean showProgress) { @@ -225,8 +236,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, else m_articles.remove(m_articles.size()-1); // remove previous placeholder - int last_position = m_articles.size(); - for (Article f : articles) m_articles.add(f); @@ -241,12 +250,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, m_adapter.notifyDataSetChanged(); - /* ListView list = (ListView)getView().findViewById(R.id.headlines); - - if (list != null && m_offset != 0 && articles.size() > 0) { - list.setSelection(last_position-1); - } */ - if (m_articles.size() == 0) setLoadingStatus(R.string.no_headlines_to_display, false); else @@ -379,14 +382,48 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, TextView te = (TextView)v.findViewById(R.id.excerpt); if (te != null) { - String excerpt = Jsoup.parse(article.content).text(); + if (!m_combinedMode) { + String excerpt = Jsoup.parse(article.content).text(); - if (excerpt.length() > 100) - excerpt = excerpt.substring(0, 100) + "..."; + if (excerpt.length() > 100) + excerpt = excerpt.substring(0, 100) + "..."; - te.setText(excerpt); + te.setText(excerpt); + } else { + te.setVisibility(View.GONE); + } } + WebView web = (WebView)v.findViewById(R.id.content); + + if (web != null) { + if (m_combinedMode) { + String content; + String cssOverride = ""; + + if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) { + web.setBackgroundColor(android.R.color.black); + cssOverride = "body { background : black; color : #f0f0f0}\n"; + } + + content = + "" + + "" + + "" + + "" + + "" + + "" + article.content + ""; + + web.loadDataWithBaseURL(null, content, "text/html", "utf-8", null); + } else { + web.setVisibility(View.GONE); + } + } + TextView dv = (TextView) v.findViewById(R.id.date); if (dv != null) { @@ -481,7 +518,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, @Override public void onScrollStateChanged(AbsListView view, int scrollState) { - // TODO Auto-generated method stub + // no-op } }