]> _ Git - tortuga-home.git/commitdiff
.
authorVincent <vincent@enhydra.fr>
Thu, 29 Oct 2020 08:57:39 +0000 (09:57 +0100)
committerVincent <vincent@enhydra.fr>
Thu, 29 Oct 2020 08:57:39 +0000 (09:57 +0100)
.idea/workspace.xml
index.php
scripts/lib/lib.php
scripts/lib/shield.php [new file with mode: 0644]
scripts/shield.php [new file with mode: 0644]
service-worker.js

index f78f3201222c5ddaaefebed0545b7778ef51d4b3..92979e7e24e39f984034df703334109b91d05d4c 100644 (file)
@@ -2,13 +2,12 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="352ce63a-b52a-41a2-979b-becda7920939" name="Default" comment=".">
-      <change afterPath="$PROJECT_DIR$/cache-polyfill.js" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/scripts/lib/shield.php" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/scripts/shield.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/index.php" beforeDir="false" afterPath="$PROJECT_DIR$/index.php" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/js/webapp.js" beforeDir="false" afterPath="$PROJECT_DIR$/js/webapp.js" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/manifest.php" beforeDir="false" afterPath="$PROJECT_DIR$/manifest.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/lib.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/lib.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/service-worker.js" beforeDir="false" afterPath="$PROJECT_DIR$/service-worker.js" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/service-worker.js.template" beforeDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1603095373591" duration="1368000" />
       <workItem from="1603270756890" duration="3366000" />
       <workItem from="1603558842019" duration="15438000" />
-      <workItem from="1603646440968" duration="3050000" />
-    </task>
-    <task id="LOCAL-00306" summary=".">
-      <created>1582220578115</created>
-      <option name="number" value="00306" />
-      <option name="presentableId" value="LOCAL-00306" />
-      <option name="project" value="LOCAL" />
-      <updated>1582220578115</updated>
+      <workItem from="1603646440968" duration="3909000" />
+      <workItem from="1603811262372" duration="1988000" />
+      <workItem from="1603958541180" duration="2708000" />
     </task>
     <task id="LOCAL-00307" summary=".">
       <created>1582798632124</created>
       <option name="project" value="LOCAL" />
       <updated>1603643895376</updated>
     </task>
-    <option name="localTasksCounter" value="355" />
+    <task id="LOCAL-00355" summary=".">
+      <created>1603650334848</created>
+      <option name="number" value="00355" />
+      <option name="presentableId" value="LOCAL-00355" />
+      <option name="project" value="LOCAL" />
+      <updated>1603650334849</updated>
+    </task>
+    <option name="localTasksCounter" value="356" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
     <state x="872" y="161" key="#Plugins/0.0.2560.1040@0.0.2560.1040" timestamp="1596008801840" />
-    <state x="198" y="0" width="745" height="567" key="CommitChangelistDialog2" timestamp="1603643887312">
+    <state x="198" y="0" width="745" height="567" key="CommitChangelistDialog2" timestamp="1603650331491">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
     <state x="701" y="75" key="CommitChangelistDialog2/0.0.1920.1160@0.0.1920.1160" timestamp="1602171117745" />
-    <state x="198" y="0" width="745" height="567" key="CommitChangelistDialog2/0.0.2560.1040@0.0.2560.1040" timestamp="1603643887312" />
-    <state x="1114" y="443" key="NewPhpFileDialog" timestamp="1603637447680">
+    <state x="198" y="0" width="745" height="567" key="CommitChangelistDialog2/0.0.2560.1040@0.0.2560.1040" timestamp="1603650331491" />
+    <state x="1114" y="443" key="NewPhpFileDialog" timestamp="1603958673068">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
-    <state x="1114" y="443" key="NewPhpFileDialog/0.0.2560.1040@0.0.2560.1040" timestamp="1603637447680" />
+    <state x="1114" y="443" key="NewPhpFileDialog/0.0.2560.1040@0.0.2560.1040" timestamp="1603958673068" />
     <state x="781" y="165" key="SettingsEditor" timestamp="1596008871908">
       <screen x="0" y="0" width="2560" height="1040" />
     </state>
