updates
[webos-internals:modifications.git] / top-bar / top-bar-rotated-270deg-battery-icon-and-percent.patch
1 diff --git a/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js b/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
2 index 6d0a87a..cc916e8 100644
3 --- a/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
4 +++ b/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
5 @@ -1962,6 +1962,23 @@ closePbapAlert: function() {
6         }       
7  },
8  
9 +
10 +getBatteryLevelColor: function(percent, charging) {
11 +               if (charging == 1)
12 +                       batPercentColor = "charging";
13 +               else if (percent >= 70) 
14 +                       batPercentColor = "full";
15 +               else if(percent <= 69 && percent >= 45) 
16 +                       batPercentColor = "medium";
17 +               else if(percent <= 44 && percent >= 20)
18 +                       batPercentColor = "low";
19 +               else if(percent <= 19)
20 +                       batPercentColor = "critical";
21 +
22 +       return batPercentColor;
23 +},
24 +
25 +
26  /*
27   * Handle power and charging notifications
28   */
29 @@ -1994,6 +2011,8 @@ handlePowerNotifications: function(payload) {
30                         if (!this.isCharging) {
31                                 Mojo.Log.info("SystemUI- Is Charging "+ this.isCharging + " Battery level "+ i);
32                                 Mojo.Dom.get('power').className = 'battery-' + i;
33 +                               Mojo.Dom.get('batpercent').className = this.getBatteryLevelColor(payload.percent_ui);
34 +                               Mojo.Dom.get('batpercent').innerHTML = this.batteryLevel + unescape('%');
35                                 
36                                 //Show Banner Message if the Battery level is below 20%
37                                 var batteryalert = $L("#{percent_ui}% battery remaining").interpolate(payload); 
38 @@ -2032,6 +2051,10 @@ handlePowerNotifications: function(payload) {
39                                 else
40                                         Mojo.Dom.get('power').className = 'battery-charging-' + i;
41                                         
42 +                               Mojo.Dom.get('batpercent').className = this.getBatteryLevelColor(payload.percent_ui, true);
43 +                               Mojo.Dom.get('batpercent').innerHTML = this.batteryLevel + unescape('%');
44 +
45 +                                       
46                         }
47                         
48                         if(this.batteryLevel > 5 && this.batteryLevel <= 10) {                          
49 @@ -2080,6 +2103,9 @@ handlePowerNotifications: function(payload) {
50                         else
51                                 Mojo.Dom.get('power').className = 'battery-charging-' + this.lastBatteryLevel;
52                                                 
53 +                       Mojo.Dom.get('batpercent').className = this.getBatteryLevelColor(this.batteryLevel, true);
54 +                       Mojo.Dom.get('batpercent').innerHTML = this.batteryLevel + unescape('%');
55 +                       
56                         var stageController = Mojo.Controller.getAppController().getStageController("LowBatteryAlert");
57                         if (stageController) {
58                                 stageController.delegateToSceneAssistant("close");
59 @@ -2103,6 +2129,8 @@ handlePowerNotifications: function(payload) {
60                         this.chargingBannerShown = false;                       
61                         Mojo.Log.info("SystemUI- Charger Notification "+ this.isCharging + " Last battery level "+ this.lastBatteryLevel);
62                         Mojo.Dom.get('power').className = 'battery-' + this.lastBatteryLevel;   
63 +                       Mojo.Dom.get('batpercent').className = this.getBatteryLevelColor(this.batteryLevel);
64 +                       Mojo.Dom.get('batpercent').innerHTML = this.batteryLevel + unescape('%');
65                         Mojo.Controller.getAppController().removeBanner('chargingAlert');       
66                         if (this.batteryLevel < this.minBatThresholdForUpdate) {
67                                 Mojo.Log.info("SystemUI - OTA - Closing All Update Alerts due to battery level dropped below threshold level and charger disconnected.");
68 diff --git a/usr/lib/luna/system/luna-systemui/app/views/bar/bar-scene.html b/usr/lib/luna/system/luna-systemui/app/views/bar/bar-scene.html
69 index d728ec9..bd088a3 100644
70 --- a/usr/lib/luna/system/luna-systemui/app/views/bar/bar-scene.html
71 +++ b/usr/lib/luna/system/luna-systemui/app/views/bar/bar-scene.html
72 @@ -13,6 +13,8 @@
73         </div>
74  
75         <div id="devicemenu">
76 +               <span id="batpercent">
77 +               </span>
78                 <div id="power"></div>
79                 <div id="rssi"></div>
80                 <div id="ev1x">
81 diff --git a/usr/lib/luna/system/luna-systemui/stylesheets/systemui.css b/usr/lib/luna/system/luna-systemui/stylesheets/systemui.css
82 index f3cacab..75f834a 100644
83 --- a/usr/lib/luna/system/luna-systemui/stylesheets/systemui.css
84 +++ b/usr/lib/luna/system/luna-systemui/stylesheets/systemui.css
85 @@ -120,6 +120,7 @@ body.palm-default {
86  /* device menu icons */
87  
88  #power,
89 +#batpercent,
90  #rssi,
91  #roaming,
92  #datanet,
93 @@ -141,8 +142,37 @@ body.palm-default {
94  }
95  
96  #power {
97 +       position:absolute;
98 +       right: 2px;
99 +       top: 9px;
100 +       margin-top: 0px;
101 +       height: 20px;
102 +       width: 20px;
103 +       -webkit-transform: rotate(270deg);
104 +}
105 +#batpercent { 
106         margin-left: 2px;
107 -       width: 17px;            
108 +       position: relative;
109 +       bottom: 11px;
110 +       font-size: 12px;
111 +       margin-right: 2px;
112 +       min-width: 22px;
113 +       text-align: center;
114 +}
115 +#batpercent.charging {
116 +       /*color: #33CCFF;*/
117 +}
118 +#batpercent.full {
119 +       /*color: #33FF33;*/
120 +}
121 +#batpercent.medium {
122 +       /*color: #FFFF33;*/
123 +}
124 +#batpercent.low {
125 +       /*color: #FFCC00;*/
126 +}
127 +#batpercent.critical {
128 +       /*color: #FF0000;*/
129  }
130  
131  #power.error { background-image: url(../images/battery-error.png); }