Merge "[Output Switcher] change color lint api"
This commit is contained in:
@@ -31,7 +31,6 @@ import static android.media.MediaRoute2Info.TYPE_USB_DEVICE;
|
||||
import static android.media.MediaRoute2Info.TYPE_USB_HEADSET;
|
||||
import static android.media.MediaRoute2Info.TYPE_WIRED_HEADPHONES;
|
||||
import static android.media.MediaRoute2Info.TYPE_WIRED_HEADSET;
|
||||
import static android.media.MediaRoute2ProviderService.REASON_UNKNOWN_ERROR;
|
||||
|
||||
import static com.android.settingslib.media.LocalMediaManager.MediaDeviceState.STATE_SELECTED;
|
||||
|
||||
@@ -621,9 +620,11 @@ public class InfoMediaManager extends MediaManager {
|
||||
dispatchConnectedDeviceChanged(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ignore callback here since we'll also receive {@link onRequestFailed} with reason code.
|
||||
*/
|
||||
@Override
|
||||
public void onTransferFailed(RoutingSessionInfo session, MediaRoute2Info route) {
|
||||
dispatchOnRequestFailed(REASON_UNKNOWN_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,6 +30,7 @@ import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -799,12 +800,12 @@ public class InfoMediaManagerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onTransferFailed_shouldDispatchOnRequestFailed() {
|
||||
public void onTransferFailed_notDispatchOnRequestFailed() {
|
||||
mInfoMediaManager.registerCallback(mCallback);
|
||||
|
||||
mInfoMediaManager.mMediaRouterCallback.onTransferFailed(null, null);
|
||||
|
||||
verify(mCallback).onRequestFailed(REASON_UNKNOWN_ERROR);
|
||||
verify(mCallback, never()).onRequestFailed(REASON_UNKNOWN_ERROR);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -26,8 +26,6 @@ import static com.android.settingslib.media.MediaDevice.SelectionBehavior.SELECT
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.AnimatedVectorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
@@ -297,6 +295,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
|
||||
&& mController.isAdvancedLayoutSupported()) {
|
||||
//If device is connected and there's other selectable devices, layout as
|
||||
// one of selected devices.
|
||||
updateTitleIcon(R.drawable.media_output_icon_volume,
|
||||
mController.getColorItemContent());
|
||||
boolean isDeviceDeselectable = isDeviceIncluded(
|
||||
mController.getDeselectableMediaDevice(), device);
|
||||
updateGroupableCheckBox(true, isDeviceDeselectable, device);
|
||||
@@ -372,7 +372,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
|
||||
mEndClickIcon.setOnClickListener(null);
|
||||
mEndTouchArea.setOnClickListener(null);
|
||||
updateEndClickAreaColor(mController.getColorSeekbarProgress());
|
||||
mEndClickIcon.setColorFilter(mController.getColorItemContent());
|
||||
mEndClickIcon.setImageTintList(
|
||||
ColorStateList.valueOf(mController.getColorItemContent()));
|
||||
mEndClickIcon.setOnClickListener(
|
||||
v -> mController.tryToLaunchInAppRoutingIntent(device.getId(), v));
|
||||
mEndTouchArea.setOnClickListener(v -> mCheckBox.performClick());
|
||||
@@ -380,8 +381,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
|
||||
|
||||
public void updateEndClickAreaColor(int color) {
|
||||
if (mController.isAdvancedLayoutSupported()) {
|
||||
mEndTouchArea.getBackground().setColorFilter(
|
||||
new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
|
||||
mEndTouchArea.setBackgroundTintList(
|
||||
ColorStateList.valueOf(color));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,22 +396,22 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
|
||||
private void updateConnectionFailedStatusIcon() {
|
||||
mStatusIcon.setImageDrawable(
|
||||
mContext.getDrawable(R.drawable.media_output_status_failed));
|
||||
mStatusIcon.setColorFilter(mController.getColorItemContent());
|
||||
mStatusIcon.setImageTintList(
|
||||
ColorStateList.valueOf(mController.getColorItemContent()));
|
||||
}
|
||||
|
||||
private void updateDeviceStatusIcon(Drawable drawable) {
|
||||
mStatusIcon.setImageDrawable(drawable);
|
||||
mStatusIcon.setColorFilter(mController.getColorItemContent());
|
||||
mStatusIcon.setImageTintList(
|
||||
ColorStateList.valueOf(mController.getColorItemContent()));
|
||||
if (drawable instanceof AnimatedVectorDrawable) {
|
||||
((AnimatedVectorDrawable) drawable).start();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateProgressBarColor() {
|
||||
mProgressBar.getIndeterminateDrawable().setColorFilter(
|
||||
new PorterDuffColorFilter(
|
||||
mController.getColorItemContent(),
|
||||
PorterDuff.Mode.SRC_IN));
|
||||
mProgressBar.getIndeterminateDrawable().setTintList(
|
||||
ColorStateList.valueOf(mController.getColorItemContent()));
|
||||
}
|
||||
|
||||
public void updateEndClickArea(MediaDevice device, boolean isDeviceDeselectable) {
|
||||
@@ -420,9 +421,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
|
||||
mEndTouchArea.setImportantForAccessibility(
|
||||
View.IMPORTANT_FOR_ACCESSIBILITY_YES);
|
||||
if (mController.isAdvancedLayoutSupported()) {
|
||||
mEndTouchArea.getBackground().setColorFilter(
|
||||
new PorterDuffColorFilter(mController.getColorItemBackground(),
|
||||
PorterDuff.Mode.SRC_IN));
|
||||
mEndTouchArea.setBackgroundTintList(
|
||||
ColorStateList.valueOf(mController.getColorItemBackground()));
|
||||
}
|
||||
setUpContentDescriptionForView(mEndTouchArea, true, device);
|
||||
}
|
||||
@@ -451,11 +451,11 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
|
||||
setSingleLineLayout(mContext.getText(R.string.media_output_dialog_pairing_new));
|
||||
final Drawable addDrawable = mContext.getDrawable(R.drawable.ic_add);
|
||||
mTitleIcon.setImageDrawable(addDrawable);
|
||||
mTitleIcon.setColorFilter(mController.getColorItemContent());
|
||||
mTitleIcon.setImageTintList(
|
||||
ColorStateList.valueOf(mController.getColorItemContent()));
|
||||
if (mController.isAdvancedLayoutSupported()) {
|
||||
mIconAreaLayout.getBackground().setColorFilter(
|
||||
new PorterDuffColorFilter(mController.getColorItemBackground(),
|
||||
PorterDuff.Mode.SRC_IN));
|
||||
mIconAreaLayout.setBackgroundTintList(
|
||||
ColorStateList.valueOf(mController.getColorItemBackground()));
|
||||
}
|
||||
mContainerLayout.setOnClickListener(mController::launchBluetoothPairing);
|
||||
}
|
||||
|
||||
@@ -23,8 +23,7 @@ import android.animation.ValueAnimator;
|
||||
import android.annotation.DrawableRes;
|
||||
import android.app.WallpaperColors;
|
||||
import android.content.Context;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.ClipDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -196,9 +195,8 @@ public abstract class MediaOutputBaseAdapter extends
|
||||
mIconAreaLayout.setOnClickListener(null);
|
||||
mVolumeValueText.setTextColor(mController.getColorItemContent());
|
||||
}
|
||||
mSeekBar.getProgressDrawable().setColorFilter(
|
||||
new PorterDuffColorFilter(mController.getColorSeekbarProgress(),
|
||||
PorterDuff.Mode.SRC_IN));
|
||||
mSeekBar.setProgressTintList(
|
||||
ColorStateList.valueOf(mController.getColorSeekbarProgress()));
|
||||
}
|
||||
|
||||
abstract void onBind(int customizedItem);
|
||||
@@ -224,16 +222,14 @@ public abstract class MediaOutputBaseAdapter extends
|
||||
updateSeekbarProgressBackground();
|
||||
}
|
||||
}
|
||||
mItemLayout.getBackground().setColorFilter(new PorterDuffColorFilter(
|
||||
isActive ? mController.getColorConnectedItemBackground()
|
||||
: mController.getColorItemBackground(),
|
||||
PorterDuff.Mode.SRC_IN));
|
||||
mItemLayout.setBackgroundTintList(
|
||||
ColorStateList.valueOf(isActive ? mController.getColorConnectedItemBackground()
|
||||
: mController.getColorItemBackground()));
|
||||
if (mController.isAdvancedLayoutSupported()) {
|
||||
mIconAreaLayout.getBackground().setColorFilter(new PorterDuffColorFilter(
|
||||
showSeekBar ? mController.getColorSeekbarProgress()
|
||||
mIconAreaLayout.setBackgroundTintList(
|
||||
ColorStateList.valueOf(showSeekBar ? mController.getColorSeekbarProgress()
|
||||
: showProgressBar ? mController.getColorConnectedItemBackground()
|
||||
: mController.getColorItemBackground(),
|
||||
PorterDuff.Mode.SRC_IN));
|
||||
: mController.getColorItemBackground()));
|
||||
}
|
||||
mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE);
|
||||
mSeekBar.setAlpha(1);
|
||||
@@ -251,7 +247,8 @@ public abstract class MediaOutputBaseAdapter extends
|
||||
params.rightMargin = showEndTouchArea ? mController.getItemMarginEndSelectable()
|
||||
: mController.getItemMarginEndDefault();
|
||||
}
|
||||
mTitleIcon.setColorFilter(mController.getColorItemContent());
|
||||
mTitleIcon.setBackgroundTintList(
|
||||
ColorStateList.valueOf(mController.getColorItemContent()));
|
||||
}
|
||||
|
||||
void setTwoLineLayout(MediaDevice device, boolean bFocused, boolean showSeekBar,
|
||||
@@ -274,15 +271,14 @@ public abstract class MediaOutputBaseAdapter extends
|
||||
backgroundDrawable = mContext.getDrawable(
|
||||
showSeekBar ? R.drawable.media_output_item_background_active
|
||||
: R.drawable.media_output_item_background).mutate();
|
||||
backgroundDrawable.setColorFilter(new PorterDuffColorFilter(
|
||||
backgroundDrawable.setTint(
|
||||
showSeekBar ? mController.getColorConnectedItemBackground()
|
||||
: mController.getColorItemBackground(), PorterDuff.Mode.SRC_IN));
|
||||
mIconAreaLayout.getBackground().setColorFilter(new PorterDuffColorFilter(
|
||||
showProgressBar || isFakeActive
|
||||
: mController.getColorItemBackground());
|
||||
mIconAreaLayout.setBackgroundTintList(
|
||||
ColorStateList.valueOf(showProgressBar || isFakeActive
|
||||
? mController.getColorConnectedItemBackground()
|
||||
: showSeekBar ? mController.getColorSeekbarProgress()
|
||||
: mController.getColorItemBackground(),
|
||||
PorterDuff.Mode.SRC_IN));
|
||||
: mController.getColorItemBackground()));
|
||||
if (showSeekBar) {
|
||||
updateSeekbarProgressBackground();
|
||||
}
|
||||
@@ -297,9 +293,7 @@ public abstract class MediaOutputBaseAdapter extends
|
||||
backgroundDrawable = mContext.getDrawable(
|
||||
R.drawable.media_output_item_background)
|
||||
.mutate();
|
||||
backgroundDrawable.setColorFilter(new PorterDuffColorFilter(
|
||||
mController.getColorItemBackground(),
|
||||
PorterDuff.Mode.SRC_IN));
|
||||
backgroundDrawable.setTint(mController.getColorItemBackground());
|
||||
}
|
||||
mItemLayout.setBackground(backgroundDrawable);
|
||||
mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE);
|
||||
@@ -442,11 +436,10 @@ public abstract class MediaOutputBaseAdapter extends
|
||||
|
||||
void updateTitleIcon(@DrawableRes int id, int color) {
|
||||
mTitleIcon.setImageDrawable(mContext.getDrawable(id));
|
||||
mTitleIcon.setColorFilter(color);
|
||||
mTitleIcon.setImageTintList(ColorStateList.valueOf(color));
|
||||
if (mController.isAdvancedLayoutSupported()) {
|
||||
mIconAreaLayout.getBackground().setColorFilter(
|
||||
new PorterDuffColorFilter(mController.getColorSeekbarProgress(),
|
||||
PorterDuff.Mode.SRC_IN));
|
||||
mIconAreaLayout.setBackgroundTintList(
|
||||
ColorStateList.valueOf(mController.getColorSeekbarProgress()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -462,9 +455,7 @@ public abstract class MediaOutputBaseAdapter extends
|
||||
final Drawable backgroundDrawable = mContext.getDrawable(
|
||||
R.drawable.media_output_item_background_active)
|
||||
.mutate();
|
||||
backgroundDrawable.setColorFilter(
|
||||
new PorterDuffColorFilter(mController.getColorConnectedItemBackground(),
|
||||
PorterDuff.Mode.SRC_IN));
|
||||
backgroundDrawable.setTint(mController.getColorConnectedItemBackground());
|
||||
mItemLayout.setBackground(backgroundDrawable);
|
||||
}
|
||||
|
||||
@@ -539,10 +530,8 @@ public abstract class MediaOutputBaseAdapter extends
|
||||
Drawable getSpeakerDrawable() {
|
||||
final Drawable drawable = mContext.getDrawable(R.drawable.ic_speaker_group_black_24dp)
|
||||
.mutate();
|
||||
drawable.setColorFilter(
|
||||
new PorterDuffColorFilter(Utils.getColorStateListDefaultColor(mContext,
|
||||
R.color.media_dialog_item_main_content),
|
||||
PorterDuff.Mode.SRC_IN));
|
||||
drawable.setTint(Utils.getColorStateListDefaultColor(mContext,
|
||||
R.color.media_dialog_item_main_content));
|
||||
return drawable;
|
||||
}
|
||||
|
||||
@@ -574,7 +563,9 @@ public abstract class MediaOutputBaseAdapter extends
|
||||
return;
|
||||
}
|
||||
mTitleIcon.setImageIcon(icon);
|
||||
mTitleIcon.setColorFilter(mController.getColorItemContent());
|
||||
icon.setTint(mController.getColorItemContent());
|
||||
mTitleIcon.setImageTintList(
|
||||
ColorStateList.valueOf(mController.getColorItemContent()));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -80,6 +80,10 @@ public class MediaOutputMetricLogger {
|
||||
Log.d(TAG, "logOutputSuccess - selected device: " + selectedDeviceType);
|
||||
}
|
||||
|
||||
if (mSourceDevice == null && mTargetDevice == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateLoggingDeviceCount(deviceList);
|
||||
|
||||
SysUiStatsLog.write(
|
||||
@@ -105,6 +109,10 @@ public class MediaOutputMetricLogger {
|
||||
Log.d(TAG, "logOutputSuccess - selected device: " + selectedDeviceType);
|
||||
}
|
||||
|
||||
if (mSourceDevice == null && mTargetDevice == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateLoggingMediaItemCount(deviceItemList);
|
||||
|
||||
SysUiStatsLog.write(
|
||||
@@ -176,6 +184,10 @@ public class MediaOutputMetricLogger {
|
||||
Log.e(TAG, "logRequestFailed - " + reason);
|
||||
}
|
||||
|
||||
if (mSourceDevice == null && mTargetDevice == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateLoggingDeviceCount(deviceList);
|
||||
|
||||
SysUiStatsLog.write(
|
||||
@@ -201,6 +213,10 @@ public class MediaOutputMetricLogger {
|
||||
Log.e(TAG, "logRequestFailed - " + reason);
|
||||
}
|
||||
|
||||
if (mSourceDevice == null && mTargetDevice == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateLoggingMediaItemCount(deviceItemList);
|
||||
|
||||
SysUiStatsLog.write(
|
||||
|
||||
Reference in New Issue
Block a user