diff options
| author | 2017-04-24 20:45:54 +0000 | |
|---|---|---|
| committer | 2017-04-24 20:45:58 +0000 | |
| commit | ffef2ad2b0cd45e71357a49e5f43a8636a29e43e (patch) | |
| tree | 720922fedc87d2ef5973a6dfe5335c7f27e445cb | |
| parent | e4964118c6f906d1529e00f241b3df9947102c3b (diff) | |
| parent | 4711ed9f9f8c4a320c66f2a277817acfea127703 (diff) | |
Merge "Replaced getUrl() by getWebDomain()." into oc-dev
| -rw-r--r-- | api/current.txt | 5 | ||||
| -rw-r--r-- | api/system-current.txt | 5 | ||||
| -rw-r--r-- | api/test-current.txt | 5 | ||||
| -rw-r--r-- | core/java/android/app/assist/AssistStructure.java | 39 | ||||
| -rw-r--r-- | core/java/android/view/ViewStructure.java | 12 |
5 files changed, 46 insertions, 20 deletions
diff --git a/api/current.txt b/api/current.txt index f1be1783202c..8baca126033a 100644 --- a/api/current.txt +++ b/api/current.txt @@ -6660,8 +6660,8 @@ package android.app.assist { method public int getTextStyle(); method public int getTop(); method public android.graphics.Matrix getTransformation(); - method public java.lang.String getUrl(); method public int getVisibility(); + method public java.lang.String getWebDomain(); method public int getWidth(); method public boolean isAccessibilityFocused(); method public boolean isActivated(); @@ -46592,8 +46592,9 @@ package android.view { method public abstract void setTextLines(int[], int[]); method public abstract void setTextStyle(float, int, int, int); method public abstract void setTransformation(android.graphics.Matrix); - method public abstract void setUrl(java.lang.String); + method public abstract deprecated void setUrl(java.lang.String); method public abstract void setVisibility(int); + method public abstract void setWebDomain(java.lang.String); } public static abstract class ViewStructure.HtmlInfo { diff --git a/api/system-current.txt b/api/system-current.txt index 4f26fadd307f..5945abc802a0 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -6905,8 +6905,8 @@ package android.app.assist { method public int getTextStyle(); method public int getTop(); method public android.graphics.Matrix getTransformation(); - method public java.lang.String getUrl(); method public int getVisibility(); + method public java.lang.String getWebDomain(); method public int getWidth(); method public boolean isAccessibilityFocused(); method public boolean isActivated(); @@ -50170,8 +50170,9 @@ package android.view { method public abstract void setTextLines(int[], int[]); method public abstract void setTextStyle(float, int, int, int); method public abstract void setTransformation(android.graphics.Matrix); - method public abstract void setUrl(java.lang.String); + method public abstract deprecated void setUrl(java.lang.String); method public abstract void setVisibility(int); + method public abstract void setWebDomain(java.lang.String); } public static abstract class ViewStructure.HtmlInfo { diff --git a/api/test-current.txt b/api/test-current.txt index 776944693e3d..eac5b8028f99 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -6690,8 +6690,8 @@ package android.app.assist { method public int getTextStyle(); method public int getTop(); method public android.graphics.Matrix getTransformation(); - method public java.lang.String getUrl(); method public int getVisibility(); + method public java.lang.String getWebDomain(); method public int getWidth(); method public boolean isAccessibilityFocused(); method public boolean isActivated(); @@ -46967,8 +46967,9 @@ package android.view { method public abstract void setTextLines(int[], int[]); method public abstract void setTextStyle(float, int, int, int); method public abstract void setTransformation(android.graphics.Matrix); - method public abstract void setUrl(java.lang.String); + method public abstract deprecated void setUrl(java.lang.String); method public abstract void setVisibility(int); + method public abstract void setWebDomain(java.lang.String); } public static abstract class ViewStructure.HtmlInfo { diff --git a/core/java/android/app/assist/AssistStructure.java b/core/java/android/app/assist/AssistStructure.java index ca74d540fbd7..7c1bcf08ad63 100644 --- a/core/java/android/app/assist/AssistStructure.java +++ b/core/java/android/app/assist/AssistStructure.java @@ -6,6 +6,7 @@ import android.app.Activity; import android.content.ComponentName; import android.graphics.Matrix; import android.graphics.Rect; +import android.net.Uri; import android.os.BadParcelableException; import android.os.Binder; import android.os.Bundle; @@ -666,7 +667,7 @@ public class AssistStructure implements Parcelable { ViewNodeText mText; int mInputType; - String mUrl; + String mWebDomain; Bundle mExtras; LocaleList mLocaleList; @@ -743,7 +744,7 @@ public class AssistStructure implements Parcelable { mInputType = in.readInt(); } if ((flags&FLAGS_HAS_URL) != 0) { - mUrl = in.readString(); + mWebDomain = in.readString(); } if ((flags&FLAGS_HAS_LOCALE_LIST) != 0) { mLocaleList = in.readParcelable(null); @@ -805,7 +806,7 @@ public class AssistStructure implements Parcelable { if (mInputType != 0) { flags |= FLAGS_HAS_INPUT_TYPE; } - if (mUrl != null) { + if (mWebDomain != null) { flags |= FLAGS_HAS_URL; } if (mLocaleList != null) { @@ -900,7 +901,7 @@ public class AssistStructure implements Parcelable { out.writeInt(mInputType); } if ((flags&FLAGS_HAS_URL) != 0) { - out.writeString(mUrl); + out.writeString(mWebDomain); } if ((flags&FLAGS_HAS_LOCALE_LIST) != 0) { out.writeParcelable(mLocaleList, 0); @@ -1237,17 +1238,20 @@ public class AssistStructure implements Parcelable { } /** - * Returns the URL represented by this view. + * Returns the domain of the HTML document represented by this view. * * <p>Typically used when the view associated with the view is a container for an HTML * document. * * <strong>WARNING:</strong> a {@link android.service.autofill.AutofillService} should only - * use this URL for Autofill purposes when it trusts the app generating it (i.e., the app + * use this domain for Autofill purposes when it trusts the app generating it (i.e., the app * defined by {@link AssistStructure#getActivityComponent()}). + * + * @return domain-only part of the document. For example, if the full URL is + * {@code http://my.site/login?user=my_user}, it returns {@code my.site}. */ - @Nullable public String getUrl() { - return mUrl; + @Nullable public String getWebDomain() { + return mWebDomain; } /** @@ -1724,7 +1728,18 @@ public class AssistStructure implements Parcelable { @Override public void setUrl(String url) { - mNode.mUrl = url; + if (url == null) return; + + setWebDomain(url); + } + + @Override + public void setWebDomain(@Nullable String domain) { + if (domain == null) { + mNode.mWebDomain = null; + return; + } + mNode.mWebDomain = Uri.parse(domain).getHost(); } @Override @@ -1946,9 +1961,9 @@ public class AssistStructure implements Parcelable { Log.i(TAG, prefix + " Text color fg: #" + Integer.toHexString(node.getTextColor()) + ", bg: #" + Integer.toHexString(node.getTextBackgroundColor())); } - CharSequence url = node.getUrl(); - if (url != null) { - Log.i(TAG, prefix + " URL: " + url); + String webDomain = node.getWebDomain(); + if (webDomain != null) { + Log.i(TAG, prefix + " Web domain: " + webDomain); } HtmlInfo htmlInfo = node.getHtmlInfo(); if (htmlInfo != null) { diff --git a/core/java/android/view/ViewStructure.java b/core/java/android/view/ViewStructure.java index 435610e648cb..387a9ce41f90 100644 --- a/core/java/android/view/ViewStructure.java +++ b/core/java/android/view/ViewStructure.java @@ -362,11 +362,19 @@ public abstract class ViewStructure { public abstract AutofillId getAutofillId(); /** - * Sets the URL represented by this node. + * @deprecated - use {@link #setWebDomain(String)} instead. + */ + @Deprecated + public abstract void setUrl(String url); + + /** + * Sets the Web domain represented by this node. * * <p>Typically used when the view is a container for an HTML document. + * + * @param domain URL representing the domain; only the host part will be used. */ - public abstract void setUrl(String url); + public abstract void setWebDomain(@Nullable String domain); /** * Sets the the list of locales associated with this node. |