@@ -1482,10 +1482,10 @@ public void run() {
1482
1482
if (VoiceControlForPlexApplication .getInstance ().hasLocalmedia ())
1483
1483
hidePurchaseLocalmediaMenuItem ();
1484
1484
1485
- if ( VoiceControlForPlexApplication . getInstance (). hasChromecast ()) {
1486
- MenuItem chromecastOptionsItem = menu .findItem (R .id .menu_chromecast_video );
1487
- chromecastOptionsItem .setVisible (true );
1488
- }
1485
+ MenuItem chromecastOptionsItem = menu . findItem ( R . id . menu_chromecast_video );
1486
+ MenuItem chromecastPurchaseItem = menu .findItem (R .id .menu_purchase_chromecast );
1487
+ chromecastPurchaseItem .setVisible (! VoiceControlForPlexApplication . getInstance (). hasChromecast () );
1488
+ chromecastOptionsItem . setVisible ( VoiceControlForPlexApplication . getInstance (). hasChromecast ());
1489
1489
1490
1490
SwitchCompat usageExamplesSwitch = (SwitchCompat )menu .findItem (R .id .menu_usage_hints_switch ).getActionView ();
1491
1491
usageExamplesSwitch .setChecked (prefs .get (Preferences .SHOW_USAGE_HINTS , true ));
@@ -1640,7 +1640,7 @@ public void onDeviceSelected(PlexDevice device, boolean resume) {
1640
1640
animateCastIcon ();
1641
1641
1642
1642
if (clientSelected .isCastClient ) {
1643
- if (VoiceControlForPlexApplication .getInstance ().hasChromecast ()) {
1643
+ if (VoiceControlForPlexApplication .getInstance ().hasChromecast () || prefs . get ( Preferences . HAS_SHOWN_INITIAL_CHROMECAST_PURCHASE , false ) ) {
1644
1644
client = clientSelected ;
1645
1645
logger .d ("subscribing to %s" , client .name );
1646
1646
castPlayerManager .subscribe (client , !castPlayerManager .isSubscribed ());
@@ -2210,15 +2210,20 @@ public void run() {
2210
2210
2211
2211
}
2212
2212
2213
- protected void showChromecastPurchase (PlexClient client , Runnable onSuccess ) {
2213
+ public void purchaseChromecast (MenuItem item ) {
2214
+ VoiceControlForPlexApplication .getInstance ().getIabHelper ().launchPurchaseFlow (MainActivity .this , VoiceControlForPlexApplication .SKU_CHROMECAST , 10001 , mPurchaseFinishedListener , VoiceControlForPlexApplication .SKU_TEST_PURCHASED == VoiceControlForPlexApplication .SKU_CHROMECAST ? VoiceControlForPlexApplication .getInstance ().getEmailHash () : "" );
2215
+ }
2216
+
2217
+ protected void showChromecastPurchase (PlexClient client , final Runnable onSuccess ) {
2214
2218
postChromecastPurchaseClient = client ;
2215
2219
postChromecastPurchaseAction = onSuccess ;
2220
+ prefs .put (Preferences .HAS_SHOWN_INITIAL_CHROMECAST_PURCHASE , true );
2216
2221
AlertDialog .Builder builder = new AlertDialog .Builder (this );
2217
2222
View view = getLayoutInflater ().inflate (R .layout .popup_chromecast_purchase , null );
2218
2223
builder .setView (view );
2219
2224
final AlertDialog dialog = builder .setCancelable (false ).create ();
2220
2225
TextView popupChromecastPurchaseMessage = (TextView )view .findViewById (R .id .popupChromecastPurchaseMessage );
2221
- popupChromecastPurchaseMessage .setText (String .format (getString (R .string .must_purchase_chromecast ), VoiceControlForPlexApplication .getChromecastPrice ()));
2226
+ popupChromecastPurchaseMessage .setText (String .format (getString (R .string .must_purchase_chromecast2 ), VoiceControlForPlexApplication .getChromecastPrice ()));
2222
2227
Button popupChromecastPurchaseOKButton = (Button )view .findViewById (R .id .popupChromecastPurchaseOKButton );
2223
2228
popupChromecastPurchaseOKButton .setOnClickListener (new View .OnClickListener () {
2224
2229
@ Override
@@ -2232,7 +2237,7 @@ public void onClick(View v) {
2232
2237
@ Override
2233
2238
public void onClick (View v ) {
2234
2239
dialog .cancel ();
2235
- setCastIconInactive ();
2240
+ onSuccess . run ();
2236
2241
}
2237
2242
});
2238
2243
dialog .show ();
0 commit comments