From 16fda5c5ae839c51debb882f4d3c24d276393f3b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 22 Jun 2012 17:40:29 +0400 Subject: [PATCH] remove hardcoded gray from headline rows layout properly deselect active article in headlines when closing article panel --- res/layout-port/headlines_row.xml | 2 +- res/layout-port/headlines_row_selected.xml | 4 +-- res/layout-port/headlines_row_unread.xml | 2 +- .../headlines_row_selected.xml | 2 +- res/layout-xlarge/headlines_row.xml | 2 +- res/layout-xlarge/headlines_row_selected.xml | 2 +- res/layout-xlarge/headlines_row_unread.xml | 2 +- res/layout/headlines_row.xml | 2 +- res/layout/headlines_row_selected.xml | 4 +-- res/layout/headlines_row_unread.xml | 2 +- src/org/fox/ttrss/HeadlinesFragment.java | 27 +++++++++---------- src/org/fox/ttrss/MainActivity.java | 14 +++++----- src/org/fox/ttrss/OnlineServices.java | 3 --- 13 files changed, 33 insertions(+), 35 deletions(-) diff --git a/res/layout-port/headlines_row.xml b/res/layout-port/headlines_row.xml index 85710827..106c659e 100644 --- a/res/layout-port/headlines_row.xml +++ b/res/layout-port/headlines_row.xml @@ -68,7 +68,7 @@ android:layout_height="wrap_content" android:layout_weight="1" android:text="Jan 01, 00:00" - android:textColor="#909090" + android:textColor="?headlineExcerptTextColor" android:textSize="11sp" /> diff --git a/res/layout-xlarge/headlines_row.xml b/res/layout-xlarge/headlines_row.xml index 9a311ef9..6b46d81d 100644 --- a/res/layout-xlarge/headlines_row.xml +++ b/res/layout-xlarge/headlines_row.xml @@ -64,7 +64,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Jan 01" - android:textColor="#909090" + android:textColor="?headlineExcerptTextColor" android:textSize="13sp" > diff --git a/res/layout-xlarge/headlines_row_selected.xml b/res/layout-xlarge/headlines_row_selected.xml index 80dfaac2..66343703 100644 --- a/res/layout-xlarge/headlines_row_selected.xml +++ b/res/layout-xlarge/headlines_row_selected.xml @@ -63,7 +63,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Jan 01" - android:textColor="#909090" + android:textColor="?headlineSelectedExcerptTextColor" android:textSize="13sp" > diff --git a/res/layout-xlarge/headlines_row_unread.xml b/res/layout-xlarge/headlines_row_unread.xml index 23f648a2..3e66e6ed 100644 --- a/res/layout-xlarge/headlines_row_unread.xml +++ b/res/layout-xlarge/headlines_row_unread.xml @@ -63,7 +63,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Jan 01" - android:textColor="#909090" + android:textColor="?headlineExcerptTextColor" android:textSize="13sp" > diff --git a/res/layout/headlines_row.xml b/res/layout/headlines_row.xml index b338d3a3..b028eeb0 100644 --- a/res/layout/headlines_row.xml +++ b/res/layout/headlines_row.xml @@ -76,7 +76,7 @@ android:layout_height="wrap_content" android:gravity="center_horizontal" android:text="Jan 01" - android:textColor="#909090" + android:textColor="?headlineExcerptTextColor" android:textSize="10sp" > diff --git a/res/layout/headlines_row_selected.xml b/res/layout/headlines_row_selected.xml index 4edae560..e18f866e 100644 --- a/res/layout/headlines_row_selected.xml +++ b/res/layout/headlines_row_selected.xml @@ -66,7 +66,7 @@ android:gravity="center_horizontal|right" android:singleLine="true" android:text="{Feed title...}" - android:textColor="?headlineExcerptTextColor" + android:textColor="?headlineSelectedExcerptTextColor" android:textSize="10sp" /> diff --git a/res/layout/headlines_row_unread.xml b/res/layout/headlines_row_unread.xml index 36cb4706..33d50dfa 100644 --- a/res/layout/headlines_row_unread.xml +++ b/res/layout/headlines_row_unread.xml @@ -75,7 +75,7 @@ android:layout_height="wrap_content" android:gravity="center_horizontal" android:text="Jan 01" - android:textColor="#909090" + android:textColor="?headlineExcerptTextColor" android:textSize="10sp" > diff --git a/src/org/fox/ttrss/HeadlinesFragment.java b/src/org/fox/ttrss/HeadlinesFragment.java index 64254e4f..0e3ace31 100644 --- a/src/org/fox/ttrss/HeadlinesFragment.java +++ b/src/org/fox/ttrss/HeadlinesFragment.java @@ -64,7 +64,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, private final String TAG = this.getClass().getSimpleName(); private Feed m_feed; - private int m_activeArticleId; + private Article m_activeArticle; private boolean m_refreshInProgress = false; private boolean m_canLoadMore = false; private boolean m_combinedMode = true; @@ -128,7 +128,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, if (savedInstanceState != null) { m_feed = savedInstanceState.getParcelable("feed"); m_articles = savedInstanceState.getParcelable("articles"); - m_activeArticleId = savedInstanceState.getInt("activeArticleId"); + m_activeArticle = savedInstanceState.getParcelable("activeArticle"); m_selectedArticles = savedInstanceState.getParcelable("selectedArticles"); m_canLoadMore = savedInstanceState.getBoolean("canLoadMore"); m_combinedMode = savedInstanceState.getBoolean("combinedMode"); @@ -183,7 +183,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, m_onlineServices.openArticle(article, 0); } - m_activeArticleId = article.id; + m_activeArticle = article; m_adapter.notifyDataSetChanged(); } } @@ -245,7 +245,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, out.putParcelable("feed", m_feed); out.putParcelable("articles", m_articles); - out.putInt("activeArticleId", m_activeArticleId); + out.putParcelable("activeArticle", m_activeArticle); out.putParcelable("selectedArticles", m_selectedArticles); out.putBoolean("canLoadMore", m_canLoadMore); out.putBoolean("combinedMode", m_combinedMode); @@ -355,7 +355,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, if (a.id == -1) { return VIEW_LOADMORE; - } else if (a.id == m_activeArticleId) { + } else if (m_activeArticle != null && a.id == m_activeArticle.id) { return VIEW_SELECTED; } else if (a.unread) { return VIEW_UNREAD; @@ -606,23 +606,22 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, m_adapter.notifyDataSetChanged(); Article article = m_onlineServices.getSelectedArticle(); - if (article != null) { - setActiveArticleId(article.id); - } + + setActiveArticle(article); } public ArticleList getAllArticles() { return m_articles; } - public void setActiveArticleId(int id) { - m_activeArticleId = id; + public void setActiveArticle(Article article) { + m_activeArticle = article; m_adapter.notifyDataSetChanged(); ListView list = (ListView)getView().findViewById(R.id.headlines); - if (list != null) { - int position = m_adapter.getPosition(getArticleById(id)); + if (list != null && article != null) { + int position = m_adapter.getPosition(article); list.setSelection(position); } } @@ -677,8 +676,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, // no-op } - public int getActiveArticleId() { - return m_activeArticleId; + public Article getActiveArticle() { + return m_activeArticle; } public int getArticlePosition(Article article) { diff --git a/src/org/fox/ttrss/MainActivity.java b/src/org/fox/ttrss/MainActivity.java index e8b8adc4..070a4e59 100644 --- a/src/org/fox/ttrss/MainActivity.java +++ b/src/org/fox/ttrss/MainActivity.java @@ -1300,9 +1300,11 @@ public class MainActivity extends FragmentActivity implements OnlineServices { findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE); findViewById(R.id.article_fragment).setVisibility(View.GONE); ft.replace(R.id.article_fragment, new DummyFragment(), FRAG_ARTICLE); + + updateHeadlines(); } ft.commit(); - + initMainMenu(); } @@ -1717,7 +1719,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices { .findFragmentByTag(FRAG_HEADLINES); if (hf != null) { - hf.setActiveArticleId(article.id); + hf.setActiveArticle(article); } Fragment frag; @@ -2044,13 +2046,13 @@ public class MainActivity extends FragmentActivity implements OnlineServices { .findFragmentByTag(FRAG_HEADLINES); if (hf != null && m_activeFeed != null) { - Article base = hf.getArticleById(hf.getActiveArticleId()); + Article base = hf.getActiveArticle(); Article next = base != null ? getRelativeArticle(base, RelativeArticle.AFTER) : hf.getArticleAtPosition(0); if (next != null) { - hf.setActiveArticleId(next.id); + hf.setActiveArticle(next); boolean combinedMode = m_prefs.getBoolean( "combined_mode", false); @@ -2071,14 +2073,14 @@ public class MainActivity extends FragmentActivity implements OnlineServices { .findFragmentByTag(FRAG_HEADLINES); if (hf != null && m_activeFeed != null) { - Article base = hf.getArticleById(hf.getActiveArticleId()); + Article base = hf.getActiveArticle(); Article prev = base != null ? getRelativeArticle(base, RelativeArticle.BEFORE) : hf .getArticleAtPosition(0); if (prev != null) { - hf.setActiveArticleId(prev.id); + hf.setActiveArticle(prev); boolean combinedMode = m_prefs.getBoolean( "combined_mode", false); diff --git a/src/org/fox/ttrss/OnlineServices.java b/src/org/fox/ttrss/OnlineServices.java index 8040e871..3f019e63 100644 --- a/src/org/fox/ttrss/OnlineServices.java +++ b/src/org/fox/ttrss/OnlineServices.java @@ -11,7 +11,6 @@ public interface OnlineServices { public void saveArticleUnread(final Article article); public void saveArticleMarked(final Article article); public void saveArticlePublished(final Article article); - public void updateHeadlines(); public void openArticle(Article article, int compatAnimation); public Article getRelativeArticle(Article article, RelativeArticle ra); @@ -20,8 +19,6 @@ public interface OnlineServices { public void initMainMenu(); public void login(); - //public Feed getActiveFeed(); - //public FeedCategory getActiveCategory(); public String getSessionId(); public boolean getUnreadArticlesOnly(); public boolean isSmallScreen();