ChargeBar

Share and discuss your flows and ideas with other users.

Moderator: Martin

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

ChargeBar

Post by Bushmills » 28 May 2016 20:56

A widget with a supporting set of flows, displayed in an overlay. It occupies the first screen line, indicating battery status by its width, and charger status by colour.
Because running in its 1 pixel high overlay, it is visible all the time.

I may need feedback whether everything runs as intended, because I had to strip the original flows a bit, and testing was a bit difficult with two sets of similar flows. Though I disabled the originals, these flows also activate/deactivate each other, which made verifying proper function a bit hard. It seemed to function though.

The flows in detail:

Automagic start: determines screen orientation and width, displays widget in overlay.

Portrait/Landscape: detects screen rotation, reloads widget with proper scaling.

Battery level: responds to change of battery level, updates widget accordingly. Note: on some systems, this is triggered more frequently than needed - to avoid unnecessary updates of widget, a condition, testing for substantial change of charge level may be needed to reduce power dissipation. This is the case on an S3, but not on a Nexus7.

Screen on, screen off: enable and disable the battery level flow, to save power when display is off.

Charger connected, charger disconnected: update widget colour. Green: charge, orange: discharge.
Orange tends to yield better contrast than red, resulting in a generally better visible gauge.

To start: enable all flows, then manually execute the flow "Automagic start". This flow also takes care of launching the widget after system restart.

Screenshot: charge bar at top, charger connected (green), about 65% charge.
Screenshot_2016-05-28-22-55-29.png
Screenshot_2016-05-28-22-55-29.png (107.78 KiB) Viewed 33804 times
Flows and widget:
http://automagic4android.com/flow.php?i ... e98bc40322

vamzicool
Posts: 67
Joined: 29 Dec 2014 17:47

Re: ChargeBar

Post by vamzicool » 30 May 2016 09:59

I got the following error after executing start flow :

30.05.2016 15:25:20.647 [ChargeBar: Automagic start] Start executing action 'Kommandozeilenbefehl ausführen: wm size in '
30.05.2016 15:25:21.920 [ChargeBar: Automagic start] Action 'Kommandozeilenbefehl ausführen: wm size in ' stdout=Physical size: 720x1280

30.05.2016 15:25:21.921 [ChargeBar: Automagic start] Action 'Kommandozeilenbefehl ausführen: wm size in ' stderr=
30.05.2016 15:25:21.921 [ChargeBar: Automagic start] Action 'Kommandozeilenbefehl ausführen: wm size in ' exit_code=0
30.05.2016 15:25:21.921 [ChargeBar: Automagic start] End executing action 'Kommandozeilenbefehl ausführen: wm size in '
30.05.2016 15:25:21.944 [ChargeBar: Automagic start] Flow continues executing with the next step.
30.05.2016 15:25:21.946 [ChargeBar: Automagic start] Start executing action 'Script: geometry = split(replace(stdout, "Physical size: ", ""), "x"); x = toNumber(geometry[0]); y = toNumber(geometry[1]); global_screen_short = min(x, y); global_screen_long = max(x, y);'
30.05.2016 15:25:21.978 [ChargeBar: Automagic start] Action 'Script: geometry = split(replace(stdout, "Physical size: ", ""), "x"); x = toNumber(geometry[0]); y = toNumber(geometry[1]); global_screen_short = min(x, y); global_screen_long = max(x, y);'
ch.gridvision.ppam.androidautomagic.simplelang.a.d: Could not evaluate expression 'geometry = split(replace(stdout, "Physical size: ", ""), "x");
x = toNumber(geometry[0]);
y = toNumber(geometry[1]);
global_screen_short = min(x, y);
global_screen_long = max(x, y);' due to errors: [';' expected[84], ')' or ',' expected[84], "TO" expected[86], expression expected[86], ';' expected[87], expression expected[87], ';' expected[87], ';' expected[111], ')' or ',' expected[111], "TO" expected[113], expression expected[113], ';' expected[114], expression expected[114], ';' expected[114]]
at ch.gridvision.ppam.androidautomagic.simplelang.a.k.a(SourceFile:847)
at ch.gridvision.ppam.androidautomagic.simplelang.a.k.a(SourceFile:817)
at ch.gridvision.ppam.androidautomagic.c.a.et$1.d(SourceFile:119)
at ch.gridvision.ppam.androidautomagic.c.a.et$1.a(SourceFile:110)
at ch.gridvision.ppam.androidautomagiclib.util.de$1.run(SourceFile:39)
at java.lang.Thread.run(Thread.java:818)

