Loading core/java/com/android/internal/app/MediaRouteChooserDialog.java +33 −16 Original line number Diff line number Diff line Loading @@ -16,25 +16,26 @@ package com.android.internal.app; import com.android.internal.R; import android.app.Dialog; import android.app.AlertDialog; import android.content.Context; import android.media.MediaRouter; import android.media.MediaRouter.RouteInfo; import android.os.Bundle; import android.text.TextUtils; import android.util.TypedValue; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import com.android.internal.R; import java.util.Comparator; /** Loading @@ -48,9 +49,10 @@ import java.util.Comparator; * * 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 MediaRouterCallback mCallback; private final boolean mShowProgressBarWhenEmpty; private int mRouteTypes; private View.OnClickListener mExtendedSettingsClickListener; Loading @@ -60,10 +62,15 @@ public class MediaRouteChooserDialog extends Dialog { private boolean mAttachedToWindow; public MediaRouteChooserDialog(Context context, int theme) { this(context, theme, true); } public MediaRouteChooserDialog(Context context, int theme, boolean showProgressBarWhenEmpty) { super(context, theme); mRouter = (MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE); mCallback = new MediaRouterCallback(); mShowProgressBarWhenEmpty = showProgressBarWhenEmpty; } /** Loading Loading @@ -120,28 +127,38 @@ public class MediaRouteChooserDialog extends Dialog { @Override 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 ? R.string.media_route_chooser_title_for_remote_display : R.string.media_route_chooser_title); // Must be called after setContentView. getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, isLightTheme(getContext()) ? R.drawable.ic_media_route_off_holo_light setIcon(isLightTheme(getContext()) ? R.drawable.ic_media_route_off_holo_light : R.drawable.ic_media_route_off_holo_dark); super.onCreate(savedInstanceState); View emptyView = findViewById(android.R.id.empty); mAdapter = new RouteAdapter(getContext()); mListView = (ListView) findViewById(R.id.media_route_list); mListView.setAdapter(mAdapter); mListView.setOnItemClickListener(mAdapter); mListView.setEmptyView(findViewById(android.R.id.empty)); mListView.setEmptyView(emptyView); mExtendedSettingsButton = (Button) findViewById(R.id.media_route_extended_settings_button); 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() { Loading core/java/com/android/internal/app/MediaRouteDialogPresenter.java +19 −6 Original line number Diff line number Diff line Loading @@ -66,24 +66,37 @@ public abstract class MediaRouteDialogPresenter { } } /** Create a media route dialog as appropriate. */ public static Dialog createDialog(Context context, int routeTypes, View.OnClickListener extendedSettingsClickListener) { final MediaRouter router = (MediaRouter)context.getSystemService( Context.MEDIA_ROUTER_SERVICE); int theme = MediaRouteChooserDialog.isLightTheme(context) ? android.R.style.Theme_DeviceDefault_Light_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(); 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.setExtendedSettingsClickListener(extendedSettingsClickListener); return d; } else { MediaRouteControllerDialog d = new MediaRouteControllerDialog(context, theme); return d; return new MediaRouteControllerDialog(context, theme); } } } core/res/res/layout/media_route_chooser_dialog.xml +14 −13 Original line number Diff line number Diff line Loading @@ -28,13 +28,14 @@ <!-- Content to show when list is empty. --> <LinearLayout android:id="@android:id/empty" android:layout_width="match_parent" android:layout_height="64dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingLeft="16dp" android:paddingRight="16dp" 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_gravity="center" /> <TextView android:layout_width="wrap_content" Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1676,6 +1676,7 @@ <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_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_for_remote_display" /> <java-symbol type="string" name="media_route_controller_disconnect" /> Loading packages/SystemUI/res/drawable/qs_dialog_btn_filled_large.xml 0 → 100644 +32 −0 Original line number 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
core/java/com/android/internal/app/MediaRouteChooserDialog.java +33 −16 Original line number Diff line number Diff line Loading @@ -16,25 +16,26 @@ package com.android.internal.app; import com.android.internal.R; import android.app.Dialog; import android.app.AlertDialog; import android.content.Context; import android.media.MediaRouter; import android.media.MediaRouter.RouteInfo; import android.os.Bundle; import android.text.TextUtils; import android.util.TypedValue; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import com.android.internal.R; import java.util.Comparator; /** Loading @@ -48,9 +49,10 @@ import java.util.Comparator; * * 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 MediaRouterCallback mCallback; private final boolean mShowProgressBarWhenEmpty; private int mRouteTypes; private View.OnClickListener mExtendedSettingsClickListener; Loading @@ -60,10 +62,15 @@ public class MediaRouteChooserDialog extends Dialog { private boolean mAttachedToWindow; public MediaRouteChooserDialog(Context context, int theme) { this(context, theme, true); } public MediaRouteChooserDialog(Context context, int theme, boolean showProgressBarWhenEmpty) { super(context, theme); mRouter = (MediaRouter) context.getSystemService(Context.MEDIA_ROUTER_SERVICE); mCallback = new MediaRouterCallback(); mShowProgressBarWhenEmpty = showProgressBarWhenEmpty; } /** Loading Loading @@ -120,28 +127,38 @@ public class MediaRouteChooserDialog extends Dialog { @Override 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 ? R.string.media_route_chooser_title_for_remote_display : R.string.media_route_chooser_title); // Must be called after setContentView. getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, isLightTheme(getContext()) ? R.drawable.ic_media_route_off_holo_light setIcon(isLightTheme(getContext()) ? R.drawable.ic_media_route_off_holo_light : R.drawable.ic_media_route_off_holo_dark); super.onCreate(savedInstanceState); View emptyView = findViewById(android.R.id.empty); mAdapter = new RouteAdapter(getContext()); mListView = (ListView) findViewById(R.id.media_route_list); mListView.setAdapter(mAdapter); mListView.setOnItemClickListener(mAdapter); mListView.setEmptyView(findViewById(android.R.id.empty)); mListView.setEmptyView(emptyView); mExtendedSettingsButton = (Button) findViewById(R.id.media_route_extended_settings_button); 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() { Loading
core/java/com/android/internal/app/MediaRouteDialogPresenter.java +19 −6 Original line number Diff line number Diff line Loading @@ -66,24 +66,37 @@ public abstract class MediaRouteDialogPresenter { } } /** Create a media route dialog as appropriate. */ public static Dialog createDialog(Context context, int routeTypes, View.OnClickListener extendedSettingsClickListener) { final MediaRouter router = (MediaRouter)context.getSystemService( Context.MEDIA_ROUTER_SERVICE); int theme = MediaRouteChooserDialog.isLightTheme(context) ? android.R.style.Theme_DeviceDefault_Light_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(); 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.setExtendedSettingsClickListener(extendedSettingsClickListener); return d; } else { MediaRouteControllerDialog d = new MediaRouteControllerDialog(context, theme); return d; return new MediaRouteControllerDialog(context, theme); } } }
core/res/res/layout/media_route_chooser_dialog.xml +14 −13 Original line number Diff line number Diff line Loading @@ -28,13 +28,14 @@ <!-- Content to show when list is empty. --> <LinearLayout android:id="@android:id/empty" android:layout_width="match_parent" android:layout_height="64dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:paddingLeft="16dp" android:paddingRight="16dp" 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_gravity="center" /> <TextView android:layout_width="wrap_content" Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1676,6 +1676,7 @@ <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_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_for_remote_display" /> <java-symbol type="string" name="media_route_controller_disconnect" /> Loading
packages/SystemUI/res/drawable/qs_dialog_btn_filled_large.xml 0 → 100644 +32 −0 Original line number 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>