diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 54380629e4cad..60e7f0bc91c0f 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -8457,9 +8457,7 @@ 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()); - } + 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. @@ -8513,10 +8511,6 @@ 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; @@ -8553,10 +8547,6 @@ public class Notification implements Parcelable big.setViewVisibility(MEDIA_BUTTON_IDS[i], View.GONE); } } - bindMediaActionButton(big, 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); - big.setViewVisibility(R.id.media_seamless, View.GONE); handleImage(big); return big; } diff --git a/core/java/android/view/NotificationHeaderView.java b/core/java/android/view/NotificationHeaderView.java index 0c3d61f31dfb2..8b0de08078726 100644 --- a/core/java/android/view/NotificationHeaderView.java +++ b/core/java/android/view/NotificationHeaderView.java @@ -28,7 +28,6 @@ import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.widget.ImageView; -import android.widget.LinearLayout; import android.widget.RemoteViews; import com.android.internal.R; @@ -54,7 +53,6 @@ public class NotificationHeaderView extends ViewGroup { private OnClickListener mExpandClickListener; private OnClickListener mFeedbackListener; private HeaderTouchListener mTouchListener = new HeaderTouchListener(); - private LinearLayout mTransferChip; private NotificationExpandButton mExpandButton; private CachingIconView mIcon; private View mProfileBadge; @@ -111,7 +109,6 @@ 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); @@ -143,8 +140,7 @@ public class NotificationHeaderView extends ViewGroup { // Icons that should go at the end if ((child == mExpandButton && mShowExpandButtonAtEnd) || child == mProfileBadge - || child == mFeedbackIcon - || child == mTransferChip) { + || child == mFeedbackIcon) { iconWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth(); } else { totalWidth += lp.leftMargin + lp.rightMargin + child.getMeasuredWidth(); @@ -208,8 +204,7 @@ public class NotificationHeaderView extends ViewGroup { // Icons that should go at the end if ((child == mExpandButton && mShowExpandButtonAtEnd) || child == mProfileBadge - || child == mFeedbackIcon - || child == mTransferChip) { + || child == mFeedbackIcon) { if (end == getMeasuredWidth()) { layoutRight = end - mContentEndMargin; } else { diff --git a/core/res/res/layout/notification_material_media_transfer_action.xml b/core/res/res/layout/notification_material_media_transfer_action.xml deleted file mode 100644 index 98d8f1eee8c97..0000000000000 --- a/core/res/res/layout/notification_material_media_transfer_action.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/core/res/res/layout/notification_template_header.xml b/core/res/res/layout/notification_template_header.xml index 9a1b592c895a2..88493c9505edb 100644 --- a/core/res/res/layout/notification_template_header.xml +++ b/core/res/res/layout/notification_template_header.xml @@ -160,9 +160,5 @@ android:visibility="gone" android:contentDescription="@string/notification_work_profile_content_description" /> - diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 9858f5e7c5855..f8a20467f291c 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -200,9 +200,6 @@ - - - diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/MediaTransferManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/MediaTransferManager.java deleted file mode 100644 index 1b1a51b8a57b7..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/statusbar/MediaTransferManager.java +++ /dev/null @@ -1,212 +0,0 @@ -/* - * 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. - */ - -package com.android.systemui.statusbar; - -import android.content.Context; -import android.content.res.ColorStateList; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.GradientDrawable; -import android.graphics.drawable.RippleDrawable; -import android.service.notification.StatusBarNotification; -import android.util.FeatureFlagUtils; -import android.util.Log; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewParent; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; - -import com.android.settingslib.bluetooth.LocalBluetoothManager; -import com.android.settingslib.media.InfoMediaManager; -import com.android.settingslib.media.LocalMediaManager; -import com.android.settingslib.media.MediaDevice; -import com.android.settingslib.widget.AdaptiveIcon; -import com.android.systemui.Dependency; -import com.android.systemui.media.dialog.MediaOutputDialogFactory; -import com.android.systemui.statusbar.notification.collection.NotificationEntry; -import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow; - -import java.util.ArrayList; -import java.util.List; - -/** - * Class for handling MediaTransfer state over a set of notifications. - */ -public class MediaTransferManager { - private final Context mContext; - private final MediaOutputDialogFactory mMediaOutputDialogFactory; - private MediaDevice mDevice; - private List mViews = new ArrayList<>(); - private LocalMediaManager mLocalMediaManager; - - private static final String TAG = "MediaTransferManager"; - - private final View.OnClickListener mOnClickHandler = new View.OnClickListener() { - @Override - public void onClick(View view) { - if (handleMediaTransfer(view)) { - return; - } - } - - private boolean handleMediaTransfer(View view) { - if (view.findViewById(com.android.internal.R.id.media_seamless) == null) { - return false; - } - - ViewParent parent = view.getParent(); - StatusBarNotification statusBarNotification = - getRowForParent(parent).getEntry().getSbn(); - mMediaOutputDialogFactory.create(statusBarNotification.getPackageName(), true); - return true; - } - }; - - private final LocalMediaManager.DeviceCallback mMediaDeviceCallback = - new LocalMediaManager.DeviceCallback() { - @Override - public void onDeviceListUpdate(List devices) { - MediaDevice currentDevice = mLocalMediaManager.getCurrentConnectedDevice(); - // Check because this can be called several times while changing devices - if (mDevice == null || !mDevice.equals(currentDevice)) { - mDevice = currentDevice; - updateAllChips(); - } - } - - @Override - public void onSelectedDeviceStateChanged(MediaDevice device, int state) { - if (mDevice == null || !mDevice.equals(device)) { - mDevice = device; - updateAllChips(); - } - } - }; - - public MediaTransferManager(Context context) { - mContext = context; - mMediaOutputDialogFactory = Dependency.get(MediaOutputDialogFactory.class); - LocalBluetoothManager lbm = Dependency.get(LocalBluetoothManager.class); - InfoMediaManager imm = new InfoMediaManager(mContext, null, null, lbm); - mLocalMediaManager = new LocalMediaManager(mContext, lbm, imm, null); - } - - /** - * Mark a view as removed. If no views remain the media device listener will be unregistered. - * @param root - */ - public void setRemoved(View root) { - if (!FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SEAMLESS_TRANSFER) - || mLocalMediaManager == null || root == null) { - return; - } - View view = root.findViewById(com.android.internal.R.id.media_seamless); - if (mViews.remove(view)) { - if (mViews.size() == 0) { - mLocalMediaManager.unregisterCallback(mMediaDeviceCallback); - } - } else { - Log.e(TAG, "Tried to remove unknown view " + view); - } - } - - private ExpandableNotificationRow getRowForParent(ViewParent parent) { - while (parent != null) { - if (parent instanceof ExpandableNotificationRow) { - return ((ExpandableNotificationRow) parent); - } - parent = parent.getParent(); - } - return null; - } - - /** - * apply the action button for MediaTransfer - * - * @param root The parent container of the view. - * @param entry The entry of MediaTransfer action button. - */ - public void applyMediaTransferView(ViewGroup root, NotificationEntry entry) { - if (!FeatureFlagUtils.isEnabled(mContext, FeatureFlagUtils.SEAMLESS_TRANSFER) - || mLocalMediaManager == null || root == null) { - return; - } - - View view = root.findViewById(com.android.internal.R.id.media_seamless); - if (view == null) { - return; - } - - view.setVisibility(View.VISIBLE); - view.setOnClickListener(mOnClickHandler); - if (!mViews.contains(view)) { - mViews.add(view); - if (mViews.size() == 1) { - mLocalMediaManager.registerCallback(mMediaDeviceCallback); - } - } - - // Initial update - mLocalMediaManager.startScan(); - mDevice = mLocalMediaManager.getCurrentConnectedDevice(); - updateChip(view); - } - - private void updateAllChips() { - for (View view : mViews) { - updateChip(view); - } - } - - private void updateChip(View view) { - ExpandableNotificationRow enr = getRowForParent(view.getParent()); - int fgColor = enr.getNotificationHeader().getOriginalIconColor(); - ColorStateList fgTintList = ColorStateList.valueOf(fgColor); - int bgColor = enr.getCurrentBackgroundTint(); - - // Update outline color - LinearLayout viewLayout = (LinearLayout) view; - RippleDrawable bkgDrawable = (RippleDrawable) viewLayout.getBackground(); - GradientDrawable rect = (GradientDrawable) bkgDrawable.getDrawable(0); - rect.setStroke(2, fgColor); - rect.setColor(bgColor); - - ImageView iconView = view.findViewById(com.android.internal.R.id.media_seamless_image); - TextView deviceName = view.findViewById(com.android.internal.R.id.media_seamless_text); - deviceName.setTextColor(fgTintList); - - if (mDevice != null) { - Drawable icon = mDevice.getIcon(); - iconView.setVisibility(View.VISIBLE); - iconView.setImageTintList(fgTintList); - - if (icon instanceof AdaptiveIcon) { - AdaptiveIcon aIcon = (AdaptiveIcon) icon; - aIcon.setBackgroundColor(bgColor); - iconView.setImageDrawable(aIcon); - } else { - iconView.setImageDrawable(icon); - } - deviceName.setText(mDevice.getName()); - } else { - // Reset to default - iconView.setVisibility(View.GONE); - deviceName.setText(com.android.internal.R.string.ext_media_seamless_action); - } - } -} diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java index 8a644ed4d3ffc..3b55f7c1e6e8f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationContentView.java @@ -44,7 +44,6 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.ContrastColorUtil; import com.android.systemui.Dependency; import com.android.systemui.R; -import com.android.systemui.statusbar.MediaTransferManager; import com.android.systemui.statusbar.RemoteInputController; import com.android.systemui.statusbar.SmartReplyController; import com.android.systemui.statusbar.TransformableView; @@ -173,12 +172,10 @@ public class NotificationContentView extends FrameLayout { private boolean mIsContentExpandable; private boolean mRemoteInputVisible; private int mUnrestrictedContentHeight; - private MediaTransferManager mMediaTransferManager; public NotificationContentView(Context context, AttributeSet attrs) { super(context, attrs); mHybridGroupManager = new HybridGroupManager(getContext()); - mMediaTransferManager = new MediaTransferManager(getContext()); mSmartReplyConstants = Dependency.get(SmartReplyConstants.class); mSmartReplyController = Dependency.get(SmartReplyController.class); initView(); @@ -1157,7 +1154,6 @@ public class NotificationContentView extends FrameLayout { mHeadsUpWrapper.onContentUpdated(row); } applyRemoteInputAndSmartReply(entry); - applyMediaTransfer(entry); updateLegacy(); mForceSelectNextLayout = true; mPreviousExpandedRemoteInputIntent = null; @@ -1185,22 +1181,6 @@ public class NotificationContentView extends FrameLayout { } } - private void applyMediaTransfer(final NotificationEntry entry) { - if (!entry.isMediaNotification()) { - return; - } - - View bigContentView = mExpandedChild; - if (bigContentView != null && (bigContentView instanceof ViewGroup)) { - mMediaTransferManager.applyMediaTransferView((ViewGroup) bigContentView, entry); - } - - View smallContentView = mContractedChild; - if (smallContentView != null && (smallContentView instanceof ViewGroup)) { - mMediaTransferManager.applyMediaTransferView((ViewGroup) smallContentView, entry); - } - } - /** * Returns whether the {@link Notification} represented by entry has a free-form remote input. * Such an input can be used e.g. to implement smart reply buttons - by passing the replies @@ -1662,11 +1642,9 @@ public class NotificationContentView extends FrameLayout { } if (mExpandedWrapper != null) { mExpandedWrapper.setRemoved(); - mMediaTransferManager.setRemoved(mExpandedChild); } if (mContractedWrapper != null) { mContractedWrapper.setRemoved(); - mMediaTransferManager.setRemoved(mContractedChild); } if (mHeadsUpWrapper != null) { mHeadsUpWrapper.setRemoved();