Commit 1e16becf authored by Christian Dullweber's avatar Christian Dullweber Committed by Commit Bot

Use truncated URL in new page info UI

Use a scheme and path-less URL in page info. Toggle to full URL display
on click.

Screenshot: https://crbug.com/1077766#27
Bug: 1077766
Change-Id: If3f50b513de84fd2a54eef9438153c00e47bc650
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2375367Reviewed-by: default avatarEhimare Okoyomon <eokoyomon@chromium.org>
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802670}
parent b8bc5dc3
...@@ -22,6 +22,16 @@ ...@@ -22,6 +22,16 @@
android:paddingEnd="@dimen/page_info_popup_padding_sides" android:paddingEnd="@dimen/page_info_popup_padding_sides"
android:paddingStart="@dimen/page_info_popup_padding_sides" > android:paddingStart="@dimen/page_info_popup_padding_sides" >
<TextView
android:id="@+id/page_info_truncated_url"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lineSpacingExtra="6dp"
android:paddingTop="16dp"
android:textAlignment="center"
android:textAppearance="@style/TextAppearance.TextLarge.Primary" />
<view class="org.chromium.components.page_info.PageInfoView$ElidedUrlTextView" <view class="org.chromium.components.page_info.PageInfoView$ElidedUrlTextView"
android:id="@+id/page_info_url" android:id="@+id/page_info_url"
android:layout_width="match_parent" android:layout_width="match_parent"
......
...@@ -44,6 +44,7 @@ import org.chromium.components.page_info.PageInfoView.ConnectionInfoParams; ...@@ -44,6 +44,7 @@ import org.chromium.components.page_info.PageInfoView.ConnectionInfoParams;
import org.chromium.components.page_info.PageInfoView.PageInfoViewParams; import org.chromium.components.page_info.PageInfoView.PageInfoViewParams;
import org.chromium.components.security_state.ConnectionSecurityLevel; import org.chromium.components.security_state.ConnectionSecurityLevel;
import org.chromium.components.security_state.SecurityStateModel; import org.chromium.components.security_state.SecurityStateModel;
import org.chromium.components.url_formatter.SchemeDisplay;
import org.chromium.components.url_formatter.UrlFormatter; import org.chromium.components.url_formatter.UrlFormatter;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.content_public.browser.WebContentsObserver; import org.chromium.content_public.browser.WebContentsObserver;
...@@ -55,12 +56,11 @@ import org.chromium.ui.modaldialog.ModalDialogProperties; ...@@ -55,12 +56,11 @@ import org.chromium.ui.modaldialog.ModalDialogProperties;
import org.chromium.ui.modaldialog.ModalDialogProperties.ButtonType; import org.chromium.ui.modaldialog.ModalDialogProperties.ButtonType;
import org.chromium.ui.modelutil.PropertyModel; import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.ui.util.ColorUtils; import org.chromium.ui.util.ColorUtils;
import org.chromium.url.URI; import org.chromium.url.GURL;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.net.URISyntaxException;
/** /**
* Java side of Android implementation of the page info UI. * Java side of Android implementation of the page info UI.
...@@ -189,11 +189,8 @@ public class PageInfoController ...@@ -189,11 +189,8 @@ public class PageInfoController
// This can happen if an invalid chrome-distiller:// url was entered. // This can happen if an invalid chrome-distiller:// url was entered.
if (mFullUrl == null) mFullUrl = ""; if (mFullUrl == null) mFullUrl = "";
try { GURL url = new GURL(mFullUrl);
mIsInternalPage = UrlUtilities.isInternalScheme(new URI(mFullUrl)); mIsInternalPage = UrlUtilities.isInternalScheme(url);
} catch (URISyntaxException e) {
// Ignore exception since this is for displaying some specific content on page info.
}
String displayUrl = UrlFormatter.formatUrlForDisplayOmitUsernamePassword(mFullUrl); String displayUrl = UrlFormatter.formatUrlForDisplayOmitUsernamePassword(mFullUrl);
if (mDelegate.isShowingOfflinePage()) { if (mDelegate.isShowingOfflinePage()) {
...@@ -223,6 +220,9 @@ public class PageInfoController ...@@ -223,6 +220,9 @@ public class PageInfoController
viewParams.urlOriginLength = mUrlOriginLength; viewParams.urlOriginLength = mUrlOriginLength;
autocompleteSchemeClassifier.destroy(); autocompleteSchemeClassifier.destroy();
viewParams.truncatedUrl =
UrlFormatter.formatUrlForSecurityDisplay(url, SchemeDisplay.OMIT_HTTP_AND_HTTPS);
if (mDelegate.isSiteSettingsAvailable()) { if (mDelegate.isSiteSettingsAvailable()) {
viewParams.siteSettingsButtonClickCallback = () -> { viewParams.siteSettingsButtonClickCallback = () -> {
// Delay while the dialog closes. // Delay while the dialog closes.
......
...@@ -134,7 +134,9 @@ public class PageInfoView extends FrameLayout implements OnClickListener, OnLong ...@@ -134,7 +134,9 @@ public class PageInfoView extends FrameLayout implements OnClickListener, OnLong
*/ */
public void toggleTruncation() { public void toggleTruncation() {
mIsShowingTruncatedText = !mIsShowingTruncatedText; mIsShowingTruncatedText = !mIsShowingTruncatedText;
updateMaxLines(); if (mFullLinesToDisplay != null) {
updateMaxLines();
}
} }
private boolean updateMaxLines() { private boolean updateMaxLines() {
...@@ -172,6 +174,7 @@ public class PageInfoView extends FrameLayout implements OnClickListener, OnLong ...@@ -172,6 +174,7 @@ public class PageInfoView extends FrameLayout implements OnClickListener, OnLong
public CharSequence url; public CharSequence url;
public CharSequence previewLoadOriginalMessage; public CharSequence previewLoadOriginalMessage;
public int urlOriginLength; public int urlOriginLength;
public CharSequence truncatedUrl;
} }
/** Parameters to configure the permission info section */ /** Parameters to configure the permission info section */
......
...@@ -8,6 +8,7 @@ import android.content.Context; ...@@ -8,6 +8,7 @@ import android.content.Context;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
...@@ -21,6 +22,7 @@ public class PageInfoViewV2 extends PageInfoView { ...@@ -21,6 +22,7 @@ public class PageInfoViewV2 extends PageInfoView {
private PageInfoRowView mConnectionRow; private PageInfoRowView mConnectionRow;
private PageInfoRowView mPermissionsRow; private PageInfoRowView mPermissionsRow;
private PageInfoRowView mCookiesRow; private PageInfoRowView mCookiesRow;
private TextView mTruncatedUrlTitle;
public PageInfoViewV2(Context context, PageInfoView.PageInfoViewParams params) { public PageInfoViewV2(Context context, PageInfoView.PageInfoViewParams params) {
super(context); super(context);
...@@ -38,8 +40,19 @@ public class PageInfoViewV2 extends PageInfoView { ...@@ -38,8 +40,19 @@ public class PageInfoViewV2 extends PageInfoView {
@Override @Override
protected void initUrlTitle(PageInfoView.PageInfoViewParams params) { protected void initUrlTitle(PageInfoView.PageInfoViewParams params) {
super.initUrlTitle(params); super.initUrlTitle(params);
// Adjust the mUrlTitle // Adjust the mUrlTitle for displaying the non-truncated URL.
mUrlTitle.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); mUrlTitle.setTextAlignment(View.TEXT_ALIGNMENT_CENTER);
mUrlTitle.setAlpha(1.0f);
mUrlTitle.setVisibility(GONE);
mUrlTitle.toggleTruncation();
// Use a separate view for truncated URL display.
mTruncatedUrlTitle = findViewById(R.id.page_info_truncated_url);
mTruncatedUrlTitle.setText(params.truncatedUrl);
if (params.urlTitleLongClickCallback != null) {
mTruncatedUrlTitle.setOnLongClickListener(this);
}
initializePageInfoViewChild(
mTruncatedUrlTitle, params.urlTitleShown, 0f, params.urlTitleClickCallback);
} }
@Override @Override
...@@ -78,12 +91,19 @@ public class PageInfoViewV2 extends PageInfoView { ...@@ -78,12 +91,19 @@ public class PageInfoViewV2 extends PageInfoView {
return mCookiesRow; return mCookiesRow;
} }
@Override
public void toggleUrlTruncation() {
mUrlTitle.setVisibility(mTruncatedUrlTitle.getVisibility());
mTruncatedUrlTitle.setVisibility(mUrlTitle.getVisibility() == VISIBLE ? GONE : VISIBLE);
}
/** /**
* Create a list of all the views which we want to individually fade in. * Create a list of all the views which we want to individually fade in.
*/ */
@Override @Override
protected List<View> collectAnimatableViews() { protected List<View> collectAnimatableViews() {
return Arrays.asList(mUrlTitle, mPreviewMessage, mPreviewLoadOriginal, mPreviewSeparator, // TODO(crbug.com/1077766): Sort and use rows instead of the rowWrapper.
mInstantAppButton, mRowWrapper, mSiteSettingsButton); return Arrays.asList(mTruncatedUrlTitle, mPreviewMessage, mPreviewLoadOriginal,
mPreviewSeparator, mInstantAppButton, mRowWrapper, mSiteSettingsButton);
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment