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

Commit b8310b0d authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Improve Cast dialog styles

This CL applies the SystemUI dialog theme to the Cast dialog. See
b/202264918#comment20 for before/after screenshots.

Bug: 202264918
Test: Manual
Change-Id: Ic20df867177986a6a73617dd9141e4d091651b5b
parent 6e77c58d
Loading
Loading
Loading
Loading
+33 −16
Original line number Original line Diff line number Diff line
@@ -16,25 +16,26 @@


package com.android.internal.app;
package com.android.internal.app;


import com.android.internal.R;
import android.app.AlertDialog;

import android.app.Dialog;
import android.content.Context;
import android.content.Context;
import android.media.MediaRouter;
import android.media.MediaRouter;
import android.media.MediaRouter.RouteInfo;
import android.media.MediaRouter.RouteInfo;
import android.os.Bundle;
import android.os.Bundle;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.TypedValue;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.TextView;


import com.android.internal.R;

import java.util.Comparator;
import java.util.Comparator;


/**
/**
@@ -48,9 +49,10 @@ import java.util.Comparator;
 *
 *
 * TODO: Move this back into the API, as in the support library media router.
 * TODO: Move this back into the API, as in the support library media router.
 */
 */
public class MediaRouteChooserDialog extends Dialog {
public class MediaRouteChooserDialog extends AlertDialog {
    private final MediaRouter mRouter;
    private final MediaRouter mRouter;
    private final MediaRouterCallback mCallback;
    private final MediaRouterCallback mCallback;
    private final boolean mShowProgressBarWhenEmpty;


    private int mRouteTypes;
    private int mRouteTypes;
    private View.OnClickListener mExtendedSettingsClickListener;
    private View.OnClickListener mExtendedSettingsClickListener;
@@ -60,10 +62,15 @@ public class MediaRouteChooserDialog extends Dialog {
    private boolean mAttachedToWindow;
    private boolean mAttachedToWindow;


    public MediaRouteChooserDialog(Context context, int theme) {
    public MediaRouteChooserDialog(Context context, int theme) {
        this(context, theme, true);
    }

    public MediaRouteChooserDialog(Context context, int theme, boolean showProgressBarWhenEmpty) {
        super(context, theme);
        super(context, theme);


        mRouter = (MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
        mRouter = (MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE);
        mCallback = new MediaRouterCallback();
        mCallback = new MediaRouterCallback();
        mShowProgressBarWhenEmpty = showProgressBarWhenEmpty;
    }
    }


    /**
    /**
@@ -120,28 +127,38 @@ public class MediaRouteChooserDialog extends Dialog {


    @Override
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Note: setView must be called before super.onCreate().
        setView(LayoutInflater.from(getContext()).inflate(R.layout.media_route_chooser_dialog,
                null));


        getWindow().requestFeature(Window.FEATURE_LEFT_ICON);

        setContentView(R.layout.media_route_chooser_dialog);
        setTitle(mRouteTypes == MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY
        setTitle(mRouteTypes == MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY
                ? R.string.media_route_chooser_title_for_remote_display
                ? R.string.media_route_chooser_title_for_remote_display
                : R.string.media_route_chooser_title);
                : R.string.media_route_chooser_title);


        // Must be called after setContentView.
        setIcon(isLightTheme(getContext()) ? R.drawable.ic_media_route_off_holo_light
        getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
                isLightTheme(getContext()) ? R.drawable.ic_media_route_off_holo_light
                : R.drawable.ic_media_route_off_holo_dark);
                : R.drawable.ic_media_route_off_holo_dark);


        super.onCreate(savedInstanceState);

        View emptyView = findViewById(android.R.id.empty);
        mAdapter = new RouteAdapter(getContext());
        mAdapter = new RouteAdapter(getContext());
        mListView = (ListView) findViewById(R.id.media_route_list);
        mListView = (ListView) findViewById(R.id.media_route_list);
        mListView.setAdapter(mAdapter);
        mListView.setAdapter(mAdapter);
        mListView.setOnItemClickListener(mAdapter);
        mListView.setOnItemClickListener(mAdapter);
        mListView.setEmptyView(findViewById(android.R.id.empty));
        mListView.setEmptyView(emptyView);


        mExtendedSettingsButton = (Button) findViewById(R.id.media_route_extended_settings_button);
        mExtendedSettingsButton = (Button) findViewById(R.id.media_route_extended_settings_button);
        updateExtendedSettingsButton();
        updateExtendedSettingsButton();

        if (!mShowProgressBarWhenEmpty) {
            findViewById(R.id.media_route_progress_bar).setVisibility(View.GONE);

            // Center the empty view when the progress bar is not shown.
            LinearLayout.LayoutParams params =
                    (LinearLayout.LayoutParams) emptyView.getLayoutParams();
            params.gravity = Gravity.CENTER;
            emptyView.setLayoutParams(params);
        }
    }
    }


    private void updateExtendedSettingsButton() {
    private void updateExtendedSettingsButton() {
+19 −6
Original line number Original line Diff line number Diff line
@@ -66,24 +66,37 @@ public abstract class MediaRouteDialogPresenter {
        }
        }
    }
    }


    /** Create a media route dialog as appropriate. */
    public static Dialog createDialog(Context context,
    public static Dialog createDialog(Context context,
            int routeTypes, View.OnClickListener extendedSettingsClickListener) {
            int routeTypes, View.OnClickListener extendedSettingsClickListener) {
        final MediaRouter router = (MediaRouter)context.getSystemService(
                Context.MEDIA_ROUTER_SERVICE);

        int theme = MediaRouteChooserDialog.isLightTheme(context)
        int theme = MediaRouteChooserDialog.isLightTheme(context)
                ? android.R.style.Theme_DeviceDefault_Light_Dialog
                ? android.R.style.Theme_DeviceDefault_Light_Dialog
                : android.R.style.Theme_DeviceDefault_Dialog;
                : android.R.style.Theme_DeviceDefault_Dialog;
        return createDialog(context, routeTypes, extendedSettingsClickListener, theme);
    }

    /** Create a media route dialog as appropriate. */
    public static Dialog createDialog(Context context,
            int routeTypes, View.OnClickListener extendedSettingsClickListener, int theme) {
        return createDialog(context, routeTypes, extendedSettingsClickListener, theme,
                true /* showProgressBarWhenEmpty */);
    }

    /** Create a media route dialog as appropriate. */
    public static Dialog createDialog(Context context, int routeTypes,
            View.OnClickListener extendedSettingsClickListener, int theme,
            boolean showProgressBarWhenEmpty) {
        final MediaRouter router = context.getSystemService(MediaRouter.class);


        MediaRouter.RouteInfo route = router.getSelectedRoute();
        MediaRouter.RouteInfo route = router.getSelectedRoute();
        if (route.isDefault() || !route.matchesTypes(routeTypes)) {
        if (route.isDefault() || !route.matchesTypes(routeTypes)) {
            final MediaRouteChooserDialog d = new MediaRouteChooserDialog(context, theme);
            final MediaRouteChooserDialog d = new MediaRouteChooserDialog(context, theme,
                    showProgressBarWhenEmpty);
            d.setRouteTypes(routeTypes);
            d.setRouteTypes(routeTypes);
            d.setExtendedSettingsClickListener(extendedSettingsClickListener);
            d.setExtendedSettingsClickListener(extendedSettingsClickListener);
            return d;
            return d;
        } else {
        } else {
            MediaRouteControllerDialog d = new MediaRouteControllerDialog(context, theme);
            return new MediaRouteControllerDialog(context, theme);
            return d;
        }
        }
    }
    }
}
}
+14 −13
Original line number Original line Diff line number Diff line
@@ -28,13 +28,14 @@


