Merge "Fixes to WearableActionExtensions" into klp-modular-dev
This commit is contained in:
@@ -4669,6 +4669,7 @@ package android.app.wearable {
|
||||
method public static android.app.wearable.WearableActionExtensions from(android.app.Notification.Action);
|
||||
method public boolean isAvailableOffline();
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator CREATOR;
|
||||
}
|
||||
|
||||
public static final class WearableActionExtensions.Builder {
|
||||
@@ -4701,11 +4702,10 @@ package android.app.wearable {
|
||||
method public void writeToParcel(android.os.Parcel, int);
|
||||
field public static final android.os.Parcelable.Creator CREATOR;
|
||||
field public static final int SIZE_DEFAULT = 0; // 0x0
|
||||
field public static final int SIZE_FULLSCREEN = 16; // 0x10
|
||||
field public static final int SIZE_LARGE = 256; // 0x100
|
||||
field public static final int SIZE_MEDIUM = 128; // 0x80
|
||||
field public static final int SIZE_SMALL = 64; // 0x40
|
||||
field public static final int SIZE_XSMALL = 32; // 0x20
|
||||
field public static final int SIZE_LARGE = 4; // 0x4
|
||||
field public static final int SIZE_MEDIUM = 3; // 0x3
|
||||
field public static final int SIZE_SMALL = 2; // 0x2
|
||||
field public static final int SIZE_XSMALL = 1; // 0x1
|
||||
field public static final int UNSET_ACTION_INDEX = -1; // 0xffffffff
|
||||
}
|
||||
|
||||
|
||||
@@ -38,13 +38,13 @@ import android.os.Parcelable;
|
||||
public final class WearableActionExtensions implements Notification.Action.Builder.Extender,
|
||||
Parcelable {
|
||||
/** Notification action extra which contains wearable extensions */
|
||||
static final String EXTRA_WEARABLE_EXTENSIONS = "android.wearable.EXTENSIONS";
|
||||
private static final String EXTRA_WEARABLE_EXTENSIONS = "android.wearable.EXTENSIONS";
|
||||
|
||||
// Flags bitwise-ored to mFlags
|
||||
static final int FLAG_AVAILABLE_OFFLINE = 1 << 0;
|
||||
private static final int FLAG_AVAILABLE_OFFLINE = 1 << 0;
|
||||
|
||||
// Default value for flags integer
|
||||
static final int DEFAULT_FLAGS = FLAG_AVAILABLE_OFFLINE;
|
||||
private static final int DEFAULT_FLAGS = FLAG_AVAILABLE_OFFLINE;
|
||||
|
||||
private final int mFlags;
|
||||
|
||||
@@ -103,7 +103,8 @@ public final class WearableActionExtensions implements Notification.Action.Build
|
||||
* Builder for {@link WearableActionExtensions} objects, which adds wearable extensions to
|
||||
* notification actions. To extend an action, create an instance of this class, call the set
|
||||
* methods present, call {@link #build}, and finally apply the options to a
|
||||
* {@link Notification.Builder} using its {@link android.app.Notification.Builder#apply} method.
|
||||
* {@link Notification.Action.Builder} using its
|
||||
* {@link android.app.Notification.Action.Builder#apply} method.
|
||||
*/
|
||||
public static final class Builder {
|
||||
private int mFlags = DEFAULT_FLAGS;
|
||||
@@ -159,4 +160,17 @@ public final class WearableActionExtensions implements Notification.Action.Build
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static final Creator<WearableActionExtensions> CREATOR =
|
||||
new Creator<WearableActionExtensions>() {
|
||||
@Override
|
||||
public WearableActionExtensions createFromParcel(Parcel in) {
|
||||
return new WearableActionExtensions(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WearableActionExtensions[] newArray(int size) {
|
||||
return new WearableActionExtensions[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -85,19 +85,13 @@ public final class WearableNotificationExtensions implements Notification.Builde
|
||||
*/
|
||||
public static final int SIZE_DEFAULT = 0;
|
||||
|
||||
/**
|
||||
* Size value for use with {@link Builder#setCustomSizePreset} to show this notification full
|
||||
* screen.
|
||||
*/
|
||||
public static final int SIZE_FULLSCREEN = 1 << 4;
|
||||
|
||||
/**
|
||||
* Size value for use with {@link Builder#setCustomSizePreset} to show this notification
|
||||
* with an extra small size.
|
||||
* <p>This value is only applicable for custom display notifications created using
|
||||
* {@link Builder#setDisplayIntent}.
|
||||
*/
|
||||
public static final int SIZE_XSMALL = 1 << 5;
|
||||
public static final int SIZE_XSMALL = 1;
|
||||
|
||||
/**
|
||||
* Size value for use with {@link Builder#setCustomSizePreset} to show this notification
|
||||
@@ -105,7 +99,7 @@ public final class WearableNotificationExtensions implements Notification.Builde
|
||||
* <p>This value is only applicable for custom display notifications created using
|
||||
* {@link Builder#setDisplayIntent}.
|
||||
*/
|
||||
public static final int SIZE_SMALL = 1 << 6;
|
||||
public static final int SIZE_SMALL = 2;
|
||||
|
||||
/**
|
||||
* Size value for use with {@link Builder#setCustomSizePreset} to show this notification
|
||||
@@ -113,7 +107,7 @@ public final class WearableNotificationExtensions implements Notification.Builde
|
||||
* <p>This value is only applicable for custom display notifications created using
|
||||
* {@link Builder#setDisplayIntent}.
|
||||
*/
|
||||
public static final int SIZE_MEDIUM = 1 << 7;
|
||||
public static final int SIZE_MEDIUM = 3;
|
||||
|
||||
/**
|
||||
* Size value for use with {@link Builder#setCustomSizePreset} to show this notification
|
||||
@@ -121,7 +115,7 @@ public final class WearableNotificationExtensions implements Notification.Builde
|
||||
* <p>This value is only applicable for custom display notifications created using
|
||||
* {@link Builder#setDisplayIntent}.
|
||||
*/
|
||||
public static final int SIZE_LARGE = 1 << 8;
|
||||
public static final int SIZE_LARGE = 4;
|
||||
|
||||
/** Notification extra which contains wearable extensions */
|
||||
static final String EXTRA_WEARABLE_EXTENSIONS = "android.wearable.EXTENSIONS";
|
||||
@@ -131,19 +125,10 @@ public final class WearableNotificationExtensions implements Notification.Builde
|
||||
static final int FLAG_HINT_HIDE_ICON = 1 << 1;
|
||||
static final int FLAG_HINT_SHOW_BACKGROUND_ONLY = 1 << 2;
|
||||
static final int FLAG_START_SCROLL_BOTTOM = 1 << 3;
|
||||
static final int FLAG_SIZE_FULLSCREEN = SIZE_FULLSCREEN;
|
||||
static final int FLAG_SIZE_XSMALL = SIZE_XSMALL;
|
||||
static final int FLAG_SIZE_SMALL = SIZE_SMALL;
|
||||
static final int FLAG_SIZE_MEDIUM = SIZE_MEDIUM;
|
||||
static final int FLAG_SIZE_LARGE = SIZE_LARGE;
|
||||
|
||||
// Default value for flags integer
|
||||
static final int DEFAULT_FLAGS = FLAG_CONTENT_INTENT_AVAILABLE_OFFLINE;
|
||||
|
||||
// Mask that will match all mutually exclusive size flags
|
||||
static final int SIZE_FLAGS_MASK = FLAG_SIZE_XSMALL | FLAG_SIZE_SMALL | FLAG_SIZE_MEDIUM
|
||||
| FLAG_SIZE_LARGE | FLAG_SIZE_FULLSCREEN;
|
||||
|
||||
private final Notification.Action[] mActions;
|
||||
private final int mFlags;
|
||||
private final PendingIntent mDisplayIntent;
|
||||
@@ -152,13 +137,14 @@ public final class WearableNotificationExtensions implements Notification.Builde
|
||||
private final int mContentIcon;
|
||||
private final int mContentIconGravity;
|
||||
private final int mContentActionIndex;
|
||||
private final int mCustomSizePreset;
|
||||
private final int mCustomContentHeight;
|
||||
private final int mGravity;
|
||||
|
||||
private WearableNotificationExtensions(Notification.Action[] actions, int flags,
|
||||
PendingIntent displayIntent, Notification[] pages, Bitmap background,
|
||||
int contentIcon, int contentIconGravity, int contentActionIndex,
|
||||
int customContentHeight, int gravity) {
|
||||
int customSizePreset, int customContentHeight, int gravity) {
|
||||
mActions = actions;
|
||||
mFlags = flags;
|
||||
mDisplayIntent = displayIntent;
|
||||
@@ -167,6 +153,7 @@ public final class WearableNotificationExtensions implements Notification.Builde
|
||||
mContentIcon = contentIcon;
|
||||
mContentIconGravity = contentIconGravity;
|
||||
mContentActionIndex = contentActionIndex;
|
||||
mCustomSizePreset = customSizePreset;
|
||||
mCustomContentHeight = customContentHeight;
|
||||
mGravity = gravity;
|
||||
}
|
||||
@@ -180,6 +167,7 @@ public final class WearableNotificationExtensions implements Notification.Builde
|
||||
mContentIcon = in.readInt();
|
||||
mContentIconGravity = in.readInt();
|
||||
mContentActionIndex = in.readInt();
|
||||
mCustomSizePreset = in.readInt();
|
||||
mCustomContentHeight = in.readInt();
|
||||
mGravity = in.readInt();
|
||||
}
|
||||
@@ -315,7 +303,7 @@ public final class WearableNotificationExtensions implements Notification.Builde
|
||||
* See also {@link Builder#setCustomContentHeight} and {@link Builder#setCustomSizePreset}.
|
||||
*/
|
||||
public int getCustomSizePreset() {
|
||||
return mFlags & SIZE_FLAGS_MASK;
|
||||
return mCustomSizePreset;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -380,6 +368,7 @@ public final class WearableNotificationExtensions implements Notification.Builde
|
||||
out.writeInt(mContentIcon);
|
||||
out.writeInt(mContentIconGravity);
|
||||
out.writeInt(mContentActionIndex);
|
||||
out.writeInt(mCustomSizePreset);
|
||||
out.writeInt(mCustomContentHeight);
|
||||
out.writeInt(mGravity);
|
||||
}
|
||||
@@ -416,6 +405,7 @@ public final class WearableNotificationExtensions implements Notification.Builde
|
||||
private int mContentIconGravity = Gravity.END;
|
||||
private int mContentActionIndex = UNSET_ACTION_INDEX;
|
||||
private int mCustomContentHeight;
|
||||
private int mCustomSizePreset = SIZE_DEFAULT;
|
||||
private int mGravity = Gravity.BOTTOM;
|
||||
|
||||
/**
|
||||
@@ -452,6 +442,7 @@ public final class WearableNotificationExtensions implements Notification.Builde
|
||||
mContentIconGravity = other.mContentIconGravity;
|
||||
mContentActionIndex = other.mContentActionIndex;
|
||||
mCustomContentHeight = other.mCustomContentHeight;
|
||||
mCustomSizePreset = other.mCustomSizePreset;
|
||||
mGravity = other.mGravity;
|
||||
}
|
||||
|
||||
@@ -618,8 +609,7 @@ public final class WearableNotificationExtensions implements Notification.Builde
|
||||
* {@link #getCustomSizePreset}.
|
||||
*/
|
||||
public Builder setCustomSizePreset(int sizePreset) {
|
||||
mFlags &= ~SIZE_FLAGS_MASK; // Clear existing size preset bits
|
||||
mFlags |= sizePreset & SIZE_FLAGS_MASK; // And merge in the new value with protection
|
||||
mCustomSizePreset = sizePreset;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -685,7 +675,7 @@ public final class WearableNotificationExtensions implements Notification.Builde
|
||||
mActions.toArray(new Notification.Action[mActions.size()]), mFlags,
|
||||
mDisplayIntent, mPages.toArray(new Notification[mPages.size()]),
|
||||
mBackground, mContentIcon, mContentIconGravity, mContentActionIndex,
|
||||
mCustomContentHeight, mGravity);
|
||||
mCustomSizePreset, mCustomContentHeight, mGravity);
|
||||
}
|
||||
|
||||
private void setFlag(int mask, boolean value) {
|
||||
|
||||
Reference in New Issue
Block a user