summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2015-06-02 12:48:42 -0700
committerKeith Packard <keithp@keithp.com>2015-06-02 12:48:42 -0700
commit7c75ec6e11a9287b2360bb62ef4ddb4f0e2083c7 (patch)
tree2b4d5057665eb80040f5dee42fc25b1a1292114c
parenta533ea525620f194fd89fedad043659bb433d71b (diff)
altosdroid: Highlight age in red when older than 10 seconds
This lets you quickly identify stale data Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java21
1 files changed, 19 insertions, 2 deletions
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
index 293dff7f..8c9ff31f 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
@@ -55,6 +55,8 @@ import android.widget.Toast;
import android.app.AlertDialog;
import android.location.Location;
import android.hardware.usb.*;
+import android.graphics.*;
+import android.graphics.drawable.*;
import org.altusmetrum.altoslib_7.*;
@@ -90,6 +92,9 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener {
private RelativeLayout mStateLayout;
private TextView mStateView;
private TextView mAgeView;
+ private boolean mAgeViewOld;
+ private int mAgeNewColor;
+ private int mAgeOldColor;
// field to display the version at the bottom of the screen
private TextView mVersion;
@@ -279,8 +284,18 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener {
}
void update_age() {
- if (saved_state != null)
- mAgeView.setText(String.format("%d", (System.currentTimeMillis() - saved_state.received_time + 500) / 1000));
+ if (saved_state != null) {
+ int age = (int) ((System.currentTimeMillis() - saved_state.received_time + 500) / 1000);
+ boolean old = age >= 10;
+ if (old != mAgeViewOld) {
+ if (old)
+ mAgeView.setTextColor(mAgeOldColor);
+ else
+ mAgeView.setTextColor(mAgeNewColor);
+ mAgeViewOld = old;
+ }
+ mAgeView.setText(String.format("%d", age));
+ }
}
void update_ui(AltosState state, Location location) {
@@ -455,6 +470,8 @@ public class AltosDroid extends FragmentActivity implements AltosUnitsListener {
mStateLayout = (RelativeLayout) findViewById(R.id.state_container);
mStateView = (TextView) findViewById(R.id.state_value);
mAgeView = (TextView) findViewById(R.id.age_value);
+ mAgeNewColor = mAgeView.getTextColors().getDefaultColor();
+ mAgeOldColor = getResources().getColor(R.color.old_color);
}
private boolean ensureBluetooth() {