* commit '4401943e7723e1ba09469df72db1f4e5b0306016': Fix issue #20654534: API Review: android.app.assist
This commit is contained in:
146
api/current.txt
146
api/current.txt
@@ -4016,79 +4016,6 @@ package android.app {
|
||||
field public java.lang.String serviceDetails;
|
||||
}
|
||||
|
||||
public deprecated class AssistContent {
|
||||
ctor public AssistContent();
|
||||
method public android.content.ClipData getClipData();
|
||||
method public android.os.Bundle getExtras();
|
||||
method public java.lang.String getStructuredData();
|
||||
method public android.net.Uri getWebUri();
|
||||
method public boolean isAppProvidedIntent();
|
||||
method public void setClipData(android.content.ClipData);
|
||||
method public void setIntent(android.content.Intent);
|
||||
method public void setStructuredData(java.lang.String);
|
||||
method public void setWebUri(android.net.Uri);
|
||||
}
|
||||
|
||||
public deprecated class AssistStructure {
|
||||
ctor public AssistStructure();
|
||||
method public android.content.ComponentName getActivityComponent();
|
||||
method public int getWindowNodeCount();
|
||||
}
|
||||
|
||||
public static class AssistStructure.ViewNode {
|
||||
method public android.app.AssistStructure.ViewNode getChildAt(int);
|
||||
method public int getChildCount();
|
||||
method public java.lang.String getClassName();
|
||||
method public java.lang.CharSequence getContentDescription();
|
||||
method public android.os.Bundle getExtras();
|
||||
method public int getHeight();
|
||||
method public java.lang.String getHint();
|
||||
method public int getId();
|
||||
method public java.lang.String getIdEntry();
|
||||
method public java.lang.String getIdPackage();
|
||||
method public java.lang.String getIdType();
|
||||
method public int getLeft();
|
||||
method public int getScrollX();
|
||||
method public int getScrollY();
|
||||
method public java.lang.CharSequence getText();
|
||||
method public int getTextBackgroundColor();
|
||||
method public int getTextColor();
|
||||
method public int getTextSelectionEnd();
|
||||
method public int getTextSelectionStart();
|
||||
method public float getTextSize();
|
||||
method public int getTextStyle();
|
||||
method public int getTop();
|
||||
method public int getVisibility();
|
||||
method public int getWidth();
|
||||
method public boolean isAccessibilityFocused();
|
||||
method public boolean isActivated();
|
||||
method public boolean isAssistBlocked();
|
||||
method public boolean isCheckable();
|
||||
method public boolean isChecked();
|
||||
method public boolean isClickable();
|
||||
method public boolean isContextClickable();
|
||||
method public boolean isEnabled();
|
||||
method public boolean isFocusable();
|
||||
method public boolean isFocused();
|
||||
method public boolean isLongClickable();
|
||||
method public boolean isSelected();
|
||||
field public static final int TEXT_COLOR_UNDEFINED = 1; // 0x1
|
||||
field public static final int TEXT_STYLE_BOLD = 1; // 0x1
|
||||
field public static final int TEXT_STYLE_ITALIC = 2; // 0x2
|
||||
field public static final int TEXT_STYLE_STRIKE_THRU = 8; // 0x8
|
||||
field public static final int TEXT_STYLE_UNDERLINE = 4; // 0x4
|
||||
}
|
||||
|
||||
public static class AssistStructure.WindowNode {
|
||||
method public int getDisplayId();
|
||||
method public int getHeight();
|
||||
method public int getLeft();
|
||||
method public android.app.AssistStructure.ViewNode getRootViewNode();
|
||||
method public java.lang.CharSequence getTitle();
|
||||
method public int getTop();
|
||||
method public int getWidth();
|
||||
}
|
||||
|
||||
public class DatePickerDialog extends android.app.AlertDialog implements android.widget.DatePicker.OnDateChangedListener android.content.DialogInterface.OnClickListener {
|
||||
ctor public DatePickerDialog(android.content.Context, android.app.DatePickerDialog.OnDateSetListener, int, int, int);
|
||||
ctor public DatePickerDialog(android.content.Context, int, android.app.DatePickerDialog.OnDateSetListener, int, int, int);
|
||||
@@ -5900,22 +5827,87 @@ package android.app.admin {
|
||||
|
||||
package android.app.assist {
|
||||
|
||||
public final class AssistContent extends android.app.AssistContent implements android.os.Parcelable {
|
||||
ctor public AssistContent(android.os.Parcel);
|
||||
public deprecated class AssistContent implements android.os.Parcelable {
|
||||
ctor public AssistContent();
|
||||
method public int describeContents();
|
||||
method public android.content.ClipData getClipData();
|
||||
method public android.os.Bundle getExtras();
|
||||
method public android.content.Intent getIntent();
|
||||
method public java.lang.String getStructuredData();
|
||||
method public android.net.Uri getWebUri();
|
||||
method public boolean isAppProvidedIntent();
|
||||
method public void setClipData(android.content.ClipData);
|
||||
method public void setIntent(android.content.Intent);
|
||||
method public void setStructuredData(java.lang.String);
|
||||
method public void setWebUri(android.net.Uri);
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.app.assist.AssistContent> CREATOR;
|
||||
}
|
||||
|
||||
public final class AssistStructure extends android.app.AssistStructure implements android.os.Parcelable {
|
||||
public class AssistStructure implements android.os.Parcelable {
|
||||
ctor public AssistStructure();
|
||||
method public int describeContents();
|
||||
method public android.app.AssistStructure.WindowNode getWindowNodeAt(int);
|
||||
method public android.content.ComponentName getActivityComponent();
|
||||
method public android.app.assist.AssistStructure.WindowNode getWindowNodeAt(int);
|
||||
method public int getWindowNodeCount();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.app.assist.AssistStructure> CREATOR;
|
||||
}
|
||||
|
||||
public static class AssistStructure.ViewNode {
|
||||
method public android.app.assist.AssistStructure.ViewNode getChildAt(int);
|
||||
method public int getChildCount();
|
||||
method public java.lang.String getClassName();
|
||||
method public java.lang.CharSequence getContentDescription();
|
||||
method public android.os.Bundle getExtras();
|
||||
method public int getHeight();
|
||||
method public java.lang.String getHint();
|
||||
method public int getId();
|
||||
method public java.lang.String getIdEntry();
|
||||
method public java.lang.String getIdPackage();
|
||||
method public java.lang.String getIdType();
|
||||
method public int getLeft();
|
||||
method public int getScrollX();
|
||||
method public int getScrollY();
|
||||
method public java.lang.CharSequence getText();
|
||||
method public int getTextBackgroundColor();
|
||||
method public int getTextColor();
|
||||
method public int getTextSelectionEnd();
|
||||
method public int getTextSelectionStart();
|
||||
method public float getTextSize();
|
||||
method public int getTextStyle();
|
||||
method public int getTop();
|
||||
method public int getVisibility();
|
||||
method public int getWidth();
|
||||
method public boolean isAccessibilityFocused();
|
||||
method public boolean isActivated();
|
||||
method public boolean isAssistBlocked();
|
||||
method public boolean isCheckable();
|
||||
method public boolean isChecked();
|
||||
method public boolean isClickable();
|
||||
method public boolean isContextClickable();
|
||||
method public boolean isEnabled();
|
||||
method public boolean isFocusable();
|
||||
method public boolean isFocused();
|
||||
method public boolean isLongClickable();
|
||||
method public boolean isSelected();
|
||||
field public static final int TEXT_COLOR_UNDEFINED = 1; // 0x1
|
||||
field public static final int TEXT_STYLE_BOLD = 1; // 0x1
|
||||
field public static final int TEXT_STYLE_ITALIC = 2; // 0x2
|
||||
field public static final int TEXT_STYLE_STRIKE_THRU = 8; // 0x8
|
||||
field public static final int TEXT_STYLE_UNDERLINE = 4; // 0x4
|
||||
}
|
||||
|
||||
public static class AssistStructure.WindowNode {
|
||||
method public int getDisplayId();
|
||||
method public int getHeight();
|
||||
method public int getLeft();
|
||||
method public android.app.assist.AssistStructure.ViewNode getRootViewNode();
|
||||
method public java.lang.CharSequence getTitle();
|
||||
method public int getTop();
|
||||
method public int getWidth();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.app.backup {
|
||||
|
||||
@@ -4112,79 +4112,6 @@ package android.app {
|
||||
field public java.lang.String serviceDetails;
|
||||
}
|
||||
|
||||
public deprecated class AssistContent {
|
||||
ctor public AssistContent();
|
||||
method public android.content.ClipData getClipData();
|
||||
method public android.os.Bundle getExtras();
|
||||
method public java.lang.String getStructuredData();
|
||||
method public android.net.Uri getWebUri();
|
||||
method public boolean isAppProvidedIntent();
|
||||
method public void setClipData(android.content.ClipData);
|
||||
method public void setIntent(android.content.Intent);
|
||||
method public void setStructuredData(java.lang.String);
|
||||
method public void setWebUri(android.net.Uri);
|
||||
}
|
||||
|
||||
public deprecated class AssistStructure {
|
||||
ctor public AssistStructure();
|
||||
method public android.content.ComponentName getActivityComponent();
|
||||
method public int getWindowNodeCount();
|
||||
}
|
||||
|
||||
public static class AssistStructure.ViewNode {
|
||||
method public android.app.AssistStructure.ViewNode getChildAt(int);
|
||||
method public int getChildCount();
|
||||
method public java.lang.String getClassName();
|
||||
method public java.lang.CharSequence getContentDescription();
|
||||
method public android.os.Bundle getExtras();
|
||||
method public int getHeight();
|
||||
method public java.lang.String getHint();
|
||||
method public int getId();
|
||||
method public java.lang.String getIdEntry();
|
||||
method public java.lang.String getIdPackage();
|
||||
method public java.lang.String getIdType();
|
||||
method public int getLeft();
|
||||
method public int getScrollX();
|
||||
method public int getScrollY();
|
||||
method public java.lang.CharSequence getText();
|
||||
method public int getTextBackgroundColor();
|
||||
method public int getTextColor();
|
||||
method public int getTextSelectionEnd();
|
||||
method public int getTextSelectionStart();
|
||||
method public float getTextSize();
|
||||
method public int getTextStyle();
|
||||
method public int getTop();
|
||||
method public int getVisibility();
|
||||
method public int getWidth();
|
||||
method public boolean isAccessibilityFocused();
|
||||
method public boolean isActivated();
|
||||
method public boolean isAssistBlocked();
|
||||
method public boolean isCheckable();
|
||||
method public boolean isChecked();
|
||||
method public boolean isClickable();
|
||||
method public boolean isContextClickable();
|
||||
method public boolean isEnabled();
|
||||
method public boolean isFocusable();
|
||||
method public boolean isFocused();
|
||||
method public boolean isLongClickable();
|
||||
method public boolean isSelected();
|
||||
field public static final int TEXT_COLOR_UNDEFINED = 1; // 0x1
|
||||
field public static final int TEXT_STYLE_BOLD = 1; // 0x1
|
||||
field public static final int TEXT_STYLE_ITALIC = 2; // 0x2
|
||||
field public static final int TEXT_STYLE_STRIKE_THRU = 8; // 0x8
|
||||
field public static final int TEXT_STYLE_UNDERLINE = 4; // 0x4
|
||||
}
|
||||
|
||||
public static class AssistStructure.WindowNode {
|
||||
method public int getDisplayId();
|
||||
method public int getHeight();
|
||||
method public int getLeft();
|
||||
method public android.app.AssistStructure.ViewNode getRootViewNode();
|
||||
method public java.lang.CharSequence getTitle();
|
||||
method public int getTop();
|
||||
method public int getWidth();
|
||||
}
|
||||
|
||||
public class BroadcastOptions {
|
||||
method public static android.app.BroadcastOptions makeBasic();
|
||||
method public void setTemporaryAppWhitelistDuration(long);
|
||||
@@ -6018,22 +5945,87 @@ package android.app.admin {
|
||||
|
||||
package android.app.assist {
|
||||
|
||||
public final class AssistContent extends android.app.AssistContent implements android.os.Parcelable {
|
||||
ctor public AssistContent(android.os.Parcel);
|
||||
public deprecated class AssistContent implements android.os.Parcelable {
|
||||
ctor public AssistContent();
|
||||
method public int describeContents();
|
||||
method public android.content.ClipData getClipData();
|
||||
method public android.os.Bundle getExtras();
|
||||
method public android.content.Intent getIntent();
|
||||
method public java.lang.String getStructuredData();
|
||||
method public android.net.Uri getWebUri();
|
||||
method public boolean isAppProvidedIntent();
|
||||
method public void setClipData(android.content.ClipData);
|
||||
method public void setIntent(android.content.Intent);
|
||||
method public void setStructuredData(java.lang.String);
|
||||
method public void setWebUri(android.net.Uri);
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.app.assist.AssistContent> CREATOR;
|
||||
}
|
||||
|
||||
public final class AssistStructure extends android.app.AssistStructure implements android.os.Parcelable {
|
||||
public class AssistStructure implements android.os.Parcelable {
|
||||
ctor public AssistStructure();
|
||||
method public int describeContents();
|
||||
method public android.app.AssistStructure.WindowNode getWindowNodeAt(int);
|
||||
method public android.content.ComponentName getActivityComponent();
|
||||
method public android.app.assist.AssistStructure.WindowNode getWindowNodeAt(int);
|
||||
method public int getWindowNodeCount();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator<android.app.assist.AssistStructure> CREATOR;
|
||||
}
|
||||
|
||||
public static class AssistStructure.ViewNode {
|
||||
method public android.app.assist.AssistStructure.ViewNode getChildAt(int);
|
||||
method public int getChildCount();
|
||||
method public java.lang.String getClassName();
|
||||
method public java.lang.CharSequence getContentDescription();
|
||||
method public android.os.Bundle getExtras();
|
||||
method public int getHeight();
|
||||
method public java.lang.String getHint();
|
||||
method public int getId();
|
||||
method public java.lang.String getIdEntry();
|
||||
method public java.lang.String getIdPackage();
|
||||
method public java.lang.String getIdType();
|
||||
method public int getLeft();
|
||||
method public int getScrollX();
|
||||
method public int getScrollY();
|
||||
method public java.lang.CharSequence getText();
|
||||
method public int getTextBackgroundColor();
|
||||
method public int getTextColor();
|
||||
method public int getTextSelectionEnd();
|
||||
method public int getTextSelectionStart();
|
||||
method public float getTextSize();
|
||||
method public int getTextStyle();
|
||||
method public int getTop();
|
||||
method public int getVisibility();
|
||||
method public int getWidth();
|
||||
method public boolean isAccessibilityFocused();
|
||||
method public boolean isActivated();
|
||||
method public boolean isAssistBlocked();
|
||||
method public boolean isCheckable();
|
||||
method public boolean isChecked();
|
||||
method public boolean isClickable();
|
||||
method public boolean isContextClickable();
|
||||
method public boolean isEnabled();
|
||||
method public boolean isFocusable();
|
||||
method public boolean isFocused();
|
||||
method public boolean isLongClickable();
|
||||
method public boolean isSelected();
|
||||
field public static final int TEXT_COLOR_UNDEFINED = 1; // 0x1
|
||||
field public static final int TEXT_STYLE_BOLD = 1; // 0x1
|
||||
field public static final int TEXT_STYLE_ITALIC = 2; // 0x2
|
||||
field public static final int TEXT_STYLE_STRIKE_THRU = 8; // 0x8
|
||||
field public static final int TEXT_STYLE_UNDERLINE = 4; // 0x4
|
||||
}
|
||||
|
||||
public static class AssistStructure.WindowNode {
|
||||
method public int getDisplayId();
|
||||
method public int getHeight();
|
||||
method public int getLeft();
|
||||
method public android.app.assist.AssistStructure.ViewNode getRootViewNode();
|
||||
method public java.lang.CharSequence getTitle();
|
||||
method public int getTop();
|
||||
method public int getWidth();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.app.backup {
|
||||
|
||||
@@ -1,219 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package android.app;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* Holds information about the content an application is viewing, to hand to an
|
||||
* assistant at the user's request. This is filled in by
|
||||
* {@link android.app.Activity#onProvideAssistContent Activity.onProvideAssistContent}.
|
||||
* @deprecated use {@link android.app.assist.AssistContent}.
|
||||
*/
|
||||
@Deprecated
|
||||
public class AssistContent {
|
||||
private boolean mIsAppProvidedIntent = false;
|
||||
private Intent mIntent;
|
||||
private String mStructuredData;
|
||||
private ClipData mClipData;
|
||||
private Uri mUri;
|
||||
private final Bundle mExtras;
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* Key name this data structure is stored in the Bundle generated by
|
||||
* {@link android.app.Activity#onProvideAssistData}.
|
||||
*/
|
||||
public static final String ASSIST_KEY = "android:assist_content";
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* Retrieve the framework-generated AssistContent that is stored within
|
||||
* the Bundle filled in by {@link android.app.Activity#onProvideAssistContent}.
|
||||
*/
|
||||
public static android.app.assist.AssistContent getAssistContent(Bundle assistBundle) {
|
||||
return assistBundle.getParcelable(ASSIST_KEY);
|
||||
}
|
||||
|
||||
public AssistContent() {
|
||||
mExtras = new Bundle();
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* Called by {@link android.app.ActivityThread} to set the default Intent based on
|
||||
* {@link android.app.Activity#getIntent Activity.getIntent}.
|
||||
*
|
||||
* <p>Automatically populates {@link #mUri} if that Intent is an {@link Intent#ACTION_VIEW}
|
||||
* of a web (http or https scheme) URI.</p>
|
||||
*/
|
||||
public void setDefaultIntent(Intent intent) {
|
||||
mIntent = intent;
|
||||
setWebUri(null);
|
||||
if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
|
||||
Uri uri = intent.getData();
|
||||
if (uri != null) {
|
||||
if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())) {
|
||||
setWebUri(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Intent associated with the content, describing the current top-level context of
|
||||
* the activity. If this contains a reference to a piece of data related to the activity,
|
||||
* be sure to set {@link Intent#FLAG_GRANT_READ_URI_PERMISSION} so the accessibility
|
||||
* service can access it.
|
||||
*/
|
||||
public void setIntent(Intent intent) {
|
||||
mIsAppProvidedIntent = true;
|
||||
mIntent = intent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current {@link #setIntent} if one is set, else the default Intent obtained from
|
||||
* {@link android.app.Activity#getIntent Activity.getIntent}. Can be modified in-place.
|
||||
* @hide
|
||||
*/
|
||||
public Intent getIntent() {
|
||||
return mIntent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the current Intent was explicitly provided in
|
||||
* {@link android.app.Activity#onProvideAssistContent Activity.onProvideAssistContent}. If not,
|
||||
* the Intent was automatically set based on
|
||||
* {@link android.app.Activity#getIntent Activity.getIntent}.
|
||||
*/
|
||||
public boolean isAppProvidedIntent() {
|
||||
return mIsAppProvidedIntent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional additional content items that are involved with
|
||||
* the current UI. Access to this content will be granted to the assistant as if you
|
||||
* are sending it through an Intent with {@link Intent#FLAG_GRANT_READ_URI_PERMISSION}.
|
||||
*/
|
||||
public void setClipData(ClipData clip) {
|
||||
mClipData = clip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current {@link #setClipData}, which you can modify in-place.
|
||||
*/
|
||||
public ClipData getClipData() {
|
||||
return mClipData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets optional structured data regarding the content being viewed. The provided data
|
||||
* must be a string represented with <a href="http://json-ld.org/">JSON-LD</a> using the
|
||||
* <a href="http://schema.org/">schema.org</a> vocabulary.
|
||||
*/
|
||||
public void setStructuredData(String structuredData) {
|
||||
mStructuredData = structuredData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current {@link #setStructuredData}.
|
||||
*/
|
||||
public String getStructuredData() {
|
||||
return mStructuredData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a web URI associated with the current data being shown to the user.
|
||||
* This URI could be opened in a web browser, or in the app as an
|
||||
* {@link Intent#ACTION_VIEW} Intent, to show the same data that is currently
|
||||
* being displayed by it. The URI here should be something that is transportable
|
||||
* off the device into other environments to acesss the same data as is currently
|
||||
* being shown in the app; if the app does not have such a representation, it should
|
||||
* leave the null and only report the local intent and clip data.
|
||||
*/
|
||||
public void setWebUri(Uri uri) {
|
||||
mUri = uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the content's web URI as per {@link #setWebUri(android.net.Uri)}, or null if
|
||||
* there is none.
|
||||
*/
|
||||
public Uri getWebUri() {
|
||||
return mUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Bundle for extra vendor-specific data that can be modified and examined.
|
||||
*/
|
||||
public Bundle getExtras() {
|
||||
return mExtras;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public AssistContent(Parcel in) {
|
||||
if (in.readInt() != 0) {
|
||||
mIntent = Intent.CREATOR.createFromParcel(in);
|
||||
}
|
||||
if (in.readInt() != 0) {
|
||||
mClipData = ClipData.CREATOR.createFromParcel(in);
|
||||
}
|
||||
if (in.readInt() != 0) {
|
||||
mUri = Uri.CREATOR.createFromParcel(in);
|
||||
}
|
||||
if (in.readInt() != 0) {
|
||||
mStructuredData = in.readString();
|
||||
}
|
||||
mIsAppProvidedIntent = in.readInt() == 1;
|
||||
mExtras = in.readBundle();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void writeToParcelInternal(Parcel dest, int flags) {
|
||||
if (mIntent != null) {
|
||||
dest.writeInt(1);
|
||||
mIntent.writeToParcel(dest, flags);
|
||||
} else {
|
||||
dest.writeInt(0);
|
||||
}
|
||||
if (mClipData != null) {
|
||||
dest.writeInt(1);
|
||||
mClipData.writeToParcel(dest, flags);
|
||||
} else {
|
||||
dest.writeInt(0);
|
||||
}
|
||||
if (mUri != null) {
|
||||
dest.writeInt(1);
|
||||
mUri.writeToParcel(dest, flags);
|
||||
} else {
|
||||
dest.writeInt(0);
|
||||
}
|
||||
if (mStructuredData != null) {
|
||||
dest.writeInt(1);
|
||||
dest.writeString(mStructuredData);
|
||||
} else {
|
||||
dest.writeInt(0);
|
||||
}
|
||||
dest.writeInt(mIsAppProvidedIntent ? 1 : 0);
|
||||
dest.writeBundle(mExtras);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -225,6 +225,9 @@ public final class VoiceInteractor {
|
||||
* Cancel this active request.
|
||||
*/
|
||||
public void cancel() {
|
||||
if (mRequestInterface == null) {
|
||||
throw new IllegalStateException("Request " + this + " is no longer active");
|
||||
}
|
||||
try {
|
||||
mRequestInterface.cancel();
|
||||
} catch (RemoteException e) {
|
||||
|
||||
@@ -1,24 +1,184 @@
|
||||
package android.app.assist;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* New home for AssistContent.
|
||||
* Holds information about the content an application is viewing, to hand to an
|
||||
* assistant at the user's request. This is filled in by
|
||||
* {@link android.app.Activity#onProvideAssistContent Activity.onProvideAssistContent}.
|
||||
*/
|
||||
public final class AssistContent extends android.app.AssistContent implements Parcelable {
|
||||
@Deprecated
|
||||
public class AssistContent implements Parcelable {
|
||||
private boolean mIsAppProvidedIntent = false;
|
||||
private Intent mIntent;
|
||||
private String mStructuredData;
|
||||
private ClipData mClipData;
|
||||
private Uri mUri;
|
||||
private final Bundle mExtras;
|
||||
|
||||
/** @hide */
|
||||
public AssistContent() {
|
||||
mExtras = new Bundle();
|
||||
}
|
||||
|
||||
public AssistContent(Parcel in) {
|
||||
super(in);
|
||||
/**
|
||||
* @hide
|
||||
* Called by {@link android.app.ActivityThread} to set the default Intent based on
|
||||
* {@link android.app.Activity#getIntent Activity.getIntent}.
|
||||
*
|
||||
* <p>Automatically populates {@link #mUri} if that Intent is an {@link Intent#ACTION_VIEW}
|
||||
* of a web (http or https scheme) URI.</p>
|
||||
*/
|
||||
public void setDefaultIntent(Intent intent) {
|
||||
mIntent = intent;
|
||||
setWebUri(null);
|
||||
if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
|
||||
Uri uri = intent.getData();
|
||||
if (uri != null) {
|
||||
if ("http".equals(uri.getScheme()) || "https".equals(uri.getScheme())) {
|
||||
setWebUri(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Intent associated with the content, describing the current top-level context of
|
||||
* the activity. If this contains a reference to a piece of data related to the activity,
|
||||
* be sure to set {@link Intent#FLAG_GRANT_READ_URI_PERMISSION} so the accessibility
|
||||
* service can access it.
|
||||
*/
|
||||
public void setIntent(Intent intent) {
|
||||
mIsAppProvidedIntent = true;
|
||||
mIntent = intent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current {@link #setIntent} if one is set, else the default Intent obtained from
|
||||
* {@link android.app.Activity#getIntent Activity.getIntent}. Can be modified in-place.
|
||||
*/
|
||||
public Intent getIntent() {
|
||||
return super.getIntent();
|
||||
return mIntent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the current Intent was explicitly provided in
|
||||
* {@link android.app.Activity#onProvideAssistContent Activity.onProvideAssistContent}. If not,
|
||||
* the Intent was automatically set based on
|
||||
* {@link android.app.Activity#getIntent Activity.getIntent}.
|
||||
*/
|
||||
public boolean isAppProvidedIntent() {
|
||||
return mIsAppProvidedIntent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional additional content items that are involved with
|
||||
* the current UI. Access to this content will be granted to the assistant as if you
|
||||
* are sending it through an Intent with {@link Intent#FLAG_GRANT_READ_URI_PERMISSION}.
|
||||
*/
|
||||
public void setClipData(ClipData clip) {
|
||||
mClipData = clip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current {@link #setClipData}, which you can modify in-place.
|
||||
*/
|
||||
public ClipData getClipData() {
|
||||
return mClipData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets optional structured data regarding the content being viewed. The provided data
|
||||
* must be a string represented with <a href="http://json-ld.org/">JSON-LD</a> using the
|
||||
* <a href="http://schema.org/">schema.org</a> vocabulary.
|
||||
*/
|
||||
public void setStructuredData(String structuredData) {
|
||||
mStructuredData = structuredData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current {@link #setStructuredData}.
|
||||
*/
|
||||
public String getStructuredData() {
|
||||
return mStructuredData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a web URI associated with the current data being shown to the user.
|
||||
* This URI could be opened in a web browser, or in the app as an
|
||||
* {@link Intent#ACTION_VIEW} Intent, to show the same data that is currently
|
||||
* being displayed by it. The URI here should be something that is transportable
|
||||
* off the device into other environments to acesss the same data as is currently
|
||||
* being shown in the app; if the app does not have such a representation, it should
|
||||
* leave the null and only report the local intent and clip data.
|
||||
*/
|
||||
public void setWebUri(Uri uri) {
|
||||
mUri = uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the content's web URI as per {@link #setWebUri(android.net.Uri)}, or null if
|
||||
* there is none.
|
||||
*/
|
||||
public Uri getWebUri() {
|
||||
return mUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return Bundle for extra vendor-specific data that can be modified and examined.
|
||||
*/
|
||||
public Bundle getExtras() {
|
||||
return mExtras;
|
||||
}
|
||||
|
||||
AssistContent(Parcel in) {
|
||||
if (in.readInt() != 0) {
|
||||
mIntent = Intent.CREATOR.createFromParcel(in);
|
||||
}
|
||||
if (in.readInt() != 0) {
|
||||
mClipData = ClipData.CREATOR.createFromParcel(in);
|
||||
}
|
||||
if (in.readInt() != 0) {
|
||||
mUri = Uri.CREATOR.createFromParcel(in);
|
||||
}
|
||||
if (in.readInt() != 0) {
|
||||
mStructuredData = in.readString();
|
||||
}
|
||||
mIsAppProvidedIntent = in.readInt() == 1;
|
||||
mExtras = in.readBundle();
|
||||
}
|
||||
|
||||
void writeToParcelInternal(Parcel dest, int flags) {
|
||||
if (mIntent != null) {
|
||||
dest.writeInt(1);
|
||||
mIntent.writeToParcel(dest, flags);
|
||||
} else {
|
||||
dest.writeInt(0);
|
||||
}
|
||||
if (mClipData != null) {
|
||||
dest.writeInt(1);
|
||||
mClipData.writeToParcel(dest, flags);
|
||||
} else {
|
||||
dest.writeInt(0);
|
||||
}
|
||||
if (mUri != null) {
|
||||
dest.writeInt(1);
|
||||
mUri.writeToParcel(dest, flags);
|
||||
} else {
|
||||
dest.writeInt(0);
|
||||
}
|
||||
if (mStructuredData != null) {
|
||||
dest.writeInt(1);
|
||||
dest.writeString(mStructuredData);
|
||||
} else {
|
||||
dest.writeInt(0);
|
||||
}
|
||||
dest.writeInt(mIsAppProvidedIntent ? 1 : 0);
|
||||
dest.writeBundle(mExtras);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1146,20 +1146,7 @@ public class VoiceInteractionSession implements KeyEvent.Callback, ComponentCall
|
||||
mContentFrame.requestApplyInsets();
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public void onHandleAssist(Bundle assistBundle) {
|
||||
}
|
||||
|
||||
public void onHandleAssist(Bundle data, AssistStructure structure, AssistContent content) {
|
||||
if (data != null) {
|
||||
Bundle assistContext = data.getBundle(Intent.EXTRA_ASSIST_CONTEXT);
|
||||
if (assistContext != null) {
|
||||
assistContext.putParcelable(AssistStructure.ASSIST_KEY, structure);
|
||||
assistContext.putParcelable(AssistContent.ASSIST_KEY, content);
|
||||
data.putBundle(Intent.EXTRA_ASSIST_CONTEXT, assistContext);
|
||||
}
|
||||
}
|
||||
onHandleAssist(data);
|
||||
}
|
||||
|
||||
public void onHandleScreenshot(Bitmap screenshot) {
|
||||
|
||||
@@ -150,7 +150,7 @@ public abstract class ViewStructure {
|
||||
* @param size The size, in pixels, of the text.
|
||||
* @param fgColor The foreground color, packed as 0xAARRGGBB.
|
||||
* @param bgColor The background color, packed as 0xAARRGGBB.
|
||||
* @param style Style flags, as defined by {@link android.app.AssistStructure.ViewNode}.
|
||||
* @param style Style flags, as defined by {@link android.app.assist.AssistStructure.ViewNode}.
|
||||
*/
|
||||
public abstract void setTextStyle(float size, int fgColor, int bgColor, int style);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import android.annotation.StringRes;
|
||||
import android.annotation.StyleRes;
|
||||
import android.annotation.XmlRes;
|
||||
import android.app.Activity;
|
||||
import android.app.AssistStructure;
|
||||
import android.app.assist.AssistStructure;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.android.test.voiceinteraction;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.AssistStructure;
|
||||
import android.app.assist.AssistStructure;
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
|
||||
@@ -18,8 +18,8 @@ package com.android.test.voiceinteraction;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.VoiceInteractor;
|
||||
import android.app.AssistContent;
|
||||
import android.app.AssistStructure;
|
||||
import android.app.assist.AssistContent;
|
||||
import android.app.assist.AssistStructure;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
@@ -123,34 +123,8 @@ public class MainInteractionSession extends VoiceInteractionSession
|
||||
}
|
||||
|
||||
public void onHandleAssist(Bundle assistBundle) {
|
||||
boolean hasStructure = false;
|
||||
if (assistBundle != null) {
|
||||
Bundle assistContext = assistBundle.getBundle(Intent.EXTRA_ASSIST_CONTEXT);
|
||||
if (assistContext != null) {
|
||||
mAssistStructure = AssistStructure.getAssistStructure(assistContext);
|
||||
if (mAssistStructure != null) {
|
||||
if (mAssistVisualizer != null) {
|
||||
mAssistVisualizer.setAssistStructure(mAssistStructure);
|
||||
hasStructure = true;
|
||||
}
|
||||
}
|
||||
AssistContent content = AssistContent.getAssistContent(assistContext);
|
||||
if (content != null) {
|
||||
Log.i(TAG, "Assist intent: " + content.getIntent());
|
||||
Log.i(TAG, "Assist clipdata: " + content.getClipData());
|
||||
}
|
||||
}
|
||||
Uri referrer = assistBundle.getParcelable(Intent.EXTRA_REFERRER);
|
||||
if (referrer != null) {
|
||||
Log.i(TAG, "Referrer: " + referrer);
|
||||
}
|
||||
}
|
||||
if (!hasStructure && mAssistVisualizer != null) {
|
||||
mAssistVisualizer.clearAssistData();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public void onHandleAssist(Bundle data, AssistStructure structure, AssistContent content) {
|
||||
mAssistStructure = structure;
|
||||
@@ -158,13 +132,22 @@ public class MainInteractionSession extends VoiceInteractionSession
|
||||
if (mAssistVisualizer != null) {
|
||||
mAssistVisualizer.setAssistStructure(mAssistStructure);
|
||||
}
|
||||
} else {
|
||||
if (mAssistVisualizer != null) {
|
||||
mAssistVisualizer.clearAssistData();
|
||||
}
|
||||
}
|
||||
if (content != null) {
|
||||
Log.i(TAG, "Assist intent: " + content.getIntent());
|
||||
Log.i(TAG, "Assist clipdata: " + content.getClipData());
|
||||
}
|
||||
if (data != null) {
|
||||
Uri referrer = data.getParcelable(Intent.EXTRA_REFERRER);
|
||||
if (referrer != null) {
|
||||
Log.i(TAG, "Referrer: " + referrer);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onHandleScreenshot(Bitmap screenshot) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.test.voiceinteraction;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.Activity;
|
||||
import android.app.VoiceInteractor;
|
||||
import android.content.ComponentName;
|
||||
@@ -111,38 +112,10 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v == mAbortButton) {
|
||||
VoiceInteractor.AbortVoiceRequest req = new VoiceInteractor.AbortVoiceRequest(
|
||||
new VoiceInteractor.Prompt("Dammit, we suck :("), null) {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
Log.i(TAG, "Canceled!");
|
||||
mLog.append("Canceled abort\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAbortResult(Bundle result) {
|
||||
Log.i(TAG, "Abort result: result=" + result);
|
||||
mLog.append("Abort: result=" + result + "\n");
|
||||
getActivity().finish();
|
||||
}
|
||||
};
|
||||
VoiceInteractor.AbortVoiceRequest req = new TestAbortVoice();
|
||||
mInteractor.submitRequest(req, REQUEST_ABORT);
|
||||
} else if (v == mCompleteButton) {
|
||||
VoiceInteractor.CompleteVoiceRequest req = new VoiceInteractor.CompleteVoiceRequest(
|
||||
new VoiceInteractor.Prompt("Woohoo, completed!"), null) {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
Log.i(TAG, "Canceled!");
|
||||
mLog.append("Canceled complete\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCompleteResult(Bundle result) {
|
||||
Log.i(TAG, "Complete result: result=" + result);
|
||||
mLog.append("Complete: result=" + result + "\n");
|
||||
getActivity().finish();
|
||||
}
|
||||
};
|
||||
VoiceInteractor.CompleteVoiceRequest req = new TestCompleteVoice();
|
||||
mInteractor.submitRequest(req, REQUEST_COMPLETE);
|
||||
} else if (v == mPickButton) {
|
||||
VoiceInteractor.PickOptionRequest.Option[] options =
|
||||
@@ -152,36 +125,7 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
|
||||
options[2] = new VoiceInteractor.PickOptionRequest.Option("Three");
|
||||
options[3] = new VoiceInteractor.PickOptionRequest.Option("Four");
|
||||
options[4] = new VoiceInteractor.PickOptionRequest.Option("Five");
|
||||
VoiceInteractor.PickOptionRequest req = new VoiceInteractor.PickOptionRequest(
|
||||
new VoiceInteractor.Prompt("Need to pick something"), options, null) {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
Log.i(TAG, "Canceled!");
|
||||
mLog.append("Canceled pick\n");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickOptionResult(boolean finished, Option[] selections, Bundle result) {
|
||||
Log.i(TAG, "Pick result: finished=" + finished + " selections=" + selections
|
||||
+ " result=" + result);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (finished) {
|
||||
sb.append("Pick final result: ");
|
||||
} else {
|
||||
sb.append("Pick intermediate result: ");
|
||||
}
|
||||
for (int i=0; i<selections.length; i++) {
|
||||
if (i >= 1) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(selections[i].getLabel());
|
||||
}
|
||||
mLog.append(sb.toString());
|
||||
if (finished) {
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
};
|
||||
VoiceInteractor.PickOptionRequest req = new TestPickOption(options);
|
||||
mInteractor.submitRequest(req, REQUEST_PICK);
|
||||
} else if (v == mJumpOutButton) {
|
||||
Log.i(TAG, "Jump out");
|
||||
@@ -200,4 +144,66 @@ public class TestInteractionActivity extends Activity implements View.OnClickLis
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
static class TestAbortVoice extends VoiceInteractor.AbortVoiceRequest {
|
||||
public TestAbortVoice() {
|
||||
super(new VoiceInteractor.Prompt("Dammit, we suck :("), null);
|
||||
}
|
||||
@Override public void onCancel() {
|
||||
Log.i(TAG, "Canceled!");
|
||||
((TestInteractionActivity)getActivity()).mLog.append("Canceled abort\n");
|
||||
}
|
||||
@Override public void onAbortResult(Bundle result) {
|
||||
Log.i(TAG, "Abort result: result=" + result);
|
||||
((TestInteractionActivity)getActivity()).mLog.append("Abort: result=" + result + "\n");
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
|
||||
static class TestCompleteVoice extends VoiceInteractor.CompleteVoiceRequest {
|
||||
public TestCompleteVoice() {
|
||||
super(new VoiceInteractor.Prompt("Woohoo, completed!"), null);
|
||||
}
|
||||
@Override public void onCancel() {
|
||||
Log.i(TAG, "Canceled!");
|
||||
((TestInteractionActivity)getActivity()).mLog.append("Canceled complete\n");
|
||||
}
|
||||
@Override public void onCompleteResult(Bundle result) {
|
||||
Log.i(TAG, "Complete result: result=" + result);
|
||||
((TestInteractionActivity)getActivity()).mLog.append("Complete: result="
|
||||
+ result + "\n");
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
|
||||
static class TestPickOption extends VoiceInteractor.PickOptionRequest {
|
||||
public TestPickOption(Option[] options) {
|
||||
super(new VoiceInteractor.Prompt("Need to pick something"), options, null);
|
||||
}
|
||||
@Override public void onCancel() {
|
||||
Log.i(TAG, "Canceled!");
|
||||
((TestInteractionActivity)getActivity()).mLog.append("Canceled pick\n");
|
||||
}
|
||||
@Override
|
||||
public void onPickOptionResult(boolean finished, Option[] selections, Bundle result) {
|
||||
Log.i(TAG, "Pick result: finished=" + finished + " selections=" + selections
|
||||
+ " result=" + result);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (finished) {
|
||||
sb.append("Pick final result: ");
|
||||
} else {
|
||||
sb.append("Pick intermediate result: ");
|
||||
}
|
||||
for (int i=0; i<selections.length; i++) {
|
||||
if (i >= 1) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(selections[i].getLabel());
|
||||
}
|
||||
((TestInteractionActivity)getActivity()).mLog.append(sb.toString());
|
||||
if (finished) {
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user