cleanup menu a bit

This commit is contained in:
Andrew Dolgov 2011-11-29 09:46:36 +03:00
parent 48b0594c0c
commit 97ecce1d42
2 changed files with 137 additions and 66 deletions

View File

@ -1,70 +1,95 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/preferences"
android:icon="@android:drawable/ic_menu_preferences"
android:title="@string/preferences"
android:showAsAction=""/>
<item android:id="@+id/login"
android:icon="@android:drawable/ic_menu_rotate"
android:title="@string/login"
android:showAsAction="ifRoom|withText"/>
<item
android:id="@+id/preferences"
android:icon="@android:drawable/ic_menu_preferences"
android:showAsAction=""
android:title="@string/preferences"/>
<item android:id="@+id/show_feeds"
android:icon="@android:drawable/ic_menu_agenda"
android:title="@string/menu_all_feeds"
android:showAsAction=""/>
<item android:id="@+id/back_to_categories"
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:title="@string/back_to_categories"
android:showAsAction="ifRoom|withText"/>
<item android:id="@+id/close_article"
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:title="@string/close_article"
android:showAsAction="ifRoom|withText"/>
<group android:id="@+id/menu_group_logged_in" >
<item android:id="@+id/load_more_articles"
android:icon="@android:drawable/ic_menu_more"
android:title="@string/load_more_articles"
android:showAsAction="ifRoom|withText"/>
<item android:id="@+id/show_all_articles"
android:icon="@android:drawable/ic_menu_agenda"
android:title="@string/show_all_articles"
android:showAsAction=""/>
<item android:id="@+id/update_feeds"
android:icon="@android:drawable/ic_menu_rotate"
android:title="@string/update_feeds"
android:showAsAction=""/>
<group android:id="@+id/menu_group_feeds" >
<item android:id="@+id/share_article"
android:icon="@android:drawable/ic_menu_share"
android:title="@string/share_article"
android:showAsAction="ifRoom"/>
<item android:id="@+id/toggle_marked"
android:icon="@android:drawable/star_off"
android:title="@string/toggle_marked"
android:showAsAction=""/>
<item
android:id="@+id/back_to_categories"
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:showAsAction="ifRoom|withText"
android:title="@string/back_to_categories"/>
<item android:id="@+id/toggle_published"
android:icon="@drawable/ic_menu_rss"
android:title="@string/toggle_published"
android:showAsAction=""/>
<item
android:id="@+id/show_feeds"
android:icon="@android:drawable/ic_menu_agenda"
android:showAsAction=""
android:title="@string/menu_all_feeds"/>
<item android:id="@+id/set_unread"
android:icon="@android:drawable/ic_menu_recent_history"
android:title="@string/set_unread"
android:showAsAction=""/>
<item android:id="@+id/logout"
android:title="@string/logout"
android:showAsAction=""/>
</menu>
<item
android:id="@+id/update_feeds"
android:icon="@android:drawable/ic_menu_rotate"
android:showAsAction=""
android:title="@string/update_feeds"/>
</group>
<group android:id="@+id/menu_group_headlines" >
<item
android:id="@+id/load_more_articles"
android:icon="@android:drawable/ic_menu_more"
android:showAsAction="ifRoom|withText"
android:title="@string/load_more_articles"/>
<item
android:id="@+id/show_all_articles"
android:icon="@android:drawable/ic_menu_agenda"
android:showAsAction=""
android:title="@string/show_all_articles"/>
</group>
<group android:id="@+id/menu_group_article" >
<item
android:id="@+id/close_article"
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:showAsAction="ifRoom|withText"
android:title="@string/close_article"/>
<item
android:id="@+id/toggle_marked"
android:icon="@android:drawable/star_off"
android:showAsAction=""
android:title="@string/toggle_marked"/>
<item
android:id="@+id/share_article"
android:icon="@android:drawable/ic_menu_share"
android:showAsAction="ifRoom"
android:title="@string/share_article"/>
<item
android:id="@+id/toggle_published"
android:icon="@drawable/ic_menu_rss"
android:showAsAction=""
android:title="@string/toggle_published"/>
<item
android:id="@+id/set_unread"
android:icon="@android:drawable/ic_menu_recent_history"
android:showAsAction=""
android:title="@string/set_unread"/>
</group>
<item
android:id="@+id/logout"
android:showAsAction=""
android:title="@string/logout"/>
</group>
<group android:id="@+id/menu_group_logged_out" >
<item
android:id="@+id/login"
android:icon="@android:drawable/ic_menu_rotate"
android:showAsAction="ifRoom|withText"
android:title="@string/login"/>
</group>
</menu>

View File

@ -542,8 +542,54 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
public void initMainMenu() {
if (m_menu != null) {
if (m_sessionId != null) {
m_menu.setGroupVisible(R.id.menu_group_logged_in, true);
m_menu.setGroupVisible(R.id.menu_group_logged_out, false);
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);
}
if (m_selectedArticle != null) {
m_menu.setGroupVisible(R.id.menu_group_article, true);
m_menu.findItem(R.id.update_feeds).setVisible(false);
m_menu.findItem(R.id.show_feeds).setVisible(false);
m_menu.findItem(R.id.back_to_categories).setVisible(false);
if (m_smallScreenMode) {
m_menu.setGroupVisible(R.id.menu_group_headlines, false);
} else {
m_menu.setGroupVisible(R.id.menu_group_headlines, true);
}
} else {
m_menu.setGroupVisible(R.id.menu_group_article, false);
if (!m_smallScreenMode || m_activeFeed == null) {
m_menu.findItem(R.id.show_feeds).setVisible(true);
m_menu.findItem(R.id.update_feeds).setVisible(true);
} else {
m_menu.findItem(R.id.show_feeds).setVisible(false);
m_menu.findItem(R.id.update_feeds).setVisible(false);
}
m_menu.findItem(R.id.back_to_categories).setVisible(m_activeCategory != null);
if (m_activeFeed != null) {
m_menu.setGroupVisible(R.id.menu_group_headlines, true);
}
}
} else {
m_menu.setGroupVisible(R.id.menu_group_logged_in, false);
m_menu.setGroupVisible(R.id.menu_group_logged_out, true);
}
/* if (m_sessionId != null) {
m_menu.findItem(R.id.login).setVisible(false);
m_menu.findItem(R.id.logout).setVisible(m_activeFeed == null && m_selectedArticle == null);
@ -598,7 +644,7 @@ public class MainActivity extends FragmentActivity implements FeedsFragment.OnFe
m_menu.findItem(R.id.update_feeds).setVisible(false);
m_menu.findItem(R.id.show_feeds).setVisible(false);
}
} */
}
}