Exemplo n.º 1
0
  public void showMenu() {
    if (mCurrentPanel == Panel.REMOTE_TABS) {
      return;
    }

    final Menu menu = mPopupMenu.getMenu();

    // Each panel has a "+" shortcut button, so don't show it for that panel.
    menu.findItem(R.id.new_tab).setVisible(mCurrentPanel != Panel.NORMAL_TABS);
    menu.findItem(R.id.new_private_tab).setVisible(mCurrentPanel != Panel.PRIVATE_TABS);

    // Only show "Clear * tabs" for current panel.
    menu.findItem(R.id.close_all_tabs).setVisible(mCurrentPanel == Panel.NORMAL_TABS);
    menu.findItem(R.id.close_private_tabs).setVisible(mCurrentPanel == Panel.PRIVATE_TABS);

    mPopupMenu.show();
  }
Exemplo n.º 2
0
  public void hide() {
    mHeaderVisible = false;

    if (mVisible) {
      mVisible = false;
      mPopupMenu.dismiss();
      dispatchLayoutChange(0, 0);
    }
  }
Exemplo n.º 3
0
  public TabsPanel(Context context, AttributeSet attrs) {
    super(context, attrs);
    mContext = context;
    mActivity = (GeckoApp) context;
    mTheme = ((GeckoApplication) context.getApplicationContext()).getLightweightTheme();

    setLayoutParams(
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
    setOrientation(LinearLayout.VERTICAL);

    mCurrentPanel = Panel.NORMAL_TABS;
    mVisible = false;
    mHeaderVisible = false;

    mIsSideBar = false;

    mPopupMenu = new GeckoPopupMenu(context);
    mPopupMenu.inflate(R.menu.tabs_menu);
    mPopupMenu.setOnMenuItemClickListener(this);

    LayoutInflater.from(context).inflate(R.layout.tabs_panel, this);
    initialize();

    mAppStateListener =
        new AppStateListener() {
          @Override
          public void onResume() {
            if (mPanel == mPanelRemote) {
              // Refresh the remote panel.
              mPanelRemote.show();
            }
          }

          @Override
          public void onOrientationChanged() {
            // Remote panel is already refreshed by chrome refresh.
          }

          @Override
          public void onPause() {}
        };
  }
Exemplo n.º 4
0
  public void show(Panel panelToShow) {
    if (!isShown()) setVisibility(View.VISIBLE);

    if (mPanel != null) {
      // Hide the old panel.
      mPanel.hide();
    }

    final boolean showAnimation = !mVisible;
    mVisible = true;
    mCurrentPanel = panelToShow;

    int index = panelToShow.ordinal();
    mTabWidget.setCurrentTab(index);

    switch (panelToShow) {
      case NORMAL_TABS:
        mPanel = mPanelNormal;
        break;
      case PRIVATE_TABS:
        mPanel = mPanelPrivate;
        break;
      case REMOTE_TABS:
        mPanel = mPanelRemote;
        break;

      default:
        throw new IllegalArgumentException("Unknown panel type " + panelToShow);
    }
    mPanel.show();

    if (mCurrentPanel == Panel.REMOTE_TABS) {
      if (mFooter != null) mFooter.setVisibility(View.GONE);

      mAddTab.setVisibility(View.INVISIBLE);

      mMenuButton.setVisibility(View.GONE);
    } else {
      if (mFooter != null) mFooter.setVisibility(View.VISIBLE);

      mAddTab.setVisibility(View.VISIBLE);
      mAddTab.setImageLevel(index);

      if (!HardwareUtils.hasMenuButton()) {
        mMenuButton.setVisibility(View.VISIBLE);
        mMenuButton.setEnabled(true);
        mPopupMenu.setAnchor(mMenuButton);
      } else {
        mPopupMenu.setAnchor(mAddTab);
      }
    }

    if (isSideBar()) {
      if (showAnimation) dispatchLayoutChange(getWidth(), getHeight());
    } else {
      int actionBarHeight =
          mContext.getResources().getDimensionPixelSize(R.dimen.browser_toolbar_height);
      int height = actionBarHeight + getTabContainerHeight(mTabsContainer);
      dispatchLayoutChange(getWidth(), height);
    }
    mHeaderVisible = true;
  }