Remove the old seamless chip

Test: manual - play audio, use the real seamless chip
Change-Id: I0cc93c222dd6ae7bc3a823f27967d98fb39e8cd9
This commit is contained in:
Jeff DeCew
2020-10-15 14:52:35 -04:00
parent 2374b9147f
commit e12ff8a21c
7 changed files with 3 additions and 298 deletions

View File

@@ -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;
}

View File

@@ -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 {

View File

@@ -1,39 +0,0 @@
<?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>

View File

@@ -160,9 +160,5 @@
android:visibility="gone"
android:contentDescription="@string/notification_work_profile_content_description"
/>
<include
layout="@layout/notification_material_media_transfer_action"
android:id="@+id/media_seamless"
/>
</NotificationHeaderView>

View File

@@ -200,9 +200,6 @@
<java-symbol type="id" name="action2" />
<java-symbol type="id" name="action3" />
<java-symbol type="id" name="action4" />
<java-symbol type="id" name="media_seamless" />
<java-symbol type="id" name="media_seamless_image" />
<java-symbol type="id" name="media_seamless_text" />
<java-symbol type="id" name="notification_media_seekbar_container" />
<java-symbol type="id" name="notification_media_content" />
<java-symbol type="id" name="notification_media_progress" />

View File

@@ -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<View> 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<MediaDevice> 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);
}
}
}

View File

@@ -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();