Loading api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -5481,6 +5481,7 @@ package android.app { method public boolean getAutoExpandBubble(); method @Nullable public android.app.PendingIntent getDeleteIntent(); method public int getDesiredHeight(); method @DimenRes public int getDesiredHeightResId(); method @NonNull public android.graphics.drawable.Icon getIcon(); method @NonNull public android.app.PendingIntent getIntent(); method public boolean getSuppressInitialNotification(); Loading @@ -5494,6 +5495,7 @@ package android.app { method @NonNull public android.app.Notification.BubbleMetadata.Builder setAutoExpandBubble(boolean); method @NonNull public android.app.Notification.BubbleMetadata.Builder setDeleteIntent(@Nullable android.app.PendingIntent); method @NonNull public android.app.Notification.BubbleMetadata.Builder setDesiredHeight(int); method @NonNull public android.app.Notification.BubbleMetadata.Builder setDesiredHeightResId(@DimenRes int); method @NonNull public android.app.Notification.BubbleMetadata.Builder setIcon(@NonNull android.graphics.drawable.Icon); method @NonNull public android.app.Notification.BubbleMetadata.Builder setIntent(@NonNull android.app.PendingIntent); method @NonNull public android.app.Notification.BubbleMetadata.Builder setSuppressInitialNotification(boolean); core/java/android/app/Notification.java +41 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.graphics.drawable.Icon.TYPE_BITMAP; import static com.android.internal.util.ContrastColorUtil.satisfiesTextContrast; import android.annotation.ColorInt; import android.annotation.DimenRes; import android.annotation.DrawableRes; import android.annotation.IdRes; import android.annotation.IntDef; Loading Loading @@ -8521,6 +8522,7 @@ public class Notification implements Parcelable private PendingIntent mDeleteIntent; private Icon mIcon; private int mDesiredHeight; @DimenRes private int mDesiredHeightResId; private int mFlags; /** Loading @@ -8547,10 +8549,11 @@ public class Notification implements Parcelable private static final int FLAG_SUPPRESS_INITIAL_NOTIFICATION = 0x00000002; private BubbleMetadata(PendingIntent expandIntent, PendingIntent deleteIntent, Icon icon, int height) { Icon icon, int height, @DimenRes int heightResId) { mPendingIntent = expandIntent; mIcon = icon; mDesiredHeight = height; mDesiredHeightResId = heightResId; mDeleteIntent = deleteIntent; } Loading @@ -8562,6 +8565,7 @@ public class Notification implements Parcelable if (in.readInt() != 0) { mDeleteIntent = PendingIntent.CREATOR.createFromParcel(in); } mDesiredHeightResId = in.readInt(); } /** Loading Loading @@ -8589,13 +8593,22 @@ public class Notification implements Parcelable } /** * @return the ideal height for the floating window that app content defined by * @return the ideal height, in DPs, for the floating window that app content defined by * {@link #getIntent()} for this bubble. */ public int getDesiredHeight() { return mDesiredHeight; } /** * @return the resId of ideal height for the floating window that app content defined by * {@link #getIntent()} for this bubble. */ @DimenRes public int getDesiredHeightResId() { return mDesiredHeightResId; } /** * @return whether this bubble should auto expand when it is posted. * Loading Loading @@ -8643,6 +8656,7 @@ public class Notification implements Parcelable if (mDeleteIntent != null) { mDeleteIntent.writeToParcel(out, 0); } out.writeInt(mDesiredHeightResId); } private void setFlags(int flags) { Loading @@ -8657,6 +8671,7 @@ public class Notification implements Parcelable private PendingIntent mPendingIntent; private Icon mIcon; private int mDesiredHeight; @DimenRes private int mDesiredHeightResId; private int mFlags; private PendingIntent mDeleteIntent; Loading Loading @@ -8709,13 +8724,35 @@ public class Notification implements Parcelable } /** * Sets the desired height for the app content defined by * Sets the desired height in DPs for the app content defined by * {@link #setIntent(PendingIntent)}, this height may not be respected if there is not * enough space on the screen or if the provided height is too small to be useful. * <p> * If {@link #setDesiredHeightResId(int)} was previously called on this builder, the * previous value set will be cleared after calling this method, and this value will * be used instead. */ @NonNull public BubbleMetadata.Builder setDesiredHeight(int height) { mDesiredHeight = Math.max(height, 0); mDesiredHeightResId = 0; return this; } /** * Sets the desired height via resId for the app content defined by * {@link #setIntent(PendingIntent)}, this height may not be respected if there is not * enough space on the screen or if the provided height is too small to be useful. * <p> * If {@link #setDesiredHeight(int)} was previously called on this builder, the * previous value set will be cleared after calling this method, and this value will * be used instead. */ @NonNull public BubbleMetadata.Builder setDesiredHeightResId(@DimenRes int heightResId) { mDesiredHeightResId = heightResId; mDesiredHeight = 0; return this; } Loading Loading @@ -8777,7 +8814,7 @@ public class Notification implements Parcelable throw new IllegalStateException("Must supply an icon for the bubble"); } BubbleMetadata data = new BubbleMetadata(mPendingIntent, mDeleteIntent, mIcon, mDesiredHeight); mIcon, mDesiredHeight, mDesiredHeightResId); data.setFlags(mFlags); return data; } Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java +35 −7 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.ShapeDrawable; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.provider.Settings; import android.service.notification.StatusBarNotification; import android.util.AttributeSet; Loading Loading @@ -457,30 +458,38 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList void updateHeight() { if (usingActivityView()) { Notification.BubbleMetadata data = mEntry.getBubbleMetadata(); int desiredHeight; float desiredHeight; if (data == null) { // This is a contentIntent based bubble, lets allow it to be the max height // as it was forced into this mode and not prepared to be small desiredHeight = mStackView.getMaxExpandedHeight(); } else { desiredHeight = data.getDesiredHeight() > 0 ? data.getDesiredHeight() : mMinHeight; boolean useRes = data.getDesiredHeightResId() != 0; float desiredPx; if (useRes) { desiredPx = getDimenForPackageUser(data.getDesiredHeightResId(), mEntry.notification.getPackageName(), mEntry.notification.getUser().getIdentifier()); } else { desiredPx = data.getDesiredHeight() * getContext().getResources().getDisplayMetrics().density; } desiredHeight = desiredPx > 0 ? desiredPx : mMinHeight; } int chromeHeight = mPermissionView.getVisibility() != View.VISIBLE ? mHeaderHeight : mPermissionHeight; int max = mStackView.getMaxExpandedHeight() - chromeHeight - mPointerView.getHeight() - mPointerMargin; int height = Math.min(desiredHeight, max); float height = Math.min(desiredHeight, max); height = Math.max(height, mMinHeight); LayoutParams lp = (LayoutParams) mActivityView.getLayoutParams(); mNeedsNewHeight = lp.height != height; if (!mKeyboardVisible) { // If the keyboard is visible... don't adjust the height because that will cause // a configuration change and the keyboard will be lost. lp.height = height; mBubbleHeight = height; lp.height = (int) height; mBubbleHeight = (int) height; mActivityView.setLayoutParams(lp); mNeedsNewHeight = false; } Loading Loading @@ -712,4 +721,23 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList mStackView.getNormalizedXPosition(), mStackView.getNormalizedYPosition()); } private int getDimenForPackageUser(int resId, String pkg, int userId) { Resources r; if (pkg != null) { try { if (userId == UserHandle.USER_ALL) { userId = UserHandle.USER_SYSTEM; } r = mPm.getResourcesForApplicationAsUser(pkg, userId); return r.getDimensionPixelSize(resId); } catch (PackageManager.NameNotFoundException ex) { // Uninstalled, don't care } catch (Resources.NotFoundException e) { // Invalid res id, return 0 and user our default Log.e(TAG, "Couldn't find desired height res id", e); } } return 0; } } Loading
api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -5481,6 +5481,7 @@ package android.app { method public boolean getAutoExpandBubble(); method @Nullable public android.app.PendingIntent getDeleteIntent(); method public int getDesiredHeight(); method @DimenRes public int getDesiredHeightResId(); method @NonNull public android.graphics.drawable.Icon getIcon(); method @NonNull public android.app.PendingIntent getIntent(); method public boolean getSuppressInitialNotification(); Loading @@ -5494,6 +5495,7 @@ package android.app { method @NonNull public android.app.Notification.BubbleMetadata.Builder setAutoExpandBubble(boolean); method @NonNull public android.app.Notification.BubbleMetadata.Builder setDeleteIntent(@Nullable android.app.PendingIntent); method @NonNull public android.app.Notification.BubbleMetadata.Builder setDesiredHeight(int); method @NonNull public android.app.Notification.BubbleMetadata.Builder setDesiredHeightResId(@DimenRes int); method @NonNull public android.app.Notification.BubbleMetadata.Builder setIcon(@NonNull android.graphics.drawable.Icon); method @NonNull public android.app.Notification.BubbleMetadata.Builder setIntent(@NonNull android.app.PendingIntent); method @NonNull public android.app.Notification.BubbleMetadata.Builder setSuppressInitialNotification(boolean);
core/java/android/app/Notification.java +41 −4 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.graphics.drawable.Icon.TYPE_BITMAP; import static com.android.internal.util.ContrastColorUtil.satisfiesTextContrast; import android.annotation.ColorInt; import android.annotation.DimenRes; import android.annotation.DrawableRes; import android.annotation.IdRes; import android.annotation.IntDef; Loading Loading @@ -8521,6 +8522,7 @@ public class Notification implements Parcelable private PendingIntent mDeleteIntent; private Icon mIcon; private int mDesiredHeight; @DimenRes private int mDesiredHeightResId; private int mFlags; /** Loading @@ -8547,10 +8549,11 @@ public class Notification implements Parcelable private static final int FLAG_SUPPRESS_INITIAL_NOTIFICATION = 0x00000002; private BubbleMetadata(PendingIntent expandIntent, PendingIntent deleteIntent, Icon icon, int height) { Icon icon, int height, @DimenRes int heightResId) { mPendingIntent = expandIntent; mIcon = icon; mDesiredHeight = height; mDesiredHeightResId = heightResId; mDeleteIntent = deleteIntent; } Loading @@ -8562,6 +8565,7 @@ public class Notification implements Parcelable if (in.readInt() != 0) { mDeleteIntent = PendingIntent.CREATOR.createFromParcel(in); } mDesiredHeightResId = in.readInt(); } /** Loading Loading @@ -8589,13 +8593,22 @@ public class Notification implements Parcelable } /** * @return the ideal height for the floating window that app content defined by * @return the ideal height, in DPs, for the floating window that app content defined by * {@link #getIntent()} for this bubble. */ public int getDesiredHeight() { return mDesiredHeight; } /** * @return the resId of ideal height for the floating window that app content defined by * {@link #getIntent()} for this bubble. */ @DimenRes public int getDesiredHeightResId() { return mDesiredHeightResId; } /** * @return whether this bubble should auto expand when it is posted. * Loading Loading @@ -8643,6 +8656,7 @@ public class Notification implements Parcelable if (mDeleteIntent != null) { mDeleteIntent.writeToParcel(out, 0); } out.writeInt(mDesiredHeightResId); } private void setFlags(int flags) { Loading @@ -8657,6 +8671,7 @@ public class Notification implements Parcelable private PendingIntent mPendingIntent; private Icon mIcon; private int mDesiredHeight; @DimenRes private int mDesiredHeightResId; private int mFlags; private PendingIntent mDeleteIntent; Loading Loading @@ -8709,13 +8724,35 @@ public class Notification implements Parcelable } /** * Sets the desired height for the app content defined by * Sets the desired height in DPs for the app content defined by * {@link #setIntent(PendingIntent)}, this height may not be respected if there is not * enough space on the screen or if the provided height is too small to be useful. * <p> * If {@link #setDesiredHeightResId(int)} was previously called on this builder, the * previous value set will be cleared after calling this method, and this value will * be used instead. */ @NonNull public BubbleMetadata.Builder setDesiredHeight(int height) { mDesiredHeight = Math.max(height, 0); mDesiredHeightResId = 0; return this; } /** * Sets the desired height via resId for the app content defined by * {@link #setIntent(PendingIntent)}, this height may not be respected if there is not * enough space on the screen or if the provided height is too small to be useful. * <p> * If {@link #setDesiredHeight(int)} was previously called on this builder, the * previous value set will be cleared after calling this method, and this value will * be used instead. */ @NonNull public BubbleMetadata.Builder setDesiredHeightResId(@DimenRes int heightResId) { mDesiredHeightResId = heightResId; mDesiredHeight = 0; return this; } Loading Loading @@ -8777,7 +8814,7 @@ public class Notification implements Parcelable throw new IllegalStateException("Must supply an icon for the bubble"); } BubbleMetadata data = new BubbleMetadata(mPendingIntent, mDeleteIntent, mIcon, mDesiredHeight); mIcon, mDesiredHeight, mDesiredHeightResId); data.setFlags(mFlags); return data; } Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java +35 −7 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.ShapeDrawable; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.provider.Settings; import android.service.notification.StatusBarNotification; import android.util.AttributeSet; Loading Loading @@ -457,30 +458,38 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList void updateHeight() { if (usingActivityView()) { Notification.BubbleMetadata data = mEntry.getBubbleMetadata(); int desiredHeight; float desiredHeight; if (data == null) { // This is a contentIntent based bubble, lets allow it to be the max height // as it was forced into this mode and not prepared to be small desiredHeight = mStackView.getMaxExpandedHeight(); } else { desiredHeight = data.getDesiredHeight() > 0 ? data.getDesiredHeight() : mMinHeight; boolean useRes = data.getDesiredHeightResId() != 0; float desiredPx; if (useRes) { desiredPx = getDimenForPackageUser(data.getDesiredHeightResId(), mEntry.notification.getPackageName(), mEntry.notification.getUser().getIdentifier()); } else { desiredPx = data.getDesiredHeight() * getContext().getResources().getDisplayMetrics().density; } desiredHeight = desiredPx > 0 ? desiredPx : mMinHeight; } int chromeHeight = mPermissionView.getVisibility() != View.VISIBLE ? mHeaderHeight : mPermissionHeight; int max = mStackView.getMaxExpandedHeight() - chromeHeight - mPointerView.getHeight() - mPointerMargin; int height = Math.min(desiredHeight, max); float height = Math.min(desiredHeight, max); height = Math.max(height, mMinHeight); LayoutParams lp = (LayoutParams) mActivityView.getLayoutParams(); mNeedsNewHeight = lp.height != height; if (!mKeyboardVisible) { // If the keyboard is visible... don't adjust the height because that will cause // a configuration change and the keyboard will be lost. lp.height = height; mBubbleHeight = height; lp.height = (int) height; mBubbleHeight = (int) height; mActivityView.setLayoutParams(lp); mNeedsNewHeight = false; } Loading Loading @@ -712,4 +721,23 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList mStackView.getNormalizedXPosition(), mStackView.getNormalizedYPosition()); } private int getDimenForPackageUser(int resId, String pkg, int userId) { Resources r; if (pkg != null) { try { if (userId == UserHandle.USER_ALL) { userId = UserHandle.USER_SYSTEM; } r = mPm.getResourcesForApplicationAsUser(pkg, userId); return r.getDimensionPixelSize(resId); } catch (PackageManager.NameNotFoundException ex) { // Uninstalled, don't care } catch (Resources.NotFoundException e) { // Invalid res id, return 0 and user our default Log.e(TAG, "Couldn't find desired height res id", e); } } return 0; } }