Bug 769001 - Site identity popup should have a max width on tablets. r=sriram

This commit is contained in:
Margaret Leibovic 2012-07-09 15:05:17 -07:00
parent dc6c283e2e
commit aa04f78e83
5 changed files with 102 additions and 6 deletions

View File

@ -310,6 +310,7 @@ RES_LAYOUT_LARGE = \
res/layout-large/gecko_app.xml \
res/layout-large/remote_tabs_child.xml \
res/layout-large/remote_tabs_group.xml \
res/layout-large/site_identity_popup.xml \
res/layout-large/tabs_panel_toolbar.xml \
res/layout-large/tabs_row.xml \
$(NULL)

View File

@ -61,7 +61,8 @@ public class SiteIdentityPopup extends PopupWindow {
private void init() {
setBackgroundDrawable(new BitmapDrawable());
setOutsideTouchable(true);
setWindowLayoutMode(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
setWindowLayoutMode(GeckoApp.mAppContext.isTablet() ? LayoutParams.WRAP_CONTENT : LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT);
LayoutInflater inflater = LayoutInflater.from(GeckoApp.mAppContext);
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.site_identity_popup, null);
@ -147,13 +148,21 @@ public class SiteIdentityPopup extends PopupWindow {
mSupplemental.setTextColor(mResources.getColor(R.color.identity_identified));
}
// Position the mArrow according to lock position
int offset = 0;
if (GeckoApp.mAppContext.isTablet()) {
int popupWidth = mResources.getDimensionPixelSize(R.dimen.site_identity_popup_width);
int arrowWidth = mResources.getDimensionPixelSize(R.dimen.doorhanger_arrow_width);
// Double arrowWidth to leave extra space on the right side of the arrow
leftMargin = popupWidth - arrowWidth*2;
offset = 0 - popupWidth + arrowWidth*3/2 + v.getWidth()/2;
}
LayoutParams layoutParams = (LayoutParams) mArrow.getLayoutParams();
LayoutParams newLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
newLayoutParams.setMargins(leftMargin, layoutParams.topMargin, 0, 0);
mArrow.setLayoutParams(newLayoutParams);
// This will place the popup at the correct vertical position
showAsDropDown(v);
showAsDropDown(v, offset, 0);
}
}

View File

@ -0,0 +1,85 @@
<?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/. -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RelativeLayout android:layout_width="@dimen/site_identity_popup_width"
android:layout_height="wrap_content"
android:layout_marginTop="24dip"
android:layout_alignParentTop="true"
android:background="@drawable/doorhanger_popup_bg">
<LinearLayout android:id="@+id/identity_info"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="12dip"
android:background="@drawable/doorhanger_bg"
android:orientation="vertical">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary"
android:text="@string/identity_connected_to"/>
<TextView android:id="@+id/host"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary"
android:text="@string/identity_run_by"/>
<TextView android:id="@+id/owner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"/>
<TextView android:id="@+id/supplemental"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<TextView android:id="@+id/verifier"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary"/>
</LinearLayout>
<ImageView android:id="@+id/larry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="12dip"
android:layout_alignParentRight="true"/>
<TextView android:id="@+id/encrypted"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/identity_info"
android:padding="12dip"
android:gravity="right"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorPrimary"/>
</RelativeLayout>
<ImageView android:id="@+id/arrow"
android:layout_width="@dimen/doorhanger_arrow_width"
android:layout_height="16dip"
android:layout_marginTop="9dip"
android:layout_alignParentTop="true"
android:src="@drawable/doorhanger_arrow"
android:scaleType="fitXY"/>
</RelativeLayout>

View File

@ -75,11 +75,10 @@
</RelativeLayout>
<ImageView android:id="@+id/arrow"
android:layout_width="44dip"
android:layout_width="@dimen/doorhanger_arrow_width"
android:layout_height="16dip"
android:layout_marginTop="9dip"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:src="@drawable/doorhanger_arrow"
android:scaleType="fitXY"/>

View File

@ -15,5 +15,7 @@
<dimen name="remote_tab_group_row_height">26dp</dimen>
<dimen name="tabs_list_divider_height">2dp</dimen>
<dimen name="tabs_counter_size">22sp</dimen>
<dimen name="site_identity_popup_width">400dp</dimen>
<dimen name="doorhanger_arrow_width">44dp</dimen>
</resources>