Merge "Change saveOnAllViewsInsible from boolean to flags" into oc-dev

This commit is contained in:
Philip P. Moltmann
2017-04-18 22:28:13 +00:00
committed by Android (Google) Code Review
5 changed files with 35 additions and 19 deletions

View File

@@ -37112,6 +37112,7 @@ package android.service.autofill {
method public int describeContents();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.autofill.SaveInfo> CREATOR;
field public static final int FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE = 1; // 0x1
field public static final int SAVE_DATA_TYPE_ADDRESS = 2; // 0x2
field public static final int SAVE_DATA_TYPE_CREDIT_CARD = 4; // 0x4
field public static final int SAVE_DATA_TYPE_EMAIL_ADDRESS = 16; // 0x10
@@ -37124,9 +37125,9 @@ package android.service.autofill {
ctor public SaveInfo.Builder(int, android.view.autofill.AutofillId[]);
method public android.service.autofill.SaveInfo build();
method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
method public android.service.autofill.SaveInfo.Builder setFlags(int);
method public android.service.autofill.SaveInfo.Builder setNegativeAction(java.lang.CharSequence, android.content.IntentSender);
method public android.service.autofill.SaveInfo.Builder setOptionalIds(android.view.autofill.AutofillId[]);
method public android.service.autofill.SaveInfo.Builder setSaveOnAllViewsInvisible(boolean);
}
public final class SaveRequest implements android.os.Parcelable {

View File

@@ -40224,6 +40224,7 @@ package android.service.autofill {
method public int describeContents();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.autofill.SaveInfo> CREATOR;
field public static final int FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE = 1; // 0x1
field public static final int SAVE_DATA_TYPE_ADDRESS = 2; // 0x2
field public static final int SAVE_DATA_TYPE_CREDIT_CARD = 4; // 0x4
field public static final int SAVE_DATA_TYPE_EMAIL_ADDRESS = 16; // 0x10
@@ -40236,9 +40237,9 @@ package android.service.autofill {
ctor public SaveInfo.Builder(int, android.view.autofill.AutofillId[]);
method public android.service.autofill.SaveInfo build();
method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
method public android.service.autofill.SaveInfo.Builder setFlags(int);
method public android.service.autofill.SaveInfo.Builder setNegativeAction(java.lang.CharSequence, android.content.IntentSender);
method public android.service.autofill.SaveInfo.Builder setOptionalIds(android.view.autofill.AutofillId[]);
method public android.service.autofill.SaveInfo.Builder setSaveOnAllViewsInvisible(boolean);
}
public final class SaveRequest implements android.os.Parcelable {

View File

@@ -37265,6 +37265,7 @@ package android.service.autofill {
method public int describeContents();
method public void writeToParcel(android.os.Parcel, int);
field public static final android.os.Parcelable.Creator<android.service.autofill.SaveInfo> CREATOR;
field public static final int FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE = 1; // 0x1
field public static final int SAVE_DATA_TYPE_ADDRESS = 2; // 0x2
field public static final int SAVE_DATA_TYPE_CREDIT_CARD = 4; // 0x4
field public static final int SAVE_DATA_TYPE_EMAIL_ADDRESS = 16; // 0x10
@@ -37277,9 +37278,9 @@ package android.service.autofill {
ctor public SaveInfo.Builder(int, android.view.autofill.AutofillId[]);
method public android.service.autofill.SaveInfo build();
method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
method public android.service.autofill.SaveInfo.Builder setFlags(int);
method public android.service.autofill.SaveInfo.Builder setNegativeAction(java.lang.CharSequence, android.content.IntentSender);
method public android.service.autofill.SaveInfo.Builder setOptionalIds(android.view.autofill.AutofillId[]);
method public android.service.autofill.SaveInfo.Builder setSaveOnAllViewsInvisible(boolean);
}
public final class SaveRequest implements android.os.Parcelable {

View File

@@ -153,13 +153,27 @@ public final class SaveInfo implements Parcelable {
@Retention(RetentionPolicy.SOURCE)
@interface SaveDataType{}
/**
* Usually {@link AutofillService#onSaveRequest(AssistStructure, Bundle, SaveCallback)}
* is called once the activity finishes. If this flag is set it is called once all saved views
* become invisible.
*/
public static final int FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE = 0x1;
/** @hide */
@IntDef(
flag = true,
value = {FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE})
@Retention(RetentionPolicy.SOURCE)
@interface SaveInfoFlags{}
private final @SaveDataType int mType;
private final CharSequence mNegativeActionTitle;
private final IntentSender mNegativeActionListener;
private final AutofillId[] mRequiredIds;
private final AutofillId[] mOptionalIds;
private final CharSequence mDescription;
private final boolean mSaveOnAllViewsInvisible;
private final int mFlags;
private SaveInfo(Builder builder) {
mType = builder.mType;
@@ -168,7 +182,7 @@ public final class SaveInfo implements Parcelable {
mRequiredIds = builder.mRequiredIds;
mOptionalIds = builder.mOptionalIds;
mDescription = builder.mDescription;
mSaveOnAllViewsInvisible = builder.mSaveOnAllViewsInvisible;
mFlags = builder.mFlags;
}
/** @hide */
@@ -197,8 +211,8 @@ public final class SaveInfo implements Parcelable {
}
/** @hide */
public boolean saveOnAllViewsInvisible() {
return mSaveOnAllViewsInvisible;
public @SaveInfoFlags int getFlags() {
return mFlags;
}
/** @hide */
@@ -219,7 +233,7 @@ public final class SaveInfo implements Parcelable {
private AutofillId[] mOptionalIds;
private CharSequence mDescription;
private boolean mDestroyed;
private boolean mSaveOnAllViewsInvisible;
private int mFlags;
/**
* Creates a new builder.
@@ -268,17 +282,15 @@ public final class SaveInfo implements Parcelable {
}
/**
* Usually {@link AutofillService#onSaveRequest(AssistStructure, Bundle, SaveCallback)}
* is called once the activity finishes. If this property is set it is called once all
* autofillable or saved views become invisible.
* Set flags changing the save behavior.
*
* @param saveOnAllViewsInvisible Set to {@code true} if the data should be saved once
* all the views become invisible.
* @param flags {@link #FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE} or 0.
* @return This builder.
*/
public @NonNull Builder setSaveOnAllViewsInvisible(boolean saveOnAllViewsInvisible) {
public @NonNull Builder setFlags(@SaveInfoFlags int flags) {
throwIfDestroyed();
mSaveOnAllViewsInvisible = saveOnAllViewsInvisible;
mFlags = Preconditions.checkFlagsArgument(flags, FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE);
return this;
}
@@ -378,7 +390,7 @@ public final class SaveInfo implements Parcelable {
.append(", requiredIds=").append(Arrays.toString(mRequiredIds))
.append(", optionalIds=").append(Arrays.toString(mOptionalIds))
.append(", description=").append(mDescription)
.append(", saveOnNoVisibleTrackedViews=").append(mSaveOnAllViewsInvisible)
.append(", mFlags=").append(mFlags)
.append("]").toString();
}
@@ -399,7 +411,7 @@ public final class SaveInfo implements Parcelable {
parcel.writeParcelable(mNegativeActionListener, flags);
parcel.writeParcelableArray(mOptionalIds, flags);
parcel.writeCharSequence(mDescription);
parcel.writeBoolean(mSaveOnAllViewsInvisible);
parcel.writeInt(mFlags);
}
public static final Parcelable.Creator<SaveInfo> CREATOR = new Parcelable.Creator<SaveInfo>() {
@@ -413,7 +425,7 @@ public final class SaveInfo implements Parcelable {
builder.setNegativeAction(parcel.readCharSequence(), parcel.readParcelable(null));
builder.setOptionalIds(parcel.readParcelableArray(null, AutofillId.class));
builder.setDescription(parcel.readCharSequence());
builder.setSaveOnAllViewsInvisible(parcel.readBoolean());
builder.setFlags(parcel.readInt());
return builder.build();
}

View File

@@ -764,7 +764,8 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
boolean saveOnAllViewsInvisible = false;
SaveInfo saveInfo = mResponses.valueAt(getLastResponseIndex()).getSaveInfo();
if (saveInfo != null) {
saveOnAllViewsInvisible = saveInfo.saveOnAllViewsInvisible();
saveOnAllViewsInvisible =
(saveInfo.getFlags() & SaveInfo.FLAG_SAVE_ON_ALL_VIEWS_INVISIBLE) != 0;
// We only need to track views if we want to save once they become invisible.
if (saveOnAllViewsInvisible) {