From 6d58a466b2b5e34eaac066fa9637056fecae0128 Mon Sep 17 00:00:00 2001 From: stweedo Date: Thu, 29 Jun 2023 08:43:45 -0500 Subject: [PATCH] [gassist] - New app for voice control --- apps/gassist/ChangeLog | 1 + apps/gassist/app.js | 11 +++++++++++ apps/gassist/app.png | Bin 0 -> 799 bytes apps/gassist/boot.js | 21 +++++++++++++++++++++ apps/gassist/gassist.json | 1 + apps/gassist/icon.js | 1 + apps/gassist/metadata.json | 18 ++++++++++++++++++ apps/gassist/settings.js | 32 ++++++++++++++++++++++++++++++++ 8 files changed, 85 insertions(+) create mode 100644 apps/gassist/ChangeLog create mode 100644 apps/gassist/app.js create mode 100644 apps/gassist/app.png create mode 100644 apps/gassist/boot.js create mode 100644 apps/gassist/gassist.json create mode 100644 apps/gassist/icon.js create mode 100644 apps/gassist/metadata.json create mode 100644 apps/gassist/settings.js diff --git a/apps/gassist/ChangeLog b/apps/gassist/ChangeLog new file mode 100644 index 000000000..5560f00bc --- /dev/null +++ b/apps/gassist/ChangeLog @@ -0,0 +1 @@ +0.01: New App! diff --git a/apps/gassist/app.js b/apps/gassist/app.js new file mode 100644 index 000000000..69e8001e3 --- /dev/null +++ b/apps/gassist/app.js @@ -0,0 +1,11 @@ +Bluetooth.println(""); +Bluetooth.println(JSON.stringify({ + t:"intent", + target:"activity", + action:"android.intent.action.VOICE_COMMAND", + flags:["FLAG_ACTIVITY_NEW_TASK"] +})); + +setTimeout(function() { + Bangle.showClock(); +}, 0); diff --git a/apps/gassist/app.png b/apps/gassist/app.png new file mode 100644 index 0000000000000000000000000000000000000000..8c190d3449e27cc6f84461dc0ea0c2a84fd25c45 GIT binary patch literal 799 zcmV+)1K|9LP)RCt{2S4(RXQ4~IC$;CflXB1nIuH5U!WUIC_k|4NsBNT*2 zK{J!?vJk;PAU=MANCI6HtgV@Be6(qkdlNTZTdlg%WTC4gXVSD|U|z}GW+L;!AtBH2 zJCE<43y>f|fpC&gbcK5G$0bQ>q~rZK9?? z-!Q~?)!_H&d*h}K%7ag{ipd*+h!2EarDA(#Y~-iS#wFDh--aQ7R1LnbEVnL>CG+a2 zXfw zzM^{{jP`CLRRI4TMu0}-D>>|kR>`h;enFN4IV$iulz>XM^N)aX?w5}Md#jW;0|ws= zBS5FN30Z+>a)($v2|WXq>>5=Gmym$SeS;c9T}+NWw;J; zJ&7-r+9?P5$Cv?hiAO_=urDuCD$u$;ka;)qy-0&T!Zs?lqa9vRhnp`?Is{k&1iT%- z3dQyeT}C2up8YfTTj!j=k7?-m3dn%BW%_|`QX`9Sxse4F@DoM_RbuG<$Po3x%pVFM zxAAYG4TuCKJfRetx5!0;x{ZB#@wkDJRR*Yl22p}6koNiBVaKA2SAn6Gx{Fro1J+pA4tic?d3q1x3|v2T z7A@Aq8bg<8&}SgNnfD}*ha%!w3A=6l$>TvRLEL~A`xsn6>OI5_SYw?K73jc33$WPe z3tiNh{1&RR{A3UDDlpq3gV<;r0xgE)Imo<4G-7*@^+DOi8e5`1KN#!|)>7~6*W#M_ d1PLI1_zPVw3^6G-%sBu6002ovPDHLkV1jq+Ys>%u literal 0 HcmV?d00001 diff --git a/apps/gassist/boot.js b/apps/gassist/boot.js new file mode 100644 index 000000000..eb2155796 --- /dev/null +++ b/apps/gassist/boot.js @@ -0,0 +1,21 @@ +// load settings +var settings = Object.assign({ + enableTap: true +}, require("Storage").readJSON("gassist.json", true) || {}); + +if (settings.enableTap) { + Bangle.on("tap", function(e) { + if (e.dir=="front" && e.double) { + Bluetooth.println(""); + Bluetooth.println(JSON.stringify({ + t:"intent", + target:"activity", + action:"android.intent.action.VOICE_COMMAND", + flags:["FLAG_ACTIVITY_NEW_TASK"] + })); + } + }); +} + +// clear variable +settings = undefined; \ No newline at end of file diff --git a/apps/gassist/gassist.json b/apps/gassist/gassist.json new file mode 100644 index 000000000..26c61fc04 --- /dev/null +++ b/apps/gassist/gassist.json @@ -0,0 +1 @@ +gassist.json \ No newline at end of file diff --git a/apps/gassist/icon.js b/apps/gassist/icon.js new file mode 100644 index 000000000..9e84990e3 --- /dev/null +++ b/apps/gassist/icon.js @@ -0,0 +1 @@ +require("heatshrink").decompress(atob("mEwxH+AH4A/AH4ALiAAFFtoxmFpQxjFxwwfFyAwdFyQwcF9wuUGDQvuFywwYF/4vUnAABF9YuCGBAv/F/6/PGC4bE3QACG5YvdFoYxSLzAvuFw4wjLxbCidhAvVGB4UFF7QxMCZAuaGJIRKF7oATFtoA/AEPMAAQttGNQuHGE4vuFxIwlF/4v/d/4vwGBAumGIwtpAH4A/AEIA==")) \ No newline at end of file diff --git a/apps/gassist/metadata.json b/apps/gassist/metadata.json new file mode 100644 index 000000000..995c44adb --- /dev/null +++ b/apps/gassist/metadata.json @@ -0,0 +1,18 @@ +{ + "id": "gassist", + "name": "Google Assist", + "version": "0.01", + "description": "A simple way to initiate Google Assistant on Android. Intents must be enabled in Gadgetbridge.", + "icon": "app.png", + "type": "app", + "tags": "tool, voice, tasker", + "supports": ["BANGLEJS","BANGLEJS2"], + "allow_emulator": false, + "storage": [ + {"name":"gassist.boot.js","url":"boot.js"}, + {"name":"gassist.app.js","url":"app.js"}, + {"name":"gassist.settings.js","url":"settings.js"}, + {"name":"gassist.img","url":"icon.js","evaluate":true} + ], + "data": [{"name":"gassist.json"}] +} \ No newline at end of file diff --git a/apps/gassist/settings.js b/apps/gassist/settings.js new file mode 100644 index 000000000..f264d99fa --- /dev/null +++ b/apps/gassist/settings.js @@ -0,0 +1,32 @@ +let storage = require('Storage'); + +(function (back) { + // Load and set default settings + let appSettings = Object.assign({ + enableTap : true + }, storage.readJSON("gassist.json", true) || {}); + + // Save settings to storage + function writeSettings() { + storage.writeJSON("gassist.json", appSettings); + } + + function showMenu() { + E.showMenu({ + "": { + "title": "Google Assist" + }, + "< Back": () => back(), + 'Front Tap:': { + value: (appSettings.enableTap === true), + format: v => v ? "On" : "Off", + onchange: v => { + appSettings.enableTap = v; + writeSettings(); + } + }, + }); + } + // Initially show the menu + showMenu(); +}); \ No newline at end of file