index 0956f1629ae34ba0f3b3cad8e32963c501a202da..3c1a2458bd926cc269a921d8a7306eb9ec4e2e0d 100644 (file)
--- a/index.php
+++ b/index.php
@@ -80,7 +80,7 @@ function relativePath($p)
     </main>
 </div>
 <?php
-if (true || $android) {
+if (false) {
     echo '<script src="' . relativePath('js/webapp.js') . '"></script>' . "\n";
 } ?>
 <script>
index 5cf1b111fee7c0b419084afa98ad5bc826f4d29c..b6ea927224ccfc82f6301600f6e1038b969c9e9d 100644 (file)
@@ -43,6 +43,7 @@ require_once ROOT . '/scripts/lib/ifttt.php';
 require_once ROOT . '/scripts/lib/router.php';
 require_once ROOT . '/scripts/lib/flowerpower.php';
 require_once ROOT . '/scripts/lib/denon.php';
+require_once ROOT . '/scripts/lib/shield.php';
 
 
 profile('Loaded libraries', __FILE__, __LINE__);
diff --git a/scripts/lib/shield.php b/scripts/lib/shield.php
new file mode 100644 (file)
index 0000000..5355177
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+define('SHIELD_HOST', '192.168.13.40');
+$shieldConnect = false;
+
+function shieldConnect()
+{
+    global $shieldConnect;
+    if (!$shieldConnect) {
+        _adb('start-server');
+        _adb('connect', SHIELD_HOST);
+    }
+}
+
+function shieldCommand($command, $params)
+{
+    shieldConnect();
+    _adb($command, $params);
+}
+
+function shieldKey($key)
+{
+    $map = ['right' => 22, 'up' => 19, 'left' => 21, 'down' => 20, 'ok' => 23, 'space' => 32];
+    if (isset($map[$key])) {
+        $key = $map[$key];
+    }
+    shieldCommand('shell', 'input keyevent ' . $key);
+}
+
+function shieldNetflix($id)
+{
+    $url = 'http://www.netflix.com/watch/' . $id;
+    _adb('shell am start', ' -c android.intent.category.LEANBACK_LAUNCHER -a android.intent.action.VIEW  -f 0x10808000 -e source 30 -d ' . $url . ' com.netflix.ninja/.MainActivity');
+}
+
+function _adb($command, $params = '')
+{
+    $c = 'adb ' . $command;
+    if ($params) {
+        $c .= ' ' . $params;
+    }
+    echo $c . ' :: ' . `$c` . "\n";
+}
\ No newline at end of file
diff --git a/scripts/shield.php b/scripts/shield.php
new file mode 100644 (file)
index 0000000..8bbcdf6
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+require_once "import.php";
+
+echo '<pre>';
+if (isset($_GET['key'])) {
+    shieldKey($_GET['key']);
+} else if (isset($_GET['netflix'])) {
+    shieldNetflix($_GET['netflix']);
+}
+echo '</pre>';
\ No newline at end of file
index c64118c4f6c0c21227a1e5e4cd0a00d1a925c166..8ad4ad86ef237f470222d8ecda9d520e1dbd0f4b 100644 (file)
@@ -38,7 +38,7 @@ self.addEventListener('install', (event) => {
                         console.info('All files are cached');
                         return self.skipWaiting(); //To forces the waiting service worker to become the active service worker
                     })
-                    .catch((error) =>  {
+                    .catch((error) => {
                         console.error('Failed to cache', error);
                     })
             })
@@ -55,13 +55,17 @@ self.addEventListener('fetch', (event) => {
 
     var request = event.request;
     var url = new URL(request.url);
-    if (url.origin === location.origin) {
-        // Static files cache
-        event.respondWith(cacheFirst(request));
-    } else {
-        // Dynamic API cache
+    // if (url.origin === location.origin) {
+    //     // Static files cache
+    //     event.respondWith(cacheFirst(request));
+    // } else {
+    //     // Dynamic API cache
+    try {
         event.respondWith(networkFirst(request));
+    } catch (e) {
+        console.log(e);
     }
+//    }
 
     // // Checking for navigation preload response
     // if (event.preloadResponse) {