1
0
Fork 0

findphone Remove HID requirement, update screen (fix #565)

master
Gordon Williams 2020-09-25 11:50:26 +01:00
parent 2e45174d4a
commit 9f7461f434
4 changed files with 37 additions and 36 deletions

View File

@ -1768,8 +1768,8 @@
"name": "Find Phone",
"shortName":"Find Phone",
"icon": "app.png",
"version":"0.01",
"description": "Find your phone via Gadgetbridge. Click any button to let your phone ring. 📳",
"version":"0.02",
"description": "Find your phone via Gadgetbridge. Click any button to let your phone ring. 📳 Note: The functionality is available even without this app, just go to Settings, App Settings, Gadgetbridge, Find Phone.",
"tags": "tool,android",
"readme": "README.md",
"allow_emulator": true,

View File

@ -1 +1,2 @@
0.01: First Version
0.01: First Version
0.02: Remove HID requirement, update screen

View File

@ -2,8 +2,7 @@
Ring your phone via GadgetBridge if you lost it somewhere.
1. Enable HID in settings
2. Connect GadgetBridge
3. Lose phone
4. Open app
5. Click any button or screen
1. Connect GadgetBridge
2. Lose phone
3. Open app
4. Click any button or screen

View File

@ -1,33 +1,34 @@
var storage = require('Storage');
//notify your phone
function find(){
Bluetooth.println(JSON.stringify({t:"findPhone", n:true}));
var finding = false;
function draw() {
// show message
g.clear();
require("Font8x12").add(Graphics);
g.setFont("8x12",3);
g.setFontAlign(0,0);
g.setColor(0x03E0);
if (finding) {
g.drawString("Finding...", g.getWidth()/2, (g.getHeight()/2)-20);
g.drawString("Click to stop", g.getWidth()/2, (g.getHeight()/2)+20);
} else {
g.drawString("Click to find", g.getWidth()/2, g.getHeight()/2);
}
g.flip();
}
//init graphics
g.clear();
require("Font8x12").add(Graphics);
g.setFont("8x12",3);
g.setFontAlign(0,0);
g.flip();
function find(){
finding = !finding;
draw();
Bluetooth.println("\n"+JSON.stringify({t:"findPhone", n:finding}));
}
//init settings
const settings = storage.readJSON('setting.json',1) || { HID: false };
draw();
//check if HID enabled and show message
if (settings.HID=="kb" || settings.HID=="kbmedia") {
g.setColor(0x03E0);
g.drawString("click to find", g.getWidth()/2, g.getHeight()/2);
//register all buttons and screen to find phone
setWatch(find, BTN1);
setWatch(find, BTN2);
setWatch(find, BTN3);
setWatch(find, BTN4);
setWatch(find, BTN5);
}else{
g.setColor(0xf800);
g.drawString("enable HID!", g.getWidth()/2, g.getHeight()/2);
}
//register all buttons and screen to find phone
setWatch(find, BTN1, {repeat:true});
setWatch(find, BTN2, {repeat:true});
setWatch(find, BTN3, {repeat:true});
setWatch(find, BTN4, {repeat:true});
setWatch(find, BTN5, {repeat:true});