Browse Source

Add app keys & backend;

master
Nero Ignis 5 years ago
parent
commit
288af13597
  1. 31
      .idea/workspace.xml
  2. 6
      ADBService.php
  3. 11
      AppNames.php
  4. 8
      execute.php
  5. 19
      index.php
  6. 22
      remote.css

31
.idea/workspace.xml

@ -5,9 +5,10 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="770ea386-39b9-422e-9e8d-15b616f9ec1c" name="Default Changelist" comment=""> <list default="true" id="770ea386-39b9-422e-9e8d-15b616f9ec1c" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" /> <change afterPath="$PROJECT_DIR$/AppNames.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ADBKeyCodes.php" beforeDir="false" afterPath="$PROJECT_DIR$/ADBKeyCodes.php" afterDir="false" /> <change beforePath="$PROJECT_DIR$/ADBService.php" beforeDir="false" afterPath="$PROJECT_DIR$/ADBService.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/execute.php" beforeDir="false" afterPath="$PROJECT_DIR$/execute.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/index.php" beforeDir="false" afterPath="$PROJECT_DIR$/index.php" afterDir="false" /> <change beforePath="$PROJECT_DIR$/index.php" beforeDir="false" afterPath="$PROJECT_DIR$/index.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/remote.css" beforeDir="false" afterPath="$PROJECT_DIR$/remote.css" afterDir="false" /> <change beforePath="$PROJECT_DIR$/remote.css" beforeDir="false" afterPath="$PROJECT_DIR$/remote.css" afterDir="false" />
</list> </list>
@ -58,14 +59,30 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1606346468032</updated> <updated>1606346468032</updated>
<workItem from="1606346469059" duration="5052000" /> <workItem from="1606346469059" duration="5052000" />
<workItem from="1606567112406" duration="1278000" /> <workItem from="1606567112406" duration="3418000" />
</task> </task>
<task id="LOCAL-00001" summary="Add media keys; Style keys;">
<created>1606568426368</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1606568426368</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" /> <option name="version" value="3" />
</component> </component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Add media keys; Style keys;" />
<option name="LAST_COMMIT_MESSAGE" value="Add media keys; Style keys;" />
</component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="222" y="0" width="912" height="720" key="CommitChangelistDialog2" timestamp="1606568426187">
<screen x="0" y="0" width="1366" height="720" />
</state>
<state x="222" y="0" width="912" height="720" key="CommitChangelistDialog2/0.0.1366.720@0.0.1366.720" timestamp="1606568426187" />
<state x="317" y="133" width="722" height="459" key="EditFileWatcherDialog" timestamp="1606348204010"> <state x="317" y="133" width="722" height="459" key="EditFileWatcherDialog" timestamp="1606348204010">
<screen x="0" y="0" width="1366" height="720" /> <screen x="0" y="0" width="1366" height="720" />
</state> </state>
@ -78,14 +95,18 @@
<screen x="0" y="0" width="1366" height="720" /> <screen x="0" y="0" width="1366" height="720" />
</state> </state>
<state x="172" y="0" key="SettingsEditor/0.0.1366.720@0.0.1366.720" timestamp="1606348206869" /> <state x="172" y="0" key="SettingsEditor/0.0.1366.720@0.0.1366.720" timestamp="1606348206869" />
<state x="278" y="92" width="800" height="542" key="Vcs.Push.Dialog.v2" timestamp="1606568427961">
<screen x="0" y="0" width="1366" height="720" />
</state>
<state x="278" y="92" width="800" height="542" key="Vcs.Push.Dialog.v2/0.0.1366.720@0.0.1366.720" timestamp="1606568427961" />
<state x="347" y="155" key="run.anything.popup" timestamp="1606347435018"> <state x="347" y="155" key="run.anything.popup" timestamp="1606347435018">
<screen x="0" y="0" width="1366" height="720" /> <screen x="0" y="0" width="1366" height="720" />
</state> </state>
<state x="347" y="155" key="run.anything.popup/0.0.1366.720@0.0.1366.720" timestamp="1606347435018" /> <state x="347" y="155" key="run.anything.popup/0.0.1366.720@0.0.1366.720" timestamp="1606347435018" />
<state x="346" y="41" width="672" height="678" key="search.everywhere.popup" timestamp="1606568056420"> <state x="346" y="41" width="672" height="678" key="search.everywhere.popup" timestamp="1606569163305">
<screen x="0" y="0" width="1366" height="720" /> <screen x="0" y="0" width="1366" height="720" />
</state> </state>
<state x="346" y="41" width="672" height="678" key="search.everywhere.popup/0.0.1366.720@0.0.1366.720" timestamp="1606568056420" /> <state x="346" y="41" width="672" height="678" key="search.everywhere.popup/0.0.1366.720@0.0.1366.720" timestamp="1606569163305" />
<state x="403" y="269" width="540" height="192" key="vcs.readOnlyHandler.ReadOnlyStatusDialog" timestamp="1606346509232"> <state x="403" y="269" width="540" height="192" key="vcs.readOnlyHandler.ReadOnlyStatusDialog" timestamp="1606346509232">
<screen x="0" y="0" width="1366" height="720" /> <screen x="0" y="0" width="1366" height="720" />
</state> </state>

