Merge "Inherit theme dark/light scheme for MediaRouter dialogs/button" into oc-dr1-dev

This commit is contained in:
TreeHugger Robot
2017-08-09 17:31:48 +00:00
committed by Android (Google) Code Review
65 changed files with 103 additions and 14 deletions

View File

@@ -24,6 +24,7 @@ import android.media.MediaRouter;
import android.media.MediaRouter.RouteInfo;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -130,7 +131,8 @@ public class MediaRouteChooserDialog extends Dialog {
// Must be called after setContentView.
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
R.drawable.ic_media_route_off_holo_dark);
isLightTheme(getContext()) ? R.drawable.ic_media_route_off_holo_light
: R.drawable.ic_media_route_off_holo_dark);
mAdapter = new RouteAdapter(getContext());
mListView = (ListView)findViewById(R.id.media_route_list);
@@ -176,6 +178,12 @@ public class MediaRouteChooserDialog extends Dialog {
}
}
static boolean isLightTheme(Context context) {
TypedValue value = new TypedValue();
return context.getTheme().resolveAttribute(R.attr.isLightTheme, value, true)
&& value.data != 0;
}
private final class RouteAdapter extends ArrayAdapter<MediaRouter.RouteInfo>
implements ListView.OnItemClickListener {
private final LayoutInflater mInflater;

View File

@@ -43,8 +43,12 @@ public class MediaRouteChooserDialogFragment extends DialogFragment {
* </p>
*/
public MediaRouteChooserDialogFragment() {
int theme = MediaRouteChooserDialog.isLightTheme(getContext())
? android.R.style.Theme_DeviceDefault_Light_Dialog
: android.R.style.Theme_DeviceDefault_Dialog;
setCancelable(true);
setStyle(STYLE_NORMAL, android.R.style.Theme_DeviceDefault_Dialog);
setStyle(STYLE_NORMAL, theme);
}
public int getRouteTypes() {

View File

@@ -71,16 +71,18 @@ public abstract class MediaRouteDialogPresenter {
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;
MediaRouter.RouteInfo route = router.getSelectedRoute();
if (route.isDefault() || !route.matchesTypes(routeTypes)) {
final MediaRouteChooserDialog d = new MediaRouteChooserDialog(
context, android.R.style.Theme_DeviceDefault_Dialog);
final MediaRouteChooserDialog d = new MediaRouteChooserDialog(context, theme);
d.setRouteTypes(routeTypes);
d.setExtendedSettingsClickListener(extendedSettingsClickListener);
return d;
} else {
MediaRouteControllerDialog d = new MediaRouteControllerDialog(
context, android.R.style.Theme_DeviceDefault_Dialog);
MediaRouteControllerDialog d = new MediaRouteControllerDialog(context, theme);
return d;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 409 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 495 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 559 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 659 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 446 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 448 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 674 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 627 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 450 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 751 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 865 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 860 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 899 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 909 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 875 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 877 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 891 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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.
-->
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:duration="500">
<bitmap android:src="@drawable/ic_media_route_on_0_mtrl_alpha"
android:tint="?attr/colorControlNormal" />
</item>
<item android:duration="500">
<bitmap android:src="@drawable/ic_media_route_on_1_mtrl_alpha"
android:tint="?attr/colorControlNormal" />
</item>
<item android:duration="500">
<bitmap android:src="@drawable/ic_media_route_on_2_mtrl_alpha"
android:tint="?attr/colorControlNormal" />
</item>
<item android:duration="500">
<bitmap android:src="@drawable/ic_media_route_on_1_mtrl_alpha"
android:tint="?attr/colorControlNormal" />
</item>
</animation-list>

View File

@@ -17,7 +17,7 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_enabled="true"
android:drawable="@android:drawable/ic_media_route_connecting_material" />
android:drawable="@android:drawable/ic_media_route_connecting_material_dark" />
<item android:state_activated="true" android:state_enabled="true">
<bitmap android:src="@android:drawable/ic_media_route_on_mtrl_alpha"
android:tint="?attr/colorControlNormal" />

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_enabled="true"
android:drawable="@android:drawable/ic_media_route_connecting_material_light" />
<item android:state_activated="true" android:state_enabled="true">
<bitmap android:src="@android:drawable/ic_media_route_on_mtrl_alpha"
android:tint="?attr/colorControlNormal" />
</item>
<item android:state_enabled="true">
<bitmap android:src="@android:drawable/ic_media_route_off_mtrl_alpha"
android:tint="?attr/colorControlNormal" />
</item>
<item>
<bitmap android:src="@android:drawable/ic_media_route_disabled_mtrl_alpha"
android:tint="?attr/colorControlNormal" />
</item>
</selector>

View File

@@ -66,8 +66,10 @@
<item>@drawable/ic_find_previous_material</item>
<item>@drawable/ic_go</item>
<item>@drawable/ic_go_search_api_material</item>
<item>@drawable/ic_media_route_connecting_material</item>
<item>@drawable/ic_media_route_material</item>
<item>@drawable/ic_media_route_connecting_material_dark</item>
<item>@drawable/ic_media_route_connecting_material_light</item>
<item>@drawable/ic_media_route_material_dark</item>
<item>@drawable/ic_media_route_material_light</item>
<item>@drawable/ic_menu_close_clear_cancel</item>
<item>@drawable/ic_menu_copy_material</item>
<item>@drawable/ic_menu_cut_material</item>

View File

@@ -1054,7 +1054,7 @@ please see styles_device_defaults.xml.
</style>
<style name="Widget.Material.MediaRouteButton" parent ="Widget.Material.ActionButton">
<item name="externalRouteEnabledDrawable">@drawable/ic_media_route_material</item>
<item name="externalRouteEnabledDrawable">@drawable/ic_media_route_material_dark</item>
<item name="contentDescription">@string/media_route_button_content_description</item>
</style>
@@ -1203,7 +1203,10 @@ please see styles_device_defaults.xml.
<style name="Widget.Material.Light.ActionBar" parent="Widget.Material.ActionBar" />
<style name="Widget.Material.Light.ActionBar.Solid" parent="Widget.Material.ActionBar.Solid" />
<style name="Widget.Material.Light.FastScroll" parent="Widget.Material.FastScroll"/>
<style name="Widget.Material.Light.MediaRouteButton" parent="Widget.Material.MediaRouteButton" />
<style name="Widget.Material.Light.MediaRouteButton" parent ="Widget.Material.MediaRouteButton">
<item name="externalRouteEnabledDrawable">@drawable/ic_media_route_material_light</item>
</style>
<!-- Animation Styles -->

View File

@@ -1318,10 +1318,8 @@
<java-symbol type="drawable" name="unlock_wave" />
<java-symbol type="drawable" name="notification_template_icon_bg" />
<java-symbol type="drawable" name="notification_template_icon_low_bg" />
<java-symbol type="drawable" name="ic_media_route_on_holo_dark" />
<java-symbol type="drawable" name="ic_media_route_off_holo_dark" />
<java-symbol type="drawable" name="ic_media_route_connecting_holo_dark" />
<java-symbol type="drawable" name="ic_media_route_disabled_holo_dark" />
<java-symbol type="drawable" name="ic_media_route_off_holo_light" />
<java-symbol type="drawable" name="cling_button" />
<java-symbol type="drawable" name="cling_arrow_up" />
<java-symbol type="drawable" name="cling_bg" />

View File

@@ -307,6 +307,9 @@
<item name="android:colorControlHighlight">@*android:color/primary_text_material_dark</item>
<item name="*android:lockPatternStyle">@style/LockPatternStyle</item>
<item name="passwordStyle">@style/PasswordTheme</item>
<!-- Needed for MediaRoute chooser dialog -->
<item name="*android:isLightTheme">false</item>
</style>
<style name="Theme.SystemUI.Light" parent="@*android:style/Theme.DeviceDefault.QuickSettings">