30.05.2016 15:25:21.983 [ChargeBar: Automagic start] End executing action 'Script: geometry = split(replace(stdout, "Physical size: ", ""), "x"); x = toNumber(geometry[0]); y = toNumber(geometry[1]); global_screen_short = min(x, y); global_screen_long = max(x, y);' and exception Could not evaluate expression 'geometry = split(replace(stdout, "Physical size: ", ""), "x");
x = toNumber(geometry[0]);
y = toNumber(geometry[1]);
global_screen_short = min(x, y);
global_screen_long = max(x, y);' due to errors: [';' expected[84], ')' or ',' expected[84], "TO" expected[86], expression expected[86], ';' expected[87], expression expected[87], ';' expected[87], ';' expected[111], ')' or ',' expected[111], "TO" expected[113], expression expected[113], ';' expected[114], expression expected[114], ';' expected[114]]
30.05.2016 15:25:22.015 [ChargeBar: Automagic start] Flow ends execution due to errors
30.05.2016 15:25:22.015 [ChargeBar: Automagic start] Error:
ch.gridvision.ppam.androidautomagic.simplelang.a.d: Could not evaluate expression 'geometry = split(replace(stdout, "Physical size: ", ""), "x");
x = toNumber(geometry[0]);
y = toNumber(geometry[1]);
global_screen_short = min(x, y);
global_screen_long = max(x, y);' due to errors: [';' expected[84], ')' or ',' expected[84], "TO" expected[86], expression expected[86], ';' expected[87], expression expected[87], ';' expected[87], ';' expected[111], ')' or ',' expected[111], "TO" expected[113], expression expected[113], ';' expected[114], expression expected[114], ';' expected[114]]
at ch.gridvision.ppam.androidautomagic.simplelang.a.k.a(SourceFile:847)
at ch.gridvision.ppam.androidautomagic.simplelang.a.k.a(SourceFile:817)
at ch.gridvision.ppam.androidautomagic.c.a.et$1.d(SourceFile:119)
at ch.gridvision.ppam.androidautomagic.c.a.et$1.a(SourceFile:110)
at ch.gridvision.ppam.androidautomagiclib.util.de$1.run(SourceFile:39)
at java.lang.Thread.run(Thread.java:818)

30.05.2016 15:25:22.032 [ChargeBar: Automagic start] Flow ended.

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: ChargeBar

Post by Bushmills » 30 May 2016 10:19

The log appears to complain about a syntax error, where I can't see any:

global_screen_short = min(x, y);
global_screen_long = max(x, y);' due to errors: [';' expected[84], ')' or ',' expected[84]

What version of Automagic are you running? Indexing list items with square brackets has only been introduced recently - that could be a problem.

Please show me a screenshot with syntax highlighting enabled of the offending script action, which should look like the one in this screenshot:
Attachments
Screenshot_2016-05-30-12-15-19.png
Screenshot_2016-05-30-12-15-19.png (96.6 KiB) Viewed 33763 times

vamzicool
Posts: 67
Joined: 29 Dec 2014 17:47

Re: ChargeBar

Post by vamzicool » 30 May 2016 11:00

Sorry @Bushmills my automagic version was 1.29. After updating it to the latest version the error has disappeared. I'm glad that i can use brackets to access list and maps with index or keys. Your flow is working fine. It looks good :)

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: ChargeBar

Post by Bushmills » 30 May 2016 11:05

Good to hear that, thank you for reporting. Check power consumption, because, as mentioned, some systems seem to require a refinement in the battery level checking flow.

User avatar
Philip
Posts: 82
Joined: 08 Jun 2015 19:20
Location: Hampshire, UK

Re: ChargeBar

Post by Philip » 30 May 2016 13:12

This seems to be working well here - many thanks for sharing!

One issue that I have is that I have a tempered glass screen protector installed on my Nexus 6. This has a black border and the transparent viewing area is very close to the size of the screen. Because it is very, very slightly misaligned (less than 1 pixel!) on my screen, the widget doesn't display well and is very dependent on the angle of viewing.

I therefore tried setting the widget to 5 pixels high (which may be too big, but I wanted to try to get the best size by trial and error). I have changed the height from 1 to 5 pixels in two separate places in the widget, but it's still displaying as 1 pixel thick. I also looked through the flows and couldn't see anything there that I needed to change (but I don't speak German and may have missed something obvious).

Any thoughts?
--
Philip

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: ChargeBar

Post by Bushmills » 30 May 2016 13:25

It's the overlay which should need resizing, in the flow "Portrait/Landscape". Twice, in the two last actions of the flow. Change the "Height" setting from 1 to desired height. The widget will adapt to changed overlay dimensions.
For a thicker gauge, you may want to consider rendering it semi-translucent, which will reduce contrast, but keeps the status line visible.
Or, change alignment to "Bottom", in the same flow actions, to move the gauge to the opposite screen side, where it shows as a seperator line between buttons and screen contents:
Attachments
Screenshot_2016-05-30-15-42-35.png
Screenshot_2016-05-30-15-42-35.png (75.58 KiB) Viewed 33748 times

User avatar
Philip
Posts: 82
Joined: 08 Jun 2015 19:20
Location: Hampshire, UK

Re: ChargeBar

Post by Philip » 30 May 2016 13:50

Thank you very much - that works perfectly (10 pixels high and 70% translucency looks good for me right now, though I may tweak it after using for a while).

(I could only see one place in the Portrait/Landscape flow where the Height appears - in Show Custom Widget Overlay).
--
Philip

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: ChargeBar

Post by Bushmills » 30 May 2016 14:03

Right, but there are two of those actions, almost identical. One for portrait, one for landscape orientation. They could be combined, but I thought it may be useful to be able to control all overlay parameters for both modes independently.

User avatar
Philip
Posts: 82
Joined: 08 Jun 2015 19:20
Location: Hampshire, UK

Re: ChargeBar

Post by Philip » 30 May 2016 14:22

Ah - the screen shot that you show seems to be different to the flow that I downloaded from the first post :-)

Image
--
Philip

Post Reply