11{ // must be inside our own scope here so that when we are unloaded everything disappears
22 let s = require ( "Storage" ) ;
33 // handle customised launcher
4- let scaleval = 1 ;
5- let vectorval = 20 ;
6- let font = g . getFonts ( ) . includes ( "12x20" ) ? "12x20" : "6x8:2" ;
7- if ( g . getFonts ( ) . includes ( "22" ) ) font = "22" ; // 2v26+
4+ let scaleval = 1 , vectorval = 20 , fonts = g . getFonts ( ) ;
5+ let font = fonts . includes ( "12x20" ) ? "12x20" : "6x8:2" ;
6+ if ( fonts . includes ( "22" ) ) font = "22" ; // 2v26+
87 let settings = Object . assign ( {
98 showClocks : true ,
109 fullscreen : false
2019 scaleval = ( font . split ( "x" ) [ 1 ] ) / 20 ;
2120 }
2221 }
22+ let height = 50 * scaleval ;
23+
24+ // Now apps list is loaded - render
25+ if ( ! settings . fullscreen ) {
26+ Bangle . loadWidgets ( ) ;
27+ } else if ( global . WIDGETS ) {
28+ require ( "widget_utils" ) . hide ( ) ;
29+ }
30+ let R = Bangle . appRect ;
31+ g . reset ( ) . clearRect ( R ) . setColor ( "#888" ) ;
32+ for ( var y = R . y ; y < R . y2 ; y += height ) {
33+ g . drawRect ( 5 * scaleval , y + 5 * scaleval , 49 * scaleval , y + 49 * scaleval ) // image
34+ . drawRect ( 54 * scaleval , y + 20 * scaleval , R . y2 - 16 , y + 34 * scaleval ) ; // text
35+ }
36+ g . flip ( ) ;
37+
2338 // cache app list so launcher loads more quickly
2439 let launchCache = s . readJSON ( "launch.cache.json" , true ) || { } ;
2540 let launchHash = require ( "Storage" ) . hash ( / \. i n f o / ) ;
2843 hash : launchHash ,
2944 apps : s . list ( / \. i n f o $ / )
3045 . map ( app => { var a = s . readJSON ( app , 1 ) ; return a && { name :a . name , type :a . type , icon :a . icon , sortorder :a . sortorder , src :a . src } ; } )
31- . filter ( app => app && ( app . type == "app" || ( app . type == "clock" && settings . showClocks ) || ! app . type ) )
46+ . filter ( app => app && ( app . type == "app" || app . type == "clock" || ! app . type ) )
3247 . sort ( ( a , b ) => {
3348 var n = ( 0 | a . sortorder ) - ( 0 | b . sortorder ) ;
3449 if ( n ) return n ; // do sortorder first
3853 } ) } ;
3954 s . writeJSON ( "launch.cache.json" , launchCache ) ;
4055 }
41- let apps = launchCache . apps ;
42- // Now apps list is loaded - render
43- if ( ! settings . fullscreen )
44- Bangle . loadWidgets ( ) ;
56+ let apps = launchCache . apps . filter ( app => app . type != "clock" || settings . showClocks ) ;
57+
4558
4659 const drawMenu = ( ) => {
47- E . showScroller ( {
48- h : 50 * scaleval , c : apps . length ,
60+ let scroller = E . showScroller ( {
61+ h : height , c : apps . length ,
4962 draw : ( i , r ) => {
5063 var app = apps [ i ] ;
5164 if ( ! app ) return ;
7184 // cleanup the timeout to not leave anything behind after being removed from ram
7285 if ( lockTimeout ) clearTimeout ( lockTimeout ) ;
7386 Bangle . removeListener ( "lock" , lockHandler ) ;
87+ // Restore widgets if they were hidden by fullscreen setting
88+ if ( global . WIDGETS ) require ( "widget_utils" ) . show ( ) ;
7489 }
7590 } ) ;
91+ if ( settings . fullscreen ) {
92+ require ( "widget_utils" ) . hide ( ) ;
93+ scroller . draw ( ) ; // FIX: The red back button will flicker before the widget is hidden and scroller redrawn.
94+ }
7695 g . flip ( ) ; // force a render before widgets have finished drawing
7796
7897 // 10s of inactivity goes back to clock
90109
91110 if ( ! settings . fullscreen ) // finally draw widgets
92111 Bangle . drawWidgets ( ) ;
93- }
112+ }
0 commit comments