Loading packages/SystemUI/res/layout/media_output_list_item.xml +11 −12 Original line number Diff line number Diff line Loading @@ -75,18 +75,6 @@ android:textSize="12sp" android:fontFamily="roboto-regular" android:visibility="gone"/> <ProgressBar android:id="@+id/volume_indeterminate_progress" style="@*android:style/Widget.Material.ProgressBar.Horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="16dp" android:layout_marginEnd="15dp" android:layout_marginBottom="1dp" android:layout_alignParentBottom="true" android:indeterminate="true" android:indeterminateOnly="true" android:visibility="gone"/> <SeekBar android:id="@+id/volume_seekbar" android:layout_width="match_parent" Loading @@ -94,6 +82,17 @@ android:layout_alignParentBottom="true"/> </RelativeLayout> <ProgressBar android:id="@+id/volume_indeterminate_progress" style="@*android:style/Widget.Material.ProgressBar.Horizontal" android:layout_width="258dp" android:layout_height="18dp" android:layout_marginStart="68dp" android:layout_marginTop="40dp" android:indeterminate="true" android:indeterminateOnly="true" android:visibility="gone"/> <View android:layout_width="1dp" android:layout_height="36dp" Loading packages/SystemUI/res/values/dimens.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1380,4 +1380,5 @@ <dimen name="media_output_dialog_header_back_icon_size">36dp</dimen> <dimen name="media_output_dialog_header_icon_padding">16dp</dimen> <dimen name="media_output_dialog_icon_corner_radius">16dp</dimen> <dimen name="media_output_dialog_title_anim_y_delta">12.5dp</dimen> </resources> packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java +28 −15 Original line number Diff line number Diff line Loading @@ -44,6 +44,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { private static final String TAG = "MediaOutputAdapter"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private ViewGroup mConnectedItem; public MediaOutputAdapter(MediaOutputController controller) { super(controller); } Loading Loading @@ -79,18 +81,6 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { return mController.getMediaDevices().size(); } void onItemClick(MediaDevice device) { mController.connectDevice(device); device.setState(MediaDeviceState.STATE_CONNECTING); notifyDataSetChanged(); } void onItemClick(int customizedItem) { if (customizedItem == CUSTOMIZED_ITEM_PAIR_NEW) { mController.launchBluetoothPairing(); } } @Override CharSequence getItemTitle(MediaDevice device) { if (device.getDeviceType() == MediaDevice.MediaDeviceType.TYPE_BLUETOOTH_DEVICE Loading @@ -117,6 +107,10 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { @Override void onBind(MediaDevice device, boolean topMargin, boolean bottomMargin) { super.onBind(device, topMargin, bottomMargin); final boolean currentlyConnected = isCurrentlyConnected(device); if (currentlyConnected) { mConnectedItem = mFrameLayout; } if (mController.isTransferring()) { if (device.getState() == MediaDeviceState.STATE_CONNECTING && !mController.hasAdjustVolumeUserRestriction()) { Loading @@ -133,16 +127,16 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { false /* showSeekBar*/, false /* showProgressBar */, true /* showSubtitle */); mSubTitleText.setText(R.string.media_output_dialog_connect_failed); mFrameLayout.setOnClickListener(v -> onItemClick(device)); mFrameLayout.setOnClickListener(v -> onItemClick(v, device)); } else if (!mController.hasAdjustVolumeUserRestriction() && isCurrentConnected(device)) { && currentlyConnected) { setTwoLineLayout(device, null /* title */, true /* bFocused */, true /* showSeekBar*/, false /* showProgressBar */, false /* showSubtitle */); initSeekbar(device); } else { setSingleLineLayout(getItemTitle(device), false /* bFocused */); mFrameLayout.setOnClickListener(v -> onItemClick(device)); mFrameLayout.setOnClickListener(v -> onItemClick(v, device)); } } } Loading @@ -160,5 +154,24 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { mFrameLayout.setOnClickListener(v -> onItemClick(CUSTOMIZED_ITEM_PAIR_NEW)); } } private void onItemClick(View view, MediaDevice device) { if (mController.isTransferring()) { return; } playSwitchingAnim(mConnectedItem, view); mController.connectDevice(device); device.setState(MediaDeviceState.STATE_CONNECTING); if (!isAnimating()) { notifyDataSetChanged(); } } private void onItemClick(int customizedItem) { if (customizedItem == CUSTOMIZED_ITEM_PAIR_NEW) { mController.launchBluetoothPairing(); } } } } packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java +68 −8 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.media.dialog; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.content.Context; import android.graphics.Typeface; import android.text.TextUtils; Loading @@ -33,6 +35,7 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.android.settingslib.media.MediaDevice; import com.android.systemui.Interpolators; import com.android.systemui.R; /** Loading @@ -50,6 +53,7 @@ public abstract class MediaOutputBaseAdapter extends private boolean mIsDragging; private int mMargin; private boolean mIsAnimating; Context mContext; View mHolderView; Loading @@ -75,7 +79,7 @@ public abstract class MediaOutputBaseAdapter extends return device.getName(); } boolean isCurrentConnected(MediaDevice device) { boolean isCurrentlyConnected(MediaDevice device) { return TextUtils.equals(device.getId(), mController.getCurrentConnectedMediaDevice().getId()); } Loading @@ -84,10 +88,17 @@ public abstract class MediaOutputBaseAdapter extends return mIsDragging; } boolean isAnimating() { return mIsAnimating; } /** * ViewHolder for binding device view. */ abstract class MediaDeviceBaseViewHolder extends RecyclerView.ViewHolder { private static final int ANIM_DURATION = 200; final FrameLayout mFrameLayout; final TextView mTitleText; final TextView mTwoLineTitleText; Loading Loading @@ -123,17 +134,16 @@ public abstract class MediaOutputBaseAdapter extends private void setMargin(boolean topMargin, boolean bottomMargin) { ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mFrameLayout .getLayoutParams(); if (topMargin) { params.topMargin = mMargin; } if (bottomMargin) { params.bottomMargin = mMargin; } params.topMargin = topMargin ? mMargin : 0; params.bottomMargin = bottomMargin ? mMargin : 0; mFrameLayout.setLayoutParams(params); } void setSingleLineLayout(CharSequence title, boolean bFocused) { mTitleText.setVisibility(View.VISIBLE); mTwoLineLayout.setVisibility(View.GONE); mProgressBar.setVisibility(View.GONE); mTitleText.setVisibility(View.VISIBLE); mTitleText.setTranslationY(0); mTitleText.setText(title); if (bFocused) { mTitleText.setTypeface(Typeface.create(FONT_SELECTED_TITLE, Typeface.NORMAL)); Loading @@ -146,9 +156,11 @@ public abstract class MediaOutputBaseAdapter extends boolean showSeekBar, boolean showProgressBar, boolean showSubtitle) { mTitleText.setVisibility(View.GONE); mTwoLineLayout.setVisibility(View.VISIBLE); mSeekBar.setAlpha(1); mSeekBar.setVisibility(showSeekBar ? View.VISIBLE : View.GONE); mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE); mSubTitleText.setVisibility(showSubtitle ? View.VISIBLE : View.GONE); mTwoLineTitleText.setTranslationY(0); if (device == null) { mTwoLineTitleText.setText(title); } else { Loading Loading @@ -189,5 +201,53 @@ public abstract class MediaOutputBaseAdapter extends } }); } void playSwitchingAnim(@NonNull View from, @NonNull View to) { final float delta = (float) (mContext.getResources().getDimensionPixelSize( R.dimen.media_output_dialog_title_anim_y_delta)); final SeekBar fromSeekBar = from.requireViewById(R.id.volume_seekbar); final TextView toTitleText = to.requireViewById(R.id.title); if (fromSeekBar.getVisibility() != View.VISIBLE || toTitleText.getVisibility() != View.VISIBLE) { return; } mIsAnimating = true; // Animation for title text toTitleText.setTypeface(Typeface.create(FONT_SELECTED_TITLE, Typeface.NORMAL)); toTitleText.animate() .setDuration(ANIM_DURATION) .translationY(-delta) .setInterpolator(Interpolators.FAST_OUT_SLOW_IN) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { to.requireViewById(R.id.volume_indeterminate_progress).setVisibility( View.VISIBLE); } }); // Animation for seek bar fromSeekBar.animate() .alpha(0) .setDuration(ANIM_DURATION) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { final TextView fromTitleText = from.requireViewById( R.id.two_line_title); fromTitleText.setTypeface(Typeface.create(FONT_TITLE, Typeface.NORMAL)); fromTitleText.animate() .setDuration(ANIM_DURATION) .translationY(delta) .setInterpolator(Interpolators.FAST_OUT_SLOW_IN) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mIsAnimating = false; notifyDataSetChanged(); } }); } }); } } } packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java +1 −1 Original line number Diff line number Diff line Loading @@ -170,7 +170,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements mHeaderSubtitle.setText(subTitle); mHeaderTitle.setGravity(Gravity.NO_GRAVITY); } if (!mAdapter.isDragging()) { if (!mAdapter.isDragging() && !mAdapter.isAnimating()) { mAdapter.notifyDataSetChanged(); } // Show when remote media session is available Loading Loading
packages/SystemUI/res/layout/media_output_list_item.xml +11 −12 Original line number Diff line number Diff line Loading @@ -75,18 +75,6 @@ android:textSize="12sp" android:fontFamily="roboto-regular" android:visibility="gone"/> <ProgressBar android:id="@+id/volume_indeterminate_progress" style="@*android:style/Widget.Material.ProgressBar.Horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="16dp" android:layout_marginEnd="15dp" android:layout_marginBottom="1dp" android:layout_alignParentBottom="true" android:indeterminate="true" android:indeterminateOnly="true" android:visibility="gone"/> <SeekBar android:id="@+id/volume_seekbar" android:layout_width="match_parent" Loading @@ -94,6 +82,17 @@ android:layout_alignParentBottom="true"/> </RelativeLayout> <ProgressBar android:id="@+id/volume_indeterminate_progress" style="@*android:style/Widget.Material.ProgressBar.Horizontal" android:layout_width="258dp" android:layout_height="18dp" android:layout_marginStart="68dp" android:layout_marginTop="40dp" android:indeterminate="true" android:indeterminateOnly="true" android:visibility="gone"/> <View android:layout_width="1dp" android:layout_height="36dp" Loading
packages/SystemUI/res/values/dimens.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1380,4 +1380,5 @@ <dimen name="media_output_dialog_header_back_icon_size">36dp</dimen> <dimen name="media_output_dialog_header_icon_padding">16dp</dimen> <dimen name="media_output_dialog_icon_corner_radius">16dp</dimen> <dimen name="media_output_dialog_title_anim_y_delta">12.5dp</dimen> </resources>
packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java +28 −15 Original line number Diff line number Diff line Loading @@ -44,6 +44,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { private static final String TAG = "MediaOutputAdapter"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private ViewGroup mConnectedItem; public MediaOutputAdapter(MediaOutputController controller) { super(controller); } Loading Loading @@ -79,18 +81,6 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { return mController.getMediaDevices().size(); } void onItemClick(MediaDevice device) { mController.connectDevice(device); device.setState(MediaDeviceState.STATE_CONNECTING); notifyDataSetChanged(); } void onItemClick(int customizedItem) { if (customizedItem == CUSTOMIZED_ITEM_PAIR_NEW) { mController.launchBluetoothPairing(); } } @Override CharSequence getItemTitle(MediaDevice device) { if (device.getDeviceType() == MediaDevice.MediaDeviceType.TYPE_BLUETOOTH_DEVICE Loading @@ -117,6 +107,10 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { @Override void onBind(MediaDevice device, boolean topMargin, boolean bottomMargin) { super.onBind(device, topMargin, bottomMargin); final boolean currentlyConnected = isCurrentlyConnected(device); if (currentlyConnected) { mConnectedItem = mFrameLayout; } if (mController.isTransferring()) { if (device.getState() == MediaDeviceState.STATE_CONNECTING && !mController.hasAdjustVolumeUserRestriction()) { Loading @@ -133,16 +127,16 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { false /* showSeekBar*/, false /* showProgressBar */, true /* showSubtitle */); mSubTitleText.setText(R.string.media_output_dialog_connect_failed); mFrameLayout.setOnClickListener(v -> onItemClick(device)); mFrameLayout.setOnClickListener(v -> onItemClick(v, device)); } else if (!mController.hasAdjustVolumeUserRestriction() && isCurrentConnected(device)) { && currentlyConnected) { setTwoLineLayout(device, null /* title */, true /* bFocused */, true /* showSeekBar*/, false /* showProgressBar */, false /* showSubtitle */); initSeekbar(device); } else { setSingleLineLayout(getItemTitle(device), false /* bFocused */); mFrameLayout.setOnClickListener(v -> onItemClick(device)); mFrameLayout.setOnClickListener(v -> onItemClick(v, device)); } } } Loading @@ -160,5 +154,24 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { mFrameLayout.setOnClickListener(v -> onItemClick(CUSTOMIZED_ITEM_PAIR_NEW)); } } private void onItemClick(View view, MediaDevice device) { if (mController.isTransferring()) { return; } playSwitchingAnim(mConnectedItem, view); mController.connectDevice(device); device.setState(MediaDeviceState.STATE_CONNECTING); if (!isAnimating()) { notifyDataSetChanged(); } } private void onItemClick(int customizedItem) { if (customizedItem == CUSTOMIZED_ITEM_PAIR_NEW) { mController.launchBluetoothPairing(); } } } }
packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java +68 −8 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.media.dialog; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.content.Context; import android.graphics.Typeface; import android.text.TextUtils; Loading @@ -33,6 +35,7 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import com.android.settingslib.media.MediaDevice; import com.android.systemui.Interpolators; import com.android.systemui.R; /** Loading @@ -50,6 +53,7 @@ public abstract class MediaOutputBaseAdapter extends private boolean mIsDragging; private int mMargin; private boolean mIsAnimating; Context mContext; View mHolderView; Loading @@ -75,7 +79,7 @@ public abstract class MediaOutputBaseAdapter extends return device.getName(); } boolean isCurrentConnected(MediaDevice device) { boolean isCurrentlyConnected(MediaDevice device) { return TextUtils.equals(device.getId(), mController.getCurrentConnectedMediaDevice().getId()); } Loading @@ -84,10 +88,17 @@ public abstract class MediaOutputBaseAdapter extends return mIsDragging; } boolean isAnimating() { return mIsAnimating; } /** * ViewHolder for binding device view. */ abstract class MediaDeviceBaseViewHolder extends RecyclerView.ViewHolder { private static final int ANIM_DURATION = 200; final FrameLayout mFrameLayout; final TextView mTitleText; final TextView mTwoLineTitleText; Loading Loading @@ -123,17 +134,16 @@ public abstract class MediaOutputBaseAdapter extends private void setMargin(boolean topMargin, boolean bottomMargin) { ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mFrameLayout .getLayoutParams(); if (topMargin) { params.topMargin = mMargin; } if (bottomMargin) { params.bottomMargin = mMargin; } params.topMargin = topMargin ? mMargin : 0; params.bottomMargin = bottomMargin ? mMargin : 0; mFrameLayout.setLayoutParams(params); } void setSingleLineLayout(CharSequence title, boolean bFocused) { mTitleText.setVisibility(View.VISIBLE); mTwoLineLayout.setVisibility(View.GONE); mProgressBar.setVisibility(View.GONE); mTitleText.setVisibility(View.VISIBLE); mTitleText.setTranslationY(0); mTitleText.setText(title); if (bFocused) { mTitleText.setTypeface(Typeface.create(FONT_SELECTED_TITLE, Typeface.NORMAL)); Loading @@ -146,9 +156,11 @@ public abstract class MediaOutputBaseAdapter extends boolean showSeekBar, boolean showProgressBar, boolean showSubtitle) { mTitleText.setVisibility(View.GONE); mTwoLineLayout.setVisibility(View.VISIBLE); mSeekBar.setAlpha(1); mSeekBar.setVisibility(showSeekBar ? View.VISIBLE : View.GONE); mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE); mSubTitleText.setVisibility(showSubtitle ? View.VISIBLE : View.GONE); mTwoLineTitleText.setTranslationY(0); if (device == null) { mTwoLineTitleText.setText(title); } else { Loading Loading @@ -189,5 +201,53 @@ public abstract class MediaOutputBaseAdapter extends } }); } void playSwitchingAnim(@NonNull View from, @NonNull View to) { final float delta = (float) (mContext.getResources().getDimensionPixelSize( R.dimen.media_output_dialog_title_anim_y_delta)); final SeekBar fromSeekBar = from.requireViewById(R.id.volume_seekbar); final TextView toTitleText = to.requireViewById(R.id.title); if (fromSeekBar.getVisibility() != View.VISIBLE || toTitleText.getVisibility() != View.VISIBLE) { return; } mIsAnimating = true; // Animation for title text toTitleText.setTypeface(Typeface.create(FONT_SELECTED_TITLE, Typeface.NORMAL)); toTitleText.animate() .setDuration(ANIM_DURATION) .translationY(-delta) .setInterpolator(Interpolators.FAST_OUT_SLOW_IN) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { to.requireViewById(R.id.volume_indeterminate_progress).setVisibility( View.VISIBLE); } }); // Animation for seek bar fromSeekBar.animate() .alpha(0) .setDuration(ANIM_DURATION) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { final TextView fromTitleText = from.requireViewById( R.id.two_line_title); fromTitleText.setTypeface(Typeface.create(FONT_TITLE, Typeface.NORMAL)); fromTitleText.animate() .setDuration(ANIM_DURATION) .translationY(delta) .setInterpolator(Interpolators.FAST_OUT_SLOW_IN) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mIsAnimating = false; notifyDataSetChanged(); } }); } }); } } }
packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseDialog.java +1 −1 Original line number Diff line number Diff line Loading @@ -170,7 +170,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements mHeaderSubtitle.setText(subTitle); mHeaderTitle.setGravity(Gravity.NO_GRAVITY); } if (!mAdapter.isDragging()) { if (!mAdapter.isDragging() && !mAdapter.isAnimating()) { mAdapter.notifyDataSetChanged(); } // Show when remote media session is available Loading