Notification progress

Post your questions and help other users.

Moderator: Martin

Post Reply
Lucy
Posts: 225
Joined: 10 Aug 2019 11:24

Notification progress

Post by Lucy » 09 Dec 2019 07:31

How can i add a static value to a notification?
I mean like, if for example i attach a notification to my battery widget flow... the script for the updated value is..

Code: Select all



global_battery_level = battery_level + "%";
if (battery_status == "1")
{ global_battery_status = "Unknown"; }
else if (battery_status == "2")
{ global_battery_status = "Charging"; }
else if (battery_status == "3")
{ global_battery_status = "Discharging"; }
else if (battery_status == "4")
{ global_battery_status = "Not charging"; }
else if (battery_status == "5")
{ global_battery_status = "Full"; }

if (battery_plugged == "1")
{ global_battery_plugged = "AC adapter"; }
else if (battery_plugged == "2")
{ global_battery_plugged = "USB"; }
else if (battery_plugged == "3")
{ global_battery_plugged = "Wireless"; }
else if (battery_plugged == "0")
{ global_battery_plugged = "Not plugged"; }

if (battery_health == "1")
{ global_battery_health = "Unknown"; }
else if (battery_health == "2")
{ global_battery_health = "Good"; }
else if (battery_health == "3")
{ global_battery_health = "Overheat"; }
else if (battery_health == "4")
{ global_battery_health = "Dead"; }
else if (battery_health == "5")
{ global_battery_health = "Over voltage"; }
else if (battery_health == "6")
{ global_battery_health = "Unspecified failure"; }
else if (battery_health == "7")
{ global_battery_health = "Cold"; }



How can i have that percentage value and battery status show in progress bar but with updated values?

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Notification progress

Post by Desmanto » 09 Dec 2019 17:51

Just use the variable in the notification text. To eliminate the too many else if, use map

status = newMapFromValues(
1, "Unknown",
2, "Charging",
3, "Discharging",
4, "Not charging",
5, "Full" );
global_battery_status = status[battery_status];

Do the same also for the plugged and health. Later use {global_battery_status} in the notification text.

To get the progress percentage, you can check Show progressbar. Progressbar value is {battery_level} and the max value is 100. The next trigger that it update the value, it will change the batttery level and increase the progressbar.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Lucy
Posts: 225
Joined: 10 Aug 2019 11:24

Re: Notification progress

Post by Lucy » 09 Dec 2019 18:34

Lol yeah i know i haven't started maps yet. Thanks for that darling ima fix it

Post Reply