ptlaunch: Respect theme colors. Fix: Do not pollute global space with internal variables ans functions in boot.js

master
crazysaem 2021-12-14 10:34:42 +00:00
parent 2d1666d037
commit cff3a99380
4 changed files with 173 additions and 172 deletions

View File

@ -4858,7 +4858,7 @@
"id": "ptlaunch", "id": "ptlaunch",
"name": "Pattern Launcher", "name": "Pattern Launcher",
"shortName": "Pattern Launcher", "shortName": "Pattern Launcher",
"version": "0.10", "version": "0.11",
"description": "Directly launch apps from the clock screen with custom patterns.", "description": "Directly launch apps from the clock screen with custom patterns.",
"icon": "app.png", "icon": "app.png",
"screenshots": [{"url":"main_menu_add.png"}, {"url":"add_pattern.png"}, {"url":"select_app.png"}, {"url":"main_menu_manage.png"}, {"url":"manage_patterns.png"}], "screenshots": [{"url":"main_menu_add.png"}, {"url":"add_pattern.png"}, {"url":"select_app.png"}, {"url":"main_menu_manage.png"}, {"url":"manage_patterns.png"}],

View File

@ -2,3 +2,4 @@
0.02: Turn on lcd when launching an app if the lock screen was disabled in the settings 0.02: Turn on lcd when launching an app if the lock screen was disabled in the settings
0.03: Make tap to confirm new pattern more reliable. Also allow for easier creation of single circle patterns. 0.03: Make tap to confirm new pattern more reliable. Also allow for easier creation of single circle patterns.
0.10: Improve the management of existing patterns: Draw the linked pattern on the left hand side of the app name within a scroller, similar to the default launcher. Slighlty clean up the code to make it less horrible. 0.10: Improve the management of existing patterns: Draw the linked pattern on the left hand side of the app name within a scroller, similar to the default launcher. Slighlty clean up the code to make it less horrible.
0.11: Respect theme colors. Fix: Do not pollute global space with internal variables ans functions in boot.js

View File

@ -119,8 +119,7 @@ var recognizeAndDrawPattern = () => {
return new Promise((resolve) => { return new Promise((resolve) => {
E.showMenu(); E.showMenu();
g.clear(); g.clear();
g.setColor(0, 0, 0); drawCirclesWithPattern([]);
CIRCLES.forEach((circle) => drawCircle(circle));
var pattern = []; var pattern = [];
@ -369,7 +368,6 @@ var drawAppWithPattern = (i, r, storedPatterns) => {
offset: { x: 1, y: 3 + r.y }, offset: { x: 1, y: 3 + r.y },
}); });
g.setColor(0, 0, 0);
if (!storedPattern.wrappedAppName) { if (!storedPattern.wrappedAppName) {
storedPattern.wrappedAppName = g storedPattern.wrappedAppName = g
.wrapString(app.name, g.getWidth() - 64) .wrapString(app.name, g.getWidth() - 64)
@ -490,7 +488,10 @@ var drawCircle = (circle, drawBuffer, scale) => {
log("drawing circle"); log("drawing circle");
log({ x: x, y: y, r: r }); log({ x: x, y: y, r: r });
drawBuffer.setColor(0);
drawBuffer.fillCircle(x, y, r); drawBuffer.fillCircle(x, y, r);
drawBuffer.setColor(1);
drawBuffer.drawCircle(x, y, r);
}; };
var cachedCirclesDrawings = {}; var cachedCirclesDrawings = {};
@ -535,17 +536,16 @@ var drawCirclesWithPattern = (pattern, options) => {
{ msb: true } { msb: true }
); );
drawBuffer.setColor(1);
CIRCLES.forEach((circle) => drawCircle(circle, drawBuffer, scale)); CIRCLES.forEach((circle) => drawCircle(circle, drawBuffer, scale));
drawBuffer.setColor(0); drawBuffer.setColor(1);
drawBuffer.setFontAlign(0, 0); drawBuffer.setFontAlign(0, 0);
drawBuffer.setFont("6x8", 4 * scale); drawBuffer.setFont("Vector", scale === 1 ? 40 : 20);
pattern.forEach((circleIndex, patternIndex) => { pattern.forEach((circleIndex, patternIndex) => {
var circle = CIRCLES[circleIndex]; var circle = CIRCLES[circleIndex];
drawBuffer.drawString( drawBuffer.drawString(
patternIndex + 1, patternIndex + 1,
circle.x * scale, (circle.x + 5) * scale,
circle.y * scale circle.y * scale
); );
}); });

View File

@ -1,13 +1,14 @@
var DEBUG = true; (function () {
var log = (message) => { var DEBUG = false;
var log = (message) => {
if (DEBUG) { if (DEBUG) {
console.log(JSON.stringify(message)); console.log(JSON.stringify(message));
} }
}; };
var storedPatterns; var storedPatterns;
var positions = []; var positions = [];
var dragHandler = (position) => { var dragHandler = (position) => {
positions.push(position); positions.push(position);
debounce().then(() => { debounce().then(() => {
@ -145,10 +146,10 @@ var dragHandler = (position) => {
} }
} }
}); });
}; };
var debounceTimeoutId; var debounceTimeoutId;
var debounce = (delay) => { var debounce = (delay) => {
if (debounceTimeoutId) { if (debounceTimeoutId) {
clearTimeout(debounceTimeoutId); clearTimeout(debounceTimeoutId);
} }
@ -159,9 +160,8 @@ var debounce = (delay) => {
resolve(); resolve();
}, delay || 500); }, delay || 500);
}); });
}; };
(function () {
var sui = Bangle.setUI; var sui = Bangle.setUI;
Bangle.setUI = function (mode, cb) { Bangle.setUI = function (mode, cb) {
sui(mode, cb); sui(mode, cb);