diff --git a/messagegui/messagegui.app.js b/messagegui/messagegui.app.js index 2f356da..9e4e9fa 100644 --- a/messagegui/messagegui.app.js +++ b/messagegui/messagegui.app.js @@ -18,6 +18,8 @@ require("messages").pushMessage({"t":"add","id":1575479849,"src":"Clock","title" require("messages").pushMessage({"t":"add","id":1,"src":"Maps","title":"0 yd - High St","body":"Campton - 11:48 ETA","img":"GhqBAAAMAAAHgAAD8AAB/gAA/8AAf/gAP/8AH//gD/98B//Pg/4B8f8Afv+PP//n3/f5//j+f/wfn/4D5/8Aef+AD//AAf/gAD/wAAf4AAD8AAAeAAADAAA="}); // call require("messages").pushMessage({"t":"add","id":"call","src":"Phone","title":"Bob","body":"12421312",positive:true,negative:true}) +// message +require("messages").pushMessage({"t":"add","id":"1234","src":"Telegram","title":"testing","body":"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.",positive:true,negative:true}) */ var Layout = require("Layout"); var settings = require('Storage').readJSON("messages.settings.json", true) || {}; @@ -190,13 +192,14 @@ function showMusicMessage(msg) { function showMessageScroller(msg) { active = "scroller"; - var bodyFont = fontBig; + var bodyFont = fontLarge; g.setFont(bodyFont); var lines = []; if (msg.title) lines = g.wrapString(msg.title, g.getWidth()-10) + lines = [lines[0]]; var titleCnt = lines.length; - if (titleCnt) lines.push(""); // add blank line after title - lines = lines.concat(g.wrapString(msg.body, g.getWidth()-10),["",/*LANG*/"< Back"]); + //if (titleCnt) lines.push(""); // add blank line after title + lines = lines.concat(g.wrapString(msg.body, g.getWidth()-10)); //,["",/*LANG*/"< Back"]); E.showScroller({ h : g.getFontHeight(), // height of each menu item in pixels c : lines.length, // number of menu items @@ -207,11 +210,13 @@ function showMessageScroller(msg) { setColor(idx=lines.length-2) - showMessage(msg.id); - }, - back : () => showMessage(msg.id) + //}, select : function(idx) { + // if (idx>=lines.length-2) + // showMessage(msg.id); + //}, + //back : () => showMessage(msg.id) + }, select : () => load(), + back : () => load() }); } @@ -262,90 +267,92 @@ function showMessage(msgid) { } active = "message"; // Normal text message display - var title=msg.title, titleFont = fontLarge, lines; - var body=msg.body, bodyFont = fontLarge; - // If no body, use the title text instead... - if (body===undefined) { - body = title; - title = undefined; - } - if (title) { - var w = g.getWidth()-48; - if (g.setFont(titleFont).stringWidth(title) > w) { - titleFont = fontBig; - if (settings.fontSize!=1 && g.setFont(titleFont).stringWidth(title) > w) - titleFont = fontMedium; - } - if (g.setFont(titleFont).stringWidth(title) > w) { - lines = g.wrapString(title, w); - title = (lines.length>2) ? lines.slice(0,2).join("\n")+"..." : lines.join("\n"); - } - } - // If body of message is only two lines long w/ large font, use large font. + //var title=msg.title, titleFont = fontLarge, lines; + //var body=msg.body, bodyFont = fontLarge; + //// If no body, use the title text instead... + //if (body===undefined) { + // body = title; + // title = undefined; + //} + //if (title) { + // var w = g.getWidth()-48; + // if (g.setFont(titleFont).stringWidth(title) > w) { + // titleFont = fontBig; + // if (settings.fontSize!=1 && g.setFont(titleFont).stringWidth(title) > w) + // titleFont = fontMedium; + // } + // if (g.setFont(titleFont).stringWidth(title) > w) { + // lines = g.wrapString(title, w); + // title = (lines.length>2) ? lines.slice(0,2).join("\n")+"..." : lines.join("\n"); + // } + //} + //// If body of message is only two lines long w/ large font, use large font. - if (body) { - var w = g.getWidth()-10; - if (false && g.setFont(bodyFont).stringWidth(body) > w * 2) { - bodyFont = fontBig; - if (settings.fontSize!=1 && g.setFont(bodyFont).stringWidth(body) > w * 3) - bodyFont = fontMedium; - } - if (g.setFont(bodyFont).stringWidth(body) > w) { - lines = g.setFont(bodyFont).wrapString(msg.body, w); - var maxLines = Math.floor((g.getHeight()-75) / g.getFontHeight()); - body = (lines.length>maxLines) ? lines.slice(0,maxLines).join("\n")+"..." : lines.join("\n"); - } - } - function goBack() { - layout = undefined; - msg.new = false; // read mail - cancelReloadTimeout(); // don't auto-reload to clock now - checkMessages({clockIfNoMsg:1,clockIfAllRead:0,showMsgIfUnread:0,openMusic:openMusic}); - } - var buttons = [ - ]; - if (false && msg.positive) { - buttons.push({type:"btn", src:atob("GRSBAAAAAYAAAcAAAeAAAfAAAfAAAfAAAfAAAfAAAfBgAfA4AfAeAfAPgfAD4fAA+fAAP/AAD/AAA/AAAPAAADAAAA=="), cb:()=>{ - msg.new = false; - cancelReloadTimeout(); // don't auto-reload to clock now - Bangle.messageResponse(msg,true); - checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1,openMusic:openMusic}); - }}); - } - if (false && msg.negative) { - if (buttons.length) buttons.push({width:32}); // nasty hack... - buttons.push({type:"btn", src:atob("FhaBADAAMeAB78AP/4B/fwP4/h/B/P4D//AH/4AP/AAf4AB/gAP/AB/+AP/8B/P4P4fx/A/v4B//AD94AHjAAMA="), cb:()=>{ - msg.new = false; - cancelReloadTimeout(); // don't auto-reload to clock now - Bangle.messageResponse(msg,false); - checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1,openMusic:openMusic}); - }}); - } + //if (body) { + // var w = g.getWidth()-10; + // if (false && g.setFont(bodyFont).stringWidth(body) > w * 2) { + // bodyFont = fontBig; + // if (settings.fontSize!=1 && g.setFont(bodyFont).stringWidth(body) > w * 3) + // bodyFont = fontMedium; + // } + // if (g.setFont(bodyFont).stringWidth(body) > w) { + // lines = g.setFont(bodyFont).wrapString(msg.body, w); + // var maxLines = Math.floor((g.getHeight()-75) / g.getFontHeight()); + // body = (lines.length>maxLines) ? lines.slice(0,maxLines).join("\n")+"..." : lines.join("\n"); + // } + //} + //function goBack() { + // layout = undefined; + // msg.new = false; // read mail + // cancelReloadTimeout(); // don't auto-reload to clock now + // checkMessages({clockIfNoMsg:1,clockIfAllRead:0,showMsgIfUnread:0,openMusic:openMusic}); + //} + //var buttons = [ + //]; + //if (false && msg.positive) { + // buttons.push({type:"btn", src:atob("GRSBAAAAAYAAAcAAAeAAAfAAAfAAAfAAAfAAAfAAAfBgAfA4AfAeAfAPgfAD4fAA+fAAP/AAD/AAA/AAAPAAADAAAA=="), cb:()=>{ + // msg.new = false; + // cancelReloadTimeout(); // don't auto-reload to clock now + // Bangle.messageResponse(msg,true); + // checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1,openMusic:openMusic}); + // }}); + //} + //if (false && msg.negative) { + // if (buttons.length) buttons.push({width:32}); // nasty hack... + // buttons.push({type:"btn", src:atob("FhaBADAAMeAB78AP/4B/fwP4/h/B/P4D//AH/4AP/AAf4AB/gAP/AB/+AP/8B/P4P4fx/A/v4B//AD94AHjAAMA="), cb:()=>{ + // msg.new = false; + // cancelReloadTimeout(); // don't auto-reload to clock now + // Bangle.messageResponse(msg,false); + // checkMessages({clockIfNoMsg:1,clockIfAllRead:1,showMsgIfUnread:1,openMusic:openMusic}); + // }}); + //} - layout = new Layout({ type:"v", c: [ - {type:"h", fillx:1, bgCol:g.theme.bg2, col: g.theme.fg2, c: [ - { type:"v", fillx:1, c: [ - {type:"txt", font:fontSmall, label:msg.src||/*LANG*/"Message", bgCol:g.theme.bg2, col: g.theme.fg2, fillx:1, pad:2, halign:1 }, - title?{type:"txt", font:titleFont, label:title, bgCol:g.theme.bg2, col: g.theme.fg2, fillx:1, pad:2 }:{}, - ]}, - { type:"btn", - src:require("messageicons").getImage(msg), - col:require("messageicons").getColor(msg, {settings:settings, default:g.theme.fg2}), - pad: 3, cb:()=>{ - cancelReloadTimeout(); // don't auto-reload to clock now - showMessageSettings(msg); - } - }, - ]}, - {type:"txt", font:bodyFont, label:body, fillx:1, filly:1, pad:2, cb:()=>{ - // allow tapping to show a larger version - showMessageScroller(msg); - } }, - {type:"h",fillx:1, c: buttons} - ]},{back:goBack}); - g.reset().clearRect(Bangle.appRect); - layout.render(); + //layout = new Layout({ type:"v", c: [ + // {type:"h", fillx:1, bgCol:g.theme.bg2, col: g.theme.fg2, c: [ + // { type:"v", fillx:1, c: [ + // {type:"txt", font:fontSmall, label:msg.src||/*LANG*/"Message", bgCol:g.theme.bg2, col: g.theme.fg2, fillx:1, pad:2, halign:1 }, + // title?{type:"txt", font:titleFont, label:title, bgCol:g.theme.bg2, col: g.theme.fg2, fillx:1, pad:2 }:{}, + // ]}, + // { type:"btn", + // src:require("messageicons").getImage(msg), + // col:require("messageicons").getColor(msg, {settings:settings, default:g.theme.fg2}), + // pad: 3, cb:()=>{ + // cancelReloadTimeout(); // don't auto-reload to clock now + // showMessageSettings(msg); + // } + // }, + // ]}, + // {type:"txt", font:bodyFont, label:body, fillx:1, filly:1, pad:2, cb:()=>{ + // // allow tapping to show a larger version + // showMessageScroller(msg); + // } }, + // {type:"h",fillx:1, c: buttons} + //]},{back:goBack}); + //g.reset().clearRect(Bangle.appRect); + //layout.render(); + + showMessageScroller(msg); }