Further refined menu behavior with people view on tablet

pull/14/head
Sam Bosley 12 years ago
parent 8c95d4a802
commit 0e85cd2714

@ -341,7 +341,8 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
private void createMainMenuPopover() {
int layout;
if (AndroidUtilities.isTabletSized(this))
boolean isTablet = AndroidUtilities.isTabletSized(this);
if (isTablet)
layout = R.layout.main_menu_popover_tablet;
else
layout = R.layout.main_menu_popover;
@ -353,6 +354,9 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
mainMenu.setSelected(false);
}
});
if (isTablet)
setupMainMenuForPeopleViewState(getIntent().getBooleanExtra(PEOPLE_VIEW, false));
}
private void setupPopoverWithFragment(FragmentPopover popover, Fragment frag, LayoutParams params) {
@ -675,7 +679,10 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
TaskListFragment tlf = getTaskListFragment();
switch (item) {
case MainMenuPopover.MAIN_MENU_ITEM_LISTS:
listsNav.performClick();
if (fragmentLayout == LAYOUT_SINGLE)
listsNav.performClick();
else
togglePeopleView();
return;
case MainMenuPopover.MAIN_MENU_ITEM_SEARCH:
onSearchRequested();
@ -708,9 +715,16 @@ public class TaskListActivity extends AstridActivity implements MainMenuListener
else
setupFragment(FilterListFragment.TAG_FILTERLIST_FRAGMENT,
R.id.filterlist_fragment_container, FilterListFragment.class, false, true);
setupMainMenuForPeopleViewState(peopleMode);
getIntent().putExtra(PEOPLE_VIEW, peopleMode);
}
private void setupMainMenuForPeopleViewState(boolean inPeopleMode) {
mainMenuPopover.setFixedItemVisibility(0, inPeopleMode ? View.VISIBLE : View.GONE, true);
mainMenuPopover.setFixedItemVisibility(1, inPeopleMode ? View.GONE : View.VISIBLE, true);
}
public MainMenuPopover getMainMenuPopover() {
return mainMenuPopover;
}

@ -97,21 +97,28 @@ public class MainMenuPopover extends FragmentPopover implements InterceptTouchLi
private void addFixedItems(boolean isTablet) {
int themeFlags = isTablet ? ThemeService.FLAG_FORCE_DARK : 0;
if (!isTablet)
addMenuItem(R.string.TLA_menu_lists,
ThemeService.getDrawable(R.drawable.icn_menu_lists, themeFlags),
MAIN_MENU_ITEM_LISTS, null, topFixed); // Lists item
addMenuItem(R.string.TLA_menu_search,
ThemeService.getDrawable(R.drawable.icn_menu_search, themeFlags),
MAIN_MENU_ITEM_SEARCH, null, topFixed);
addMenuItem(R.string.TLA_menu_lists,
ThemeService.getDrawable(R.drawable.icn_menu_lists, themeFlags),
MAIN_MENU_ITEM_LISTS, null, topFixed); // Lists item
addMenuItem(R.string.TLA_menu_friends,
R.drawable.icn_anyone,
MAIN_MENU_ITEM_FRIENDS, null, topFixed);
addMenuItem(R.string.TLA_menu_search,
ThemeService.getDrawable(R.drawable.icn_menu_search, themeFlags),
MAIN_MENU_ITEM_SEARCH, null, topFixed);
addMenuItem(R.string.TLA_menu_settings,
ThemeService.getDrawable(R.drawable.icn_menu_settings, themeFlags),
MAIN_MENU_ITEM_SETTINGS, null, bottomFixed); // Settings item
}
public void setFixedItemVisibility(int index, int visibility, boolean top) {
LinearLayout container = top ? topFixed : bottomFixed;
if (index < 0 || index >= container.getChildCount())
return;
container.getChildAt(index).setVisibility(visibility);
}
@Override
protected int getArrowLeftMargin(View arrow) {
return mRect.centerX() - arrow.getMeasuredWidth() / 2 - (int) (12 * metrics.density);

Loading…
Cancel
Save