From 7c75ec6e11a9287b2360bb62ef4ddb4f0e2083c7 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 2 Jun 2015 12:48:42 -0700 Subject: [PATCH 1/1] altosdroid: Highlight age in red when older than 10 seconds This lets you quickly identify stale data Signed-off-by: Keith Packard --- .../altusmetrum/AltosDroid/AltosDroid.java | 21 +++++++++++++++++-- 1 file 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() { -- 2.30.2