Merge "Improve Cast dialog styles" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
24637529b6
@@ -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;
|
||||
|
||||
/**
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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
|
||||
: R.drawable.ic_media_route_off_holo_dark);
|
||||
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 = (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);
|
||||
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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,20 +28,21 @@
|
||||
|
||||
<!-- Content to show when list is empty. -->
|
||||
<LinearLayout android:id="@android:id/empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:visibility="gone">
|
||||
<ProgressBar android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center" />
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:visibility="gone">
|
||||
<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"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:paddingStart="16dp"
|
||||
android:text="@string/media_route_chooser_searching" />
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:paddingStart="16dp"
|
||||
android:text="@string/media_route_chooser_searching" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Settings button. -->
|
||||
|
||||
@@ -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" />
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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>
|
||||
@@ -22,10 +22,6 @@
|
||||
android:scrollbarAlwaysDrawVerticalTrack="true"
|
||||
android:scrollIndicators="top|bottom"
|
||||
android:fillViewport="true"
|
||||
android:paddingTop="@dimen/dialog_button_bar_top_padding"
|
||||
android:paddingStart="@dimen/dialog_side_padding"
|
||||
android:paddingEnd="@dimen/dialog_side_padding"
|
||||
android:paddingBottom="@dimen/dialog_bottom_padding"
|
||||
style="?android:attr/buttonBarStyle">
|
||||
<com.android.internal.widget.ButtonBarLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -83,9 +83,15 @@
|
||||
android:layout_height="wrap_content" />
|
||||
</FrameLayout>
|
||||
|
||||
<include
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
layout="@layout/alert_dialog_button_bar_systemui" />
|
||||
android:paddingStart="@dimen/dialog_side_padding"
|
||||
android:paddingEnd="@dimen/dialog_side_padding">
|
||||
<include
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
layout="@layout/alert_dialog_button_bar_systemui" />
|
||||
</FrameLayout>
|
||||
|
||||
</com.android.internal.widget.AlertDialogLayout>
|
||||
@@ -381,12 +381,19 @@
|
||||
<item name="android:buttonBarNeutralButtonStyle">@style/Widget.Dialog.Button.BorderButton</item>
|
||||
<item name="android:colorBackground">?androidprv:attr/colorSurface</item>
|
||||
<item name="android:alertDialogStyle">@style/AlertDialogStyle</item>
|
||||
<item name="android:buttonBarStyle">@style/ButtonBarStyle</item>
|
||||
<item name="android:buttonBarButtonStyle">@style/Widget.Dialog.Button.Large</item>
|
||||
</style>
|
||||
|
||||
<style name="AlertDialogStyle" parent="@androidprv:style/AlertDialog.DeviceDefault">
|
||||
<item name="android:layout">@layout/alert_dialog_systemui</item>
|
||||
</style>
|
||||
|
||||
<style name="ButtonBarStyle" parent="@androidprv:style/DeviceDefault.ButtonBar.AlertDialog">
|
||||
<item name="android:paddingTop">@dimen/dialog_button_bar_top_padding</item>
|
||||
<item name="android:paddingBottom">@dimen/dialog_bottom_padding</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.SystemUI.Dialog.Alert" parent="@*android:style/Theme.DeviceDefault.Light.Dialog.Alert" />
|
||||
|
||||
<style name="Theme.SystemUI.Dialog.GlobalActions" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar.Fullscreen">
|
||||
@@ -962,6 +969,11 @@
|
||||
<item name="android:textColor">?android:attr/textColorPrimary</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.Dialog.Button.Large">
|
||||
<item name="android:background">@drawable/qs_dialog_btn_filled_large</item>
|
||||
<item name="android:minHeight">56dp</item>
|
||||
</style>
|
||||
|
||||
<style name="MainSwitch.Settingslib" parent="@android:style/Theme.DeviceDefault">
|
||||
<item name="android:switchMinWidth">@dimen/settingslib_min_switch_width</item>
|
||||
</style>
|
||||
|
||||
@@ -202,11 +202,12 @@ public class CastTile extends QSTileImpl<BooleanState> {
|
||||
mActivityStarter
|
||||
.postStartActivityDismissingKeyguard(getLongClickIntent(), 0,
|
||||
controller);
|
||||
});
|
||||
}, R.style.Theme_SystemUI_Dialog, false /* showProgressBarWhenEmpty */);
|
||||
holder.init(dialog);
|
||||
SystemUIDialog.setShowForAllUsers(dialog, true);
|
||||
SystemUIDialog.registerDismissListener(dialog);
|
||||
SystemUIDialog.setWindowOnTop(dialog, mKeyguard.isShowing());
|
||||
SystemUIDialog.setDialogSize(dialog);
|
||||
|
||||
mUiHandler.post(() -> {
|
||||
if (view != null) {
|
||||
|
||||
Reference in New Issue
Block a user