Last active
March 1, 2019 09:29
-
-
Save rharter/c2787f9ddd32651e8885 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<declare-styleable name="ThemeableMediaRouteButton"> | |
<!-- This drawable is a state list where the "checked" state | |
indicates active media routing. Checkable indicates connecting | |
and non-checked / non-checkable indicates | |
that media is playing to the local device only. --> | |
<attr name="routeEnabledDrawable" format="reference" /> | |
<attr name="iconColor" format="reference|color" /> | |
<attr name="android:minWidth" /> | |
<attr name="android:minHeight" /> | |
</declare-styleable> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<style name="Widget.MediaRouter.MediaRouteButton" parent="Widget.MediaRouter.Light.MediaRouteButton"> | |
<item name="routeEnabledDrawable">@drawable/ic_chrome_media_route</item> | |
<item name="iconColor">@color/red</item> | |
</style> | |
<style name="Widget.MediaRouter.MediaRouteButton.Section1"> | |
<item name="iconColor">@color/white</item> | |
</style> | |
<style name="Widget.MediaRouter.MediaRouteButton.Section2"> | |
<item name="iconColor">@color/blue</item> | |
</style> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ryanharter.mediaroute.widgets; | |
import android.content.Context; | |
import android.support.v7.app.MediaRouteActionProvider; | |
import android.support.v7.app.MediaRouteButton; | |
/** | |
* A MediaRouteActionProvider that allows the use of a ThemeableMediaRouteButton. | |
*/ | |
public class ThemeableMediaRouteActionProvider extends MediaRouteActionProvider { | |
public ThemeableMediaRouteActionProvider(Context context) { | |
super(context); | |
} | |
@Override public MediaRouteButton onCreateMediaRouteButton() { | |
return new ThemeableMediaRouteButton(getContext()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<resources> | |
<style name="Theme.MyApp"> | |
<item name="mediaRouteButtonStyle">@style/Widget.MediaRouter.MediaRouteButton</item> | |
</style> | |
<style name="Theme.MyApp.Section1"> | |
<item name="mediaRouteButtonStyle">@style/Widget.MediaRouter.MediaRouteButton.Section1</item> | |
</style> | |
<style name="Theme.MyApp.Section2"> | |
<item name="mediaRouteButtonStyle">@style/Widget.MediaRouter.MediaRouteButton.Section2</item> | |
</style> | |
</resources> |
I have just implemented the same requirement, it seems that the cast lib has evolved in the right direction since your gist, setRemoteIndicatorDrawable() is now a public method.
So all that is left is just to call it in the overrided constructor, no need to recopy half the class anymore :)
I've tried step by step... it does not work
I have done it. you are awesome man ^-^
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Harter, do you mind publishing a sample? Thanks.