    <!-- Content to show when list is empty. -->
    <!-- Content to show when list is empty. -->
    <LinearLayout android:id="@android:id/empty"
    <LinearLayout android:id="@android:id/empty"
              android:layout_width="match_parent"
        android:layout_width="wrap_content"
              android:layout_height="64dp"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:orientation="horizontal"
        android:paddingLeft="16dp"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:paddingRight="16dp"
        android:visibility="gone">
        android:visibility="gone">
        <ProgressBar android:layout_width="wrap_content"
        <ProgressBar android:id="@+id/media_route_progress_bar"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center" />
            android:layout_gravity="center" />
        <TextView android:layout_width="wrap_content"
        <TextView android:layout_width="wrap_content"
+1 −0
Original line number Original line Diff line number Diff line
@@ -1671,6 +1671,7 @@
  <java-symbol type="id" name="media_route_volume_slider" />
  <java-symbol type="id" name="media_route_volume_slider" />
  <java-symbol type="id" name="media_route_control_frame" />
  <java-symbol type="id" name="media_route_control_frame" />
  <java-symbol type="id" name="media_route_extended_settings_button" />
  <java-symbol type="id" name="media_route_extended_settings_button" />
  <java-symbol type="id" name="media_route_progress_bar" />
  <java-symbol type="string" name="media_route_chooser_title" />
  <java-symbol type="string" name="media_route_chooser_title" />
  <java-symbol type="string" name="media_route_chooser_title_for_remote_display" />
  <java-symbol type="string" name="media_route_chooser_title_for_remote_display" />
  <java-symbol type="string" name="media_route_controller_disconnect" />
  <java-symbol type="string" name="media_route_controller_disconnect" />
+32 −0
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2021 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.
  -->
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    android:color="?android:attr/colorControlHighlight">
    <item android:id="@android:id/mask">
        <shape android:shape="rectangle">
            <solid android:color="@android:color/white"/>
            <corners android:radius="18dp"/>
        </shape>
    </item>
    <item>
        <shape android:shape="rectangle">
            <corners android:radius="18dp"/>
            <solid android:color="?androidprv:attr/colorAccentPrimary"/>
        </shape>
    </item>
</ripple>
Loading