remove hardcoded gray from headline rows layout

properly deselect active article in headlines when closing article panel
This commit is contained in:
Andrew Dolgov 2012-06-22 17:40:29 +04:00
parent fbb131fa0c
commit 16fda5c5ae
13 changed files with 33 additions and 35 deletions

View File

@ -68,7 +68,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="Jan 01, 00:00" android:text="Jan 01, 00:00"
android:textColor="#909090" android:textColor="?headlineExcerptTextColor"
android:textSize="11sp" /> android:textSize="11sp" />
<TextView <TextView

View File

@ -68,7 +68,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="Jan 01, 00:00" android:text="Jan 01, 00:00"
android:textColor="#909090" android:textColor="?headlineSelectedExcerptTextColor"
android:textSize="11sp" /> android:textSize="11sp" />
<TextView <TextView
@ -80,7 +80,7 @@
android:gravity="right" android:gravity="right"
android:singleLine="true" android:singleLine="true"
android:text="{Feed title...}" android:text="{Feed title...}"
android:textColor="?headlineExcerptTextColor" android:textColor="?headlineSelectedExcerptTextColor"
android:textSize="11sp" /> android:textSize="11sp" />
<ImageView <ImageView

View File

@ -68,7 +68,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:text="Jan 01, 00:00" android:text="Jan 01, 00:00"
android:textColor="#909090" android:textColor="?headlineExcerptTextColor"
android:textSize="11sp" /> android:textSize="11sp" />
<TextView <TextView

View File

@ -63,7 +63,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Jan 01" android:text="Jan 01"
android:textColor="#909090" android:textColor="?headlineSelectedExcerptTextColor"
android:textSize="13sp" > android:textSize="13sp" >
</TextView> </TextView>

View File

@ -64,7 +64,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Jan 01" android:text="Jan 01"
android:textColor="#909090" android:textColor="?headlineExcerptTextColor"
android:textSize="13sp" > android:textSize="13sp" >
</TextView> </TextView>

View File

@ -63,7 +63,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Jan 01" android:text="Jan 01"
android:textColor="#909090" android:textColor="?headlineSelectedExcerptTextColor"
android:textSize="13sp" > android:textSize="13sp" >
</TextView> </TextView>

View File

@ -63,7 +63,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Jan 01" android:text="Jan 01"
android:textColor="#909090" android:textColor="?headlineExcerptTextColor"
android:textSize="13sp" > android:textSize="13sp" >
</TextView> </TextView>

View File

@ -76,7 +76,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:text="Jan 01" android:text="Jan 01"
android:textColor="#909090" android:textColor="?headlineExcerptTextColor"
android:textSize="10sp" > android:textSize="10sp" >
</TextView> </TextView>

View File

@ -66,7 +66,7 @@
android:gravity="center_horizontal|right" android:gravity="center_horizontal|right"
android:singleLine="true" android:singleLine="true"
android:text="{Feed title...}" android:text="{Feed title...}"
android:textColor="?headlineExcerptTextColor" android:textColor="?headlineSelectedExcerptTextColor"
android:textSize="10sp" /> android:textSize="10sp" />
<TextView <TextView
@ -75,7 +75,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:text="Jan 01" android:text="Jan 01"
android:textColor="#909090" android:textColor="?headlineSelectedExcerptTextColor"
android:textSize="10sp" > android:textSize="10sp" >
</TextView> </TextView>

View File

@ -75,7 +75,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:text="Jan 01" android:text="Jan 01"
android:textColor="#909090" android:textColor="?headlineExcerptTextColor"
android:textSize="10sp" > android:textSize="10sp" >
</TextView> </TextView>

View File

