5,606,588 Members 36,148 Now Online
XDA Developers Android and Mobile Development Forum

[Q] Percent and colors

Tip us?
 
error404
Old
#1  
error404's Avatar
Senior Member - OP
Thanks Meter 231
Posts: 260
Join Date: Jan 2011
Location: São José do Rio Preto
Default [Q] Percent and colors

I have two questions (hope you guys can help me):

1 - Is there a way to hide some numbers? Here's what i want:
$((#usedSD#/#totalSD#)*100)$ = this will give me a percentage of used space in SD card, but i don't want the decimal numbers (23,33 - want to remove the numbers after the comma).

2 - How to apply different colors to a text?
#Battery# < 20 red color
#Battery# < 60 green color
#Battery# > 60 blue color

Sorry for my english and thank you in advance.
... . -. - / ..-. .-. --- -- / -- -.-- / - . .-.. . --. .-. .- .--. ....

Powered by OmniRom.
 
kwerdenker
Old
#2  
kwerdenker's Avatar
Recognized Themer
Thanks Meter 1569
Posts: 1,238
Join Date: Apr 2010
Location: Probably the Zooper Forums
Quote:
Originally Posted by yudroid View Post
I have two questions (hope you guys can help me):

1 - Is there a way to hide some numbers? Here's what i want:
$((#usedSD#/#totalSD#)*100)$ = this will give me a percentage of used space in SD card, but i don't want the decimal numbers (23,33 - want to remove the numbers after the comma).

2 - How to apply different colors to a text?
#Battery# < 20 red color
#Battery# < 60 green color
#Battery# > 60 blue color

Sorry for my english and thank you in advance.
1. You can use floor() to round numbers to their nearest lower integer or ceil() for the upper variant. Your code should look like this $(floor((#usedSD#/#totalSD#)*100))$
You can find all the available math functions for Zooper here: http://zooper.themerapp.com/support/...th-expressions

2. Advanced Parameters are your friend here. The following code put into the Advanced Parameters of a text module will change the color according to your specifications:
Code:
$#BLEVN#<20?[c]ffff0000[/c]$$#BLEVN#>=20 && #BLEVN#<60?[c]ff00ff00[/c]$$#BLEVN#>=60?[c]ff0000ff[/c]$
Mobile: LG Nexus 4 | ROM: Paranoid Android 4.0 + Xposed | Kernel: faux Kernel
Tablet: Asus Nexus 7 (2013) | ROM: Paranoid Android 3+ | Kernel: faux Kernel


The Following 3 Users Say Thank You to kwerdenker For This Useful Post: [ Click to Expand ]
 
geeket
Old
#3  
Junior Member
Thanks Meter 0
Posts: 9
Join Date: Nov 2013
Quote:
Originally Posted by kwerdenker View Post
2. Advanced Parameters are your friend here. The following code put into the Advanced Parameters of a text module will change the color according to your specifications:
Code:
$#BLEVN#<20?[c]ffff0000[/c]$$#BLEVN#>=20 && #BLEVN#<60?[c]ff00ff00[/c]$$#BLEVN#>=60?[c]ff0000ff[/c]$
After put this code I have only this text "ff0000ff" - I do not have battery level....what is wrong ?
 
kwerdenker
Old
#4  
kwerdenker's Avatar
Recognized Themer
Thanks Meter 1569
Posts: 1,238
Join Date: Apr 2010
Location: Probably the Zooper Forums
Quote:
Originally Posted by geeket View Post
After put this code I have only this text "ff0000ff" - I do not have battery level....what is wrong ?
You probably put the code into the text field instead in the Advanced Parameters field. Scroll down to the end of the module options when editing your text module, there you'll find it.

Send from my secret moonbase via space carrier pigeons
Mobile: LG Nexus 4 | ROM: Paranoid Android 4.0 + Xposed | Kernel: faux Kernel
Tablet: Asus Nexus 7 (2013) | ROM: Paranoid Android 3+ | Kernel: faux Kernel


The Following User Says Thank You to kwerdenker For This Useful Post: [ Click to Expand ]
 
geeket
Old
#5  
Junior Member
Thanks Meter 0
Posts: 9
Join Date: Nov 2013
Quote:
Originally Posted by kwerdenker View Post
You probably put the code into the text field instead in the Advanced Parameters field. Scroll down to the end of the module options when editing your text module, there you'll find it.

Send from my secret moonbase via space carrier pigeons
OK - I have this but...all should look like this:

+add "text" -> in "edit text" write #BLEV# -> in advaced Parameters write Your code
 
kwerdenker
Old
#6  
kwerdenker's Avatar
Recognized Themer
Thanks Meter 1569
Posts: 1,238
Join Date: Apr 2010
Location: Probably the Zooper Forums
Quote:
Originally Posted by geeket View Post
OK - I have this but...all should look like this:

+add "text" -> in "edit text" write #BLEV# -> in advaced Parameters write Your code
Yes, that should work 😃

Send from my secret moonbase via space carrier pigeons
Mobile: LG Nexus 4 | ROM: Paranoid Android 4.0 + Xposed | Kernel: faux Kernel
Tablet: Asus Nexus 7 (2013) | ROM: Paranoid Android 3+ | Kernel: faux Kernel


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


XDA PORTAL POSTS

Speed up the ROM or Kernel Build Process

Creating a kernel, ROM, or any other development projectrequires knowledge and tools. While … more

Google Glass Now Open to Anyone… with $1500 to Spend (Update: Not Anymore)

Google Glass, which recently received its official update … more

Android 4.4.2 OTA Now Available for the Verizon Droid DNA

A couple of days ago, we talked about how the Android 4.4.2 upgrade for the HTC … more