Bug 1071267 - Part 2: Always display site security icon on new tablet.

This commit is contained in:
Michael Comella 2014-10-08 17:48:29 -07:00
Родитель df090e95e3
Коммит ed3b4f3c5e
5 изменённых файлов: 64 добавлений и 10 удалений

Просмотреть файл

@ -0,0 +1,14 @@
<?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/. -->
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:maxLevel="0" android:drawable="@drawable/new_tablet_site_security_unknown"/>
<item android:maxLevel="1" android:drawable="@drawable/lock_identified"/>
<item android:maxLevel="2" android:drawable="@drawable/lock_verified"/>
<item android:maxLevel="3" android:drawable="@drawable/shield"/>
<item android:maxLevel="4" android:drawable="@drawable/warning"/>
</level-list>

Просмотреть файл

@ -0,0 +1,12 @@
<?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/. -->
<!-- The favicon drawable is not the same dimensions as the site security
lock icons so we offset it using this drawable to compensate. -->
<inset
xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/favicon"
android:insetTop="@dimen/new_tablet_site_security_unknown_inset_top"
android:insetBottom="@dimen/new_tablet_site_security_unknown_inset_bottom"/>

Просмотреть файл

@ -13,13 +13,14 @@
android:paddingRight="4dip"
android:layout_gravity="center_vertical"/>
<!-- The toolbar elements are not the same height so we add a bottom margin here to align its bottom. -->
<!-- The site security icon is misaligned with the page title so
we add a bottom margin to align their bottoms. -->
<ImageButton android:id="@+id/site_security"
style="@style/UrlBar.ImageButton"
android:layout_width="@dimen/browser_toolbar_lock_width"
android:layout_width="@dimen/browser_toolbar_site_security_width"
android:scaleType="fitCenter"
android:layout_marginRight="4dip"
android:layout_marginBottom="1dp"
android:layout_marginBottom="@dimen/site_security_bottom_margin"
android:src="@drawable/site_security_level"
android:contentDescription="@string/site_security"
android:visibility="gone"/>

Просмотреть файл

@ -11,7 +11,7 @@
<dimen name="browser_toolbar_height">48dp</dimen>
<dimen name="browser_toolbar_button_padding">12dp</dimen>
<dimen name="browser_toolbar_icon_width">48dp</dimen>
<dimen name="browser_toolbar_lock_width">12dp</dimen>
<dimen name="browser_toolbar_site_security_width">12dp</dimen>
<!-- favicon_size includes 4dp of right padding. We can't use margin (which would allow us to
specify the actual size) because that would decrease the size of our hit target. -->
<dimen name="browser_toolbar_favicon_size">21.33dip</dimen>
@ -22,6 +22,9 @@
<dimen name="new_tablet_tab_strip_item_margin">-30dp</dimen>
<dimen name="new_tablet_tab_strip_favicon_size">16dp</dimen>
<dimen name="new_tablet_forward_default_offset">-6dp</dimen>
<dimen name="new_tablet_site_security_height">60dp</dimen>
<dimen name="new_tablet_site_security_width">18dp</dimen>
<dimen name="new_tablet_site_security_padding_vertical">21dp</dimen>
<dimen name="new_tablet_browser_toolbar_height">60dp</dimen>
<dimen name="new_tablet_browser_toolbar_menu_item_width">56dp</dimen>
<!-- Padding combines with an 18dp image to form the menu item width and height. -->
@ -45,6 +48,12 @@
value.-->
<dimen name="favicon_largest_interesting_size">32dp</dimen>
<!-- Site security icon -->
<!-- If one of these values changes, they all should. -->
<dimen name="site_security_bottom_margin">.5dp</dimen>
<dimen name="new_tablet_site_security_unknown_inset_top">1dp</dimen>
<dimen name="new_tablet_site_security_unknown_inset_bottom">-1dp</dimen>
<!-- Page Row height -->
<dimen name="page_row_height">64dp</dimen>

Просмотреть файл

@ -41,6 +41,7 @@ import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
/**
* {@code ToolbarDisplayLayout} is the UI for when the toolbar is in
@ -147,10 +148,27 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout
mPrivateDomainColor = new ForegroundColorSpan(res.getColor(R.color.url_bar_domaintext_private));
mFavicon = (ImageButton) findViewById(R.id.favicon);
mSiteSecurity = (ImageButton) findViewById(R.id.site_security);
if (NewTabletUI.isEnabled(context)) {
// We don't show favicons in the toolbar on new tablet.
// TODO: removeView(mFavicon);
mFavicon.setVisibility(View.GONE);
mSiteSecurity.setVisibility(View.VISIBLE);
// TODO: Rename this resource and remove this call when new tablet is default.
mSiteSecurity.setImageResource(R.drawable.new_tablet_site_security_level);
// TODO: This can likely be set statically in resources when new tablet is default.
// Dynamically update parameters for new tablet.
final LinearLayout.LayoutParams lp =
(LinearLayout.LayoutParams) mSiteSecurity.getLayoutParams();
lp.height = res.getDimensionPixelSize(R.dimen.new_tablet_site_security_height);
lp.width = res.getDimensionPixelSize(R.dimen.new_tablet_site_security_width);
mSiteSecurity.setLayoutParams(lp);
final int siteSecurityVerticalPadding =
res.getDimensionPixelSize(R.dimen.new_tablet_site_security_padding_vertical);
mSiteSecurity.setPadding(0, siteSecurityVerticalPadding, 0, siteSecurityVerticalPadding);
// We don't show favicons in the toolbar on new tablet. Note that while we could
// null the favicon reference, we don't do so to avoid excessive null-checking.
removeView(mFavicon);
} else {
if (Versions.feature16Plus) {
mFavicon.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
@ -158,7 +176,6 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout
mFaviconSize = Math.round(res.getDimension(R.dimen.browser_toolbar_favicon_size));
}
mSiteSecurity = (ImageButton) findViewById(R.id.site_security);
mSiteSecurityVisible = (mSiteSecurity.getVisibility() == View.VISIBLE);
mSiteIdentityPopup = new SiteIdentityPopup(mActivity);
@ -200,7 +217,7 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout
}
});
float slideWidth = getResources().getDimension(R.dimen.browser_toolbar_lock_width);
float slideWidth = getResources().getDimension(R.dimen.browser_toolbar_site_security_width);
LayoutParams siteSecParams = (LayoutParams) mSiteSecurity.getLayoutParams();
final float scale = getResources().getDisplayMetrics().density;
@ -456,7 +473,8 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout
}
private void setSiteSecurityVisibility(boolean visible, EnumSet<UpdateFlags> flags) {
if (visible == mSiteSecurityVisible) {
// We don't hide site security on new tablets.
if (visible == mSiteSecurityVisible || NewTabletUI.isEnabled(getContext())) {
return;
}