@ -64,7 +64,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
private final String TAG = this.getClass().getSimpleName(); private final String TAG = this.getClass().getSimpleName();
private Feed m_feed; private Feed m_feed;
private int m_activeArticleId; private Article m_activeArticle;
private boolean m_refreshInProgress = false; private boolean m_refreshInProgress = false;
private boolean m_canLoadMore = false; private boolean m_canLoadMore = false;
private boolean m_combinedMode = true; private boolean m_combinedMode = true;
@ -128,7 +128,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
if (savedInstanceState != null) { if (savedInstanceState != null) {
m_feed = savedInstanceState.getParcelable("feed"); m_feed = savedInstanceState.getParcelable("feed");
m_articles = savedInstanceState.getParcelable("articles"); m_articles = savedInstanceState.getParcelable("articles");
m_activeArticleId = savedInstanceState.getInt("activeArticleId"); m_activeArticle = savedInstanceState.getParcelable("activeArticle");
m_selectedArticles = savedInstanceState.getParcelable("selectedArticles"); m_selectedArticles = savedInstanceState.getParcelable("selectedArticles");
m_canLoadMore = savedInstanceState.getBoolean("canLoadMore"); m_canLoadMore = savedInstanceState.getBoolean("canLoadMore");
m_combinedMode = savedInstanceState.getBoolean("combinedMode"); m_combinedMode = savedInstanceState.getBoolean("combinedMode");
@ -183,7 +183,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
m_onlineServices.openArticle(article, 0); m_onlineServices.openArticle(article, 0);
} }
m_activeArticleId = article.id; m_activeArticle = article;
m_adapter.notifyDataSetChanged(); m_adapter.notifyDataSetChanged();
} }
} }
@ -245,7 +245,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
out.putParcelable("feed", m_feed); out.putParcelable("feed", m_feed);
out.putParcelable("articles", m_articles); out.putParcelable("articles", m_articles);
out.putInt("activeArticleId", m_activeArticleId); out.putParcelable("activeArticle", m_activeArticle);
out.putParcelable("selectedArticles", m_selectedArticles); out.putParcelable("selectedArticles", m_selectedArticles);
out.putBoolean("canLoadMore", m_canLoadMore); out.putBoolean("canLoadMore", m_canLoadMore);
out.putBoolean("combinedMode", m_combinedMode); out.putBoolean("combinedMode", m_combinedMode);
@ -355,7 +355,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
if (a.id == -1) { if (a.id == -1) {
return VIEW_LOADMORE; return VIEW_LOADMORE;
} else if (a.id == m_activeArticleId) { } else if (m_activeArticle != null && a.id == m_activeArticle.id) {
return VIEW_SELECTED; return VIEW_SELECTED;
} else if (a.unread) { } else if (a.unread) {
return VIEW_UNREAD; return VIEW_UNREAD;
@ -606,23 +606,22 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
m_adapter.notifyDataSetChanged(); m_adapter.notifyDataSetChanged();
Article article = m_onlineServices.getSelectedArticle(); Article article = m_onlineServices.getSelectedArticle();
if (article != null) {
setActiveArticleId(article.id); setActiveArticle(article);
}
} }
public ArticleList getAllArticles() { public ArticleList getAllArticles() {
return m_articles; return m_articles;
} }
public void setActiveArticleId(int id) { public void setActiveArticle(Article article) {
m_activeArticleId = id; m_activeArticle = article;
m_adapter.notifyDataSetChanged(); m_adapter.notifyDataSetChanged();
ListView list = (ListView)getView().findViewById(R.id.headlines); ListView list = (ListView)getView().findViewById(R.id.headlines);
if (list != null) { if (list != null && article != null) {
int position = m_adapter.getPosition(getArticleById(id)); int position = m_adapter.getPosition(article);
list.setSelection(position); list.setSelection(position);
} }
} }
@ -677,8 +676,8 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
// no-op // no-op
} }
public int getActiveArticleId() { public Article getActiveArticle() {
return m_activeArticleId; return m_activeArticle;
} }
public int getArticlePosition(Article article) { public int getArticlePosition(Article article) {

View File

@ -1300,9 +1300,11 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE); findViewById(R.id.feeds_fragment).setVisibility(View.VISIBLE);
findViewById(R.id.article_fragment).setVisibility(View.GONE); findViewById(R.id.article_fragment).setVisibility(View.GONE);
ft.replace(R.id.article_fragment, new DummyFragment(), FRAG_ARTICLE); ft.replace(R.id.article_fragment, new DummyFragment(), FRAG_ARTICLE);
updateHeadlines();
} }
ft.commit(); ft.commit();
initMainMenu(); initMainMenu();
} }
@ -1717,7 +1719,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
.findFragmentByTag(FRAG_HEADLINES); .findFragmentByTag(FRAG_HEADLINES);
if (hf != null) { if (hf != null) {
hf.setActiveArticleId(article.id); hf.setActiveArticle(article);
} }
Fragment frag; Fragment frag;
@ -2044,13 +2046,13 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
.findFragmentByTag(FRAG_HEADLINES); .findFragmentByTag(FRAG_HEADLINES);
if (hf != null && m_activeFeed != null) { if (hf != null && m_activeFeed != null) {
Article base = hf.getArticleById(hf.getActiveArticleId()); Article base = hf.getActiveArticle();
Article next = base != null ? getRelativeArticle(base, Article next = base != null ? getRelativeArticle(base,
RelativeArticle.AFTER) : hf.getArticleAtPosition(0); RelativeArticle.AFTER) : hf.getArticleAtPosition(0);
if (next != null) { if (next != null) {
hf.setActiveArticleId(next.id); hf.setActiveArticle(next);
boolean combinedMode = m_prefs.getBoolean( boolean combinedMode = m_prefs.getBoolean(
"combined_mode", false); "combined_mode", false);
@ -2071,14 +2073,14 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
.findFragmentByTag(FRAG_HEADLINES); .findFragmentByTag(FRAG_HEADLINES);
if (hf != null && m_activeFeed != null) { if (hf != null && m_activeFeed != null) {
Article base = hf.getArticleById(hf.getActiveArticleId()); Article base = hf.getActiveArticle();
Article prev = base != null ? getRelativeArticle(base, Article prev = base != null ? getRelativeArticle(base,
RelativeArticle.BEFORE) : hf RelativeArticle.BEFORE) : hf
.getArticleAtPosition(0); .getArticleAtPosition(0);
if (prev != null) { if (prev != null) {
hf.setActiveArticleId(prev.id); hf.setActiveArticle(prev);
boolean combinedMode = m_prefs.getBoolean( boolean combinedMode = m_prefs.getBoolean(
"combined_mode", false); "combined_mode", false);

View File

@ -11,7 +11,6 @@ public interface OnlineServices {
public void saveArticleUnread(final Article article); public void saveArticleUnread(final Article article);
public void saveArticleMarked(final Article article); public void saveArticleMarked(final Article article);
public void saveArticlePublished(final Article article); public void saveArticlePublished(final Article article);
public void updateHeadlines();
public void openArticle(Article article, int compatAnimation); public void openArticle(Article article, int compatAnimation);
public Article getRelativeArticle(Article article, RelativeArticle ra); public Article getRelativeArticle(Article article, RelativeArticle ra);
@ -20,8 +19,6 @@ public interface OnlineServices {
public void initMainMenu(); public void initMainMenu();
public void login(); public void login();
//public Feed getActiveFeed();
//public FeedCategory getActiveCategory();
public String getSessionId(); public String getSessionId();
public boolean getUnreadArticlesOnly(); public boolean getUnreadArticlesOnly();
public boolean isSmallScreen(); public boolean isSmallScreen();