Bug 1046209 - Part 2: Extract TabsLayout interface (r=lucasr)

This commit is contained in:
Martyn Haigh 2014-08-27 16:17:59 +01:00
parent e04d34ef33
commit 56d3538ac3
3 changed files with 16 additions and 10 deletions

View File

@ -11,6 +11,7 @@ import org.mozilla.gecko.BrowserLocaleManager;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Tabs;
import org.mozilla.gecko.tabs.TabsPanel.CloseAllPanelView;
import org.mozilla.gecko.tabs.TabsPanel.TabsLayout;
import android.content.Context;
import android.util.AttributeSet;
@ -26,16 +27,16 @@ import android.widget.FrameLayout;
*/
class PrivateTabsPanel extends FrameLayout implements CloseAllPanelView {
private TabsPanel tabsPanel;
private TabsListLayout tabsTray;
private TabsLayout tabsLayout;
public PrivateTabsPanel(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater.from(context).inflate(R.layout.private_tabs_panel, this);
tabsTray = (TabsListLayout) findViewById(R.id.private_tabs_tray);
tabsLayout = (TabsLayout) findViewById(R.id.private_tabs_tray);
final View emptyView = findViewById(R.id.private_tabs_empty);
tabsTray.setEmptyView(emptyView);
tabsLayout.setEmptyView(emptyView);
final View learnMore = findViewById(R.id.private_tabs_learn_more);
learnMore.setOnClickListener(new OnClickListener() {
@ -55,28 +56,28 @@ class PrivateTabsPanel extends FrameLayout implements CloseAllPanelView {
@Override
public void setTabsPanel(TabsPanel panel) {
tabsPanel = panel;
tabsTray.setTabsPanel(panel);
tabsLayout.setTabsPanel(panel);
}
@Override
public void show() {
tabsTray.show();
tabsLayout.show();
setVisibility(View.VISIBLE);
}
@Override
public void hide() {
setVisibility(View.GONE);
tabsTray.hide();
tabsLayout.hide();
}
@Override
public boolean shouldExpand() {
return tabsTray.shouldExpand();
return tabsLayout.shouldExpand();
}
@Override
public void closeAll() {
tabsTray.closeAll();
tabsLayout.closeAll();
}
}

View File

@ -14,6 +14,7 @@ import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Tab;
import org.mozilla.gecko.Tabs;
import org.mozilla.gecko.tabs.TabsPanel.TabsLayout;
import org.mozilla.gecko.animation.PropertyAnimator;
import org.mozilla.gecko.animation.PropertyAnimator.Property;
import org.mozilla.gecko.animation.ViewHelper;
@ -38,8 +39,8 @@ import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
class TabsListLayout extends TwoWayView implements
TabsPanel.CloseAllPanelView {
class TabsListLayout extends TwoWayView
implements TabsLayout {
private static final String LOGTAG = "Gecko" + TabsListLayout.class.getSimpleName();
private Context mContext;

View File

@ -61,6 +61,10 @@ public class TabsPanel extends LinearLayout
public void closeAll();
}
public static interface TabsLayout extends CloseAllPanelView {
public void setEmptyView(View view);
}
public static interface TabsLayoutChangeListener {
public void onTabsLayoutChange(int width, int height);
}