public ToolbarDisplayLayout(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(HORIZONTAL); mActivity = (BrowserApp) context; LayoutInflater.from(context).inflate(R.layout.toolbar_display_layout, this); mTitle = (ThemedTextView) findViewById(R.id.url_bar_title); mTitlePadding = mTitle.getPaddingRight(); final Resources res = getResources(); mUrlColor = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_urltext)); mBlockedColor = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_blockedtext)); mDomainColor = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_domaintext)); mPrivateDomainColor = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_domaintext_private)); mFavicon = (ImageButton) findViewById(R.id.favicon); mSiteSecurity = (ImageButton) findViewById(R.id.site_security); if (HardwareUtils.isTablet()) { mSiteSecurity.setVisibility(View.VISIBLE); // 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); } mFaviconSize = Math.round(Favicons.browserToolbarFaviconSize); } mSiteSecurityVisible = (mSiteSecurity.getVisibility() == View.VISIBLE); mSiteIdentityPopup = new SiteIdentityPopup(mActivity); mSiteIdentityPopup.setAnchor(this); mSiteIdentityPopup.setOnVisibilityChangeListener(mActivity); mStop = (ImageButton) findViewById(R.id.stop); mPageActionLayout = (PageActionLayout) findViewById(R.id.page_action_layout); }
public ToolbarDisplayLayout(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(HORIZONTAL); mActivity = (BrowserApp) context; LayoutInflater.from(context).inflate(R.layout.toolbar_display_layout, this); mTitle = (ThemedTextView) findViewById(R.id.url_bar_title); mTitlePadding = mTitle.getPaddingRight(); final Resources res = getResources(); mUrlColor = new ForegroundColorSpan(res.getColor(R.color.url_bar_urltext)); mBlockedColor = new ForegroundColorSpan(res.getColor(R.color.url_bar_blockedtext)); mDomainColor = new ForegroundColorSpan(res.getColor(R.color.url_bar_domaintext)); 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)) { 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); // TODO: Override a common static value when new tablet is standard. lp.rightMargin = res.getDimensionPixelSize(R.dimen.new_tablet_site_security_right_margin); mSiteSecurity.setLayoutParams(lp); final int siteSecurityVerticalPadding = res.getDimensionPixelSize(R.dimen.new_tablet_site_security_padding_vertical); final int siteSecurityHorizontalPadding = res.getDimensionPixelSize(R.dimen.new_tablet_site_security_padding_horizontal); mSiteSecurity.setPadding( siteSecurityHorizontalPadding, siteSecurityVerticalPadding, siteSecurityHorizontalPadding, 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); } mFaviconSize = Math.round(Favicons.browserToolbarFaviconSize); } mSiteSecurityVisible = (mSiteSecurity.getVisibility() == View.VISIBLE); mSiteIdentityPopup = new SiteIdentityPopup(mActivity); mSiteIdentityPopup.setAnchor(mSiteSecurity); mStop = (ImageButton) findViewById(R.id.stop); mPageActionLayout = (PageActionLayout) findViewById(R.id.page_action_layout); }