2012-06-07 21:47:22 -07:00
|
|
|
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
|
|
|
|
import android.content.Context;
|
2012-07-23 13:08:48 -07:00
|
|
|
import android.content.res.TypedArray;
|
2012-10-31 22:14:16 -07:00
|
|
|
import android.graphics.Color;
|
2012-10-12 16:23:20 -07:00
|
|
|
import android.graphics.Rect;
|
2012-10-31 22:14:16 -07:00
|
|
|
import android.graphics.drawable.ColorDrawable;
|
2012-06-07 21:47:22 -07:00
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.view.LayoutInflater;
|
2012-12-04 13:13:24 -08:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuItem;
|
2012-06-07 21:47:22 -07:00
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.Button;
|
2013-01-16 11:11:03 -08:00
|
|
|
import android.widget.AdapterView;
|
2012-12-18 17:04:39 -08:00
|
|
|
import android.widget.FrameLayout;
|
2012-06-07 21:47:22 -07:00
|
|
|
import android.widget.ImageButton;
|
2012-06-19 14:10:21 -07:00
|
|
|
import android.widget.LinearLayout;
|
2013-01-16 11:11:03 -08:00
|
|
|
import android.widget.Spinner;
|
2012-06-07 21:47:22 -07:00
|
|
|
|
2013-01-18 11:58:45 -08:00
|
|
|
public class TabsPanel extends LinearLayout
|
2012-12-04 13:13:24 -08:00
|
|
|
implements GeckoPopupMenu.OnMenuItemClickListener,
|
2013-01-16 11:11:03 -08:00
|
|
|
LightweightTheme.OnChangeListener,
|
|
|
|
AdapterView.OnItemSelectedListener {
|
2012-06-07 21:47:22 -07:00
|
|
|
private static final String LOGTAG = "GeckoTabsPanel";
|
|
|
|
|
|
|
|
public static enum Panel {
|
2012-12-18 17:04:39 -08:00
|
|
|
NORMAL_TABS,
|
|
|
|
PRIVATE_TABS,
|
2012-06-07 21:47:22 -07:00
|
|
|
REMOTE_TABS
|
|
|
|
}
|
|
|
|
|
2012-07-17 17:54:54 -07:00
|
|
|
public static interface PanelView {
|
2012-06-07 21:47:22 -07:00
|
|
|
public ViewGroup getLayout();
|
2012-07-27 23:31:40 -07:00
|
|
|
public void setTabsPanel(TabsPanel panel);
|
2012-06-07 21:47:22 -07:00
|
|
|
public void show();
|
|
|
|
public void hide();
|
|
|
|
}
|
|
|
|
|
2012-07-17 17:54:54 -07:00
|
|
|
public static interface TabsLayoutChangeListener {
|
2012-06-07 21:48:29 -07:00
|
|
|
public void onTabsLayoutChange(int width, int height);
|
|
|
|
}
|
|
|
|
|
2012-06-07 21:47:22 -07:00
|
|
|
private Context mContext;
|
2012-07-27 23:31:40 -07:00
|
|
|
private GeckoApp mActivity;
|
2012-06-07 21:47:22 -07:00
|
|
|
private PanelView mPanel;
|
2013-01-18 11:58:45 -08:00
|
|
|
private PanelView mPanelNormal;
|
|
|
|
private PanelView mPanelPrivate;
|
|
|
|
private PanelView mPanelRemote;
|
2013-01-16 14:04:53 -08:00
|
|
|
private LinearLayout mFooter;
|
2012-06-07 21:48:29 -07:00
|
|
|
private TabsLayoutChangeListener mLayoutChangeListener;
|
2012-06-07 21:47:22 -07:00
|
|
|
|
2012-12-04 13:15:50 -08:00
|
|
|
private static ImageButton mMenuButton;
|
|
|
|
private static ImageButton mAddTab;
|
2013-01-18 11:41:44 -08:00
|
|
|
private Button mTabsMenuButton;
|
2013-01-16 11:11:03 -08:00
|
|
|
private Spinner mTabsSpinner;
|
2012-06-07 21:47:22 -07:00
|
|
|
|
|
|
|
private Panel mCurrentPanel;
|
2012-07-23 13:08:48 -07:00
|
|
|
private boolean mIsSideBar;
|
2012-06-07 21:47:22 -07:00
|
|
|
private boolean mVisible;
|
2012-12-18 17:04:39 -08:00
|
|
|
private boolean mInflated;
|
2012-06-07 21:47:22 -07:00
|
|
|
|
2013-01-18 11:41:44 -08:00
|
|
|
private GeckoPopupMenu mTabsPopupMenu;
|
|
|
|
private Menu mTabsMenu;
|
|
|
|
|
2012-12-04 13:13:24 -08:00
|
|
|
private GeckoPopupMenu mPopupMenu;
|
|
|
|
private Menu mMenu;
|
|
|
|
|
2012-06-07 21:47:22 -07:00
|
|
|
public TabsPanel(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
mContext = context;
|
2012-07-27 23:31:40 -07:00
|
|
|
mActivity = (GeckoApp) context;
|
2012-06-07 21:47:22 -07:00
|
|
|
|
2013-01-18 11:58:45 -08:00
|
|
|
setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
|
|
|
|
LinearLayout.LayoutParams.FILL_PARENT));
|
|
|
|
setOrientation(LinearLayout.VERTICAL);
|
|
|
|
|
2012-12-18 17:04:39 -08:00
|
|
|
mCurrentPanel = Panel.NORMAL_TABS;
|
2012-06-07 21:47:22 -07:00
|
|
|
mVisible = false;
|
|
|
|
|
2012-07-23 13:08:48 -07:00
|
|
|
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TabsPanel);
|
|
|
|
mIsSideBar = a.getBoolean(R.styleable.TabsPanel_sidebar, false);
|
|
|
|
a.recycle();
|
|
|
|
|
2012-12-04 13:13:24 -08:00
|
|
|
mPopupMenu = new GeckoPopupMenu(context);
|
|
|
|
mPopupMenu.inflate(R.menu.tabs_menu);
|
|
|
|
mPopupMenu.setOnMenuItemClickListener(this);
|
|
|
|
mMenu = mPopupMenu.getMenu();
|
|
|
|
|
2013-01-18 11:41:44 -08:00
|
|
|
mTabsPopupMenu = new GeckoPopupMenu(context);
|
|
|
|
mTabsPopupMenu.inflate(R.menu.tabs_switcher_menu);
|
|
|
|
mTabsPopupMenu.setOnMenuItemClickListener(this);
|
|
|
|
mTabsPopupMenu.showArrowToAnchor(false);
|
|
|
|
mTabsMenu = mTabsPopupMenu.getMenu();
|
|
|
|
|
2012-12-18 17:04:39 -08:00
|
|
|
LayoutInflater.from(context).inflate(R.layout.tabs_panel, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onFinishInflate() {
|
|
|
|
super.onFinishInflate();
|
|
|
|
|
|
|
|
// HACK: Without this, the onFinishInflate is called twice
|
|
|
|
// This issue is due to a bug when Android inflates a layout with a
|
|
|
|
// parent. Fixed in Honeycomb
|
|
|
|
if (mInflated)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mInflated = true;
|
|
|
|
|
|
|
|
initialize();
|
|
|
|
}
|
|
|
|
|
2013-01-18 11:58:45 -08:00
|
|
|
void initialize() {
|
|
|
|
mPanelNormal = (TabsTray) findViewById(R.id.normal_tabs);
|
|
|
|
mPanelNormal.setTabsPanel(this);
|
2012-12-18 17:04:39 -08:00
|
|
|
|
2013-01-18 11:58:45 -08:00
|
|
|
mPanelPrivate = (TabsTray) findViewById(R.id.private_tabs);
|
|
|
|
mPanelPrivate.setTabsPanel(this);
|
2012-12-18 17:04:39 -08:00
|
|
|
|
2013-01-18 11:58:45 -08:00
|
|
|
mPanelRemote = (RemoteTabs) findViewById(R.id.synced_tabs);
|
|
|
|
mPanelRemote.setTabsPanel(this);
|
2012-12-18 17:04:39 -08:00
|
|
|
|
2013-01-16 14:04:53 -08:00
|
|
|
mFooter = (LinearLayout) findViewById(R.id.tabs_panel_footer);
|
2012-12-18 17:04:39 -08:00
|
|
|
|
2013-01-16 11:26:48 -08:00
|
|
|
mAddTab = (ImageButton) findViewById(R.id.add_tab);
|
2012-12-04 13:15:50 -08:00
|
|
|
mAddTab.setOnClickListener(new Button.OnClickListener() {
|
2012-06-07 21:47:22 -07:00
|
|
|
public void onClick(View v) {
|
2013-01-02 13:43:01 -08:00
|
|
|
TabsPanel.this.addTab();
|
2012-06-07 21:47:22 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-01-16 11:26:48 -08:00
|
|
|
mTabsSpinner = (Spinner) findViewById(R.id.tabs_menu);
|
2013-01-16 11:11:03 -08:00
|
|
|
mTabsSpinner.setOnItemSelectedListener(this);
|
2012-12-18 16:45:55 -08:00
|
|
|
|
2013-01-18 11:41:44 -08:00
|
|
|
mTabsMenuButton = (Button) findViewById(R.id.tabs_switcher_menu);
|
|
|
|
mTabsPopupMenu.setAnchor(mTabsMenuButton);
|
|
|
|
mTabsMenuButton.setOnClickListener(new Button.OnClickListener() {
|
|
|
|
public void onClick(View view) {
|
|
|
|
TabsPanel.this.openTabsSwitcherMenu();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-01-16 11:26:48 -08:00
|
|
|
mMenuButton = (ImageButton) findViewById(R.id.menu);
|
2012-12-04 13:13:24 -08:00
|
|
|
mMenuButton.setOnClickListener(new Button.OnClickListener() {
|
|
|
|
public void onClick(View view) {
|
|
|
|
TabsPanel.this.openTabsMenu();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
mPopupMenu.setAnchor(mMenuButton);
|
2012-06-12 22:29:23 -07:00
|
|
|
}
|
|
|
|
|
2013-01-02 13:43:01 -08:00
|
|
|
public void addTab() {
|
|
|
|
if (mCurrentPanel == Panel.NORMAL_TABS)
|
|
|
|
mActivity.addTab();
|
|
|
|
else
|
|
|
|
mActivity.addPrivateTab();
|
|
|
|
|
|
|
|
mActivity.autoHideTabs();
|
|
|
|
}
|
|
|
|
|
2012-12-04 13:13:24 -08:00
|
|
|
public void openTabsMenu() {
|
|
|
|
if (mCurrentPanel == Panel.REMOTE_TABS)
|
|
|
|
mMenu.findItem(R.id.close_all_tabs).setEnabled(false);
|
|
|
|
else
|
|
|
|
mMenu.findItem(R.id.close_all_tabs).setEnabled(true);
|
|
|
|
|
|
|
|
mPopupMenu.show();
|
|
|
|
}
|
|
|
|
|
2013-01-18 11:41:44 -08:00
|
|
|
public void openTabsSwitcherMenu() {
|
|
|
|
mTabsPopupMenu.show();
|
|
|
|
}
|
|
|
|
|
2013-01-16 11:11:03 -08:00
|
|
|
@Override
|
|
|
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
|
|
|
Panel panel = TabsPanel.Panel.NORMAL_TABS;
|
|
|
|
if (position == 1)
|
|
|
|
panel = TabsPanel.Panel.PRIVATE_TABS;
|
|
|
|
else if (position == 2)
|
|
|
|
panel = TabsPanel.Panel.REMOTE_TABS;
|
|
|
|
|
|
|
|
if (panel != mCurrentPanel)
|
|
|
|
show(panel);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onNothingSelected(AdapterView<?> parent) {
|
2012-12-18 16:45:55 -08:00
|
|
|
}
|
|
|
|
|
2012-12-04 13:13:24 -08:00
|
|
|
@Override
|
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
|
switch (item.getItemId()) {
|
2013-01-18 11:41:44 -08:00
|
|
|
case R.id.tabs_normal:
|
|
|
|
show(Panel.NORMAL_TABS);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.id.tabs_private:
|
|
|
|
mTabsMenuButton.setText(R.string.tabs_private);
|
|
|
|
show(Panel.PRIVATE_TABS);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
case R.id.tabs_synced:
|
|
|
|
mTabsMenuButton.setText(R.string.tabs_synced);
|
|
|
|
show(Panel.REMOTE_TABS);
|
|
|
|
return true;
|
|
|
|
|
2012-12-04 13:13:24 -08:00
|
|
|
case R.id.close_all_tabs:
|
|
|
|
for (Tab tab : Tabs.getInstance().getTabsInOrder()) {
|
|
|
|
Tabs.getInstance().closeTab(tab);
|
|
|
|
}
|
2013-01-01 13:03:41 -08:00
|
|
|
autoHidePanel();
|
2012-12-04 13:13:24 -08:00
|
|
|
return true;
|
2012-12-18 16:45:55 -08:00
|
|
|
|
2012-12-04 13:13:24 -08:00
|
|
|
case R.id.new_tab:
|
|
|
|
case R.id.new_private_tab:
|
|
|
|
hide();
|
|
|
|
// fall through
|
|
|
|
default:
|
|
|
|
return mActivity.onOptionsItemSelected(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-12 16:23:20 -07:00
|
|
|
private static int getTabContainerHeight(View view) {
|
|
|
|
Context context = view.getContext();
|
|
|
|
|
|
|
|
int actionBarHeight = context.getResources().getDimensionPixelSize(R.dimen.browser_toolbar_height);
|
|
|
|
int screenHeight = context.getResources().getDisplayMetrics().heightPixels;
|
|
|
|
|
|
|
|
Rect windowRect = new Rect();
|
|
|
|
view.getWindowVisibleDisplayFrame(windowRect);
|
|
|
|
int windowHeight = windowRect.bottom - windowRect.top;
|
|
|
|
|
|
|
|
// The web content area should have at least 1.5x the height of the action bar.
|
|
|
|
// The tabs panel shouldn't take less than 50% of the screen height and can take
|
|
|
|
// up to 80% of the window height.
|
|
|
|
return (int) Math.max(screenHeight * 0.5f,
|
|
|
|
Math.min(windowHeight - 2.5f * actionBarHeight, windowHeight * 0.8f) - actionBarHeight);
|
|
|
|
}
|
|
|
|
|
2012-10-31 22:14:16 -07:00
|
|
|
@Override
|
|
|
|
public void onAttachedToWindow() {
|
|
|
|
super.onAttachedToWindow();
|
|
|
|
mActivity.getLightweightTheme().addListener(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDetachedFromWindow() {
|
|
|
|
super.onDetachedFromWindow();
|
|
|
|
mActivity.getLightweightTheme().removeListener(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onLightweightThemeChanged() {
|
2012-12-13 13:13:36 -08:00
|
|
|
LightweightThemeDrawable drawable = mActivity.getLightweightTheme().getTextureDrawable(this, R.drawable.tabs_tray_bg_repeat, true);
|
2012-10-31 22:14:16 -07:00
|
|
|
if (drawable == null)
|
|
|
|
return;
|
|
|
|
|
2012-12-13 13:13:36 -08:00
|
|
|
drawable.setAlpha(34, 0);
|
|
|
|
setBackgroundDrawable(drawable);
|
2012-10-31 22:14:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onLightweightThemeReset() {
|
|
|
|
setBackgroundResource(R.drawable.tabs_tray_bg_repeat);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
|
|
|
super.onLayout(changed, left, top, right, bottom);
|
|
|
|
onLightweightThemeChanged();
|
|
|
|
}
|
|
|
|
|
2012-06-12 22:29:23 -07:00
|
|
|
// Tabs List Container holds the ListView
|
2012-12-18 17:04:39 -08:00
|
|
|
public static class TabsListContainer extends FrameLayout {
|
2012-07-27 23:31:40 -07:00
|
|
|
private Context mContext;
|
|
|
|
|
2012-06-12 22:29:23 -07:00
|
|
|
public TabsListContainer(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
2012-07-27 23:31:40 -07:00
|
|
|
mContext = context;
|
2012-06-12 22:29:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
2012-07-23 13:08:48 -07:00
|
|
|
if (!GeckoApp.mAppContext.hasTabsSideBar()) {
|
2013-01-18 11:58:45 -08:00
|
|
|
int heightSpec = MeasureSpec.makeMeasureSpec(getTabContainerHeight(TabsListContainer.this), MeasureSpec.EXACTLY);
|
2012-06-12 22:29:23 -07:00
|
|
|
super.onMeasure(widthMeasureSpec, heightSpec);
|
|
|
|
} else {
|
|
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
|
|
}
|
|
|
|
}
|
2012-06-07 21:47:22 -07:00
|
|
|
}
|
|
|
|
|
2012-06-19 14:10:21 -07:00
|
|
|
// Tabs Panel Toolbar contains the Buttons
|
2012-12-19 12:27:42 -08:00
|
|
|
public static class TabsPanelToolbar extends LinearLayout
|
2012-10-31 22:12:02 -07:00
|
|
|
implements LightweightTheme.OnChangeListener {
|
|
|
|
private BrowserApp mActivity;
|
|
|
|
|
2012-06-19 14:10:21 -07:00
|
|
|
public TabsPanelToolbar(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
2012-12-04 13:13:24 -08:00
|
|
|
mActivity = (BrowserApp) context;
|
2012-06-19 14:10:21 -07:00
|
|
|
|
|
|
|
setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
|
|
|
|
(int) context.getResources().getDimension(R.dimen.browser_toolbar_height)));
|
|
|
|
|
2012-12-19 12:27:42 -08:00
|
|
|
setOrientation(LinearLayout.HORIZONTAL);
|
2012-10-31 22:12:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAttachedToWindow() {
|
|
|
|
super.onAttachedToWindow();
|
|
|
|
mActivity.getLightweightTheme().addListener(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onDetachedFromWindow() {
|
|
|
|
super.onDetachedFromWindow();
|
|
|
|
mActivity.getLightweightTheme().removeListener(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onLightweightThemeChanged() {
|
2012-12-13 13:13:36 -08:00
|
|
|
LightweightThemeDrawable drawable = mActivity.getLightweightTheme().getTextureDrawable(this, R.drawable.tabs_tray_bg_repeat);
|
2012-10-31 22:12:02 -07:00
|
|
|
if (drawable == null)
|
|
|
|
return;
|
|
|
|
|
2012-12-13 13:13:36 -08:00
|
|
|
drawable.setAlpha(34, 34);
|
|
|
|
setBackgroundDrawable(drawable);
|
2012-10-31 22:12:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onLightweightThemeReset() {
|
2012-10-31 22:14:16 -07:00
|
|
|
setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
2012-10-31 22:12:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
|
|
|
super.onLayout(changed, left, top, right, bottom);
|
|
|
|
onLightweightThemeChanged();
|
2012-06-19 14:10:21 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-07 21:47:22 -07:00
|
|
|
public void show(Panel panel) {
|
|
|
|
if (mPanel != null) {
|
2012-12-18 17:04:39 -08:00
|
|
|
// Hide the old panel.
|
2012-06-07 21:47:22 -07:00
|
|
|
mPanel.hide();
|
|
|
|
}
|
|
|
|
|
2012-08-15 14:37:00 -07:00
|
|
|
final boolean showAnimation = !mVisible;
|
2012-06-07 21:47:22 -07:00
|
|
|
mVisible = true;
|
|
|
|
mCurrentPanel = panel;
|
|
|
|
|
2012-12-18 17:04:39 -08:00
|
|
|
int index = panel.ordinal();
|
2013-01-16 11:11:03 -08:00
|
|
|
mTabsSpinner.setSelection(index);
|
2012-06-07 21:47:22 -07:00
|
|
|
|
2013-01-18 11:58:45 -08:00
|
|
|
if (index == 0) {
|
|
|
|
mPanel = mPanelNormal;
|
2013-01-18 11:41:44 -08:00
|
|
|
mTabsMenuButton.setText(R.string.tabs_normal);
|
2013-01-18 11:58:45 -08:00
|
|
|
} else if (index == 1) {
|
|
|
|
mPanel = mPanelPrivate;
|
2013-01-18 11:41:44 -08:00
|
|
|
mTabsMenuButton.setText(R.string.tabs_private);
|
2013-01-18 11:58:45 -08:00
|
|
|
} else {
|
|
|
|
mPanel = mPanelRemote;
|
2013-01-18 11:41:44 -08:00
|
|
|
mTabsMenuButton.setText(R.string.tabs_synced);
|
2013-01-18 11:58:45 -08:00
|
|
|
}
|
2013-01-18 11:41:44 -08:00
|
|
|
|
2012-06-07 21:47:22 -07:00
|
|
|
mPanel.show();
|
2012-06-07 21:48:29 -07:00
|
|
|
|
2013-01-10 12:22:43 -08:00
|
|
|
if (mCurrentPanel == Panel.REMOTE_TABS) {
|
2013-01-16 11:26:48 -08:00
|
|
|
if (mFooter != null)
|
|
|
|
mFooter.setVisibility(View.GONE);
|
|
|
|
|
2013-01-02 13:43:01 -08:00
|
|
|
mAddTab.setVisibility(View.INVISIBLE);
|
2013-01-10 13:06:32 -08:00
|
|
|
mMenuButton.setVisibility(View.INVISIBLE);
|
2013-01-10 12:22:43 -08:00
|
|
|
} else {
|
2013-01-16 11:26:48 -08:00
|
|
|
if (mFooter != null)
|
|
|
|
mFooter.setVisibility(View.VISIBLE);
|
|
|
|
|
2013-01-02 13:43:01 -08:00
|
|
|
mAddTab.setVisibility(View.VISIBLE);
|
2013-01-10 12:22:43 -08:00
|
|
|
mAddTab.setImageLevel(index);
|
2013-01-10 13:06:32 -08:00
|
|
|
mMenuButton.setVisibility(View.VISIBLE);
|
2013-01-10 12:22:43 -08:00
|
|
|
}
|
2013-01-02 13:43:01 -08:00
|
|
|
|
2012-07-27 23:31:40 -07:00
|
|
|
if (isSideBar()) {
|
2012-08-15 14:37:00 -07:00
|
|
|
if (showAnimation)
|
|
|
|
dispatchLayoutChange(getWidth(), getHeight());
|
2012-06-12 22:29:23 -07:00
|
|
|
} else {
|
2012-10-12 16:23:20 -07:00
|
|
|
int actionBarHeight = mContext.getResources().getDimensionPixelSize(R.dimen.browser_toolbar_height);
|
2013-01-18 11:58:45 -08:00
|
|
|
int height = actionBarHeight + getTabContainerHeight(this);
|
2012-08-31 11:14:43 -07:00
|
|
|
dispatchLayoutChange(getWidth(), height);
|
2012-06-12 22:29:23 -07:00
|
|
|
}
|
2012-06-07 21:47:22 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public void hide() {
|
2012-06-12 22:47:52 -07:00
|
|
|
if (mVisible) {
|
|
|
|
mVisible = false;
|
2012-12-04 13:13:24 -08:00
|
|
|
mPopupMenu.dismiss();
|
2012-06-12 22:47:52 -07:00
|
|
|
dispatchLayoutChange(0, 0);
|
2012-12-26 12:56:34 -08:00
|
|
|
|
2013-01-18 11:58:45 -08:00
|
|
|
if (mPanel != null) {
|
|
|
|
mPanel.hide();
|
|
|
|
mPanel = null;
|
|
|
|
}
|
2012-06-12 22:47:52 -07:00
|
|
|
}
|
2012-06-07 21:48:29 -07:00
|
|
|
}
|
|
|
|
|
2012-06-07 21:47:22 -07:00
|
|
|
public void refresh() {
|
2012-12-18 17:04:39 -08:00
|
|
|
removeAllViews();
|
2012-06-19 14:10:21 -07:00
|
|
|
|
2012-12-18 17:04:39 -08:00
|
|
|
LayoutInflater.from(mContext).inflate(R.layout.tabs_panel, this);
|
|
|
|
initialize();
|
2012-06-19 14:10:21 -07:00
|
|
|
|
|
|
|
if (mVisible)
|
2012-06-07 21:47:22 -07:00
|
|
|
show(mCurrentPanel);
|
|
|
|
}
|
|
|
|
|
2012-07-27 23:31:40 -07:00
|
|
|
public void autoHidePanel() {
|
|
|
|
mActivity.autoHideTabs();
|
|
|
|
}
|
|
|
|
|
2012-06-07 21:47:22 -07:00
|
|
|
@Override
|
|
|
|
public boolean isShown() {
|
|
|
|
return mVisible;
|
|
|
|
}
|
2012-06-07 21:48:29 -07:00
|
|
|
|
2012-07-23 13:08:48 -07:00
|
|
|
public boolean isSideBar() {
|
|
|
|
return mIsSideBar;
|
|
|
|
}
|
|
|
|
|
2012-06-07 21:48:29 -07:00
|
|
|
public void setTabsLayoutChangeListener(TabsLayoutChangeListener listener) {
|
|
|
|
mLayoutChangeListener = listener;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void dispatchLayoutChange(int width, int height) {
|
|
|
|
if (mLayoutChangeListener != null)
|
|
|
|
mLayoutChangeListener.onTabsLayoutChange(width, height);
|
|
|
|
}
|
2012-06-07 21:47:22 -07:00
|
|
|
}
|