use actionbar better in online mode, menu cleanup

This commit is contained in:
Andrew Dolgov 2011-12-07 08:14:13 +03:00
parent 8fa8debdca
commit 160115b84c
2 changed files with 31 additions and 34 deletions

View File

@ -40,7 +40,7 @@
<item <item
android:id="@+id/go_offline" android:id="@+id/go_offline"
android:icon="@drawable/ic_menu_cloud" android:icon="@drawable/ic_menu_cloud"
android:showAsAction="ifRoom|withText"
android:title="@string/go_offline"/> android:title="@string/go_offline"/>
<item <item
@ -52,6 +52,7 @@
<item <item
android:id="@+id/headlines_select" android:id="@+id/headlines_select"
android:icon="@drawable/ic_menu_database" android:icon="@drawable/ic_menu_database"
android:showAsAction="ifRoom"
android:title="@string/headlines_select"/> android:title="@string/headlines_select"/>
</group> </group>
@ -59,20 +60,20 @@
<item <item
android:id="@+id/selection_toggle_unread" android:id="@+id/selection_toggle_unread"
android:icon="@android:drawable/ic_menu_rotate" android:icon="@android:drawable/ic_menu_recent_history"
android:showAsAction="" android:showAsAction=""
android:title="@string/selection_toggle_unread"/> android:title="@string/selection_toggle_unread"/>
<item <item
android:id="@+id/selection_toggle_marked" android:id="@+id/selection_toggle_marked"
android:icon="@drawable/ic_menu_marked" android:icon="@drawable/ic_menu_marked"
android:showAsAction="" android:showAsAction="ifRoom"
android:title="@string/selection_toggle_marked"/> android:title="@string/selection_toggle_marked"/>
<item <item
android:id="@+id/selection_toggle_published" android:id="@+id/selection_toggle_published"
android:icon="@drawable/ic_menu_rss" android:icon="@drawable/ic_menu_rss"
android:showAsAction="" android:showAsAction="ifRoom"
android:title="@string/selection_toggle_published"/> android:title="@string/selection_toggle_published"/>
<item <item
@ -93,13 +94,13 @@
<item <item
android:id="@+id/toggle_marked" android:id="@+id/toggle_marked"
android:icon="@drawable/ic_menu_marked" android:icon="@drawable/ic_menu_marked"
android:showAsAction="" android:showAsAction="ifRoom"
android:title="@string/article_toggle_marked"/> android:title="@string/article_toggle_marked"/>
<item <item
android:id="@+id/toggle_published" android:id="@+id/toggle_published"
android:icon="@drawable/ic_menu_rss" android:icon="@drawable/ic_menu_rss"
android:showAsAction="" android:showAsAction="ifRoom"
android:title="@string/article_toggle_published"/> android:title="@string/article_toggle_published"/>
<item <item

View File

