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

Commit 266e39c1 authored by shaoweishen's avatar shaoweishen Committed by Automerger Merge Worker
Browse files

[Output Switcher] Set clickable on MediaMetadata section am: 8027f460

parents 02ac6e45 8027f460
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/media_metadata_section"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="start|center_vertical"
+8 −10
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
    private RecyclerView mDevicesRecyclerView;
    private LinearLayout mDeviceListLayout;
    private LinearLayout mCastAppLayout;
    private LinearLayout mMediaMetadataSectionLayout;
    private Button mDoneButton;
    private Button mStopButton;
    private Button mAppButton;
@@ -240,6 +241,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
        mHeaderSubtitle = mDialogView.requireViewById(R.id.header_subtitle);
        mHeaderIcon = mDialogView.requireViewById(R.id.header_icon);
        mDevicesRecyclerView = mDialogView.requireViewById(R.id.list_result);
        mMediaMetadataSectionLayout = mDialogView.requireViewById(R.id.media_metadata_section);
        mDeviceListLayout = mDialogView.requireViewById(R.id.device_list);
        mDoneButton = mDialogView.requireViewById(R.id.done);
        mStopButton = mDialogView.requireViewById(R.id.stop);
@@ -255,21 +257,17 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
        mDevicesRecyclerView.setLayoutManager(mLayoutManager);
        mDevicesRecyclerView.setAdapter(mAdapter);
        mDevicesRecyclerView.setHasFixedSize(false);
        // Init header icon
        mHeaderIcon.setOnClickListener(v -> onHeaderIconClick());
        // Init bottom buttons
        mDoneButton.setOnClickListener(v -> dismiss());
        mStopButton.setOnClickListener(v -> {
            mMediaOutputController.releaseSession();
            dismiss();
        });
        mAppButton.setOnClickListener(v -> {
            mBroadcastSender.closeSystemDialogs();
            if (mMediaOutputController.getAppLaunchIntent() != null) {
                mContext.startActivity(mMediaOutputController.getAppLaunchIntent());
        mAppButton.setOnClickListener(v -> mMediaOutputController.tryToLaunchMediaApplication());
        if (mMediaOutputController.isAdvancedLayoutSupported()) {
            mMediaMetadataSectionLayout.setOnClickListener(
                    v -> mMediaOutputController.tryToLaunchMediaApplication());
        }
            dismiss();
        });
    }

    @Override
@@ -560,7 +558,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements

    @Override
    public void dismissDialog() {
        dismiss();
        mBroadcastSender.closeSystemDialogs();
    }

    void onHeaderIconClick() {
+9 −0
Original line number Diff line number Diff line
@@ -382,6 +382,15 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
        return mContext.getPackageManager().getLaunchIntentForPackage(mPackageName);
    }

    void tryToLaunchMediaApplication() {
        Intent launchIntent = getAppLaunchIntent();
        if (launchIntent != null) {
            launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mCallback.dismissDialog();
            mContext.startActivity(launchIntent);
        }
    }

    CharSequence getHeaderTitle() {
        if (mMediaController != null) {
            final MediaMetadata metadata = mMediaController.getMetadata();
+7 −0
Original line number Diff line number Diff line
@@ -242,6 +242,13 @@ public class MediaOutputBaseDialogTest extends SysuiTestCase {
        verify(mMediaOutputBaseAdapter).notifyDataSetChanged();
    }

    @Test
    public void dismissDialog_closesDialogByBroadcastSender() {
        mMediaOutputBaseDialogImpl.dismissDialog();

        verify(mBroadcastSender).closeSystemDialogs();
    }

    @Test
    public void whenBroadcasting_verifyLeBroadcastServiceCallBackIsRegisteredAndUnregistered() {
        when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
+7 −0
Original line number Diff line number Diff line
@@ -251,6 +251,13 @@ public class MediaOutputControllerTest extends SysuiTestCase {
        verify(mNearbyMediaDevicesManager).unregisterNearbyDevicesCallback(any());
    }

    @Test
    public void tryToLaunchMediaApplication_nullIntent_skip() {
        mMediaOutputController.tryToLaunchMediaApplication();

        verify(mCb, never()).dismissDialog();
    }

    @Test
    public void onDevicesUpdated_unregistersNearbyDevicesCallback() throws RemoteException {
        mMediaOutputController.start(mCb);