mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 762727: Tabs Panel refresh on rotation. [r=mfinkle]
--HG-- rename : mobile/android/base/resources/layout-sw600dp/tabs_panel.xml => mobile/android/base/resources/layout-sw600dp/tabs_panel_toolbar.xml rename : mobile/android/base/resources/layout-xlarge/tabs_panel.xml => mobile/android/base/resources/layout-xlarge/tabs_panel_toolbar.xml
This commit is contained in:
parent
6a0f56a62e
commit
31362ed220
@ -271,6 +271,7 @@ RES_LAYOUT = \
|
||||
res/layout/remote_tabs_group.xml \
|
||||
res/layout/tabs_counter.xml \
|
||||
res/layout/tabs_panel.xml \
|
||||
res/layout/tabs_panel_toolbar.xml \
|
||||
res/layout/tabs_row.xml \
|
||||
res/layout/tabs_tray.xml \
|
||||
res/layout/list_item_header.xml \
|
||||
@ -292,7 +293,7 @@ RES_LAYOUT_XLARGE = \
|
||||
res/layout-xlarge/gecko_app.xml \
|
||||
res/layout-xlarge/remote_tabs_child.xml \
|
||||
res/layout-xlarge/remote_tabs_group.xml \
|
||||
res/layout-xlarge/tabs_panel.xml \
|
||||
res/layout-xlarge/tabs_panel_toolbar.xml \
|
||||
res/layout-xlarge/tabs_row.xml \
|
||||
$(NULL)
|
||||
|
||||
@ -301,7 +302,7 @@ RES_LAYOUT_SW600DP = \
|
||||
res/layout-sw600dp/gecko_app.xml \
|
||||
res/layout-sw600dp/remote_tabs_child.xml \
|
||||
res/layout-sw600dp/remote_tabs_group.xml \
|
||||
res/layout-sw600dp/tabs_panel.xml \
|
||||
res/layout-sw600dp/tabs_panel_toolbar.xml \
|
||||
res/layout-sw600dp/tabs_row.xml \
|
||||
$(NULL)
|
||||
|
||||
|
@ -13,9 +13,10 @@ import android.view.animation.AnimationUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.mozilla.gecko.sync.setup.SyncAccounts;
|
||||
@ -40,7 +41,8 @@ public class TabsPanel extends LinearLayout {
|
||||
|
||||
private Context mContext;
|
||||
private PanelView mPanel;
|
||||
private LinearLayout mListContainer;
|
||||
private TabsPanelToolbar mToolbar;
|
||||
private TabsListContainer mListContainer;
|
||||
private TabsLayoutChangeListener mLayoutChangeListener;
|
||||
|
||||
private static ImageButton mRemoteTabs;
|
||||
@ -62,8 +64,15 @@ public class TabsPanel extends LinearLayout {
|
||||
mCurrentPanel = Panel.LOCAL_TABS;
|
||||
mVisible = false;
|
||||
|
||||
mTitle = (TextView) findViewById(R.id.title);
|
||||
ImageButton addTab = (ImageButton) findViewById(R.id.add_tab);
|
||||
mToolbar = (TabsPanelToolbar) findViewById(R.id.toolbar);
|
||||
mListContainer = (TabsListContainer) findViewById(R.id.list_container);
|
||||
|
||||
initToolbar();
|
||||
}
|
||||
|
||||
void initToolbar() {
|
||||
mTitle = (TextView) mToolbar.findViewById(R.id.title);
|
||||
ImageButton addTab = (ImageButton) mToolbar.findViewById(R.id.add_tab);
|
||||
addTab.setOnClickListener(new Button.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
GeckoApp.mAppContext.addTab();
|
||||
@ -71,7 +80,7 @@ public class TabsPanel extends LinearLayout {
|
||||
}
|
||||
});
|
||||
|
||||
mRemoteTabs = (ImageButton) findViewById(R.id.remote_tabs);
|
||||
mRemoteTabs = (ImageButton) mToolbar.findViewById(R.id.remote_tabs);
|
||||
mRemoteTabs.setOnClickListener(new Button.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
if (mRemoteTabs.getDrawable().getLevel() == REMOTE_TABS_SHOWN)
|
||||
@ -80,8 +89,6 @@ public class TabsPanel extends LinearLayout {
|
||||
GeckoApp.mAppContext.showRemoteTabs();
|
||||
}
|
||||
});
|
||||
|
||||
mListContainer = (LinearLayout) findViewById(R.id.list_container);
|
||||
}
|
||||
|
||||
// Tabs List Container holds the ListView
|
||||
@ -105,6 +112,18 @@ public class TabsPanel extends LinearLayout {
|
||||
}
|
||||
}
|
||||
|
||||
// Tabs Panel Toolbar contains the Buttons
|
||||
public static class TabsPanelToolbar extends RelativeLayout {
|
||||
public TabsPanelToolbar(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,
|
||||
(int) context.getResources().getDimension(R.dimen.browser_toolbar_height)));
|
||||
|
||||
LayoutInflater.from(context).inflate(R.layout.tabs_panel_toolbar, this);
|
||||
}
|
||||
}
|
||||
|
||||
public void show(Panel panel) {
|
||||
if (mPanel != null) {
|
||||
// Remove the old panel.
|
||||
@ -133,7 +152,14 @@ public class TabsPanel extends LinearLayout {
|
||||
dispatchLayoutChange(getWidth(), getHeight());
|
||||
} else {
|
||||
int actionBarHeight = (int) (mContext.getResources().getDimension(R.dimen.browser_toolbar_height));
|
||||
int height = actionBarHeight + mListContainer.getHeight();
|
||||
|
||||
// TabsListContainer takes time to resize on rotation.
|
||||
// It's better to add 50% of the screen-size and dispatch it as height.
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
GeckoApp.mAppContext.getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||
int listHeight = (int) (0.5 * metrics.heightPixels);
|
||||
|
||||
int height = actionBarHeight + listHeight;
|
||||
dispatchLayoutChange(getWidth(), height);
|
||||
}
|
||||
|
||||
@ -164,10 +190,17 @@ public class TabsPanel extends LinearLayout {
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
if (mVisible) {
|
||||
mListContainer.requestLayout();
|
||||
mListContainer.forceLayout();
|
||||
|
||||
int index = indexOfChild(mToolbar);
|
||||
removeViewAt(index);
|
||||
|
||||
mToolbar = new TabsPanelToolbar(mContext, null);
|
||||
addView(mToolbar, index);
|
||||
initToolbar();
|
||||
|
||||
if (mVisible)
|
||||
show(mCurrentPanel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,59 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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/. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<RelativeLayout android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/browser_toolbar_height">
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/tabs_tray_bg_repeat">
|
||||
|
||||
<ImageButton android:id="@+id/add_tab"
|
||||
android:layout_width="@dimen/browser_toolbar_height"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:paddingTop="15dip"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="20dip"
|
||||
android:paddingRight="20dip"
|
||||
android:src="@drawable/tab_new"
|
||||
android:contentDescription="@string/new_tab"
|
||||
android:background="@drawable/action_bar_button"/>
|
||||
|
||||
<ImageButton android:id="@+id/remote_tabs"
|
||||
android:layout_width="@dimen/browser_toolbar_height"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:paddingTop="15dip"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="20dip"
|
||||
android:paddingRight="20dip"
|
||||
android:src="@drawable/remote_tabs_level"
|
||||
android:contentDescription="@string/remote_tabs"
|
||||
android:background="@drawable/action_bar_button"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/tabs_tray_list_divider"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<view class="org.mozilla.gecko.TabsPanel$TabsListContainer"
|
||||
android:id="@+id/list_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/tabs_tray_bg_repeat"/>
|
||||
|
||||
</merge>
|
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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/. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/tabs_tray_bg_repeat">
|
||||
|
||||
<ImageButton android:id="@+id/add_tab"
|
||||
android:layout_width="@dimen/browser_toolbar_height"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:paddingTop="15dip"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="20dip"
|
||||
android:paddingRight="20dip"
|
||||
android:src="@drawable/tab_new"
|
||||
android:contentDescription="@string/new_tab"
|
||||
android:background="@drawable/action_bar_button"/>
|
||||
|
||||
<ImageButton android:id="@+id/remote_tabs"
|
||||
android:layout_width="@dimen/browser_toolbar_height"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:paddingTop="15dip"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="20dip"
|
||||
android:paddingRight="20dip"
|
||||
android:src="@drawable/remote_tabs_level"
|
||||
android:contentDescription="@string/remote_tabs"
|
||||
android:background="@drawable/action_bar_button"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/tabs_tray_list_divider"/>
|
||||
|
||||
</merge>
|
@ -1,59 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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/. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<RelativeLayout android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/browser_toolbar_height">
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/tabs_tray_bg_repeat">
|
||||
|
||||
<ImageButton android:id="@+id/add_tab"
|
||||
android:layout_width="@dimen/browser_toolbar_height"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:paddingTop="15dip"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="20dip"
|
||||
android:paddingRight="20dip"
|
||||
android:src="@drawable/tab_new"
|
||||
android:contentDescription="@string/new_tab"
|
||||
android:background="@drawable/action_bar_button"/>
|
||||
|
||||
<ImageButton android:id="@+id/remote_tabs"
|
||||
android:layout_width="@dimen/browser_toolbar_height"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:paddingTop="15dip"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="20dip"
|
||||
android:paddingRight="20dip"
|
||||
android:src="@drawable/remote_tabs_level"
|
||||
android:contentDescription="@string/remote_tabs"
|
||||
android:background="@drawable/action_bar_button"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/tabs_tray_list_divider"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<view class="org.mozilla.gecko.TabsPanel$TabsListContainer"
|
||||
android:id="@+id/list_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/tabs_tray_bg_repeat"/>
|
||||
|
||||
</merge>
|
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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/. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/tabs_tray_bg_repeat">
|
||||
|
||||
<ImageButton android:id="@+id/add_tab"
|
||||
android:layout_width="@dimen/browser_toolbar_height"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:paddingTop="15dip"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="20dip"
|
||||
android:paddingRight="20dip"
|
||||
android:src="@drawable/tab_new"
|
||||
android:contentDescription="@string/new_tab"
|
||||
android:background="@drawable/action_bar_button"/>
|
||||
|
||||
<ImageButton android:id="@+id/remote_tabs"
|
||||
android:layout_width="@dimen/browser_toolbar_height"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:paddingTop="15dip"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="20dip"
|
||||
android:paddingRight="20dip"
|
||||
android:src="@drawable/remote_tabs_level"
|
||||
android:contentDescription="@string/remote_tabs"
|
||||
android:background="@drawable/action_bar_button"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/tabs_tray_list_divider"/>
|
||||
|
||||
</merge>
|
@ -5,53 +5,10 @@
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<RelativeLayout android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/browser_toolbar_height">
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/tabs_tray_bg_repeat">
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1.0"
|
||||
style="@style/TabRowTextAppearance"
|
||||
android:gravity="center_vertical"
|
||||
android:padding="10dip"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<ImageButton android:id="@+id/remote_tabs"
|
||||
android:layout_width="@dimen/browser_toolbar_height"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:paddingTop="15dip"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="20dip"
|
||||
android:paddingRight="20dip"
|
||||
android:src="@drawable/remote_tabs_level"
|
||||
android:contentDescription="@string/remote_tabs"
|
||||
android:background="@drawable/action_bar_button"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageButton android:id="@+id/add_tab"
|
||||
android:layout_width="@dimen/browser_toolbar_height"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:paddingTop="15dip"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="20dip"
|
||||
android:paddingRight="20dip"
|
||||
android:src="@drawable/tab_new"
|
||||
android:contentDescription="@string/new_tab"
|
||||
android:background="@drawable/action_bar_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/tabs_tray_list_divider"/>
|
||||
|
||||
</RelativeLayout>
|
||||
<view class="org.mozilla.gecko.TabsPanel$TabsPanelToolbar"
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/browser_toolbar_height"/>
|
||||
|
||||
<view class="org.mozilla.gecko.TabsPanel$TabsListContainer"
|
||||
android:id="@+id/list_container"
|
||||
|
51
mobile/android/base/resources/layout/tabs_panel_toolbar.xml
Normal file
51
mobile/android/base/resources/layout/tabs_panel_toolbar.xml
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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/. -->
|
||||
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/tabs_tray_bg_repeat">
|
||||
|
||||
<TextView android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1.0"
|
||||
style="@style/TabRowTextAppearance"
|
||||
android:gravity="center_vertical"
|
||||
android:padding="10dip"
|
||||
android:textSize="16sp"/>
|
||||
|
||||
<ImageButton android:id="@+id/remote_tabs"
|
||||
android:layout_width="@dimen/browser_toolbar_height"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:paddingTop="15dip"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="20dip"
|
||||
android:paddingRight="20dip"
|
||||
android:src="@drawable/remote_tabs_level"
|
||||
android:contentDescription="@string/remote_tabs"
|
||||
android:background="@drawable/action_bar_button"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageButton android:id="@+id/add_tab"
|
||||
android:layout_width="@dimen/browser_toolbar_height"
|
||||
android:layout_height="@dimen/browser_toolbar_height"
|
||||
android:paddingTop="15dip"
|
||||
android:paddingBottom="15dip"
|
||||
android:paddingLeft="20dip"
|
||||
android:paddingRight="20dip"
|
||||
android:src="@drawable/tab_new"
|
||||
android:contentDescription="@string/new_tab"
|
||||
android:background="@drawable/action_bar_button"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@drawable/tabs_tray_list_divider"/>
|
||||
|
||||
</merge>
|
Loading…
Reference in New Issue
Block a user