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

This commit is contained in:
Christofer Åkersten
2017-08-09 16:45:51 +00:00
committed by Android (Google) Code Review
6 changed files with 28 additions and 9 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;
}
}

View File

@@ -47,6 +47,10 @@
<item>@drawable/ic_clear_material</item>
<item>@drawable/ic_dialog_alert_material</item>
<item>@drawable/ic_go_search_api_material</item>
<item>@drawable/ic_media_route_connecting_dark_material</item>
<item>@drawable/ic_media_route_connecting_light_material</item>
<item>@drawable/ic_media_route_dark_material</item>
<item>@drawable/ic_media_route_light_material</item>
<item>@drawable/ic_menu_copy_material</item>
<item>@drawable/ic_menu_cut_material</item>
<item>@drawable/ic_menu_moreoverflow_material</item>

View File

@@ -1306,10 +1306,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">