@ -824,6 +824,7 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
ArticleList selected = hf.getSelectedArticles(); ArticleList selected = hf.getSelectedArticles();
if (selected.size() > 0) { if (selected.size() > 0) {
selected.clear(); selected.clear();
initMainMenu();
hf.notifyUpdated(); hf.notifyUpdated();
} }
} }
@ -970,62 +971,55 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
public void initMainMenu() { public void initMainMenu() {
if (m_menu != null) { if (m_menu != null) {
if (m_sessionId != null) { if (m_sessionId != null) {
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment);
int numSelected = 0;
if (hf != null)
numSelected = hf.getSelectedArticles().size();
m_menu.setGroupVisible(R.id.menu_group_logged_in, true); m_menu.setGroupVisible(R.id.menu_group_logged_in, true);
m_menu.setGroupVisible(R.id.menu_group_logged_out, false); m_menu.setGroupVisible(R.id.menu_group_logged_out, false);
if (m_activeFeed != null) { if (m_activeFeed == null) {
//m_menu.findItem(R.id.load_more_articles).setVisible(m_canLoadMore);
//m_menu.findItem(R.id.show_all_articles).setVisible(true);
} else {
m_menu.setGroupVisible(R.id.menu_group_headlines, false); m_menu.setGroupVisible(R.id.menu_group_headlines, false);
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false); m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false);
} }
if (m_selectedArticle != null) { if (m_selectedArticle != null && numSelected == 0) {
m_menu.setGroupVisible(R.id.menu_group_article, true); m_menu.setGroupVisible(R.id.menu_group_article, true);
m_menu.setGroupVisible(R.id.menu_group_feeds, false); m_menu.setGroupVisible(R.id.menu_group_feeds, false);
if (m_smallScreenMode) { //if (m_smallScreenMode) {
m_menu.setGroupVisible(R.id.menu_group_headlines, false); m_menu.setGroupVisible(R.id.menu_group_headlines, false);
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false); m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false);
} else { //} else {
m_menu.setGroupVisible(R.id.menu_group_headlines, true); // m_menu.setGroupVisible(R.id.menu_group_headlines, true);
} //}
} else { } else {
m_menu.setGroupVisible(R.id.menu_group_article, false); m_menu.setGroupVisible(R.id.menu_group_article, false);
if (m_activeFeed != null) { if (m_activeFeed != null) {
HeadlinesFragment hf = (HeadlinesFragment)getSupportFragmentManager().findFragmentById(R.id.headlines_fragment); if (numSelected != 0) {
m_menu.setGroupVisible(R.id.menu_group_headlines, false);
if (hf != null) { m_menu.setGroupVisible(R.id.menu_group_headlines_selection, true);
int numSelected = hf.getSelectedArticles().size();
if (numSelected != 0) {
m_menu.setGroupVisible(R.id.menu_group_headlines, false);
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, true);
} else {
m_menu.setGroupVisible(R.id.menu_group_headlines, true);
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false);
}
} else { } else {
m_menu.setGroupVisible(R.id.menu_group_headlines, true); m_menu.setGroupVisible(R.id.menu_group_headlines, true);
m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false); m_menu.setGroupVisible(R.id.menu_group_headlines_selection, false);
} }
m_menu.setGroupVisible(R.id.menu_group_feeds, false); m_menu.setGroupVisible(R.id.menu_group_feeds, false);
} else { } else {
m_menu.setGroupVisible(R.id.menu_group_feeds, true); m_menu.setGroupVisible(R.id.menu_group_feeds, true);
} }
if (!m_smallScreenMode || m_activeFeed == null) { /* if (!m_smallScreenMode || m_activeFeed == null) {
m_menu.findItem(R.id.show_feeds).setVisible(true); m_menu.findItem(R.id.show_feeds).setVisible(true);
m_menu.findItem(R.id.update_feeds).setVisible(true); m_menu.findItem(R.id.update_feeds).setVisible(true);
} } */
m_menu.findItem(R.id.back_to_categories).setVisible(m_activeCategory != null); m_menu.findItem(R.id.back_to_categories).setVisible(m_activeCategory != null);
} }
@ -1804,8 +1798,8 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
@Override @Override
public void onTabReselected(Tab tab, public void onTabReselected(Tab tab,
android.app.FragmentTransaction _ft) { android.app.FragmentTransaction _ft) {
// TODO Auto-generated method stub
closeArticle();
} }
@Override @Override
@ -1829,7 +1823,9 @@ public class MainActivity extends FragmentActivity implements OnlineServices {
@Override @Override
public void onTabUnselected(Tab tab, public void onTabUnselected(Tab tab,
android.app.FragmentTransaction _ft) { android.app.FragmentTransaction _ft) {
closeArticle();
findViewById(R.id.feeds_fragment).setVisibility(View.GONE); findViewById(R.id.feeds_fragment).setVisibility(View.GONE);
findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE); findViewById(R.id.cats_fragment).setVisibility(View.VISIBLE);