diff options
| author | Beth Thibodeau <ethibodeau@google.com> | 2019-09-18 15:14:09 -0400 |
|---|---|---|
| committer | Beth Thibodeau <ethibodeau@google.com> | 2019-09-18 15:29:41 -0400 |
| commit | 750ec58fecfce6cb7bc4d349086b4e3f7a8202b3 (patch) | |
| tree | 2d5e047c1ade09e32f1538f936a99319145a5626 /core/java/android | |
| parent | 630f991cf29405b4a748c4511fcb88d2b631c9bb (diff) | |
Output switch button in media notification header
Adds a chip-like button to the header of media notifications which will
open the media output slice. This was previously implemented as an
action button behind the feature flag and can be enabled by toggling
settings_seamless_transfer
Test: manual
Change-Id: I447b0add9d9de378fa09b5cf087518a81ec941e5
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/Notification.java | 8 | ||||
| -rw-r--r-- | core/java/android/view/NotificationHeaderView.java | 11 |
2 files changed, 16 insertions, 3 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index bb4e99873f26..2f03ed484e96 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -8150,7 +8150,9 @@ public class Notification implements Parcelable Action action, StandardTemplateParams p) { final boolean tombstone = (action.actionIntent == null); container.setViewVisibility(buttonId, View.VISIBLE); - container.setImageViewIcon(buttonId, action.getIcon()); + if (buttonId != R.id.media_seamless) { + container.setImageViewIcon(buttonId, action.getIcon()); + } // If the action buttons should not be tinted, then just use the default // notification color. Otherwise, just use the passed-in color. @@ -8204,6 +8206,10 @@ public class Notification implements Parcelable view.setViewVisibility(MEDIA_BUTTON_IDS[i], View.GONE); } } + bindMediaActionButton(view, R.id.media_seamless, new Action( + R.drawable.ic_media_seamless, mBuilder.mContext.getString( + com.android.internal.R.string.ext_media_seamless_action), null), p); + view.setViewVisibility(R.id.media_seamless, View.GONE); handleImage(view); // handle the content margin int endMargin = R.dimen.notification_content_margin_end; diff --git a/core/java/android/view/NotificationHeaderView.java b/core/java/android/view/NotificationHeaderView.java index b2f3f5edcd20..d54e9d58356b 100644 --- a/core/java/android/view/NotificationHeaderView.java +++ b/core/java/android/view/NotificationHeaderView.java @@ -30,6 +30,7 @@ import android.graphics.drawable.Drawable; import android.util.ArraySet; import android.util.AttributeSet; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.RemoteViews; import com.android.internal.R; @@ -54,6 +55,7 @@ public class NotificationHeaderView extends ViewGroup { private OnClickListener mExpandClickListener; private OnClickListener mAppOpsListener; private HeaderTouchListener mTouchListener = new HeaderTouchListener(); + private LinearLayout mTransferChip; private ImageView mExpandButton; private CachingIconView mIcon; private View mProfileBadge; @@ -116,6 +118,7 @@ public class NotificationHeaderView extends ViewGroup { mAppName = findViewById(com.android.internal.R.id.app_name_text); mHeaderText = findViewById(com.android.internal.R.id.header_text); mSecondaryHeaderText = findViewById(com.android.internal.R.id.header_text_secondary); + mTransferChip = findViewById(com.android.internal.R.id.media_seamless); mExpandButton = findViewById(com.android.internal.R.id.expand_button); mIcon = findViewById(com.android.internal.R.id.icon); mProfileBadge = findViewById(com.android.internal.R.id.profile_badge); @@ -148,9 +151,11 @@ public class NotificationHeaderView extends ViewGroup { int childHeightSpec = getChildMeasureSpec(wrapContentHeightSpec, lp.topMargin + lp.bottomMargin, lp.height); child.measure(childWidthSpec, childHeightSpec); + // Icons that should go at the end if ((child == mExpandButton && mShowExpandButtonAtEnd) || child == mProfileBadge - || child == mAppOps) { + || child == mAppOps + || child == mTransferChip) { iconWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth(); } else { totalWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth(); @@ -211,9 +216,11 @@ public class NotificationHeaderView extends ViewGroup { int layoutRight; int top = (int) (getPaddingTop() + (ownHeight - childHeight) / 2.0f); int bottom = top + childHeight; + // Icons that should go at the end if ((child == mExpandButton && mShowExpandButtonAtEnd) || child == mProfileBadge - || child == mAppOps) { + || child == mAppOps + || child == mTransferChip) { if (end == getMeasuredWidth()) { layoutRight = end - mContentEndMargin; } else { |
