mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 1091587 - Dynamically layout private tabs panel on new tablet. r=lucasr
This commit is contained in:
parent
1603c59730
commit
5e9ce44872
@ -18,7 +18,8 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView style="@style/TabsPanelItem.TextAppearance.Header.PrivateTabs"
|
||||
<TextView android:id="@+id/private_tabs_empty_header"
|
||||
style="@style/TabsPanelItem.TextAppearance.Header.PrivateTabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/private_browsing_title"/>
|
||||
|
@ -6,6 +6,9 @@
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:gecko="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<!-- The layout_height value is used in TabsPanel.getTabsLayoutContainerHeight
|
||||
and as an offset in PrivateTabsPanel: if you change it here,
|
||||
change it there! -->
|
||||
<RelativeLayout android:id="@+id/tabs_panel_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/browser_toolbar_height">
|
||||
|
@ -42,6 +42,7 @@
|
||||
<dimen name="new_tablet_browser_toolbar_menu_item_inset_horizontal">3dp</dimen>
|
||||
<dimen name="new_tablet_browser_toolbar_menu_item_corner_radius">5dp</dimen>
|
||||
<dimen name="new_tablet_tab_strip_button_inset">5dp</dimen>
|
||||
<dimen name="new_tablet_private_tabs_panel_empty_width">300dp</dimen>
|
||||
<dimen name="forward_default_offset">-13dip</dimen>
|
||||
|
||||
<!-- Dimensions used by Favicons and FaviconView -->
|
||||
|
@ -8,16 +8,20 @@ package org.mozilla.gecko.tabs;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.mozilla.gecko.BrowserLocaleManager;
|
||||
import org.mozilla.gecko.NewTabletUI;
|
||||
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.content.res.Resources;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
/**
|
||||
* A container that wraps the private tabs {@link android.widget.AdapterView} and empty
|
||||
@ -27,16 +31,28 @@ import android.widget.FrameLayout;
|
||||
*/
|
||||
class PrivateTabsPanel extends FrameLayout implements CloseAllPanelView {
|
||||
private TabsPanel tabsPanel;
|
||||
|
||||
private final TabsLayout tabsLayout;
|
||||
private final View emptyTabsHeader;
|
||||
private final LinearLayout emptyTabsFrame;
|
||||
|
||||
private final int emptyTabsFrameWidth;
|
||||
private final int emptyTabsFrameVerticalOffset;
|
||||
|
||||
public PrivateTabsPanel(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
final Resources res = getResources();
|
||||
emptyTabsFrameVerticalOffset = res.getDimensionPixelOffset(R.dimen.browser_toolbar_height);
|
||||
emptyTabsFrameWidth =
|
||||
res.getDimensionPixelSize(R.dimen.new_tablet_private_tabs_panel_empty_width);
|
||||
|
||||
LayoutInflater.from(context).inflate(R.layout.private_tabs_panel, this);
|
||||
tabsLayout = (TabsLayout) findViewById(R.id.private_tabs_layout);
|
||||
emptyTabsHeader = findViewById(R.id.private_tabs_empty_header);
|
||||
|
||||
final View emptyView = findViewById(R.id.private_tabs_empty);
|
||||
tabsLayout.setEmptyView(emptyView);
|
||||
emptyTabsFrame = (LinearLayout) findViewById(R.id.private_tabs_empty);
|
||||
tabsLayout.setEmptyView(emptyTabsFrame);
|
||||
|
||||
final View learnMore = findViewById(R.id.private_tabs_learn_more);
|
||||
learnMore.setOnClickListener(new OnClickListener() {
|
||||
@ -61,6 +77,8 @@ class PrivateTabsPanel extends FrameLayout implements CloseAllPanelView {
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
updateStyleForNewTablet();
|
||||
|
||||
tabsLayout.show();
|
||||
setVisibility(View.VISIBLE);
|
||||
}
|
||||
@ -80,4 +98,27 @@ class PrivateTabsPanel extends FrameLayout implements CloseAllPanelView {
|
||||
public void closeAll() {
|
||||
tabsLayout.closeAll();
|
||||
}
|
||||
|
||||
private void updateStyleForNewTablet() {
|
||||
if (!NewTabletUI.isEnabled(getContext())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Move this to styles when removing old tablet.
|
||||
// Delete the emptyTabsFrame & Header class vars too.
|
||||
emptyTabsFrame.setOrientation(LinearLayout.VERTICAL);
|
||||
|
||||
final FrameLayout.LayoutParams lp =
|
||||
(FrameLayout.LayoutParams) emptyTabsFrame.getLayoutParams();
|
||||
lp.width = getResources().getDimensionPixelSize(
|
||||
R.dimen.new_tablet_private_tabs_panel_empty_width);
|
||||
lp.height = LayoutParams.WRAP_CONTENT;
|
||||
|
||||
// We want to center the content on the screen, not in the View,
|
||||
// so add padding to compensate for the header.
|
||||
lp.gravity = Gravity.CENTER;
|
||||
emptyTabsFrame.setPadding(0, 0, 0, emptyTabsFrameVerticalOffset);
|
||||
|
||||
emptyTabsHeader.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user