diff --git a/app/src/main/java/com/nightscout/android/MainActivity.java b/app/src/main/java/com/nightscout/android/MainActivity.java index df635f82..e7fdd29a 100644 --- a/app/src/main/java/com/nightscout/android/MainActivity.java +++ b/app/src/main/java/com/nightscout/android/MainActivity.java @@ -23,6 +23,7 @@ import com.google.android.gms.analytics.Tracker; import com.nightscout.android.dexcom.SyncingService; import com.nightscout.android.preferences.AndroidPreferences; +import com.nightscout.android.preferences.PreferenceKeys; import com.nightscout.android.settings.SettingsActivity; import com.nightscout.android.wearables.Pebble; import com.nightscout.core.dexcom.Constants; @@ -226,6 +227,10 @@ protected void onResume() { mWebView.loadUrl("javascript:updateUnits(" + Boolean.toString(currentUnits == Constants.MG_DL_TO_MMOL_L) + ")"); mHandler.post(updateTimeAgo); + // FIXME: (klee) need to find a better way to do this. Too many things are hooking in here. + if (statusBarIcons != null) { + statusBarIcons.checkForRootOptionChanged(); + } } private String getSGVStringByUnit(int sgv, TrendArrow trend){ @@ -459,22 +464,36 @@ public class StatusBarIcons { private ImageView mImageViewUpload; private ImageView mImageViewTimeIndicator; private ImageView mImageRcvrBattery; + private TextView mRcvrBatteryLabel; private boolean usbActive; private boolean uploadActive; private boolean displayTimeSync; private int batteryLevel; - StatusBarIcons(){ + StatusBarIcons() { mImageViewUSB = (ImageView) findViewById(R.id.imageViewUSB); mImageViewUpload = (ImageView) findViewById(R.id.imageViewUploadStatus); mImageViewTimeIndicator = (ImageView) findViewById(R.id.imageViewTimeIndicator); mImageRcvrBattery = (ImageView) findViewById(R.id.imageViewRcvrBattery); mImageRcvrBattery.setImageResource(R.drawable.battery); + mRcvrBatteryLabel = (TextView) findViewById(R.id.rcvrBatteryLabel); setDefaults(); } + public void checkForRootOptionChanged() { + if (!PreferenceManager.getDefaultSharedPreferences( + getApplicationContext()).getBoolean(PreferenceKeys.ROOT_ENABLED, false)) { + mImageRcvrBattery.setVisibility(View.GONE); + mRcvrBatteryLabel.setVisibility(View.GONE); + } else { + mImageRcvrBattery.setVisibility(View.VISIBLE); + mRcvrBatteryLabel.setVisibility(View.VISIBLE); + } + } + + public void setDefaults() { setUSB(false); setUpload(false); diff --git a/app/src/main/java/com/nightscout/android/preferences/PreferenceKeys.java b/app/src/main/java/com/nightscout/android/preferences/PreferenceKeys.java index 6f865b1c..95f49a96 100644 --- a/app/src/main/java/com/nightscout/android/preferences/PreferenceKeys.java +++ b/app/src/main/java/com/nightscout/android/preferences/PreferenceKeys.java @@ -11,6 +11,7 @@ public final class PreferenceKeys { public static final String MONGO_COLLECTION = "cloud_storage_mongodb_collection"; public static final String MONGO_DEVICE_STATUS_COLLECTION = "cloud_storage_mongodb_device_status_collection"; + public static final String ROOT_ENABLED = "root_support_enabled"; public static final String PREFERRED_UNITS = "display_options_units"; public static final String PWD_NAME = "pwd_name"; } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 8f8014c6..2cb93956 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -126,6 +126,7 @@