Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6da4068d authored by Sam Blitzstein's avatar Sam Blitzstein
Browse files

Show menu when moving in landscape from timer to clock tab.

Bug: 10534546
Change-Id: I216300ebcdd59e80e5da49fcb1fb4509a43a94e0
(cherry picked from commit 7244a01b)
parent 3e8ebd96
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -251,14 +251,19 @@ public class DeskClock extends Activity implements LabelDialogFragment.TimerLabe
    public boolean onCreateOptionsMenu(Menu menu) {
        // We only want to show it as a menu in landscape, and only for clock/alarm fragment.
        mMenu = menu;
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE
                && (mActionBar.getSelectedNavigationIndex() == ALARM_TAB_INDEX ||
                        mActionBar.getSelectedNavigationIndex() == CLOCK_TAB_INDEX)) {
        if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
            if (mActionBar.getSelectedNavigationIndex() == ALARM_TAB_INDEX ||
                    mActionBar.getSelectedNavigationIndex() == CLOCK_TAB_INDEX) {
                // Clear the menu so that it doesn't get duplicate items in case onCreateOptionsMenu
                // was called multiple times.
                menu.clear();
                getMenuInflater().inflate(R.menu.desk_clock_menu, menu);
            }
            // Always return true for landscape, regardless of whether we've inflated the menu, so
            // that when we switch tabs this method will get called and we can inflate the menu.
            return true;
        } else {
            return false;
        }
        return false;
    }

    @Override
@@ -413,17 +418,20 @@ public class DeskClock extends Activity implements LabelDialogFragment.TimerLabe

        @Override
        public void onPageSelected(int position) {
            // Set the page before doing the menu so that onCreateOptionsMenu knows what page it is.
            mMainActionBar.setSelectedNavigationItem(getRtlPosition(position));
            notifyPageChanged(position);

            // Only show the overflow menu for alarm and world clock.
            if (mMenu != null) {
                // Make sure the menu's been initialized.
                if (position == ALARM_TAB_INDEX || position == CLOCK_TAB_INDEX) {
                    mMenu.setGroupVisible(R.id.menu_items, true);
                    onCreateOptionsMenu(mMenu);
                } else {
                    mMenu.setGroupVisible(R.id.menu_items, false);
                }
            }
            mMainActionBar.setSelectedNavigationItem(getRtlPosition(position));
            notifyPageChanged(position);
        }

        @Override