Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 750ec58f authored by Beth Thibodeau's avatar Beth Thibodeau
Browse files

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
parent 630f991c
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -8150,7 +8150,9 @@ public class Notification implements Parcelable
                Action action, StandardTemplateParams p) {
            final boolean tombstone = (action.actionIntent == null);
            container.setViewVisibility(buttonId, View.VISIBLE);
            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;
+9 −2
Original line number Diff line number Diff line
@@ -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 {
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2019 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
  -->
<ripple
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="#1f000000">
    <item android:id="@android:id/background">
        <shape android:shape="rectangle">
            <stroke android:width="1dp" android:color="#1f000000"/>
            <corners android:radius="20dp"/>
        </shape>
    </item>
</ripple>
+39 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2019 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
  -->
<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:visibility="gone"
        android:padding="4dp"
        android:layout_marginStart="10dp"
        android:gravity="center"
        android:background="@drawable/media_seamless_background">
    <ImageView
        android:layout_width="?attr/notificationHeaderIconSize"
        android:layout_height="?attr/notificationHeaderIconSize"
        android:src="@drawable/ic_media_seamless"
        android:id="@+id/media_seamless_image" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?attr/notificationHeaderTextAppearance"
        android:text="@string/ext_media_seamless_action"
        android:id="@+id/media_seamless_text"
        android:paddingEnd="2dp" />
</LinearLayout>
 No newline at end of file
+4 −0
Original line number Diff line number Diff line
@@ -175,5 +175,9 @@
            android:contentDescription="@string/notification_appops_overlay_active"
            />
    </LinearLayout>
    <include
        layout="@layout/notification_material_media_transfer_action"
        android:id="@+id/media_seamless"
    />
</NotificationHeaderView>
Loading