mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1250671 - Show full URL in URL bar on tablets. r=mcomella, a=ritu
MozReview-Commit-ID: 9zEh5jNm1Tr
This commit is contained in:
parent
309647569c
commit
052d9ab0c1
@ -22,15 +22,14 @@ import org.mozilla.gecko.animation.PropertyAnimator;
|
|||||||
import org.mozilla.gecko.animation.ViewHelper;
|
import org.mozilla.gecko.animation.ViewHelper;
|
||||||
import org.mozilla.gecko.toolbar.BrowserToolbarTabletBase.ForwardButtonAnimation;
|
import org.mozilla.gecko.toolbar.BrowserToolbarTabletBase.ForwardButtonAnimation;
|
||||||
import org.mozilla.gecko.util.ColorUtils;
|
import org.mozilla.gecko.util.ColorUtils;
|
||||||
|
import org.mozilla.gecko.util.HardwareUtils;
|
||||||
import org.mozilla.gecko.util.StringUtils;
|
import org.mozilla.gecko.util.StringUtils;
|
||||||
import org.mozilla.gecko.widget.themed.ThemedLinearLayout;
|
import org.mozilla.gecko.widget.themed.ThemedLinearLayout;
|
||||||
import org.mozilla.gecko.widget.themed.ThemedTextView;
|
import org.mozilla.gecko.widget.themed.ThemedTextView;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.content.ContextCompat;
|
|
||||||
import android.text.Spannable;
|
import android.text.Spannable;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.SpannableStringBuilder;
|
import android.text.SpannableStringBuilder;
|
||||||
@ -125,7 +124,11 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout {
|
|||||||
// Icon used for about:home
|
// Icon used for about:home
|
||||||
private static final int LEVEL_SEARCH_ICON = 999;
|
private static final int LEVEL_SEARCH_ICON = 999;
|
||||||
|
|
||||||
private final ForegroundColorSpan mBlockedColor;
|
private final ForegroundColorSpan mUrlColorSpan;
|
||||||
|
private final ForegroundColorSpan mBlockedColorSpan;
|
||||||
|
private final ForegroundColorSpan mDomainColorSpan;
|
||||||
|
private final ForegroundColorSpan mPrivateDomainColorSpan;
|
||||||
|
private final ForegroundColorSpan mCertificateOwnerColorSpan;
|
||||||
|
|
||||||
public ToolbarDisplayLayout(Context context, AttributeSet attrs) {
|
public ToolbarDisplayLayout(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@ -138,7 +141,11 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout {
|
|||||||
mTitle = (ThemedTextView) findViewById(R.id.url_bar_title);
|
mTitle = (ThemedTextView) findViewById(R.id.url_bar_title);
|
||||||
mTitlePadding = mTitle.getPaddingRight();
|
mTitlePadding = mTitle.getPaddingRight();
|
||||||
|
|
||||||
mBlockedColor = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_blockedtext));
|
mUrlColorSpan = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_urltext));
|
||||||
|
mBlockedColorSpan = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_blockedtext));
|
||||||
|
mDomainColorSpan = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_domaintext));
|
||||||
|
mPrivateDomainColorSpan = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.url_bar_domaintext_private));
|
||||||
|
mCertificateOwnerColorSpan = new ForegroundColorSpan(ColorUtils.getColor(context, R.color.affirmative_green));
|
||||||
|
|
||||||
mSiteSecurity = (ImageButton) findViewById(R.id.site_security);
|
mSiteSecurity = (ImageButton) findViewById(R.id.site_security);
|
||||||
|
|
||||||
@ -249,7 +256,7 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout {
|
|||||||
final String title = tab.getDisplayTitle();
|
final String title = tab.getDisplayTitle();
|
||||||
|
|
||||||
final SpannableStringBuilder builder = new SpannableStringBuilder(title);
|
final SpannableStringBuilder builder = new SpannableStringBuilder(title);
|
||||||
builder.setSpan(mBlockedColor, 0, title.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
builder.setSpan(mBlockedColorSpan, 0, title.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||||
|
|
||||||
setTitle(builder);
|
setTitle(builder);
|
||||||
setContentDescription(null);
|
setContentDescription(null);
|
||||||
@ -271,6 +278,18 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout {
|
|||||||
|
|
||||||
final SiteIdentity siteIdentity = tab.getSiteIdentity();
|
final SiteIdentity siteIdentity = tab.getSiteIdentity();
|
||||||
if (siteIdentity.hasOwner()) {
|
if (siteIdentity.hasOwner()) {
|
||||||
|
// Show Owner of EV certificate as title
|
||||||
|
updateTitleFromSiteIdentity(siteIdentity);
|
||||||
|
} else if (!HardwareUtils.isTablet() && !TextUtils.isEmpty(baseDomain)) {
|
||||||
|
// Show just the base domain as title
|
||||||
|
setTitle(baseDomain);
|
||||||
|
} else {
|
||||||
|
// Display full URL as title
|
||||||
|
updateAndColorTitleFromFullURL(strippedURL, baseDomain, tab.isPrivate());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTitleFromSiteIdentity(SiteIdentity siteIdentity) {
|
||||||
final String title;
|
final String title;
|
||||||
|
|
||||||
if (siteIdentity.hasCountry()) {
|
if (siteIdentity.hasCountry()) {
|
||||||
@ -279,17 +298,26 @@ public class ToolbarDisplayLayout extends ThemedLinearLayout {
|
|||||||
title = siteIdentity.getOwner();
|
title = siteIdentity.getOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
final int color = ContextCompat.getColor(getContext(), R.color.affirmative_green);
|
|
||||||
|
|
||||||
final SpannableString spannable = new SpannableString(title);
|
final SpannableString spannable = new SpannableString(title);
|
||||||
spannable.setSpan(new ForegroundColorSpan(color), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
spannable.setSpan(mCertificateOwnerColorSpan, 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||||
|
|
||||||
setTitle(spannable);
|
setTitle(spannable);
|
||||||
} else if (!TextUtils.isEmpty(baseDomain)) {
|
|
||||||
setTitle(baseDomain);
|
|
||||||
} else {
|
|
||||||
setTitle(strippedURL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateAndColorTitleFromFullURL(String url, String baseDomain, boolean isPrivate) {
|
||||||
|
int index = url.indexOf(baseDomain);
|
||||||
|
if (index == -1) {
|
||||||
|
setTitle(url);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final SpannableStringBuilder builder = new SpannableStringBuilder(url);
|
||||||
|
|
||||||
|
builder.setSpan(mUrlColorSpan, 0, url.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||||
|
builder.setSpan(isPrivate ? mPrivateDomainColorSpan : mDomainColorSpan,
|
||||||
|
index, index + baseDomain.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE);
|
||||||
|
|
||||||
|
setTitle(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String stripAboutReaderURL(final String url) {
|
private String stripAboutReaderURL(final String url) {
|
||||||
|
@ -110,6 +110,9 @@
|
|||||||
<color name="textbox_stroke">#000</color>
|
<color name="textbox_stroke">#000</color>
|
||||||
<color name="textbox_stroke_disabled">#666</color>
|
<color name="textbox_stroke_disabled">#666</color>
|
||||||
|
|
||||||
|
<color name="url_bar_urltext">#A6A6A6</color>
|
||||||
|
<color name="url_bar_domaintext">#000</color>
|
||||||
|
<color name="url_bar_domaintext_private">#FFF</color>
|
||||||
<color name="url_bar_blockedtext">#b14646</color>
|
<color name="url_bar_blockedtext">#b14646</color>
|
||||||
<color name="url_bar_shadow">#12000000</color>
|
<color name="url_bar_shadow">#12000000</color>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user