6
ADBService.php

@ -1,6 +1,7 @@
<?php <?php
include_once 'ADBKeyCodes.php'; include_once 'ADBKeyCodes.php';
include_once 'AppNames.php';
class ADBService class ADBService
{ {
@ -32,4 +33,9 @@ class ADBService
{ {
return $this->executeCommand(' shell input keyevent ' . ADB_KEYCODES[$keyIdentifier]); return $this->executeCommand(' shell input keyevent ' . ADB_KEYCODES[$keyIdentifier]);
} }
public function startApp($appName)
{
return $this->executeCommand(' shell am start ' . APP_NAMES[$appName]);
}
} }

11
AppNames.php

@ -0,0 +1,11 @@
<?php
const APP_NAMES = array(
'youtube' => 'com.google.android.youtube.tv',
'plex' => 'com.plexapp.android.app',
'twitch' => 'tv.twitch.android.app',
'netflix' => 'com.netflix.mediaclient'
);
// :(

8
execute.php

@ -7,4 +7,10 @@ include_once 'ADBService.php';
$service = new ADBService(ADBService::DEFAULT_HOST); $service = new ADBService(ADBService::DEFAULT_HOST);
$service->connect(); $service->connect();
echo json_encode([$service->sendKey($axiosRequest->keyCode)]); if (isset($axiosRequest->keyCode)) {
echo json_encode([$service->sendKey($axiosRequest->keyCode)]);
}
if (isset($axiosRequest->appName)) {
echo json_encode([$service->startApp($axiosRequest->appName)]);
}

19
index.php

@ -41,10 +41,18 @@ $service = new ADBService(ADBService::DEFAULT_HOST);
<a class="col-4"></a> <a class="col-4"></a>
<a class="col-4 btn btn-secondary" onclick="sendKey('VOLUME_DOWN')"><i class="fas fa-volume-down"></i></a> <a class="col-4 btn btn-secondary" onclick="sendKey('VOLUME_DOWN')"><i class="fas fa-volume-down"></i></a>
<hr class="col-md-12"/>
<a class="col-4 btn btn-secondary" onclick="sendKey('MEDIA_PREVIOUS')"><i class="fas fa-backward"></i></a> <a class="col-4 btn btn-secondary" onclick="sendKey('MEDIA_PREVIOUS')"><i class="fas fa-backward"></i></a>
<a class="col-4 btn btn-secondary" onclick="sendKey('MEDIA_PLAY_PAUSE')"><img src="play.png" alt="" class="play-pause-button"></a> <a class="col-4 btn btn-secondary" onclick="sendKey('MEDIA_PLAY_PAUSE')"><img src="play.png" alt="" class="play-pause-button"></a>
<a class="col-4 btn btn-secondary" onclick="sendKey('MEDIA_NEXT')"><i class="fas fa-forward"></i></a> <a class="col-4 btn btn-secondary" onclick="sendKey('MEDIA_NEXT')"><i class="fas fa-forward"></i></a>
<hr class="col-md-12"/>
<a class="col-4 btn btn-secondary btn-youtube" onclick="startApp('youtube')"><i class="fab fa-youtube fa-1c5x"></i></a>
<a class="col-4 btn btn-secondary btn-plex" onclick="startApp('plex')"><img src="plex.png" alt="" class="plex-button fa-1c5x"></a>
<a class="col-4 btn btn-secondary btn-twitch" onclick="startApp('twitch')"><i class="fab fa-twitch"></i></a>
<div class="alert alert-info connected-info"> <div class="alert alert-info connected-info">
<?= str_replace('already ', '', $service->connect()) ?> <?= str_replace('already ', '', $service->connect()) ?>
</div> </div>
@ -60,7 +68,16 @@ $service = new ADBService(ADBService::DEFAULT_HOST);
keyCode: key keyCode: key
}).then((response) => { }).then((response) => {
// console.log(response); // console.log(response);
}).catch((error) => { }).catch((error) => {22
console.log(error);
})
}
function startApp(appName) {
axios.post('execute.php', {
appName: appName
}).then((response) => {
// console.log(response);
}).catch((error) => {22
console.log(error); console.log(error);
}) })
} }

22
remote.css

@ -16,3 +16,25 @@
max-height: 0.8em; max-height: 0.8em;
margin-bottom: 3px; /* WEIL LUKI SCHAßAUGAT IST */ margin-bottom: 3px; /* WEIL LUKI SCHAßAUGAT IST */
} }
.plex-button {
margin-bottom: 1px;
max-height: 14px;
}
.btn-youtube {
background: white;
color: red;
}
.btn-plex {
background: #3b3b3b;
}
.btn-twitch {
background: rebeccapurple;
}
.btn {
border-radius: 50px;
}
Loading…
Cancel
Save