From f67f57726d93e1d8fcb67d5bad34dfae6901f1c4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 5 Jun 2015 01:32:14 -0400 Subject: [PATCH] update connect --- dashboard-ui/css/search.css | 16 ++- dashboard-ui/thirdparty/cordova/chromecast.js | 3 - .../thirdparty/cordova/generaldevice.js | 97 ++++++++++--------- .../cordova/registrationservices.js | 5 + dashboard-ui/voice/voice.js | 4 +- 5 files changed, 75 insertions(+), 50 deletions(-) diff --git a/dashboard-ui/css/search.css b/dashboard-ui/css/search.css index ee046f0ef8..79fd6dc0c5 100644 --- a/dashboard-ui/css/search.css +++ b/dashboard-ui/css/search.css @@ -206,7 +206,21 @@ } .searchResultsContainer { - padding: 2em; + padding: .5em; +} + +@media all and (min-width: 800px) { + .searchResultsContainer { + padding-left: 1em; + padding-right: 1em; + } +} + +@media all and (min-height: 800px) { + .searchResultsContainer { + padding-top: 1em; + padding-bottom: 1em; + } } .btnCloseSearch { diff --git a/dashboard-ui/thirdparty/cordova/chromecast.js b/dashboard-ui/thirdparty/cordova/chromecast.js index fcfbf97f02..9d218f4b14 100644 --- a/dashboard-ui/thirdparty/cordova/chromecast.js +++ b/dashboard-ui/thirdparty/cordova/chromecast.js @@ -604,9 +604,6 @@ console.log('Will attempt to connect to Chromecast'); - Dashboard.showModalLoadingMsg(); - setTimeout(Dashboard.hideModalLoadingMsg, 3000); - if (device.isReady()) { console.log('Device is already ready, calling onDeviceReady'); onDeviceReady(device); diff --git a/dashboard-ui/thirdparty/cordova/generaldevice.js b/dashboard-ui/thirdparty/cordova/generaldevice.js index f0331d15a0..9fcb561fc5 100644 --- a/dashboard-ui/thirdparty/cordova/generaldevice.js +++ b/dashboard-ui/thirdparty/cordova/generaldevice.js @@ -1,6 +1,7 @@ (function () { var currentPairingDeviceId; + var currentPairedDeviceId; var currentDevice; var PlayerName = "ConnectSDK"; @@ -478,69 +479,41 @@ return data; }; - function onDisconnected(device) { + function cleanupSession() { - if (currentDevice && device.getId() == currentDevice.getId()) { - currentDevice = null; - MediaController.removeActiveTarget(device.getId()); + if (currentDevice != null) { + currentDevice.off("ready"); + currentDevice.off("disconnect"); + + currentDevice.disconnect(); } + + currentPairedDeviceId = null; + currentDevice = null; } - function onDeviceReady(device) { + function onDeviceReady(device, deferred) { if (currentPairingDeviceId != device.getId()) { console.log('device ready fired for a different device. ignoring.'); return; } - currentDevice = device; - MediaController.setActivePlayer(PlayerName, convertDeviceToTarget(device)); + deferred.resolve(); } - var boundHandlers = []; - self.tryPair = function (target) { var deferred = $.Deferred(); - var manager = ConnectSDK.discoveryManager; - - var device = manager.getDeviceList().filter(function (d) { + var device = ConnectSDK.discoveryManager.getDeviceList().filter(function (d) { return d.getId() == target.id; })[0]; if (device) { - var deviceId = device.getId(); - currentPairingDeviceId = deviceId; - - console.log('Will attempt to connect to device'); - - if (device.isReady()) { - console.log('Device is already ready, calling onDeviceReady'); - onDeviceReady(device); - } else { - - console.log('Binding device ready handler'); - - if (boundHandlers.indexOf(deviceId) == -1) { - - boundHandlers.push(deviceId); - device.on("ready", function () { - console.log('device.ready fired'); - onDeviceReady(device); - }); - device.on("disconnect", function () { - console.log('device.disconnect fired'); - onDisconnected(device); - }); - } - - console.log('Calling device.connect'); - device.connect(); - } - //deferred.resolve(); + self.tryPairWithDevice(device, deferred); } else { deferred.reject(); @@ -549,11 +522,47 @@ return deferred.promise(); }; + self.tryPairWithDevice = function (device, deferred) { + + var deviceId = device.getId(); + currentPairingDeviceId = deviceId; + + console.log('Will attempt to connect to Connect device'); + + Dashboard.showModalLoadingMsg(); + setTimeout(Dashboard.hideModalLoadingMsg, 3000); + + if (device.isReady()) { + console.log('Device is already ready, calling onDeviceReady'); + onDeviceReady(device, deferred); + } else { + + console.log('Binding device ready handler'); + + device.on("ready", function () { + console.log('device.ready fired'); + onDeviceReady(device, deferred); + }); + + device.on("disconnect", function () { + device.off("ready"); + device.off("disconnect"); + }); + + console.log('Calling device.connect'); + device.connect(); + } + }; + $(MediaController).on('playerchange', function (e, newPlayer, newTarget) { - if (currentDevice && newTarget.id != currentDevice.getId()) { - MediaController.removeActiveTarget(currentDevice.getId()); - currentDevice = null; + if (currentPairedDeviceId) { + if (newTarget.id != currentPairedDeviceId) { + if (currentDevice) { + console.log('Disconnecting from connect device'); + cleanupSession(); + } + } } }); } diff --git a/dashboard-ui/thirdparty/cordova/registrationservices.js b/dashboard-ui/thirdparty/cordova/registrationservices.js index fc195a0d93..be0904d680 100644 --- a/dashboard-ui/thirdparty/cordova/registrationservices.js +++ b/dashboard-ui/thirdparty/cordova/registrationservices.js @@ -29,6 +29,11 @@ function validateLiveTV(deferred) { + if (!isAndroid()) { + deferred.resolve(); + return; + } + validateFeature(getPremiumUnlockFeatureId(), deferred); } diff --git a/dashboard-ui/voice/voice.js b/dashboard-ui/voice/voice.js index f7968d5a94..c1516df547 100644 --- a/dashboard-ui/voice/voice.js +++ b/dashboard-ui/voice/voice.js @@ -311,7 +311,7 @@ items = shuffleArray(items); } - items = items.map(function(i) { + items = items.map(function (i) { return i.Id; }); @@ -437,7 +437,7 @@ $('.voiceInputText').html(text); - if (text) { + if (text || AppInfo.isNativeApp) { $('.blockedMessage').hide(); } else { $('.blockedMessage').show();