[Android] UI: change battery indicator color depending on the value
Sébastien Toque
git at videolan.org
Fri Sep 21 21:34:05 CEST 2012
vlc-ports/android | branch: master | Sébastien Toque <xilasz at gmail.com> | Fri Sep 21 21:33:03 2012 +0200| [46a4574e9c442f179ae9d727bb9c3a279bc8e057] | committer: Sébastien Toque
UI: change battery indicator color depending on the value
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=46a4574e9c442f179ae9d727bb9c3a279bc8e057
---
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index c3dbabf..0afa4f3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -53,6 +53,7 @@ import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
+import android.graphics.Color;
import android.graphics.PixelFormat;
import android.media.AudioManager;
import android.os.Build;
@@ -391,6 +392,12 @@ public class VideoPlayerActivity extends Activity {
public void onReceive(Context context, Intent intent)
{
int batteryLevel = intent.getIntExtra("level", 0);
+ if (batteryLevel >= 50)
+ mBattery.setTextColor(Color.GREEN);
+ else if (batteryLevel >= 30)
+ mBattery.setTextColor(Color.YELLOW);
+ else
+ mBattery.setTextColor(Color.RED);
mBattery.setText(String.format("%d%%", batteryLevel));
}
};
More information about the Android
mailing list