power: Stop making time estimates

Any time estimates we can come up with are notoriously unreliable;
even on devices that report correct (dis)charging rates, any change
in workload, screen brightness etc. can throw our estimate off by
a huge amount. This is further compounded by bad firmware and battery
firmware which reports inaccurate data as neither Windows nor Android do
not use that data.

So instead, limit ourselves to only showing the current percentage
and leave its interpretation to the user.

As an added bonus, we end up with shorter strings that are less likely
to cause problems with ellipsization when translated.

https://bugzilla.gnome.org/show_bug.cgi?id=708472
This commit is contained in:
Florian Müllner 2015-09-25 01:38:59 +02:00 committed by Bastien Nocera
parent 8d7bb6496c
commit 6c08799c7b

View File

@ -59,39 +59,11 @@ const Indicator = new Lang.Class({
},
_getStatus: function() {
let seconds = 0;
if (this._proxy.State == UPower.DeviceState.FULLY_CHARGED)
return _("Fully Charged");
else if (this._proxy.State == UPower.DeviceState.CHARGING)
seconds = this._proxy.TimeToFull;
else if (this._proxy.State == UPower.DeviceState.DISCHARGING)
seconds = this._proxy.TimeToEmpty;
// state is one of PENDING_CHARGING, PENDING_DISCHARGING
else
return _("Estimating…");
let time = Math.round(seconds / 60);
if (time == 0) {
// 0 is reported when UPower does not have enough data
// to estimate battery life
return _("Estimating…");
}
let minutes = time % 60;
let hours = Math.floor(time / 60);
if (this._proxy.State == UPower.DeviceState.DISCHARGING) {
// Translators: this is <hours>:<minutes> Remaining (<percentage>)
return _("%d\u2236%02d Remaining (%d\u2009%%)").format(hours, minutes, this._proxy.Percentage);
}
if (this._proxy.State == UPower.DeviceState.CHARGING) {
// Translators: this is <hours>:<minutes> Until Full (<percentage>)
return _("%d\u2236%02d Until Full (%d\u2009%%)").format(hours, minutes, this._proxy.Percentage);
}
return null;
return _("%d\u2009%% Charging").format(hours, minutes, this._proxy.Percentage);
return _("%d\u2009%% Charged").format(this._proxy.Percentage);
},
_sync: function() {