From 7ec3ff2a1794bd4141c06b276a21d830d46a8914 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 6 Feb 2017 16:47:23 +0100 Subject: [PATCH 01/48] Wear bolus progress as card --- .../plugins/Actions/ActionsFragment.java | 4 +-- .../androidaps/plugins/Wear/WearPlugin.java | 9 +++++ .../wearintegration/WatchUpdaterService.java | 18 ++++++++++ .../androidaps/ListenerService.java | 31 +++++++++++++++- wear/wear.iml | 35 +++++++++++-------- 5 files changed, 79 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java index e7a8bb2efc..bf3dc7f9d2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java @@ -106,9 +106,9 @@ public class ActionsFragment extends Fragment implements FragmentBase, View.OnCl tempBasal.setVisibility(View.GONE); else tempBasal.setVisibility(View.VISIBLE); - if (!MainApp.getConfigBuilder().getPumpDescription().isRefillingCapable || !MainApp.getConfigBuilder().isInitialized()) + /* if (!MainApp.getConfigBuilder().getPumpDescription().isRefillingCapable || !MainApp.getConfigBuilder().isInitialized()) fill.setVisibility(View.GONE); - else + else */ fill.setVisibility(View.VISIBLE); if (!Config.APS) tempTarget.setVisibility(View.GONE); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java index cac8007e69..2941148ce5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java @@ -15,6 +15,7 @@ import info.nightscout.androidaps.events.EventTempBasalChange; import info.nightscout.androidaps.events.EventTreatmentChange; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification; +import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Wear.wearintegration.WatchUpdaterService; /** @@ -141,6 +142,14 @@ public class WearPlugin implements PluginBase { sendDataToWatch(false, true, false); } + + @Subscribe + public void onStatusEvent(final EventOverviewBolusProgress ev) { + Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS); + intent.putExtra("progresspercent", ev.percent); + ctx.startService(intent); + } + public static boolean isEnabled() { return fragmentEnabled; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index 66383cf7d5..0eb903de90 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -44,6 +44,7 @@ public class WatchUpdaterService extends WearableListenerService implements public static final String ACTION_OPEN_SETTINGS = WatchUpdaterService.class.getName().concat(".OpenSettings"); public static final String ACTION_SEND_STATUS = WatchUpdaterService.class.getName().concat(".SendStatus"); public static final String ACTION_SEND_BASALS = WatchUpdaterService.class.getName().concat(".SendBasals"); + public static final String ACTION_SEND_BOLUSPROGRESS = WatchUpdaterService.class.getName().concat(".BolusProgress"); private GoogleApiClient googleApiClient; @@ -52,6 +53,7 @@ public class WatchUpdaterService extends WearableListenerService implements private static final String OPEN_SETTINGS_PATH = "/openwearsettings"; private static final String NEW_STATUS_PATH = "/sendstatustowear"; public static final String BASAL_DATA_PATH = "/nightscout_watch_basal"; + public static final String BOLUS_PROGRESS_PATH = "/nightscout_watch_bolusprogress"; boolean wear_integration = false; @@ -115,6 +117,8 @@ public class WatchUpdaterService extends WearableListenerService implements sendStatus(); } else if (ACTION_SEND_BASALS.equals(action)) { sendBasals(); + } else if (ACTION_SEND_BOLUSPROGRESS.equals(action)){ + sendBolusProgress(intent.getIntExtra("progresspercent", 0)); } else { sendData(); } @@ -423,6 +427,20 @@ public class WatchUpdaterService extends WearableListenerService implements } } + private void sendBolusProgress(int progresspercent) { + if (googleApiClient.isConnected()) { + PutDataMapRequest dataMapRequest = PutDataMapRequest.create(BOLUS_PROGRESS_PATH); + //unique content + dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis()); + dataMapRequest.getDataMap().putString("bolusProgress", "bolusProgress"); + dataMapRequest.getDataMap().putInt("progresspercent", progresspercent); + PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest(); + Wearable.DataApi.putDataItem(googleApiClient, putDataRequest); + } else { + Log.e("BolusProgress", "No connection to wearable available!"); + } + } + private void sendStatus() { if (googleApiClient.isConnected()) { diff --git a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java index d969706e11..43dd7afd8d 100644 --- a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java @@ -1,10 +1,15 @@ package info.nightscout.androidaps; +import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.content.LocalBroadcastManager; +import android.support.v4.app.NotificationCompat; +import android.support.v4.app.NotificationManagerCompat; +import android.support.v4.app.NotificationCompat.WearableExtender; + import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.api.GoogleApiClient; @@ -27,6 +32,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp private static final String OPEN_SETTINGS = "/openwearsettings"; private static final String NEW_STATUS_PATH = "/sendstatustowear"; public static final String BASAL_DATA_PATH = "/nightscout_watch_basal"; + public static final String BOLUS_PROGRESS_PATH = "/nightscout_watch_bolusprogress"; private static final String ACTION_RESEND = "com.dexdrip.stephenblack.nightwatch.RESEND_DATA"; @@ -97,7 +103,9 @@ public class ListenerService extends WearableListenerService implements GoogleAp Intent intent = new Intent(this, NWPreferences.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); - + } else if (path.equals(BOLUS_PROGRESS_PATH)) { + int progress = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getInt("progresspercent", 0); + showBolusProgress(progress); } else if (path.equals(NEW_STATUS_PATH)) { dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap(); Intent messageIntent = new Intent(); @@ -121,6 +129,27 @@ public class ListenerService extends WearableListenerService implements GoogleAp } } + private void showBolusProgress(int progresspercent) { + int notificationId = 001; +// Build intent for notification content + Intent viewIntent = new Intent(); + PendingIntent viewPendingIntent = PendingIntent.getActivity(this, 0, viewIntent, 0); + + NotificationCompat.Builder notificationBuilder = + new NotificationCompat.Builder(this) + .setSmallIcon(R.drawable.ic_icon) + .setContentTitle("Bolus Progress") + .setContentText(progresspercent + "%") + .setContentIntent(viewPendingIntent); + +// Get an instance of the NotificationManager service + NotificationManagerCompat notificationManager = + NotificationManagerCompat.from(this); + +// Build the notification and issues it with notification manager. + notificationManager.notify(notificationId, notificationBuilder.build()); + } + public static void requestData(Context context) { Intent intent = new Intent(context, ListenerService.class); intent.setAction(ACTION_RESEND); diff --git a/wear/wear.iml b/wear/wear.iml index d38c08321d..ce3df746e7 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -43,13 +43,6 @@ - - - - - - - @@ -58,6 +51,13 @@ + + + + + + + @@ -66,14 +66,6 @@ - - - - - - - - @@ -82,6 +74,14 @@ + + + + + + + + @@ -122,6 +122,7 @@ + @@ -134,10 +135,14 @@ + + + + From 8c37809751790aebcbd8590745d8b3538ab5a5bf Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 6 Feb 2017 19:35:27 +0100 Subject: [PATCH 02/48] Wear cancel bolus via content intent to progress card --- .../wearintegration/WatchUpdaterService.java | 15 ++++- .../androidaps/ListenerService.java | 64 +++++++++++++++++-- wear/wear.iml | 14 ++-- 3 files changed, 79 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index 0eb903de90..7f5575e01d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -50,12 +50,14 @@ public class WatchUpdaterService extends WearableListenerService implements private GoogleApiClient googleApiClient; public static final String WEARABLE_DATA_PATH = "/nightscout_watch_data"; public static final String WEARABLE_RESEND_PATH = "/nightscout_watch_data_resend"; + private static final String WEARABLE_CANCELBOLUS_PATH = "/nightscout_watch_cancel_bolus"; private static final String OPEN_SETTINGS_PATH = "/openwearsettings"; private static final String NEW_STATUS_PATH = "/sendstatustowear"; public static final String BASAL_DATA_PATH = "/nightscout_watch_basal"; public static final String BOLUS_PROGRESS_PATH = "/nightscout_watch_bolusprogress"; + boolean wear_integration = false; SharedPreferences mPrefs; @@ -139,11 +141,22 @@ public class WatchUpdaterService extends WearableListenerService implements @Override public void onMessageReceived(MessageEvent event) { if (wear_integration) { - if (event != null && event.getPath().equals(WEARABLE_RESEND_PATH)) + if (event != null && event.getPath().equals(WEARABLE_RESEND_PATH)) { resendData(); + } + + if (event != null && event.getPath().equals(WEARABLE_CANCELBOLUS_PATH)) { + cancelBolus(); + } } } + private void cancelBolus() { + //ToastUtils.showToastInUiThread(this, "cancelBolus()"); + PumpInterface pump = MainApp.getConfigBuilder(); + pump.stopBolusDelivering(); + } + private void sendData() { BgReading lastBG = MainApp.getDbHelper().lastBg(); diff --git a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java index 43dd7afd8d..3dd01cdaf9 100644 --- a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java @@ -22,6 +22,8 @@ import com.google.android.gms.wearable.NodeApi; import com.google.android.gms.wearable.Wearable; import com.google.android.gms.wearable.WearableListenerService; +import java.util.concurrent.TimeUnit; + /** * Created by emmablack on 12/26/14. */ @@ -29,13 +31,18 @@ public class ListenerService extends WearableListenerService implements GoogleAp GoogleApiClient.OnConnectionFailedListener { private static final String WEARABLE_DATA_PATH = "/nightscout_watch_data"; private static final String WEARABLE_RESEND_PATH = "/nightscout_watch_data_resend"; + private static final String WEARABLE_CANCELBOLUS_PATH = "/nightscout_watch_cancel_bolus"; + private static final String OPEN_SETTINGS = "/openwearsettings"; private static final String NEW_STATUS_PATH = "/sendstatustowear"; public static final String BASAL_DATA_PATH = "/nightscout_watch_basal"; public static final String BOLUS_PROGRESS_PATH = "/nightscout_watch_bolusprogress"; + private static final String ACTION_RESEND = "com.dexdrip.stephenblack.nightwatch.RESEND_DATA"; + private static final String ACTION_CANCELBOLUS = "com.dexdrip.stephenblack.nightwatch.CANCELBOLUS"; + private static final String ACTION_RESEND_BULK = "com.dexdrip.stephenblack.nightwatch.RESEND_BULK_DATA"; GoogleApiClient googleApiClient; private long lastRequest = 0; @@ -65,10 +72,45 @@ public class ListenerService extends WearableListenerService implements GoogleAp } } + public class BolusCancelTask extends AsyncTask { + Context mContext; + + BolusCancelTask(Context context) { + mContext = context; + } + + @Override + protected Void doInBackground(Void... params) { + if (googleApiClient.isConnected()) { + NodeApi.GetConnectedNodesResult nodes = + Wearable.NodeApi.getConnectedNodes(googleApiClient).await(); + for (Node node : nodes.getNodes()) { + Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), WEARABLE_CANCELBOLUS_PATH, null); + } + + } else { + googleApiClient.blockingConnect(15, TimeUnit.SECONDS); + if (googleApiClient.isConnected()) { + NodeApi.GetConnectedNodesResult nodes = + Wearable.NodeApi.getConnectedNodes(googleApiClient).await(); + for (Node node : nodes.getNodes()) { + Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), WEARABLE_CANCELBOLUS_PATH, null); + } + + } + } + return null; + } + } + public void requestData() { new DataRequester(this).execute(); } + public void cancelBolus() { + new BolusCancelTask(this).execute(); + } + public void googleApiConnect() { googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) @@ -84,7 +126,11 @@ public class ListenerService extends WearableListenerService implements GoogleAp if (intent != null && ACTION_RESEND.equals(intent.getAction())) { googleApiConnect(); requestData(); + } else if(intent != null && ACTION_CANCELBOLUS.equals(intent.getAction())){ + googleApiConnect(); + cancelBolus(); } + //TODO: add action to cancel bolus return START_STICKY; } @@ -131,23 +177,29 @@ public class ListenerService extends WearableListenerService implements GoogleAp private void showBolusProgress(int progresspercent) { int notificationId = 001; -// Build intent for notification content - Intent viewIntent = new Intent(); - PendingIntent viewPendingIntent = PendingIntent.getActivity(this, 0, viewIntent, 0); + // Build intent for notification content + //TODO: Add Action in order to see that it is a cancel event + Intent cancelIntent = new Intent(this, ListenerService.class); + cancelIntent.setAction(ACTION_CANCELBOLUS); + PendingIntent cancelPendingIntent = PendingIntent.getService(this, 0, cancelIntent, 0);; NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_icon) .setContentTitle("Bolus Progress") .setContentText(progresspercent + "%") - .setContentIntent(viewPendingIntent); + .setContentIntent(cancelPendingIntent); -// Get an instance of the NotificationManager service + //TODO: set separate cancel extension with icon + + // Get an instance of the NotificationManager service NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); -// Build the notification and issues it with notification manager. + // Build the notification and issues it with notification manager. notificationManager.notify(notificationId, notificationBuilder.build()); + + //TODO: Cancel notification when 100% } public static void requestData(Context context) { diff --git a/wear/wear.iml b/wear/wear.iml index ce3df746e7..33cd39a6c1 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -43,6 +43,13 @@ + + + + + + + @@ -51,13 +58,6 @@ - - - - - - - From 10d71325dda6a8437d462170a1e9a277edeb9a17 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 6 Feb 2017 21:10:55 +0100 Subject: [PATCH 03/48] Wear separate cancel action extra with bolus progress card --- .../nightscout/androidaps/ListenerService.java | 5 ++++- wear/src/main/res/drawable-hdpi/ic_cancel.png | Bin 0 -> 991 bytes wear/src/main/res/drawable-mdpi/ic_cancel.png | Bin 0 -> 601 bytes wear/src/main/res/drawable-xhdpi/ic_cancel.png | Bin 0 -> 1234 bytes wear/src/main/res/drawable-xxhdpi/ic_cancel.png | Bin 0 -> 2121 bytes 5 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 wear/src/main/res/drawable-hdpi/ic_cancel.png create mode 100644 wear/src/main/res/drawable-mdpi/ic_cancel.png create mode 100644 wear/src/main/res/drawable-xhdpi/ic_cancel.png create mode 100644 wear/src/main/res/drawable-xxhdpi/ic_cancel.png diff --git a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java index 3dd01cdaf9..b38f138c23 100644 --- a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java @@ -188,7 +188,10 @@ public class ListenerService extends WearableListenerService implements GoogleAp .setSmallIcon(R.drawable.ic_icon) .setContentTitle("Bolus Progress") .setContentText(progresspercent + "%") - .setContentIntent(cancelPendingIntent); + .setContentIntent(cancelPendingIntent) + .setPriority(NotificationCompat.PRIORITY_MAX) + .setVibrate(new long[]{0, 100, 1000}) + .addAction(R.drawable.ic_cancel, "CANCEL BOLUS", cancelPendingIntent); //TODO: set separate cancel extension with icon diff --git a/wear/src/main/res/drawable-hdpi/ic_cancel.png b/wear/src/main/res/drawable-hdpi/ic_cancel.png new file mode 100644 index 0000000000000000000000000000000000000000..f3f1437a8855f7c2a6ac613ec1c895a305f3b36b GIT binary patch literal 991 zcmV<510ei~P)VW$!s4=cnOez&4;IF`$9*KMNQGBmgl)0zaDrQ~|#wI&J`)fRJh9qkwmk zhkgM(7kf1I31_}ZbRGa6n|$+}@mGK)L6aTm9ssOJ?$UvglK>^J80F&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n~G>YQ?3g87(o&MLW} z3vXa9rdv@=D0Cv#trHF(Sb3X;ARHA`mod}MUI`R;oqUD})Vz94zWV2clNk@xB6EUb zsmO$b1;W9m8{fQSOrQeetgi72BK5G8Q|+O0yq1{fmDU0ZBRfyoQN@a}!-nrLAf#~p z1Tohso%Q?)$KW^FA_vK{D(*L+Q^9vP;1>OdB=0F8D#l}5{RB2)LeUXL@~QizL`Wl_ z9?WD#7$@f3YDa)~97DG<-xPwTW2vrkC227H-Q#MQZ9U@BM zGSye<&~7HcW`Do#cJd=nQ3TZ`ZAt_c^7*(S%bRb|Za#fWC_1cQ zqe-@z!D*`0D_l=K{b`+wsuBZGrqN6Ge;#U!*APc@u9c%d$M_PVY{DZOBSGAi=FM@= zgo837qBBf-Kmcm*;!GxE$vTM$&hzzWk^G=wJ<(^gw>0l>aB+zWj-K>z>%07*qoM6N<$f(sKm_y7O^ literal 0 HcmV?d00001 diff --git a/wear/src/main/res/drawable-xxhdpi/ic_cancel.png b/wear/src/main/res/drawable-xxhdpi/ic_cancel.png new file mode 100644 index 0000000000000000000000000000000000000000..89e1bd0695bc72a0284401f0377b14d22b16356d GIT binary patch literal 2121 zcmV-P2)6f$P)QzzXrAQQwHF~BM-$)uO^1&bkIFL}X{4ncd&+&g@Gd;EF4* zxZ;W{uDIfgE3U}O^78U3KrtW;C_#kr-&Q#b@fv#rpbpRqxDJQ{MgS9lNx&4~CH_2t zzZ(Kv!@oHw9ONuXH@Ilc4S=hFF~9;~NfV-uQ9u{q2w=Ul^oK@Y3pfPm1xy1L8H}C@ zi`Z*!0`>zwTFHhlMw%EmZ1ikB<1wHG5L#(8(~hlu$rAhpI1N}==(Cq&fTuZX@f3P` z0yqjNDm3G70Sqt=s(w(@Z9r8a7(NI%0eEG=Q1gH{h|i4d@2!64YftuOh%6K#xaCoUnde00kp}=ZYUT2lx(YBj4iGTK!Le3JZI16-H7Q6b9z74XvkJVWlZ%Hft;%!$N?I3O%7K*9tci7eW65 zPUX=wTEvCk64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3m2?5`%}U1BF^JpKy-(95Baw zG2%AJje(U?FumEKxB}%y4C7Pbz)CIXhupB++!JE{|p zIVTokiASA71@{c0E3UZWiYu Date: Tue, 7 Feb 2017 09:17:19 +0100 Subject: [PATCH 04/48] Wear added bolusprogress and dismiss when finished --- .../androidaps/plugins/Wear/WearPlugin.java | 1 + .../wearintegration/WatchUpdaterService.java | 6 +-- .../androidaps/ListenerService.java | 43 +++++++++++++------ wear/wear.iml | 16 +++---- 4 files changed, 42 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java index 2941148ce5..9ee4e974a8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java @@ -147,6 +147,7 @@ public class WearPlugin implements PluginBase { public void onStatusEvent(final EventOverviewBolusProgress ev) { Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS); intent.putExtra("progresspercent", ev.percent); + intent.putExtra("progressstatus", ev.status); ctx.startService(intent); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index 7f5575e01d..e84ab99730 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -120,7 +120,7 @@ public class WatchUpdaterService extends WearableListenerService implements } else if (ACTION_SEND_BASALS.equals(action)) { sendBasals(); } else if (ACTION_SEND_BOLUSPROGRESS.equals(action)){ - sendBolusProgress(intent.getIntExtra("progresspercent", 0)); + sendBolusProgress(intent.getIntExtra("progresspercent", 0), intent.hasExtra("progressstatus")?intent.getStringExtra("progressstatus"):""); } else { sendData(); } @@ -152,7 +152,6 @@ public class WatchUpdaterService extends WearableListenerService implements } private void cancelBolus() { - //ToastUtils.showToastInUiThread(this, "cancelBolus()"); PumpInterface pump = MainApp.getConfigBuilder(); pump.stopBolusDelivering(); } @@ -440,12 +439,13 @@ public class WatchUpdaterService extends WearableListenerService implements } } - private void sendBolusProgress(int progresspercent) { + private void sendBolusProgress(int progresspercent, String status) { if (googleApiClient.isConnected()) { PutDataMapRequest dataMapRequest = PutDataMapRequest.create(BOLUS_PROGRESS_PATH); //unique content dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis()); dataMapRequest.getDataMap().putString("bolusProgress", "bolusProgress"); + dataMapRequest.getDataMap().putString("progressstatus", status); dataMapRequest.getDataMap().putInt("progresspercent", progresspercent); PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest(); Wearable.DataApi.putDataItem(googleApiClient, putDataRequest); diff --git a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java index b38f138c23..9cb724bac9 100644 --- a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps; +import android.app.Activity; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; @@ -8,7 +9,6 @@ import android.os.Bundle; import android.support.v4.content.LocalBroadcastManager; import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationManagerCompat; -import android.support.v4.app.NotificationCompat.WearableExtender; import com.google.android.gms.common.ConnectionResult; @@ -38,7 +38,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp public static final String BASAL_DATA_PATH = "/nightscout_watch_basal"; public static final String BOLUS_PROGRESS_PATH = "/nightscout_watch_bolusprogress"; - + public static final int NOTIFICATION_ID = 001; private static final String ACTION_RESEND = "com.dexdrip.stephenblack.nightwatch.RESEND_DATA"; private static final String ACTION_CANCELBOLUS = "com.dexdrip.stephenblack.nightwatch.CANCELBOLUS"; @@ -151,7 +151,8 @@ public class ListenerService extends WearableListenerService implements GoogleAp startActivity(intent); } else if (path.equals(BOLUS_PROGRESS_PATH)) { int progress = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getInt("progresspercent", 0); - showBolusProgress(progress); + String status = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("progressstatus", ""); + showBolusProgress(progress, status); } else if (path.equals(NEW_STATUS_PATH)) { dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap(); Intent messageIntent = new Intent(); @@ -175,10 +176,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp } } - private void showBolusProgress(int progresspercent) { - int notificationId = 001; - // Build intent for notification content - //TODO: Add Action in order to see that it is a cancel event + private void showBolusProgress(int progresspercent, String progresstatus) { Intent cancelIntent = new Intent(this, ListenerService.class); cancelIntent.setAction(ACTION_CANCELBOLUS); PendingIntent cancelPendingIntent = PendingIntent.getService(this, 0, cancelIntent, 0);; @@ -187,24 +185,43 @@ public class ListenerService extends WearableListenerService implements GoogleAp new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_icon) .setContentTitle("Bolus Progress") - .setContentText(progresspercent + "%") + .setContentText(progresspercent + "% - " + progresstatus) .setContentIntent(cancelPendingIntent) .setPriority(NotificationCompat.PRIORITY_MAX) - .setVibrate(new long[]{0, 100, 1000}) + .setVibrate(new long[]{0, 50, 1000}) .addAction(R.drawable.ic_cancel, "CANCEL BOLUS", cancelPendingIntent); - //TODO: set separate cancel extension with icon - // Get an instance of the NotificationManager service NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); // Build the notification and issues it with notification manager. - notificationManager.notify(notificationId, notificationBuilder.build()); + notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build()); - //TODO: Cancel notification when 100% + if (progresspercent == 100){ + scheduleDismiss(); + } } + private void scheduleDismiss() { + Thread t = new Thread(new Runnable() { + @Override + public void run() { + try { + Thread.sleep(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + NotificationManagerCompat notificationManager = + NotificationManagerCompat.from(ListenerService.this); + notificationManager.cancel(NOTIFICATION_ID); + } + }); + t.start(); + } + + + public static void requestData(Context context) { Intent intent = new Intent(context, ListenerService.class); intent.setAction(ACTION_RESEND); diff --git a/wear/wear.iml b/wear/wear.iml index 33cd39a6c1..20c1f89da7 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -106,14 +106,6 @@ - - - - - - - - @@ -122,6 +114,14 @@ + + + + + + + + From 5cff42cd92768da5f79eb600b7c493fdcbbdb6f0 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Tue, 7 Feb 2017 09:29:59 +0100 Subject: [PATCH 05/48] wear toggle setting to enable watch vibration on bolus --- .../info/nightscout/androidaps/ListenerService.java | 13 ++++++++++++- wear/src/main/res/xml/preferences.xml | 8 ++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java index 9cb724bac9..a2b3646f1c 100644 --- a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java @@ -6,6 +6,7 @@ import android.content.Context; import android.content.Intent; import android.os.AsyncTask; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.v4.content.LocalBroadcastManager; import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationManagerCompat; @@ -47,6 +48,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp GoogleApiClient googleApiClient; private long lastRequest = 0; + public class DataRequester extends AsyncTask { Context mContext; @@ -181,6 +183,15 @@ public class ListenerService extends WearableListenerService implements GoogleAp cancelIntent.setAction(ACTION_CANCELBOLUS); PendingIntent cancelPendingIntent = PendingIntent.getService(this, 0, cancelIntent, 0);; + long[] vibratePattern; + boolean vibreate = PreferenceManager + .getDefaultSharedPreferences(this).getBoolean("vibrateOnBolus", true); + if(vibreate){ + vibratePattern = new long[]{0, 50, 1000}; + } else { + vibratePattern = new long[]{0, 1, 1000}; + } + NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_icon) @@ -188,7 +199,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp .setContentText(progresspercent + "% - " + progresstatus) .setContentIntent(cancelPendingIntent) .setPriority(NotificationCompat.PRIORITY_MAX) - .setVibrate(new long[]{0, 50, 1000}) + .setVibrate(vibratePattern) .addAction(R.drawable.ic_cancel, "CANCEL BOLUS", cancelPendingIntent); // Get an instance of the NotificationManager service diff --git a/wear/src/main/res/xml/preferences.xml b/wear/src/main/res/xml/preferences.xml index 97f8bb4027..d5c8503423 100644 --- a/wear/src/main/res/xml/preferences.xml +++ b/wear/src/main/res/xml/preferences.xml @@ -1,6 +1,14 @@ + + + Date: Tue, 7 Feb 2017 11:09:16 +0100 Subject: [PATCH 06/48] wear event for bolus requests to show card early on --- .../events/EventBolusRequested.java | 21 +++++++++++++++++++ .../ConfigBuilder/ConfigBuilderPlugin.java | 5 +++++ .../androidaps/plugins/Wear/WearPlugin.java | 16 ++++++++++++++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 43 insertions(+) create mode 100644 app/src/main/java/info/nightscout/androidaps/events/EventBolusRequested.java diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventBolusRequested.java b/app/src/main/java/info/nightscout/androidaps/events/EventBolusRequested.java new file mode 100644 index 0000000000..1f41119b4b --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/events/EventBolusRequested.java @@ -0,0 +1,21 @@ +package info.nightscout.androidaps.events; + +/** + * Created by adrian on 07/02/17. + */ + +public class EventBolusRequested { + private double amount; + + public EventBolusRequested (double amount){ + this.amount = amount; + } + + public double getAmount() { + return amount; + } + + public void setAmount(double amount) { + this.amount = amount; + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index 1a21fb9dd6..69e6b910c7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -26,6 +26,7 @@ import info.nightscout.androidaps.Services.Intents; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.db.TempBasal; import info.nightscout.androidaps.db.Treatment; +import info.nightscout.androidaps.events.EventBolusRequested; import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventTempBasalChange; import info.nightscout.androidaps.events.EventTreatmentChange; @@ -424,6 +425,8 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain bolusProgressDialog.show(((AppCompatActivity) context).getSupportFragmentManager(), "BolusProgress"); } + MainApp.bus().post(new EventBolusRequested(insulin)); + PumpEnactResult result = activePump.deliverTreatment(insulin, carbs, context); BolusProgressDialog.bolusEnded = true; @@ -469,6 +472,8 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain bolusProgressDialog.show(((AppCompatActivity) context).getSupportFragmentManager(), "BolusProgress"); } + MainApp.bus().post(new EventBolusRequested(insulin)); + PumpEnactResult result = activePump.deliverTreatment(insulin, carbs, context); BolusProgressDialog.bolusEnded = true; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java index 9ee4e974a8..3d01bafb16 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java @@ -7,6 +7,7 @@ import com.squareup.otto.Subscribe; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.events.EventBolusRequested; import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBasalProfile; import info.nightscout.androidaps.events.EventPreferenceChange; @@ -17,6 +18,7 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Wear.wearintegration.WatchUpdaterService; +import info.nightscout.utils.ToastUtils; /** * Created by adrian on 17/11/16. @@ -151,6 +153,20 @@ public class WearPlugin implements PluginBase { ctx.startService(intent); } + @Subscribe + public void onStatusEvent(final EventBolusRequested ev) { + ToastUtils.showToastInUiThread(ctx, "EventBolusRequested !!!"); + String status = String.format(MainApp.sResources.getString(R.string.bolusrequested), ev.getAmount()); + + Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS); + intent.putExtra("progresspercent", 0); + intent.putExtra("progressstatus", status); + ToastUtils.showToastInUiThread(ctx, "before startService"); + ctx.startService(intent); + ToastUtils.showToastInUiThread(ctx, "after startService"); + + } + public static boolean isEnabled() { return fragmentEnabled; } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6903b66124..1aa42e39b4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -252,6 +252,7 @@ To deliver bolus %.2fU reply with code %s Bolus failed Bolus %.2fU delivered successfully + Going to deliver %.2fU Bolus %.2fU delivered successfully Delivering %.2fU Allow remote commands via SMS From e261fa3ec8b9264f65202196a0450f2f077edc7c Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Tue, 7 Feb 2017 12:02:02 +0100 Subject: [PATCH 07/48] wear re-disable fill bolus for virtual pump --- .../androidaps/plugins/Actions/ActionsFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java index bf3dc7f9d2..e7a8bb2efc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java @@ -106,9 +106,9 @@ public class ActionsFragment extends Fragment implements FragmentBase, View.OnCl tempBasal.setVisibility(View.GONE); else tempBasal.setVisibility(View.VISIBLE); - /* if (!MainApp.getConfigBuilder().getPumpDescription().isRefillingCapable || !MainApp.getConfigBuilder().isInitialized()) + if (!MainApp.getConfigBuilder().getPumpDescription().isRefillingCapable || !MainApp.getConfigBuilder().isInitialized()) fill.setVisibility(View.GONE); - else */ + else fill.setVisibility(View.VISIBLE); if (!Config.APS) tempTarget.setVisibility(View.GONE); From 20d32d042fdc53e85bc34c47ff333e571e1ab0cc Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Tue, 7 Feb 2017 12:08:13 +0100 Subject: [PATCH 08/48] wear bolusprogress cleanup --- .../info/nightscout/androidaps/plugins/Wear/WearPlugin.java | 4 ---- .../main/java/info/nightscout/androidaps/ListenerService.java | 3 --- 2 files changed, 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java index 3d01bafb16..c941851234 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java @@ -155,15 +155,11 @@ public class WearPlugin implements PluginBase { @Subscribe public void onStatusEvent(final EventBolusRequested ev) { - ToastUtils.showToastInUiThread(ctx, "EventBolusRequested !!!"); String status = String.format(MainApp.sResources.getString(R.string.bolusrequested), ev.getAmount()); - Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS); intent.putExtra("progresspercent", 0); intent.putExtra("progressstatus", status); - ToastUtils.showToastInUiThread(ctx, "before startService"); ctx.startService(intent); - ToastUtils.showToastInUiThread(ctx, "after startService"); } diff --git a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java index a2b3646f1c..c13c75f69c 100644 --- a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java @@ -132,7 +132,6 @@ public class ListenerService extends WearableListenerService implements GoogleAp googleApiConnect(); cancelBolus(); } - //TODO: add action to cancel bolus return START_STICKY; } @@ -202,11 +201,9 @@ public class ListenerService extends WearableListenerService implements GoogleAp .setVibrate(vibratePattern) .addAction(R.drawable.ic_cancel, "CANCEL BOLUS", cancelPendingIntent); - // Get an instance of the NotificationManager service NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); - // Build the notification and issues it with notification manager. notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build()); if (progresspercent == 100){ From d1a3645be781d41d7ea54ecc82ac92fefb609172 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 8 Feb 2017 10:22:35 +0100 Subject: [PATCH 09/48] wear dismiss progressnotification on cancel + stub for treatment confirmation --- .../androidaps/ListenerService.java | 65 +++++++++++++++--- .../src/main/res/drawable-hdpi/ic_confirm.png | Bin 0 -> 291 bytes .../src/main/res/drawable-mdpi/ic_confirm.png | Bin 0 -> 196 bytes .../main/res/drawable-xhdpi/ic_confirm.png | Bin 0 -> 289 bytes .../main/res/drawable-xxhdpi/ic_confirm.png | Bin 0 -> 462 bytes wear/wear.iml | 32 ++++----- 6 files changed, 73 insertions(+), 24 deletions(-) create mode 100644 wear/src/main/res/drawable-hdpi/ic_confirm.png create mode 100644 wear/src/main/res/drawable-mdpi/ic_confirm.png create mode 100644 wear/src/main/res/drawable-xhdpi/ic_confirm.png create mode 100644 wear/src/main/res/drawable-xxhdpi/ic_confirm.png diff --git a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java index c13c75f69c..4aeee4d7ec 100644 --- a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java @@ -1,6 +1,5 @@ package info.nightscout.androidaps; -import android.app.Activity; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; @@ -39,10 +38,13 @@ public class ListenerService extends WearableListenerService implements GoogleAp public static final String BASAL_DATA_PATH = "/nightscout_watch_basal"; public static final String BOLUS_PROGRESS_PATH = "/nightscout_watch_bolusprogress"; - public static final int NOTIFICATION_ID = 001; + public static final int BOLUS_PROGRESS_NOTIF_ID = 001; + public static final int CONFIRM_NOTIF_ID = 002; private static final String ACTION_RESEND = "com.dexdrip.stephenblack.nightwatch.RESEND_DATA"; private static final String ACTION_CANCELBOLUS = "com.dexdrip.stephenblack.nightwatch.CANCELBOLUS"; + private static final String ACTION_CONFIRMATION = "com.dexdrip.stephenblack.nightwatch.CONFIRMACTION"; + private static final String ACTION_RESEND_BULK = "com.dexdrip.stephenblack.nightwatch.RESEND_BULK_DATA"; GoogleApiClient googleApiClient; @@ -130,8 +132,27 @@ public class ListenerService extends WearableListenerService implements GoogleAp requestData(); } else if(intent != null && ACTION_CANCELBOLUS.equals(intent.getAction())){ googleApiConnect(); + + //dismiss notification + NotificationManagerCompat notificationManager = + NotificationManagerCompat.from(ListenerService.this); + notificationManager.cancel(BOLUS_PROGRESS_NOTIF_ID); + + //send cancel-request to phone. cancelBolus(); - } + + + } else if(intent != null && ACTION_CONFIRMATION.equals(intent.getAction())){ + googleApiConnect(); + + //dismiss notification + NotificationManagerCompat notificationManager = + NotificationManagerCompat.from(ListenerService.this); + notificationManager.cancel(CONFIRM_NOTIF_ID); + + + //TODO: send confirmation string to phone + } return START_STICKY; } @@ -204,25 +225,53 @@ public class ListenerService extends WearableListenerService implements GoogleAp NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); - notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build()); + notificationManager.notify(BOLUS_PROGRESS_NOTIF_ID, notificationBuilder.build()); if (progresspercent == 100){ - scheduleDismiss(); + scheduleDismiss(BOLUS_PROGRESS_NOTIF_ID, 5); } } - private void scheduleDismiss() { + private void showConfirmationDialog(String title, String message, String actionstring) { + + Intent actionIntent = new Intent(this, ListenerService.class); + actionIntent.setAction(ACTION_CONFIRMATION); + PendingIntent actionPendingIntent = PendingIntent.getService(this, 0, actionIntent, 0);; + + long[] vibratePattern = new long[]{0, 100, 50, 100, 50}; + + NotificationCompat.Builder notificationBuilder = + new NotificationCompat.Builder(this) + .setSmallIcon(R.drawable.ic_icon) + .setContentTitle(title) + .setContentText(message) + .setContentIntent(actionPendingIntent) + .setPriority(NotificationCompat.PRIORITY_MAX) + .setVibrate(vibratePattern) + .addAction(R.drawable.ic_confirm, title, actionPendingIntent); + + NotificationManagerCompat notificationManager = + NotificationManagerCompat.from(this); + + notificationManager.notify(CONFIRM_NOTIF_ID, notificationBuilder.build()); + + // keep the confirmation dialog open for half a minute. + scheduleDismiss(CONFIRM_NOTIF_ID, 30); + + } + + private void scheduleDismiss(final int notificationId, final int seconds) { Thread t = new Thread(new Runnable() { @Override public void run() { try { - Thread.sleep(5000); + Thread.sleep(seconds * 1000); } catch (InterruptedException e) { e.printStackTrace(); } NotificationManagerCompat notificationManager = NotificationManagerCompat.from(ListenerService.this); - notificationManager.cancel(NOTIFICATION_ID); + notificationManager.cancel(notificationId); } }); t.start(); diff --git a/wear/src/main/res/drawable-hdpi/ic_confirm.png b/wear/src/main/res/drawable-hdpi/ic_confirm.png new file mode 100644 index 0000000000000000000000000000000000000000..757596cba2f32fb110e0a040d5f014d493a29e24 GIT binary patch literal 291 zcmV+;0o?wHP)ul&>G#zmlnL)p!soCVP$y4phz+qJ zHt!1`#P={gIBYchLl+#^l-LX#dH6mG@1hb0Vz&tkh_Cvp(-JMjZWEPozm$+`C-GFp zZlfh`nG$B<{-fAd^^y7(C!M^l@+0*Lr>d}7iIasm+Z1rZIolL)f;!vea2jBKgCsa% p9El4h@WLl0FvC+6MN!n2dI29vujRZ{tZ4uM002ovPDHLkV1jK1eA55` literal 0 HcmV?d00001 diff --git a/wear/src/main/res/drawable-mdpi/ic_confirm.png b/wear/src/main/res/drawable-mdpi/ic_confirm.png new file mode 100644 index 0000000000000000000000000000000000000000..b7887421b62062a9c8db2c89eff5146321be3ac6 GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJZci7-kcwN$2@~)ow1Skkb!`!vemSO z3A|Dg>{en6T$7|-rdOzcp17csGn0$sT&CU6I5#Ub zV4Ujd;uunK>+KC|FXljzhKD~i z7Pnd#@FzWFy5l0{D$vxsdxO8AKuq_tFNW1!&rh|m6dJfbn|Gkbe$J%>w&kBrrkG4p z@kF4yD81>AXS|-_eEUS?Kb>c`X-UeZ)9a;-`!jF-?AW<=W|e5MNn~>>Cd28yjohB(PiGIOw;wIsS;v)b(~{ujGCyJTrQ>);1*afQ0o|zPM@s zf4y$lJZri^O4+(3FrGH1OE@65TM?QguC6=xy!#XHQ>u!5K(D?UE=h@MGYfhQ1{{Oa} zmVcISU0c{P*QIa6 - - - - - - - - @@ -82,6 +74,14 @@ + + + + + + + + @@ -106,14 +106,6 @@ - - - - - - - - @@ -122,6 +114,14 @@ + + + + + + + + From 8e9d73e3a3796d55b18b63e37e865a5be35fc4cb Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 8 Feb 2017 11:53:26 +0100 Subject: [PATCH 10/48] wear sending confirmation requests --- .../androidaps/plugins/Wear/WearFragment.java | 5 +- .../androidaps/plugins/Wear/WearPlugin.java | 9 +++ .../wearintegration/WatchUpdaterService.java | 42 +++++++++++- .../androidaps/ListenerService.java | 64 +++++++++++++++++-- 4 files changed, 112 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java index 8f4e7f9be2..7b830182de 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java @@ -42,7 +42,10 @@ public class WearFragment extends Fragment implements FragmentBase { view.findViewById(R.id.wear_opensettings).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - getPlugin(getContext()).openSettings(); + //TODO: revert after debugging! + //getPlugin(getContext()).openSettings(); + getPlugin(getContext()).requestActionConfirmation("Titel", "bla bla", "action 1 string"); + } }); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java index c941851234..96f2b75062 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearPlugin.java @@ -163,6 +163,15 @@ public class WearPlugin implements PluginBase { } + public void requestActionConfirmation(String title, String message, String actionstring){ + + Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_ACTIONCONFIRMATIONREQUEST); + intent.putExtra("title", title); + intent.putExtra("message", message); + intent.putExtra("actionstring", actionstring); + ctx.startService(intent); + } + public static boolean isEnabled() { return fragmentEnabled; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index e84ab99730..812ebaddc8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -45,16 +45,21 @@ public class WatchUpdaterService extends WearableListenerService implements public static final String ACTION_SEND_STATUS = WatchUpdaterService.class.getName().concat(".SendStatus"); public static final String ACTION_SEND_BASALS = WatchUpdaterService.class.getName().concat(".SendBasals"); public static final String ACTION_SEND_BOLUSPROGRESS = WatchUpdaterService.class.getName().concat(".BolusProgress"); + public static final String ACTION_SEND_ACTIONCONFIRMATIONREQUEST = WatchUpdaterService.class.getName().concat(".ActionConfirmationRequest"); private GoogleApiClient googleApiClient; public static final String WEARABLE_DATA_PATH = "/nightscout_watch_data"; public static final String WEARABLE_RESEND_PATH = "/nightscout_watch_data_resend"; private static final String WEARABLE_CANCELBOLUS_PATH = "/nightscout_watch_cancel_bolus"; + public static final String WEARABLE_CONFIRM_ACTIONSTRING_PATH = "/nightscout_watch_confirmactionstring"; + public static final String WEARABLE_INITIATE_ACTIONSTRING_PATH = "/nightscout_watch_initiateactionstring"; + private static final String OPEN_SETTINGS_PATH = "/openwearsettings"; private static final String NEW_STATUS_PATH = "/sendstatustowear"; public static final String BASAL_DATA_PATH = "/nightscout_watch_basal"; public static final String BOLUS_PROGRESS_PATH = "/nightscout_watch_bolusprogress"; + public static final String ACTION_CONFIRMATION_REQUEST_PATH = "/nightscout_watch_actionconfirmationrequest"; @@ -121,7 +126,13 @@ public class WatchUpdaterService extends WearableListenerService implements sendBasals(); } else if (ACTION_SEND_BOLUSPROGRESS.equals(action)){ sendBolusProgress(intent.getIntExtra("progresspercent", 0), intent.hasExtra("progressstatus")?intent.getStringExtra("progressstatus"):""); - } else { + } else if (ACTION_SEND_ACTIONCONFIRMATIONREQUEST.equals(action)){ + String title = intent.getStringExtra("title"); + String message = intent.getStringExtra("message"); + String actionstring = intent.getStringExtra("actionstring"); + sendActionConfirmationRequest(title, message, actionstring); + } + else { sendData(); } } else { @@ -148,6 +159,18 @@ public class WatchUpdaterService extends WearableListenerService implements if (event != null && event.getPath().equals(WEARABLE_CANCELBOLUS_PATH)) { cancelBolus(); } + + if (event != null && event.getPath().equals(WEARABLE_INITIATE_ACTIONSTRING_PATH)) { + String actionstring = new String(event.getData()); + ToastUtils.showToastInUiThread(this, "INITIATE: " + actionstring); + //TODO: watch initiated action + } + + if (event != null && event.getPath().equals(WEARABLE_CONFIRM_ACTIONSTRING_PATH)) { + String actionstring = new String(event.getData()); + ToastUtils.showToastInUiThread(this, "CONFIRM: " + actionstring); + //TODO: watch confirmed action + } } } @@ -454,6 +477,23 @@ public class WatchUpdaterService extends WearableListenerService implements } } + private void sendActionConfirmationRequest(String title, String message, String actionstring) { + if (googleApiClient.isConnected()) { + PutDataMapRequest dataMapRequest = PutDataMapRequest.create(ACTION_CONFIRMATION_REQUEST_PATH); + //unique content + dataMapRequest.getDataMap().putDouble("timestamp", System.currentTimeMillis()); + dataMapRequest.getDataMap().putString("actionConfirmationRequest", "actionConfirmationRequest"); + dataMapRequest.getDataMap().putString("title", title); + dataMapRequest.getDataMap().putString("message", message); + dataMapRequest.getDataMap().putString("actionstring", actionstring); + + PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest(); + Wearable.DataApi.putDataItem(googleApiClient, putDataRequest); + } else { + Log.e("ActionConfirmationRequest", "No connection to wearable available!"); + } + } + private void sendStatus() { if (googleApiClient.isConnected()) { diff --git a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java index 4aeee4d7ec..3a98f4c9fa 100644 --- a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java @@ -32,11 +32,15 @@ public class ListenerService extends WearableListenerService implements GoogleAp private static final String WEARABLE_DATA_PATH = "/nightscout_watch_data"; private static final String WEARABLE_RESEND_PATH = "/nightscout_watch_data_resend"; private static final String WEARABLE_CANCELBOLUS_PATH = "/nightscout_watch_cancel_bolus"; + public static final String WEARABLE_CONFIRM_ACTIONSTRING_PATH = "/nightscout_watch_confirmactionstring"; + public static final String WEARABLE_INITIATE_ACTIONSTRING_PATH = "/nightscout_watch_initiateactionstring"; private static final String OPEN_SETTINGS = "/openwearsettings"; private static final String NEW_STATUS_PATH = "/sendstatustowear"; public static final String BASAL_DATA_PATH = "/nightscout_watch_basal"; public static final String BOLUS_PROGRESS_PATH = "/nightscout_watch_bolusprogress"; + public static final String ACTION_CONFIRMATION_REQUEST_PATH = "/nightscout_watch_actionconfirmationrequest"; + public static final int BOLUS_PROGRESS_NOTIF_ID = 001; public static final int CONFIRM_NOTIF_ID = 002; @@ -86,11 +90,11 @@ public class ListenerService extends WearableListenerService implements GoogleAp @Override protected Void doInBackground(Void... params) { if (googleApiClient.isConnected()) { - NodeApi.GetConnectedNodesResult nodes = - Wearable.NodeApi.getConnectedNodes(googleApiClient).await(); - for (Node node : nodes.getNodes()) { - Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), WEARABLE_CANCELBOLUS_PATH, null); - } + NodeApi.GetConnectedNodesResult nodes = + Wearable.NodeApi.getConnectedNodes(googleApiClient).await(); + for (Node node : nodes.getNodes()) { + Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), WEARABLE_CANCELBOLUS_PATH, null); + } } else { googleApiClient.blockingConnect(15, TimeUnit.SECONDS); @@ -107,6 +111,37 @@ public class ListenerService extends WearableListenerService implements GoogleAp } } + public class MessageActionTask extends AsyncTask { + Context mContext; + String mActionstring; + String mMessagePath; + + MessageActionTask(Context context, String messagePath, String actionstring) { + mContext = context; + mActionstring = actionstring; + mMessagePath = messagePath; + } + + @Override + protected Void doInBackground(Void... params) { + if (googleApiClient.isConnected()) { + NodeApi.GetConnectedNodesResult nodes = + Wearable.NodeApi.getConnectedNodes(googleApiClient).await(); + for (Node node : nodes.getNodes()) { + Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), mMessagePath, mActionstring.getBytes()); + } + + } else { + googleApiClient.blockingConnect(15, TimeUnit.SECONDS); + if (googleApiClient.isConnected()) { + //TODO: copy send code + + } + } + return null; + } + } + public void requestData() { new DataRequester(this).execute(); } @@ -115,6 +150,14 @@ public class ListenerService extends WearableListenerService implements GoogleAp new BolusCancelTask(this).execute(); } + private void sendConfirmActionstring(String actionstring) { + new MessageActionTask(this, WEARABLE_CONFIRM_ACTIONSTRING_PATH, actionstring).execute(); + } + + private void sendInitiateActionstring(String actionstring) { + new MessageActionTask(this, WEARABLE_INITIATE_ACTIONSTRING_PATH, actionstring).execute(); + } + public void googleApiConnect() { googleApiClient = new GoogleApiClient.Builder(this) .addConnectionCallbacks(this) @@ -150,12 +193,15 @@ public class ListenerService extends WearableListenerService implements GoogleAp NotificationManagerCompat.from(ListenerService.this); notificationManager.cancel(CONFIRM_NOTIF_ID); + String actionstring = intent.getStringExtra("actionstring"); + sendConfirmActionstring(actionstring); //TODO: send confirmation string to phone } return START_STICKY; } + @Override public void onDataChanged(DataEventBuffer dataEvents) { @@ -175,7 +221,12 @@ public class ListenerService extends WearableListenerService implements GoogleAp int progress = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getInt("progresspercent", 0); String status = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("progressstatus", ""); showBolusProgress(progress, status); - } else if (path.equals(NEW_STATUS_PATH)) { + } else if (path.equals(ACTION_CONFIRMATION_REQUEST_PATH)) { + String title = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("title"); + String message = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("message"); + String actionstring = DataMapItem.fromDataItem(event.getDataItem()).getDataMap().getString("actionstring"); + showConfirmationDialog(title, message, actionstring); + }else if (path.equals(NEW_STATUS_PATH)) { dataMap = DataMapItem.fromDataItem(event.getDataItem()).getDataMap(); Intent messageIntent = new Intent(); messageIntent.setAction(Intent.ACTION_SEND); @@ -236,6 +287,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp Intent actionIntent = new Intent(this, ListenerService.class); actionIntent.setAction(ACTION_CONFIRMATION); + actionIntent.putExtra("actionstring", actionstring); PendingIntent actionPendingIntent = PendingIntent.getService(this, 0, actionIntent, 0);; long[] vibratePattern = new long[]{0, 100, 50, 100, 50}; From d2d0d4b51a30e31fa636ce84698853b4289603dd Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 8 Feb 2017 15:15:22 +0100 Subject: [PATCH 11/48] wear confirm roundtrip working --- .../androidaps/plugins/Wear/WearFragment.java | 7 ++++++- .../Wear/wearintegration/WatchUpdaterService.java | 6 +++++- .../nightscout/androidaps/ListenerService.java | 14 +++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java index 7b830182de..26a67957c5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java @@ -44,7 +44,12 @@ public class WearFragment extends Fragment implements FragmentBase { public void onClick(View view) { //TODO: revert after debugging! //getPlugin(getContext()).openSettings(); - getPlugin(getContext()).requestActionConfirmation("Titel", "bla bla", "action 1 string"); + String title = "CONFIRM"; //TODO: i18n + String message = "Insulin: 7.0U \n" + + "Carbs: 26 \n" + + "CONSTRAINTS APPLIED!!!"; //TODO: apply constraints + String actionstring = "Bolus 7.0 Carbs 26"; //TODO: to be returned by watch if confirmed + getPlugin(getContext()).requestActionConfirmation(title, message, actionstring); } }); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index 812ebaddc8..0b5129c5cc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -161,6 +161,8 @@ public class WatchUpdaterService extends WearableListenerService implements } if (event != null && event.getPath().equals(WEARABLE_INITIATE_ACTIONSTRING_PATH)) { + ToastUtils.showToastInUiThread(this, "INITIATE1"); + String actionstring = new String(event.getData()); ToastUtils.showToastInUiThread(this, "INITIATE: " + actionstring); //TODO: watch initiated action @@ -487,10 +489,12 @@ public class WatchUpdaterService extends WearableListenerService implements dataMapRequest.getDataMap().putString("message", message); dataMapRequest.getDataMap().putString("actionstring", actionstring); + ToastUtils.showToastInUiThread(this, "SENT: " + actionstring); + PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest(); Wearable.DataApi.putDataItem(googleApiClient, putDataRequest); } else { - Log.e("ActionConfirmationRequest", "No connection to wearable available!"); + Log.e("confirmationRequest", "No connection to wearable available!"); } } diff --git a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java index 3a98f4c9fa..6e2f8e72ac 100644 --- a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java @@ -3,6 +3,7 @@ package info.nightscout.androidaps; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; +import android.graphics.Color; import android.os.AsyncTask; import android.os.Bundle; import android.preference.PreferenceManager; @@ -134,8 +135,11 @@ public class ListenerService extends WearableListenerService implements GoogleAp } else { googleApiClient.blockingConnect(15, TimeUnit.SECONDS); if (googleApiClient.isConnected()) { - //TODO: copy send code - + NodeApi.GetConnectedNodesResult nodes = + Wearable.NodeApi.getConnectedNodes(googleApiClient).await(); + for (Node node : nodes.getNodes()) { + Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), mMessagePath, mActionstring.getBytes()); + } } } return null; @@ -288,7 +292,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp Intent actionIntent = new Intent(this, ListenerService.class); actionIntent.setAction(ACTION_CONFIRMATION); actionIntent.putExtra("actionstring", actionstring); - PendingIntent actionPendingIntent = PendingIntent.getService(this, 0, actionIntent, 0);; + PendingIntent actionPendingIntent = PendingIntent.getService(this, 0, actionIntent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_UPDATE_CURRENT);; long[] vibratePattern = new long[]{0, 100, 50, 100, 50}; @@ -307,8 +311,8 @@ public class ListenerService extends WearableListenerService implements GoogleAp notificationManager.notify(CONFIRM_NOTIF_ID, notificationBuilder.build()); - // keep the confirmation dialog open for half a minute. - scheduleDismiss(CONFIRM_NOTIF_ID, 30); + // keep the confirmation dialog open for one minute. + scheduleDismiss(CONFIRM_NOTIF_ID, 60); } From 6556ddda37cd3aaddf2b529f2c420b8a54efb850 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 8 Feb 2017 17:06:07 +0100 Subject: [PATCH 12/48] wear menu mockup --- wear/src/main/AndroidManifest.xml | 9 ++ .../actions/ActionsListActivity.java | 111 ++++++++++++++++++ .../actions/WearableListItemLayout.java | 65 ++++++++++ wear/src/main/res/drawable-nodpi/ic_icon.png | Bin 1099 -> 0 bytes .../main/res/drawable/nslogo_background.png | Bin 0 -> 31107 bytes wear/src/main/res/drawable/wl_circle.xml | 6 + .../main/res/layout/actions_list_activity.xml | 21 ++++ wear/src/main/res/layout/list_item.xml | 23 ++++ wear/src/main/res/values/colors.xml | 5 + wear/src/main/res/values/strings.xml | 1 + wear/wear.iml | 30 ++--- 11 files changed, 256 insertions(+), 15 deletions(-) create mode 100644 wear/src/main/java/info/nightscout/androidaps/actions/ActionsListActivity.java create mode 100644 wear/src/main/java/info/nightscout/androidaps/actions/WearableListItemLayout.java delete mode 100755 wear/src/main/res/drawable-nodpi/ic_icon.png create mode 100644 wear/src/main/res/drawable/nslogo_background.png create mode 100644 wear/src/main/res/drawable/wl_circle.xml create mode 100644 wear/src/main/res/layout/actions_list_activity.xml create mode 100644 wear/src/main/res/layout/list_item.xml diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index e534380a56..f4c8363c6d 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -86,6 +86,15 @@ + + + + + + + diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsListActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsListActivity.java new file mode 100644 index 0000000000..2fa629f613 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsListActivity.java @@ -0,0 +1,111 @@ +package info.nightscout.androidaps.actions; + +import android.app.Activity; +import android.content.Context; +import android.os.Bundle; +import android.support.wearable.view.WearableListView; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import info.nightscout.androidaps.R; + +/** + * Created by adrian on 08/02/17. + */ + +public class ActionsListActivity extends Activity + implements WearableListView.ClickListener { + + // Sample dataset for the list + String[] elements = { "Temp Target", "Bolus", "Settings"}; + +@Override +protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.actions_list_activity); + + // Get the list component from the layout of the activity + WearableListView listView = + (WearableListView) findViewById(R.id.wearable_list); + + // Assign an adapter to the list + listView.setAdapter(new Adapter(this, elements)); + + // Set a click listener + listView.setClickListener(this); + } + +// WearableListView click listener +@Override +public void onClick(WearableListView.ViewHolder v) { + Integer tag = (Integer) v.itemView.getTag(); + // use this data to complete some action ... + } + +@Override +public void onTopEmptyRegionClick() { + } + + + private static final class Adapter extends WearableListView.Adapter { + private String[] mDataset; + private final Context mContext; + private final LayoutInflater mInflater; + + // Provide a suitable constructor (depends on the kind of dataset) + public Adapter(Context context, String[] dataset) { + mContext = context; + mInflater = LayoutInflater.from(context); + mDataset = dataset; + } + + // Provide a reference to the type of views you're using + public static class ItemViewHolder extends WearableListView.ViewHolder { + private TextView textView; + public ItemViewHolder(View itemView) { + super(itemView); + // find the text view within the custom item's layout + textView = (TextView) itemView.findViewById(R.id.name); + } + } + + // Create new views for list items + // (invoked by the WearableListView's layout manager) + @Override + public WearableListView.ViewHolder onCreateViewHolder(ViewGroup parent, + int viewType) { + // Inflate our custom layout for list items + return new ItemViewHolder(mInflater.inflate(R.layout.list_item, null)); + } + + // Replace the contents of a list item + // Instead of creating new views, the list tries to recycle existing ones + // (invoked by the WearableListView's layout manager) + @Override + public void onBindViewHolder(WearableListView.ViewHolder holder, + int position) { + // retrieve the text view + ItemViewHolder itemHolder = (ItemViewHolder) holder; + TextView view = itemHolder.textView; + // replace text contents + view.setText(mDataset[position]); + // replace list item's metadata + holder.itemView.setTag(position); + } + + // Return the size of your dataset + // (invoked by the WearableListView's layout manager) + @Override + public int getItemCount() { + return mDataset.length; + } + } + + + + + + +} \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/WearableListItemLayout.java b/wear/src/main/java/info/nightscout/androidaps/actions/WearableListItemLayout.java new file mode 100644 index 0000000000..28acb60fdf --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/actions/WearableListItemLayout.java @@ -0,0 +1,65 @@ +package info.nightscout.androidaps.actions; + +import android.content.Context; +import android.graphics.drawable.GradientDrawable; +import android.support.wearable.view.WearableListView; +import android.util.AttributeSet; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import info.nightscout.androidaps.R; + +/** + * Created by adrian on 08/02/17. + */ + +public class WearableListItemLayout extends LinearLayout + implements WearableListView.OnCenterProximityListener { + + private ImageView mCircle; + private TextView mName; + + private final float mFadedTextAlpha; + private final int mFadedCircleColor; + private final int mChosenCircleColor; + + public WearableListItemLayout(Context context) { + this(context, null); + } + + public WearableListItemLayout(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public WearableListItemLayout(Context context, AttributeSet attrs, + int defStyle) { + super(context, attrs, defStyle); + + mFadedTextAlpha = 40 / 100f; + mFadedCircleColor = getResources().getColor(R.color.grey); + mChosenCircleColor = getResources().getColor(R.color.blue); + } + + // Get references to the icon and text in the item layout definition + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + // These are defined in the layout file for list items + // (see next section) + mCircle = (ImageView) findViewById(R.id.circle); + mName = (TextView) findViewById(R.id.name); + } + + @Override + public void onCenterPosition(boolean animate) { + mName.setAlpha(1f); + ((GradientDrawable) mCircle.getDrawable()).setColor(mChosenCircleColor); + } + + @Override + public void onNonCenterPosition(boolean animate) { + ((GradientDrawable) mCircle.getDrawable()).setColor(mFadedCircleColor); + mName.setAlpha(mFadedTextAlpha); + } +} diff --git a/wear/src/main/res/drawable-nodpi/ic_icon.png b/wear/src/main/res/drawable-nodpi/ic_icon.png deleted file mode 100755 index 700e274f5bd0b1bd6ed0be5ed1018677f6175b8a..0000000000000000000000000000000000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xZeaqNBvItSoYwmVpYguszD+;$Nk_B1@Nyn$KC*WkX<7 z+WLsvf?4nFPA<<+T;;7~R&^dBr%G{89VexjSo0YNU?;j4hA-%mQ^+$Xi>rc8p>OAmJQ|sP ztAx&o4h(vkT+wq?^dM{;}J~E!B=_IgQ5^Cjn{XCD9CgRK- zpj4VKkdB{eFJQ-t1hXNFv!w5NUMZql1P}n1vb|a_+1aJ860z;P-@lz zX@skfT#ly{QJFMm*4^9(=?)*S*U9dweHFJZ_iyr<^bO> zhGyg=KS!U`j$)N*>Ty};j=RK)9&>=(7sEoRnJkxxFA{V{QT)RT&Y2|Ks&G)6tf9lz zB?jeF({Jq%-P(ms9kor|u_16eepu>B@ku@ZwJR8!VN$Kurj7m2@x!$y!KE&}XKB8# z0GAgD3Nt8@`pB^~E(ZeE9%2TH)j>%B#zQf*UzukVlUVT?ETHrah~$tR-0gxQ(vc*1 ztRIN!IiiwXEeL`6?>iLvopb@pgHX*M#mjlv7_}iK5Yntz_k(K64HICYPgawmL$71W?uC&)mgSlX4$Fztbw4owM@;*3b{Cl(E5@Zs zS*W^FPDG(!L)ou8eE_Gy%>$!ev;;rlFy^kwjqTrLur@hAJ9Rb?u9P=Xtr6Sf^Pcsb z!;>Z2@`Je^{{()L>zfKB_|fr=4GQ|?om7p9bGAqu%)rhJOkcFDvVA2@PJD~$bPyNEO_>ed_%JTjPna@IB7Wbjzbqp~3-#7pQu@Ns1bLQPM#_>Oht F{{Zi7hWG#g literal 0 HcmV?d00001 diff --git a/wear/src/main/res/drawable/wl_circle.xml b/wear/src/main/res/drawable/wl_circle.xml new file mode 100644 index 0000000000..07c2ad61d3 --- /dev/null +++ b/wear/src/main/res/drawable/wl_circle.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/wear/src/main/res/layout/actions_list_activity.xml b/wear/src/main/res/layout/actions_list_activity.xml new file mode 100644 index 0000000000..1779f1b4ab --- /dev/null +++ b/wear/src/main/res/layout/actions_list_activity.xml @@ -0,0 +1,21 @@ + + + + + + + + + diff --git a/wear/src/main/res/layout/list_item.xml b/wear/src/main/res/layout/list_item.xml new file mode 100644 index 0000000000..c193f0bd2c --- /dev/null +++ b/wear/src/main/res/layout/list_item.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/wear/src/main/res/values/colors.xml b/wear/src/main/res/values/colors.xml index eae224ef41..f401fa83b8 100644 --- a/wear/src/main/res/values/colors.xml +++ b/wear/src/main/res/values/colors.xml @@ -1,5 +1,10 @@ + + #2878ff + #c1c1c1 + #434343 + @color/black @color/black diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml index 2462ff00a4..1e5ae77c0a 100644 --- a/wear/src/main/res/values/strings.xml +++ b/wear/src/main/res/values/strings.xml @@ -2,6 +2,7 @@ AAPS Prefs. + AAPS Actions 1 hour diff --git a/wear/wear.iml b/wear/wear.iml index f2951e6bcf..ce3df746e7 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -43,13 +43,6 @@ - - - - - - - @@ -58,6 +51,13 @@ + + + + + + + @@ -66,14 +66,6 @@ - - - - - - - - @@ -82,6 +74,14 @@ + + + + + + + + From b8588b2c3cc9ee5d2c483c2b14de30336d8a3df4 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 9 Feb 2017 00:00:54 +0100 Subject: [PATCH 13/48] wear action menu refactored and opens on double tap --- .../info/nightscout/androidaps/BIGChart.java | 15 +++++ .../androidaps/CircleWatchface.java | 26 +++++++- .../java/info/nightscout/androidaps/Home.java | 17 ++++++ .../info/nightscout/androidaps/LargeHome.java | 24 ++++++++ .../androidaps/ListenerService.java | 18 +++++- .../actions/ActionsDefinitions.java | 60 +++++++++++++++++++ .../actions/ActionsListActivity.java | 36 ++++++----- .../actions/WearableListItemLayout.java | 4 +- wear/src/main/res/layout/list_item.xml | 2 +- wear/wear.iml | 16 ++--- 10 files changed, 184 insertions(+), 34 deletions(-) create mode 100644 wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java diff --git a/wear/src/main/java/info/nightscout/androidaps/BIGChart.java b/wear/src/main/java/info/nightscout/androidaps/BIGChart.java index 637908600e..af69c8f546 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BIGChart.java +++ b/wear/src/main/java/info/nightscout/androidaps/BIGChart.java @@ -39,6 +39,7 @@ import com.ustwo.clockwise.common.WatchShape; import java.util.ArrayList; import java.util.Date; +import info.nightscout.androidaps.actions.ActionsListActivity; import lecho.lib.hellocharts.view.LineChartView; /** @@ -83,6 +84,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre private String externalStatusString = "no status"; private TextView statusView; private long chartTapTime = 0l; + private long sgvTapTime = 0l; @Override public void onCreate() { @@ -143,6 +145,8 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre @Override protected void onTapCommand(int tapType, int x, int y, long eventTime) { + int extra = mSgv!=null?(mSgv.getRight() - mSgv.getLeft())/2:0; + if (tapType == TAP_TYPE_TAP&& x >=chart.getLeft() && x <= chart.getRight()&& @@ -152,6 +156,17 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre changeChartTimeframe(); } chartTapTime = eventTime; + } else if (tapType == TAP_TYPE_TAP&& + x + extra >=mSgv.getLeft() && + x - extra <= mSgv.getRight()&& + y >= mSgv.getTop() && + y <= mSgv.getBottom()){ + if (eventTime - sgvTapTime < 800){ + Intent intent = new Intent(this, ActionsListActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } + sgvTapTime = eventTime; } } diff --git a/wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java b/wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java index c81b6de6f1..26b8f0198e 100644 --- a/wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java +++ b/wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java @@ -35,6 +35,8 @@ import java.util.Date; import java.util.HashSet; import java.util.TreeSet; +import info.nightscout.androidaps.actions.ActionsListActivity; + public class CircleWatchface extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener { public final float PADDING = 20f; @@ -79,6 +81,8 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh private View myLayout; protected SharedPreferences sharedPrefs; + private TextView mSgv; + private long sgvTapTime = 0; @Override @@ -144,7 +148,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh // prepare fields TextView textView = null; - + mSgv = (TextView) myLayout.findViewById(R.id.sgvString); textView = (TextView) myLayout.findViewById(R.id.sgvString); if (sharedPrefs.getBoolean("showBG", true)) { textView.setVisibility(View.VISIBLE); @@ -700,4 +704,24 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh addArch(canvas, (float) size, offset * offsetMultiplier + 11, color, (float) (360f - size)); // Dark fill addArch(canvas, (offset + .8f) * offsetMultiplier + 11, getBackgroundColor(), 360); } + + @Override + protected void onTapCommand(int tapType, int x, int y, long eventTime) { + + int extra = mSgv!=null?(mSgv.getRight() - mSgv.getLeft())/2:0; + + if (tapType == TAP_TYPE_TAP&& + x + extra >=mSgv.getLeft() && + x - extra <= mSgv.getRight()&& + y >= mSgv.getTop() && + y <= mSgv.getBottom()){ + if (eventTime - sgvTapTime < 800){ + Intent intent = new Intent(this, ActionsListActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } + sgvTapTime = eventTime; + } + } + } \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/Home.java b/wear/src/main/java/info/nightscout/androidaps/Home.java index e84098a341..45803e8b47 100644 --- a/wear/src/main/java/info/nightscout/androidaps/Home.java +++ b/wear/src/main/java/info/nightscout/androidaps/Home.java @@ -1,5 +1,6 @@ package info.nightscout.androidaps; +import android.content.Intent; import android.graphics.Color; import android.support.v4.content.ContextCompat; import android.support.wearable.watchface.WatchFaceStyle; @@ -7,9 +8,12 @@ import android.view.LayoutInflater; import com.ustwo.clockwise.common.WatchMode; +import info.nightscout.androidaps.actions.ActionsListActivity; + public class Home extends BaseWatchFace { private long chartTapTime = 0; + private long sgvTapTime = 0; @Override public void onCreate() { @@ -22,6 +26,8 @@ public class Home extends BaseWatchFace { @Override protected void onTapCommand(int tapType, int x, int y, long eventTime) { + int extra = mSgv!=null?(mSgv.getRight() - mSgv.getLeft())/2:0; + if (tapType == TAP_TYPE_TAP&& x >=chart.getLeft() && x <= chart.getRight()&& @@ -31,6 +37,17 @@ public class Home extends BaseWatchFace { changeChartTimeframe(); } chartTapTime = eventTime; + } else if (tapType == TAP_TYPE_TAP&& + x + extra >=mSgv.getLeft() && + x - extra <= mSgv.getRight()&& + y >= mSgv.getTop() && + y <= mSgv.getBottom()){ + if (eventTime - sgvTapTime < 800){ + Intent intent = new Intent(this, ActionsListActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } + sgvTapTime = eventTime; } } diff --git a/wear/src/main/java/info/nightscout/androidaps/LargeHome.java b/wear/src/main/java/info/nightscout/androidaps/LargeHome.java index 9f412702d4..1e5fedc336 100644 --- a/wear/src/main/java/info/nightscout/androidaps/LargeHome.java +++ b/wear/src/main/java/info/nightscout/androidaps/LargeHome.java @@ -1,13 +1,18 @@ package info.nightscout.androidaps; +import android.content.Intent; import android.graphics.Color; import android.support.v4.content.ContextCompat; import android.view.LayoutInflater; import com.ustwo.clockwise.common.WatchMode; +import info.nightscout.androidaps.actions.ActionsListActivity; + public class LargeHome extends BaseWatchFace { + private long sgvTapTime = 0; + @Override public void onCreate() { super.onCreate(); @@ -16,6 +21,25 @@ public class LargeHome extends BaseWatchFace { performViewSetup(); } + @Override + protected void onTapCommand(int tapType, int x, int y, long eventTime) { + + int extra = mSgv!=null?(mSgv.getRight() - mSgv.getLeft())/2:0; + + if (tapType == TAP_TYPE_TAP&& + x + extra >=mSgv.getLeft() && + x - extra <= mSgv.getRight()&& + y >= mSgv.getTop() && + y <= mSgv.getBottom()){ + if (eventTime - sgvTapTime < 800){ + Intent intent = new Intent(this, ActionsListActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + } + sgvTapTime = eventTime; + } + } + @Override protected void setColorDark(){ mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mLinearLayout)); diff --git a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java index 6e2f8e72ac..d1cb44093d 100644 --- a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/ListenerService.java @@ -49,6 +49,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp private static final String ACTION_RESEND = "com.dexdrip.stephenblack.nightwatch.RESEND_DATA"; private static final String ACTION_CANCELBOLUS = "com.dexdrip.stephenblack.nightwatch.CANCELBOLUS"; private static final String ACTION_CONFIRMATION = "com.dexdrip.stephenblack.nightwatch.CONFIRMACTION"; + private static final String ACTION_INITIATE_ACTION = "com.dexdrip.stephenblack.nightwatch.INITIATE_ACTION"; private static final String ACTION_RESEND_BULK = "com.dexdrip.stephenblack.nightwatch.RESEND_BULK_DATA"; @@ -200,8 +201,14 @@ public class ListenerService extends WearableListenerService implements GoogleAp String actionstring = intent.getStringExtra("actionstring"); sendConfirmActionstring(actionstring); - //TODO: send confirmation string to phone - } + } else if(intent != null && ACTION_INITIATE_ACTION.equals(intent.getAction())){ + googleApiConnect(); + + String actionstring = intent.getStringExtra("actionstring"); + sendInitiateActionstring(actionstring); + + } + return START_STICKY; } @@ -341,6 +348,13 @@ public class ListenerService extends WearableListenerService implements GoogleAp context.startService(intent); } + public static void initiateAction(Context context, String actionstring) { + Intent intent = new Intent(context, ListenerService.class); + intent.putExtra("actionstring", actionstring); + intent.setAction(ACTION_INITIATE_ACTION); + context.startService(intent); + } + @Override public void onConnected(Bundle bundle) { requestData(); diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java new file mode 100644 index 0000000000..0b6d90c150 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java @@ -0,0 +1,60 @@ +package info.nightscout.androidaps.actions; + +import android.content.Context; +import android.content.Intent; + +import info.nightscout.androidaps.ListenerService; +import info.nightscout.androidaps.NWPreferences; + +/** + * Created by adrian on 08/02/17. + */ + +final class ActionsDefinitions { + + private static final String[] ACTION_NAMES = { + "Temp Target", + "Bolus", + "Settings", + "Resend Data", + "Fillpreset 1", + "Fillpreset 2", + "Fillpreset 3", + "003"}; + + + public static void doAction(int position, Context ctx) { + + switch (position) { + case 0: + break; + case 1: + break; + case 2: + Intent intent = new Intent(ctx, NWPreferences.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + ctx.startActivity(intent); + break; + case 3: + ListenerService.requestData(ctx); + break; + case 4: + ListenerService.initiateAction(ctx, "fillpreset 1"); + break; + case 5: + ListenerService.initiateAction(ctx, "fillpreset 2"); + break; + case 6: + ListenerService.initiateAction(ctx, "fillpreset 3"); + break; + } + + } + + + public static String[] getActionNames() { + //posibility for later i18n + return ACTION_NAMES; + } + +} diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsListActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsListActivity.java index 2fa629f613..f1202797d4 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsListActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsListActivity.java @@ -18,35 +18,36 @@ import info.nightscout.androidaps.R; public class ActionsListActivity extends Activity implements WearableListView.ClickListener { - // Sample dataset for the list - String[] elements = { "Temp Target", "Bolus", "Settings"}; + String[] elements = ActionsDefinitions.getActionNames(); -@Override -protected void onCreate(Bundle savedInstanceState) { + @Override + protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.actions_list_activity); // Get the list component from the layout of the activity WearableListView listView = - (WearableListView) findViewById(R.id.wearable_list); + (WearableListView) findViewById(R.id.wearable_list); // Assign an adapter to the list listView.setAdapter(new Adapter(this, elements)); // Set a click listener listView.setClickListener(this); - } + } -// WearableListView click listener -@Override -public void onClick(WearableListView.ViewHolder v) { + // WearableListView click listener + @Override + public void onClick(WearableListView.ViewHolder v) { Integer tag = (Integer) v.itemView.getTag(); - // use this data to complete some action ... - } + ActionsDefinitions.doAction(tag, this); + //ActionsDefinitions.doAction(v.getAdapterPosition(), this); + finish(); + } -@Override -public void onTopEmptyRegionClick() { - } + @Override + public void onTopEmptyRegionClick() { + } private static final class Adapter extends WearableListView.Adapter { @@ -64,10 +65,11 @@ public void onTopEmptyRegionClick() { // Provide a reference to the type of views you're using public static class ItemViewHolder extends WearableListView.ViewHolder { private TextView textView; + public ItemViewHolder(View itemView) { super(itemView); // find the text view within the custom item's layout - textView = (TextView) itemView.findViewById(R.id.name); + textView = (TextView) itemView.findViewById(R.id.actionitem); } } @@ -104,8 +106,4 @@ public void onTopEmptyRegionClick() { } - - - - } \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/WearableListItemLayout.java b/wear/src/main/java/info/nightscout/androidaps/actions/WearableListItemLayout.java index 28acb60fdf..bb027ba438 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/WearableListItemLayout.java +++ b/wear/src/main/java/info/nightscout/androidaps/actions/WearableListItemLayout.java @@ -45,10 +45,8 @@ public class WearableListItemLayout extends LinearLayout @Override protected void onFinishInflate() { super.onFinishInflate(); - // These are defined in the layout file for list items - // (see next section) mCircle = (ImageView) findViewById(R.id.circle); - mName = (TextView) findViewById(R.id.name); + mName = (TextView) findViewById(R.id.actionitem); } @Override diff --git a/wear/src/main/res/layout/list_item.xml b/wear/src/main/res/layout/list_item.xml index c193f0bd2c..4ca65adaa6 100644 --- a/wear/src/main/res/layout/list_item.xml +++ b/wear/src/main/res/layout/list_item.xml @@ -10,7 +10,7 @@ android:layout_width="20dp" android:src="@drawable/wl_circle"/> - - - - - - - - @@ -82,6 +74,14 @@ + + + + + + + + From 8d6760081e6ddb615d39620108c90afc3cec45a8 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 9 Feb 2017 00:15:14 +0100 Subject: [PATCH 14/48] wear circle watchface fix --- .../androidaps/CircleWatchface.java | 19 +++++++++++++------ .../info/nightscout/androidaps/LargeHome.java | 6 ++++++ .../actions/ActionsDefinitions.java | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java b/wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java index 26b8f0198e..968e29e7bc 100644 --- a/wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java +++ b/wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java @@ -17,6 +17,7 @@ import android.os.Bundle; import android.os.PowerManager; import android.preference.PreferenceManager; import android.support.v4.content.LocalBroadcastManager; +import android.support.wearable.watchface.WatchFaceStyle; import android.util.Log; import android.util.TypedValue; import android.view.Display; @@ -346,7 +347,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh } public int getInRangeColor() { - if (sharedPrefs.getBoolean("dark", false)) { + if (sharedPrefs.getBoolean("dark", true)) { return Color.argb(255, 120, 255, 120); } else { return Color.argb(255, 0, 240, 0); @@ -355,7 +356,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh } public int getHighColor() { - if (sharedPrefs.getBoolean("dark", false)) { + if (sharedPrefs.getBoolean("dark", true)) { return Color.argb(255, 255, 255, 120); } else { return Color.argb(255, 255, 200, 0); @@ -364,7 +365,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh } public int getBackgroundColor() { - if (sharedPrefs.getBoolean("dark", false)) { + if (sharedPrefs.getBoolean("dark", true)) { return Color.BLACK; } else { return Color.WHITE; @@ -373,7 +374,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh } public int getTextColor() { - if (sharedPrefs.getBoolean("dark", false)) { + if (sharedPrefs.getBoolean("dark", true)) { return Color.WHITE; } else { return Color.BLACK; @@ -666,7 +667,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh Log.d("CircleWatchface", "addReadingSoft"); double size; int color = Color.LTGRAY; - if (sharedPrefs.getBoolean("dark", false)) { + if (sharedPrefs.getBoolean("dark", true)) { color = Color.DKGRAY; } @@ -684,7 +685,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh double size; int color = Color.LTGRAY; int indicatorColor = Color.DKGRAY; - if (sharedPrefs.getBoolean("dark", false)) { + if (sharedPrefs.getBoolean("dark", true)) { color = Color.DKGRAY; indicatorColor = Color.LTGRAY; } @@ -724,4 +725,10 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh } } + @Override + protected WatchFaceStyle getWatchFaceStyle(){ + return new WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build(); + } + + } \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/LargeHome.java b/wear/src/main/java/info/nightscout/androidaps/LargeHome.java index 1e5fedc336..b3a342f2d8 100644 --- a/wear/src/main/java/info/nightscout/androidaps/LargeHome.java +++ b/wear/src/main/java/info/nightscout/androidaps/LargeHome.java @@ -3,6 +3,7 @@ package info.nightscout.androidaps; import android.content.Intent; import android.graphics.Color; import android.support.v4.content.ContextCompat; +import android.support.wearable.watchface.WatchFaceStyle; import android.view.LayoutInflater; import com.ustwo.clockwise.common.WatchMode; @@ -40,6 +41,11 @@ public class LargeHome extends BaseWatchFace { } } + @Override + protected WatchFaceStyle getWatchFaceStyle(){ + return new WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build(); + } + @Override protected void setColorDark(){ mLinearLayout.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), R.color.dark_mLinearLayout)); diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java index 0b6d90c150..2265abdd88 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java +++ b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java @@ -20,7 +20,7 @@ final class ActionsDefinitions { "Fillpreset 1", "Fillpreset 2", "Fillpreset 3", - "003"}; + "004"}; public static void doAction(int position, Context ctx) { From 74107f58fe07681432c211a5a76f8b743f277ace Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 9 Feb 2017 01:53:28 +0100 Subject: [PATCH 15/48] wear first fill bolus working --- .../ConfigBuilder/ConfigBuilderPlugin.java | 2 +- .../plugins/Wear/ActionStringHandler.java | 126 ++++++++++++++++++ .../wearintegration/WatchUpdaterService.java | 5 +- 3 files changed, 130 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index 69e6b910c7..784888bdac 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -466,7 +466,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain carbs = applyCarbsConstraints(carbs); BolusProgressDialog bolusProgressDialog = null; - if (context != null) { + if (context != null ) { bolusProgressDialog = new BolusProgressDialog(); bolusProgressDialog.setInsulin(insulin); bolusProgressDialog.show(((AppCompatActivity) context).getSupportFragmentManager(), "BolusProgress"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java new file mode 100644 index 0000000000..ec7d03cf3b --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -0,0 +1,126 @@ +package info.nightscout.androidaps.plugins.Wear; + +import android.content.SharedPreferences; +import android.os.Handler; +import android.os.HandlerThread; +import android.preference.PreferenceManager; +import android.support.v7.app.AlertDialog; + +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog; +import info.nightscout.utils.DecimalFormatter; +import info.nightscout.utils.SafeParse; +import info.nightscout.utils.ToastUtils; + +/** + * Created by adrian on 09/02/17. + */ + +public class ActionStringHandler { + + public static final int TIMEOUT = 65 * 1000; + + private static long lastSentTimestamp = 0; + private static String lastConfirmActionString = null; + private static SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); + + + private static HandlerThread handlerThread = new HandlerThread(FillDialog.class.getSimpleName()); + static { + handlerThread.start(); + } + + public synchronized static void handleInitiate(String actionstring){ + + String rTitle = "CONFIRM"; //TODO: i18n + String rMessage = ""; + String rAction = ""; + + + // do the parsing and check constraints + String[] act = actionstring.split("\\s+"); + + if ("fillpreset".equals(act[0])) { + double amount = 0d; + if ("1".equals(act[1])) { + amount = SafeParse.stringToDouble(DecimalFormatter.to2Decimal(SafeParse.stringToDouble(sp.getString("fill_button1", "0.3")))); + } else if ("2".equals(act[1])) { + amount = SafeParse.stringToDouble(DecimalFormatter.to2Decimal(SafeParse.stringToDouble(sp.getString("fill_button2", "0")))); + } else if ("3".equals(act[1])) { + amount = SafeParse.stringToDouble(DecimalFormatter.to2Decimal(SafeParse.stringToDouble(sp.getString("fill_button3", "0")))); + } else { + return; + } + Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(amount); + rMessage += MainApp.instance().getString(R.string.primefill) + ": " + insulinAfterConstraints + "U"; + if (insulinAfterConstraints - amount != 0) + rMessage += "\n" + MainApp.instance().getString(R.string.constraintapllied); + + rAction += "fill " + insulinAfterConstraints; + + } else if(false){ + //... add more actions + + } else return; + + + + + // send result + WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation(rTitle, rMessage, rAction); + lastSentTimestamp = System.currentTimeMillis(); + lastConfirmActionString = rAction; + } + + + public synchronized static void handleConfirmation(String actionString){ + + //Guard from old or duplicate confirmations + if (lastConfirmActionString == null) return; + if (!lastConfirmActionString.equals(actionString)) return; + if (System.currentTimeMillis() - lastSentTimestamp > TIMEOUT) return; + lastConfirmActionString = null; + + // do the parsing, check constraints and enact! + String[] act = actionString.split("\\s+"); + + if ("fill".equals(act[0])){ + Double amount = SafeParse.stringToDouble(act[1]); + Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(amount); + if(amount - insulinAfterConstraints != 0){ + ToastUtils.showToastInUiThread(MainApp.instance(), "aborting: previously applied constraint changed"); + sendError("aborting: previously applied constraint changed"); + return; + } + doFillBolus(amount); + } + + + + } + + private static void doFillBolus(final Double amount) { + Handler handler = new Handler(handlerThread.getLooper()); + handler.post(new Runnable() { + @Override + public void run() { + PumpEnactResult result = MainApp.getConfigBuilder().deliverTreatment(amount, 0, null, false); + if (!result.success) { + sendError(MainApp.sResources.getString(R.string.treatmentdeliveryerror) + + "\n" + + result.comment); + } + } + }); + } + + private synchronized static void sendError(String errormessage){ + WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation("ERROR", errormessage, "error"); + lastSentTimestamp = System.currentTimeMillis(); + lastConfirmActionString = null; + } + + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index 0b5129c5cc..677b1679f1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -31,6 +31,7 @@ import info.nightscout.androidaps.db.TempBasal; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.plugins.Overview.OverviewPlugin; +import info.nightscout.androidaps.plugins.Wear.ActionStringHandler; import info.nightscout.androidaps.plugins.Wear.WearPlugin; import info.nightscout.client.data.NSProfile; import info.nightscout.utils.DecimalFormatter; @@ -165,13 +166,13 @@ public class WatchUpdaterService extends WearableListenerService implements String actionstring = new String(event.getData()); ToastUtils.showToastInUiThread(this, "INITIATE: " + actionstring); - //TODO: watch initiated action + ActionStringHandler.handleInitiate(actionstring); } if (event != null && event.getPath().equals(WEARABLE_CONFIRM_ACTIONSTRING_PATH)) { String actionstring = new String(event.getData()); ToastUtils.showToastInUiThread(this, "CONFIRM: " + actionstring); - //TODO: watch confirmed action + ActionStringHandler.handleConfirmation(actionstring); } } } From bf7a96b3e78b6a0216e8f28c7837c5eb8783414b Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 9 Feb 2017 03:15:13 +0100 Subject: [PATCH 16/48] bolus progress dialog without activity context --- app/src/main/AndroidManifest.xml | 1 + .../ConfigBuilder/ConfigBuilderPlugin.java | 7 ++++++ .../Overview/Dialogs/BolusProgressDialog.java | 13 ++++++++++ .../Dialogs/BolusProgressHelperActivity.java | 24 +++++++++++++++++++ app/src/main/res/values/styles.xml | 8 +++++++ 5 files changed, 53 insertions(+) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressHelperActivity.java diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 58cdb693a1..8f500c4421 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,6 +33,7 @@ + diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index 784888bdac..f34e08ec49 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -46,6 +46,7 @@ import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA; import info.nightscout.androidaps.plugins.OpenAPSMA.DetermineBasalResultMA; import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog; +import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressHelperActivity; import info.nightscout.androidaps.plugins.Overview.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; @@ -470,6 +471,12 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain bolusProgressDialog = new BolusProgressDialog(); bolusProgressDialog.setInsulin(insulin); bolusProgressDialog.show(((AppCompatActivity) context).getSupportFragmentManager(), "BolusProgress"); + } else { + Intent i = new Intent(); + i.putExtra("insulin", insulin.doubleValue()); + i.setClass(MainApp.instance(), BolusProgressHelperActivity.class); + i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + MainApp.instance().startActivity(i); } MainApp.bus().post(new EventBolusRequested(insulin)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java index 537613b9e2..090a63e47a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java @@ -29,6 +29,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL TextView statusView; TextView stopPressedView; ProgressBar progressBar; + BolusProgressHelperActivity helperActivity; static double amount; public static boolean bolusEnded = false; @@ -45,6 +46,10 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL bolusEnded = false; } + public void setHelperActivity(BolusProgressHelperActivity activity){ + this.helperActivity = activity; + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -71,6 +76,14 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL if (bolusEnded) dismiss(); } + @Override + public void dismiss(){ + super.dismiss(); + if (helperActivity!= null){ + helperActivity.finish(); + } + } + @Override public void onPause() { super.onPause(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressHelperActivity.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressHelperActivity.java new file mode 100644 index 0000000000..6fddc218ac --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressHelperActivity.java @@ -0,0 +1,24 @@ +package info.nightscout.androidaps.plugins.Overview.Dialogs; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; + +/** + * Created by adrian on 09/02/17. + */ + +public class BolusProgressHelperActivity extends AppCompatActivity { + public BolusProgressHelperActivity() { + super(); + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + this.getIntent().getDoubleExtra("insulin", 0d); + BolusProgressDialog bolusProgressDialog = new BolusProgressDialog(); + bolusProgressDialog.setHelperActivity(this); + bolusProgressDialog.setInsulin(this.getIntent().getDoubleExtra("insulin", 0d)); + bolusProgressDialog.show(this.getSupportFragmentManager(), "BolusProgress"); + } +} diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 4d2ddf901c..4cafe9dd35 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -14,4 +14,12 @@ + From cb2319d1f2e15f4a30ab022ee6279a9192e0a2f8 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 9 Feb 2017 04:50:36 +0100 Subject: [PATCH 17/48] wear first gui draft bolus --- wear/src/main/AndroidManifest.xml | 90 +++++++++++------- .../actions/ActionsDefinitions.java | 9 +- .../actions/bolus/BolusActivity.java | 26 +++++ wear/src/main/res/drawable/circle.xml | 11 +++ wear/src/main/res/drawable/ic_action_add.png | Bin 0 -> 139 bytes .../src/main/res/drawable/ic_action_minus.png | Bin 0 -> 131 bytes wear/src/main/res/layout/activity_bolus.xml | 11 +++ .../main/res/layout/rect_activity_bolus.xml | 54 +++++++++++ .../main/res/layout/round_activity_bolus.xml | 16 ++++ wear/src/main/res/values/colors.xml | 2 + wear/src/main/res/values/strings.xml | 3 + 11 files changed, 188 insertions(+), 34 deletions(-) create mode 100644 wear/src/main/java/info/nightscout/androidaps/actions/bolus/BolusActivity.java create mode 100644 wear/src/main/res/drawable/circle.xml create mode 100644 wear/src/main/res/drawable/ic_action_add.png create mode 100644 wear/src/main/res/drawable/ic_action_minus.png create mode 100644 wear/src/main/res/layout/activity_bolus.xml create mode 100644 wear/src/main/res/layout/rect_activity_bolus.xml create mode 100644 wear/src/main/res/layout/round_activity_bolus.xml diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index f4c8363c6d..34e1156ae7 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -1,7 +1,9 @@ - + + @@ -9,92 +11,116 @@ android:allowBackup="true" android:icon="@drawable/ic_icon" android:label="@string/app_name" - android:theme="@android:style/Theme.DeviceDefault" > + android:theme="@android:style/Theme.DeviceDefault"> + android:name="com.google.android.gms.version" + android:value="@integer/google_play_services_version" /> - - + + + + - - - + + + + - - - + + + + - - - + + + + - - - + + + android:name=".NWPreferences" + android:label="@string/label_xdrip_activity"> - + android:name=".actions.ActionsListActivity" + android:label="@string/label_actions_activity"> + + + + + + + - + \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java index 2265abdd88..49bf50b726 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java +++ b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java @@ -5,6 +5,7 @@ import android.content.Intent; import info.nightscout.androidaps.ListenerService; import info.nightscout.androidaps.NWPreferences; +import info.nightscout.androidaps.actions.bolus.BolusActivity; /** * Created by adrian on 08/02/17. @@ -20,18 +21,22 @@ final class ActionsDefinitions { "Fillpreset 1", "Fillpreset 2", "Fillpreset 3", - "004"}; + "005"}; public static void doAction(int position, Context ctx) { + Intent intent; switch (position) { case 0: break; case 1: + intent = new Intent(ctx, BolusActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + ctx.startActivity(intent); break; case 2: - Intent intent = new Intent(ctx, NWPreferences.class); + intent = new Intent(ctx, NWPreferences.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ctx.startActivity(intent); break; diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/bolus/BolusActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/bolus/BolusActivity.java new file mode 100644 index 0000000000..9157468562 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/actions/bolus/BolusActivity.java @@ -0,0 +1,26 @@ +package info.nightscout.androidaps.actions.bolus; + +import android.app.Activity; +import android.os.Bundle; +import android.support.wearable.view.WatchViewStub; +import android.widget.TextView; + +import info.nightscout.androidaps.R; + +public class BolusActivity extends Activity { + + private TextView mTextView; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_bolus); + final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub); + stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() { + @Override + public void onLayoutInflated(WatchViewStub stub) { + //bmTextView = (TextView) stub.findViewById(R.id.text); + } + }); + } +} diff --git a/wear/src/main/res/drawable/circle.xml b/wear/src/main/res/drawable/circle.xml new file mode 100644 index 0000000000..9f5b7f5fab --- /dev/null +++ b/wear/src/main/res/drawable/circle.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/wear/src/main/res/drawable/ic_action_add.png b/wear/src/main/res/drawable/ic_action_add.png new file mode 100644 index 0000000000000000000000000000000000000000..ca13239a7d6102d789ddef86e219ccb44ae56950 GIT binary patch literal 139 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpUtAWs*^kcwMxZ*1gcP~dQN{1*Q! zJNXeqltbT>uQ86!sw>Zl0#yOQ0ha^w=0KPX47-@$wbrp42tDXvgbLY|Ls;{+F)({= UU3IEMqYNbD>FVdQ&MBb@0GInDp#T5? literal 0 HcmV?d00001 diff --git a/wear/src/main/res/drawable/ic_action_minus.png b/wear/src/main/res/drawable/ic_action_minus.png new file mode 100644 index 0000000000000000000000000000000000000000..e68aed5a2f8985f44411ecbdc5a2fa7074c86f82 GIT binary patch literal 131 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCFHaZ8kcwMxFCXM&P!M1~_~m}d z77jswwGFIilrv|aWCbcg1`l!%#O1SoP(9Geh%C&&(6^1@ytJ!kYjBknNW#{;R literal 0 HcmV?d00001 diff --git a/wear/src/main/res/layout/activity_bolus.xml b/wear/src/main/res/layout/activity_bolus.xml new file mode 100644 index 0000000000..33eb156f99 --- /dev/null +++ b/wear/src/main/res/layout/activity_bolus.xml @@ -0,0 +1,11 @@ + + diff --git a/wear/src/main/res/layout/rect_activity_bolus.xml b/wear/src/main/res/layout/rect_activity_bolus.xml new file mode 100644 index 0000000000..90d343ba4f --- /dev/null +++ b/wear/src/main/res/layout/rect_activity_bolus.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + diff --git a/wear/src/main/res/layout/round_activity_bolus.xml b/wear/src/main/res/layout/round_activity_bolus.xml new file mode 100644 index 0000000000..eead135de3 --- /dev/null +++ b/wear/src/main/res/layout/round_activity_bolus.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/wear/src/main/res/values/colors.xml b/wear/src/main/res/values/colors.xml index f401fa83b8..0a20535687 100644 --- a/wear/src/main/res/values/colors.xml +++ b/wear/src/main/res/values/colors.xml @@ -4,6 +4,8 @@ #2878ff #c1c1c1 #434343 + #779ECB + @color/black diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml index 1e5ae77c0a..4ef81f535e 100644 --- a/wear/src/main/res/values/strings.xml +++ b/wear/src/main/res/values/strings.xml @@ -19,5 +19,8 @@ 4 5 + BolusActivity + Hello Round World! + Hello Square World! From ef2654d3eba36b5ed9f24b4f3c970471b27ac060 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 9 Feb 2017 06:32:29 +0100 Subject: [PATCH 18/48] wear better bolus layout --- wear/src/main/AndroidManifest.xml | 8 +++ .../actions/ActionsDefinitions.java | 8 ++- .../actions/bolus/GridActivity.java | 71 +++++++++++++++++++ wear/src/main/res/layout/grid_layout.xml | 19 +++++ .../main/res/layout/grid_view_pager_item.xml | 61 ++++++++++++++++ 5 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java create mode 100644 wear/src/main/res/layout/grid_layout.xml create mode 100644 wear/src/main/res/layout/grid_view_pager_item.xml diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index 34e1156ae7..d2a06c5c12 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -121,6 +121,14 @@ + + + + + + \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java index 49bf50b726..a1cdd49744 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java +++ b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java @@ -6,6 +6,7 @@ import android.content.Intent; import info.nightscout.androidaps.ListenerService; import info.nightscout.androidaps.NWPreferences; import info.nightscout.androidaps.actions.bolus.BolusActivity; +import info.nightscout.androidaps.actions.bolus.GridActivity; /** * Created by adrian on 08/02/17. @@ -21,7 +22,7 @@ final class ActionsDefinitions { "Fillpreset 1", "Fillpreset 2", "Fillpreset 3", - "005"}; + "006"}; public static void doAction(int position, Context ctx) { @@ -52,6 +53,11 @@ final class ActionsDefinitions { case 6: ListenerService.initiateAction(ctx, "fillpreset 3"); break; + case 7: + intent = new Intent(ctx, GridActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + ctx.startActivity(intent); + break; } } diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java new file mode 100644 index 0000000000..1e50854683 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java @@ -0,0 +1,71 @@ +package info.nightscout.androidaps.actions.bolus; + + +import android.app.Activity; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Color; +import android.os.Bundle; +import android.support.wearable.view.DotsPageIndicator; +import android.support.wearable.view.GridPagerAdapter; +import android.support.wearable.view.GridViewPager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import info.nightscout.androidaps.R; + +/** + * Created by adrian on 09/02/17. + */ + + +public class GridActivity extends Activity { + + + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.grid_layout); + final Resources res = getResources(); + final GridViewPager pager = (GridViewPager) findViewById(R.id.pager); + + pager.setAdapter(new MyGridViewPagerAdapter()); + DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator); + dotsPageIndicator.setPager(pager); + } + + private class MyGridViewPagerAdapter extends GridPagerAdapter { + @Override + public int getColumnCount(int arg0) { + return 3; + } + + @Override + public int getRowCount() { + return 1; + } + + @Override + public Object instantiateItem(ViewGroup container, int row, int col) { + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.grid_view_pager_item, container, false); + final TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText("label: " + col); + container.addView(view); + return view; + } + + @Override + public void destroyItem(ViewGroup container, int row, int col, Object view) { + container.removeView((View)view); + } + + @Override + public boolean isViewFromObject(View view, Object object) { + return view==object; + } + } +} \ No newline at end of file diff --git a/wear/src/main/res/layout/grid_layout.xml b/wear/src/main/res/layout/grid_layout.xml new file mode 100644 index 0000000000..2b37f71cae --- /dev/null +++ b/wear/src/main/res/layout/grid_layout.xml @@ -0,0 +1,19 @@ + + + + + + + + + \ No newline at end of file diff --git a/wear/src/main/res/layout/grid_view_pager_item.xml b/wear/src/main/res/layout/grid_view_pager_item.xml new file mode 100644 index 0000000000..2979dc00cb --- /dev/null +++ b/wear/src/main/res/layout/grid_view_pager_item.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + From 6737cdf3650ace6ec50a67e2f6da4b0d27e5802f Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 9 Feb 2017 07:04:52 +0100 Subject: [PATCH 19/48] wear close activity when paused --- .../androidaps/actions/ActionsDefinitions.java | 2 +- .../androidaps/actions/bolus/GridActivity.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java index a1cdd49744..be134955b0 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java +++ b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java @@ -22,7 +22,7 @@ final class ActionsDefinitions { "Fillpreset 1", "Fillpreset 2", "Fillpreset 3", - "006"}; + "008"}; public static void doAction(int position, Context ctx) { diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java index 1e50854683..230c8bc2e4 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java @@ -6,6 +6,7 @@ import android.content.Context; import android.content.res.Resources; import android.graphics.Color; import android.os.Bundle; +import android.support.wearable.activity.WearableActivity; import android.support.wearable.view.DotsPageIndicator; import android.support.wearable.view.GridPagerAdapter; import android.support.wearable.view.GridViewPager; @@ -36,8 +37,18 @@ public class GridActivity extends Activity { pager.setAdapter(new MyGridViewPagerAdapter()); DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator); dotsPageIndicator.setPager(pager); + } + + + @Override + protected void onPause() { + super.onPause(); + finish(); + } + + private class MyGridViewPagerAdapter extends GridPagerAdapter { @Override public int getColumnCount(int arg0) { @@ -67,5 +78,7 @@ public class GridActivity extends Activity { public boolean isViewFromObject(View view, Object object) { return view==object; } + + } } \ No newline at end of file From a2723f60e064218f8cff273ad7e3add1a91cec89 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 9 Feb 2017 14:25:25 +0100 Subject: [PATCH 20/48] wear wizard on watch part first working --- wear/src/main/AndroidManifest.xml | 10 +- .../actions/ActionsDefinitions.java | 7 +- .../actions/bolus/GridActivity.java | 6 +- .../actions/utils/PlusMinusEditText.java | 196 ++++++++++++++++++ .../androidaps/actions/utils/SafeParse.java | 36 ++++ .../actions/wizard/WizardActivity.java | 107 ++++++++++ ...item.xml => action_editplusminus_item.xml} | 6 +- wear/src/main/res/layout/action_send_item.xml | 28 +++ wear/wear.iml | 30 +-- 9 files changed, 399 insertions(+), 27 deletions(-) create mode 100644 wear/src/main/java/info/nightscout/androidaps/actions/utils/PlusMinusEditText.java create mode 100644 wear/src/main/java/info/nightscout/androidaps/actions/utils/SafeParse.java create mode 100644 wear/src/main/java/info/nightscout/androidaps/actions/wizard/WizardActivity.java rename wear/src/main/res/layout/{grid_view_pager_item.xml => action_editplusminus_item.xml} (91%) create mode 100644 wear/src/main/res/layout/action_send_item.xml diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index d2a06c5c12..2c1a9f01eb 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -129,6 +129,14 @@ - + + + + + + + \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java index be134955b0..150edb7d66 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java +++ b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java @@ -7,6 +7,7 @@ import info.nightscout.androidaps.ListenerService; import info.nightscout.androidaps.NWPreferences; import info.nightscout.androidaps.actions.bolus.BolusActivity; import info.nightscout.androidaps.actions.bolus.GridActivity; +import info.nightscout.androidaps.actions.wizard.WizardActivity; /** * Created by adrian on 08/02/17. @@ -16,13 +17,13 @@ final class ActionsDefinitions { private static final String[] ACTION_NAMES = { "Temp Target", - "Bolus", + "Wizard", "Settings", "Resend Data", "Fillpreset 1", "Fillpreset 2", "Fillpreset 3", - "008"}; + "009"}; public static void doAction(int position, Context ctx) { @@ -32,7 +33,7 @@ final class ActionsDefinitions { case 0: break; case 1: - intent = new Intent(ctx, BolusActivity.class); + intent = new Intent(ctx, WizardActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ctx.startActivity(intent); break; diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java index 230c8bc2e4..e18d2e839e 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java @@ -2,18 +2,14 @@ package info.nightscout.androidaps.actions.bolus; import android.app.Activity; -import android.content.Context; import android.content.res.Resources; -import android.graphics.Color; import android.os.Bundle; -import android.support.wearable.activity.WearableActivity; import android.support.wearable.view.DotsPageIndicator; import android.support.wearable.view.GridPagerAdapter; import android.support.wearable.view.GridViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; import android.widget.TextView; import info.nightscout.androidaps.R; @@ -62,7 +58,7 @@ public class GridActivity extends Activity { @Override public Object instantiateItem(ViewGroup container, int row, int col) { - final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.grid_view_pager_item, container, false); + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); final TextView textView = (TextView) view.findViewById(R.id.label); textView.setText("label: " + col); container.addView(view); diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/utils/PlusMinusEditText.java b/wear/src/main/java/info/nightscout/androidaps/actions/utils/PlusMinusEditText.java new file mode 100644 index 0000000000..b92603c567 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/actions/utils/PlusMinusEditText.java @@ -0,0 +1,196 @@ +package info.nightscout.androidaps.actions.utils; + +import android.os.Handler; +import android.os.Message; +import android.view.KeyEvent; +import android.view.MotionEvent; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import java.text.NumberFormat; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + + +/** + * Created by mike on 28.06.2016. + */ +public class PlusMinusEditText implements View.OnKeyListener, + View.OnTouchListener, View.OnClickListener { + + Integer editTextID; + public TextView editText; + ImageView minusImage; + ImageView plusImage; + + Double value; + Double minValue = 0d; + Double maxValue = 1d; + Double step = 1d; + NumberFormat formater; + boolean allowZero = false; + + private Handler mHandler; + private ScheduledExecutorService mUpdater; + + private class UpdateCounterTask implements Runnable { + private boolean mInc; + private int repeated = 0; + private int multiplier = 1; + + private final int doubleLimit = 5; + + public UpdateCounterTask(boolean inc) { + mInc = inc; + } + + public void run() { + Message msg = new Message(); + if (repeated % doubleLimit == 0) multiplier *= 2; + repeated++; + msg.arg1 = multiplier; + msg.arg2 = repeated; + if (mInc) { + msg.what = MSG_INC; + } else { + msg.what = MSG_DEC; + } + mHandler.sendMessage(msg); + } + } + + private static final int MSG_INC = 0; + private static final int MSG_DEC = 1; + + public PlusMinusEditText(View view, int editTextID, int plusID, int minusID, Double initValue, Double minValue, Double maxValue, Double step, NumberFormat formater, boolean allowZero) { + editText = (TextView) view.findViewById(editTextID); + minusImage = (ImageView) view.findViewById(minusID); + plusImage = (ImageView) view.findViewById(plusID); + + this.value = initValue; + this.minValue = minValue; + this.maxValue = maxValue; + this.step = step; + this.formater = formater; + this.allowZero = allowZero; + + mHandler = new Handler() { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_INC: + inc(msg.arg1); + return; + case MSG_DEC: + dec(msg.arg1); + return; + } + super.handleMessage(msg); + } + }; + + minusImage.setOnTouchListener(this); + minusImage.setOnKeyListener(this); + minusImage.setOnClickListener(this); + plusImage.setOnTouchListener(this); + plusImage.setOnKeyListener(this); + plusImage.setOnClickListener(this); + updateEditText(); + } + + public void setValue(Double value) { + this.value = value; + updateEditText(); + } + + public Double getValue() { + return value; + } + + public void setStep(Double step) { + this.step = step; + } + + private void inc(int multiplier) { + value += step * multiplier; + if (value > maxValue) { + value = maxValue; + stopUpdating(); + } + updateEditText(); + } + + private void dec( int multiplier) { + value -= step * multiplier; + if (value < minValue) { + value = minValue; + stopUpdating(); + } + updateEditText(); + } + + private void updateEditText() { + if (value == 0d && !allowZero) + editText.setText(""); + else + editText.setText(formater.format(value)); + } + + private void startUpdating(boolean inc) { + if (mUpdater != null) { + return; + } + mUpdater = Executors.newSingleThreadScheduledExecutor(); + mUpdater.scheduleAtFixedRate(new UpdateCounterTask(inc), 200, 200, + TimeUnit.MILLISECONDS); + } + + private void stopUpdating() { + if (mUpdater != null) { + mUpdater.shutdownNow(); + mUpdater = null; + } + } + + @Override + public void onClick(View v) { + if (mUpdater == null) { + if (v == plusImage) { + inc(1); + } else { + dec(1); + } + } + } + + @Override + public boolean onKey(View v, int keyCode, KeyEvent event) { + boolean isKeyOfInterest = keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER; + boolean isReleased = event.getAction() == KeyEvent.ACTION_UP; + boolean isPressed = event.getAction() == KeyEvent.ACTION_DOWN + && event.getAction() != KeyEvent.ACTION_MULTIPLE; + + if (isKeyOfInterest && isReleased) { + stopUpdating(); + } else if (isKeyOfInterest && isPressed) { + startUpdating(v == plusImage); + } + return false; + } + + @Override + public boolean onTouch(View v, MotionEvent event) { + boolean isReleased = event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_CANCEL; + boolean isPressed = event.getAction() == MotionEvent.ACTION_DOWN; + + if (isReleased) { + stopUpdating(); + } else if (isPressed) { + startUpdating(v == plusImage); + } + return false; + } + +} diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/utils/SafeParse.java b/wear/src/main/java/info/nightscout/androidaps/actions/utils/SafeParse.java new file mode 100644 index 0000000000..2f896155fb --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/actions/utils/SafeParse.java @@ -0,0 +1,36 @@ +package info.nightscout.androidaps.actions.utils; + +/** + * Created by mike on 23.06.2016. + */ +public class SafeParse { + public static Double stringToDouble(String input) { + Double result = 0d; + input = input.replace(",", "."); + try { + result = Double.parseDouble(input); + } catch (Exception e) { + } + return result; + } + + public static Integer stringToInt(String input) { + Integer result = 0; + input = input.replace(",", "."); + try { + result = Integer.parseInt(input); + } catch (Exception e) { + } + return result; + } + + public static Long stringToLong(String input) { + Long result = 0L; + input = input.replace(",", "."); + try { + result = Long.parseLong(input); + } catch (Exception e) { + } + return result; + } +} diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/wizard/WizardActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/wizard/WizardActivity.java new file mode 100644 index 0000000000..a00b78a3df --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/actions/wizard/WizardActivity.java @@ -0,0 +1,107 @@ +package info.nightscout.androidaps.actions.wizard; + + +import android.app.Activity; +import android.content.res.Resources; +import android.os.Bundle; +import android.support.wearable.view.DotsPageIndicator; +import android.support.wearable.view.GridPagerAdapter; +import android.support.wearable.view.GridViewPager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import java.text.DecimalFormat; + +import info.nightscout.androidaps.ListenerService; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.actions.utils.PlusMinusEditText; +import info.nightscout.androidaps.actions.utils.SafeParse; + +/** + * Created by adrian on 09/02/17. + */ + + +public class WizardActivity extends Activity { + + PlusMinusEditText editCarbs; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.grid_layout); + final Resources res = getResources(); + final GridViewPager pager = (GridViewPager) findViewById(R.id.pager); + + pager.setAdapter(new MyGridViewPagerAdapter()); + DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator); + dotsPageIndicator.setPager(pager); + } + + + @Override + protected void onPause() { + super.onPause(); + finish(); + } + + + private class MyGridViewPagerAdapter extends GridPagerAdapter { + @Override + public int getColumnCount(int arg0) { + return 2; + } + + @Override + public int getRowCount() { + return 1; + } + + @Override + public Object instantiateItem(ViewGroup container, int row, int col) { + + if(col == 0){ + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); + final TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText("carbs"); + editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 100d, 1d, new DecimalFormat("0"), false); + container.addView(view); + return view; + } else { + + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false); + final ImageView confirmbutton = (ImageView) view.findViewById(R.id.confirmbutton); + confirmbutton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + //TODO: check if it can happen that the fagment is never created that hold data + // (you have to swipe past them anyways - but still) + + String actionstring = "wizard " + SafeParse.stringToInt(editCarbs.editText.getText().toString());; + ListenerService.initiateAction(WizardActivity.this, actionstring); + finish(); + } + }); + container.addView(view); + return view; + } + } + + @Override + public void destroyItem(ViewGroup container, int row, int col, Object view) { + //TODO: Handle this to get the data before the view is destroyed? + container.removeView((View)view); + } + + @Override + public boolean isViewFromObject(View view, Object object) { + return view==object; + } + + + } +} \ No newline at end of file diff --git a/wear/src/main/res/layout/grid_view_pager_item.xml b/wear/src/main/res/layout/action_editplusminus_item.xml similarity index 91% rename from wear/src/main/res/layout/grid_view_pager_item.xml rename to wear/src/main/res/layout/action_editplusminus_item.xml index 2979dc00cb..6e12ad857b 100644 --- a/wear/src/main/res/layout/grid_view_pager_item.xml +++ b/wear/src/main/res/layout/action_editplusminus_item.xml @@ -12,7 +12,7 @@ android:gravity="center"> + + + + + + + + + + diff --git a/wear/wear.iml b/wear/wear.iml index 9ccd598295..33cd39a6c1 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -43,6 +43,13 @@ + + + + + + + @@ -51,13 +58,6 @@ - - - - - - - @@ -66,14 +66,6 @@ - - - - - - - - @@ -82,6 +74,14 @@ + + + + + + + + From b8c3fe2933dd7408f0f6e4983deea8c9ff92e896 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 9 Feb 2017 16:16:31 +0100 Subject: [PATCH 21/48] wear wizard including bg and iob toggles --- .../plugins/Overview/OverviewFragment.java | 2 +- .../plugins/Wear/ActionStringHandler.java | 26 ++++++- .../wearintegration/WatchUpdaterService.java | 2 - .../actions/wizard/WizardActivity.java | 73 +++++++++++++++++- .../main/res/drawable-hdpi/ic_toggle_off.png | Bin 0 -> 250 bytes .../main/res/drawable-hdpi/ic_toggle_on.png | Bin 0 -> 396 bytes .../main/res/drawable-mdpi/ic_toggle_off.png | Bin 0 -> 184 bytes .../main/res/drawable-mdpi/ic_toggle_on.png | Bin 0 -> 279 bytes .../main/res/drawable-xhdpi/ic_toggle_off.png | Bin 0 -> 295 bytes .../main/res/drawable-xhdpi/ic_toggle_on.png | Bin 0 -> 478 bytes .../res/drawable-xxhdpi/ic_toggle_off.png | Bin 0 -> 488 bytes .../main/res/drawable-xxhdpi/ic_toggle_on.png | Bin 0 -> 790 bytes .../main/res/layout/action_toggle_item.xml | 41 ++++++++++ 13 files changed, 134 insertions(+), 10 deletions(-) create mode 100644 wear/src/main/res/drawable-hdpi/ic_toggle_off.png create mode 100644 wear/src/main/res/drawable-hdpi/ic_toggle_on.png create mode 100644 wear/src/main/res/drawable-mdpi/ic_toggle_off.png create mode 100644 wear/src/main/res/drawable-mdpi/ic_toggle_on.png create mode 100644 wear/src/main/res/drawable-xhdpi/ic_toggle_off.png create mode 100644 wear/src/main/res/drawable-xhdpi/ic_toggle_on.png create mode 100644 wear/src/main/res/drawable-xxhdpi/ic_toggle_off.png create mode 100644 wear/src/main/res/drawable-xxhdpi/ic_toggle_on.png create mode 100644 wear/src/main/res/layout/action_toggle_item.xml diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index fa1ef08986..076d1c63b5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -292,7 +292,7 @@ public class OverviewFragment extends Fragment { final JSONObject boluscalcJSON = new JSONObject(); try { - boluscalcJSON.put("eventTime", DateUtil.toISOString(new Date())); + boluscalcJSON.put("eventTime", DateUtil.toISOString(new Date())); boluscalcJSON.put("targetBGLow", wizard.targetBGLow); boluscalcJSON.put("targetBGHigh", wizard.targetBGHigh); boluscalcJSON.put("isf", wizard.sens); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index ec7d03cf3b..bc6f470229 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -1,15 +1,29 @@ package info.nightscout.androidaps.plugins.Wear; +import android.content.DialogInterface; import android.content.SharedPreferences; import android.os.Handler; import android.os.HandlerThread; import android.preference.PreferenceManager; import android.support.v7.app.AlertDialog; +import android.view.View; + +import org.json.JSONException; +import org.json.JSONObject; + +import java.text.DecimalFormat; +import java.util.Date; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.PumpEnactResult; +import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog; +import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; +import info.nightscout.androidaps.plugins.Overview.QuickWizard; +import info.nightscout.client.data.NSProfile; +import info.nightscout.utils.BolusWizard; +import info.nightscout.utils.DateUtil; import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.SafeParse; import info.nightscout.utils.ToastUtils; @@ -60,7 +74,15 @@ public class ActionStringHandler { rAction += "fill " + insulinAfterConstraints; - } else if(false){ + } else if ("wizard".equals(act[0])) { + Integer carbsBeforeConstraints = SafeParse.stringToInt(act[1]); + Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(carbsBeforeConstraints); + //TODO: wizard calculation + return; + + } + + else if(false){ //... add more actions } else return; @@ -121,6 +143,4 @@ public class ActionStringHandler { lastSentTimestamp = System.currentTimeMillis(); lastConfirmActionString = null; } - - } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index 677b1679f1..0ff2056d74 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -162,8 +162,6 @@ public class WatchUpdaterService extends WearableListenerService implements } if (event != null && event.getPath().equals(WEARABLE_INITIATE_ACTIONSTRING_PATH)) { - ToastUtils.showToastInUiThread(this, "INITIATE1"); - String actionstring = new String(event.getData()); ToastUtils.showToastInUiThread(this, "INITIATE: " + actionstring); ActionStringHandler.handleInitiate(actionstring); diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/wizard/WizardActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/wizard/WizardActivity.java index a00b78a3df..a01439a639 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/wizard/WizardActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/actions/wizard/WizardActivity.java @@ -29,6 +29,10 @@ public class WizardActivity extends Activity { PlusMinusEditText editCarbs; + boolean useBG; + boolean includeBolusIOB; + boolean includeBasalIOB; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -52,7 +56,7 @@ public class WizardActivity extends Activity { private class MyGridViewPagerAdapter extends GridPagerAdapter { @Override public int getColumnCount(int arg0) { - return 2; + return 5; } @Override @@ -70,6 +74,63 @@ public class WizardActivity extends Activity { editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 100d, 1d, new DecimalFormat("0"), false); container.addView(view); return view; + } else if(col == 1){ + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_toggle_item, container, false); + final TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText("include BG?"); + + final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton); + togglebutton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + useBG = !useBG; + if(useBG){ + togglebutton.setImageResource(R.drawable.ic_toggle_on); + } else { + togglebutton.setImageResource(R.drawable.ic_toggle_off); + } + } + }); + container.addView(view); + return view; + } else if(col == 2){ + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_toggle_item, container, false); + final TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText("Bolus IOB?"); + + final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton); + togglebutton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + includeBolusIOB = !includeBolusIOB; + if(includeBolusIOB){ + togglebutton.setImageResource(R.drawable.ic_toggle_on); + } else { + togglebutton.setImageResource(R.drawable.ic_toggle_off); + } + } + }); + container.addView(view); + return view; + } else if(col == 3){ + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_toggle_item, container, false); + final TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText("Basal IOB?"); + + final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton); + togglebutton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + includeBasalIOB = !includeBasalIOB; + if(includeBasalIOB){ + togglebutton.setImageResource(R.drawable.ic_toggle_on); + } else { + togglebutton.setImageResource(R.drawable.ic_toggle_off); + } + } + }); + container.addView(view); + return view; } else { final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false); @@ -78,10 +139,13 @@ public class WizardActivity extends Activity { @Override public void onClick(View v) { - //TODO: check if it can happen that the fagment is never created that hold data + //check if it can happen that the fagment is never created that hold data? // (you have to swipe past them anyways - but still) - String actionstring = "wizard " + SafeParse.stringToInt(editCarbs.editText.getText().toString());; + String actionstring = "wizard " + SafeParse.stringToInt(editCarbs.editText.getText().toString()) + + " " + useBG + + " " + includeBolusIOB + + " " + includeBasalIOB; ListenerService.initiateAction(WizardActivity.this, actionstring); finish(); } @@ -93,7 +157,8 @@ public class WizardActivity extends Activity { @Override public void destroyItem(ViewGroup container, int row, int col, Object view) { - //TODO: Handle this to get the data before the view is destroyed? + // Handle this to get the data before the view is destroyed? + // Object should still be kept by this, just setup for reinit? container.removeView((View)view); } diff --git a/wear/src/main/res/drawable-hdpi/ic_toggle_off.png b/wear/src/main/res/drawable-hdpi/ic_toggle_off.png new file mode 100644 index 0000000000000000000000000000000000000000..ea0e7e636ea6a115d9fce7a58bde63e888813f52 GIT binary patch literal 250 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpUtgPtyqAr-gY-rUI5Y#`G5&_}kV zsYJhvU)$*=x9G}*T{p|U@)cNTe~ijA`on%MW5@hJ_Qx`cEg`c7oYdzo>Hd;?XL-q# zxUGl3U)p)#L8ZJ_OH9e?gdh3tya{K;DkZ-^FTBL?jk_XKJGZCmq@X)vp}Ak1d_Ty3 zOu$*t$FX?Ze}*4-nWCK{uBMw8Tx57B`ZsRANrU3tNmJzPkKr-q8o#y4Zo#rV5G_+}*dGa^$*V<47 z7^RI4fJ{ECZzi7V)Xj@U7DsiJ q#*+3jNBg1wAIv=EcGWmLOwio>{e;M~v{}N*VQFIB2j1W{q z;0sr?EPUx3!E&XnxaQiDVnqf<4hIG%fd&SaI>iN3-^d90T``~f=EsI9Ks{PQPj<{$ flIvbmGr^Mo<+6pjcB1_tH!^s-`njxgN@xNA6zD*7 literal 0 HcmV?d00001 diff --git a/wear/src/main/res/drawable-mdpi/ic_toggle_on.png b/wear/src/main/res/drawable-mdpi/ic_toggle_on.png new file mode 100644 index 0000000000000000000000000000000000000000..ad595bcc8fa2e439d4b7bb8866088c9770f3561f GIT binary patch literal 279 zcmV+y0qFjTP)>4nbix#g2Xsr0u?Pr$GyZj-~W=>fnX~`^002ovPDHLkV1fi-YDNG6 literal 0 HcmV?d00001 diff --git a/wear/src/main/res/drawable-xhdpi/ic_toggle_off.png b/wear/src/main/res/drawable-xhdpi/ic_toggle_off.png new file mode 100644 index 0000000000000000000000000000000000000000..20ed7755dbacd00d4669ebe38d36260c597f81eb GIT binary patch literal 295 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=?>t=`Ln>~)y=BYQ>>$wgaBrtV z({+zoxkXb p#?PY{lrX=Ly5Zp+M8-iRE5Lmbvm{yxY)T6tij)TZ^KE011lIO zR2NMD=HzMnRP1pW!)~VkL3ZEQ0o_6@IN;B4ydxlD_u9TC>;BiNl^gOHWH4;GwEW=1 z$GOF8whMH0H$ePt-TT#c{@N?>SgwSo>QLnk+ zr^eu231bcc_Xgqry5bP9H7sDmAs{#0Z0G`V2!Mce1-w!}hAQBNdO^MPNk~yZ1@DZn zl<+we0S$O(j91jJ)CKH?cgA^}vH&0aBIPM?G<*sIg5a$S2!^*TfCb*F05*6n0ngNj z7~wSplH;A1%tXh_h6kLf_9lAsMA+lkN{ejJ4W2!H?xFnCGoedyQZ z9t{gva|oDGe+i_l0kaNhsmx+&9K&^>m2&ov^LXAgB0)1A-t3f*`*90{2(t U4VXN--~a#s07*qoM6N<$g8sbDoB#j- literal 0 HcmV?d00001 diff --git a/wear/src/main/res/drawable-xxhdpi/ic_toggle_off.png b/wear/src/main/res/drawable-xxhdpi/ic_toggle_off.png new file mode 100644 index 0000000000000000000000000000000000000000..8d34740c21bd583a7b2603a1491908c00e07346a GIT binary patch literal 488 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>U|jF%;uunK>+Ri*eun}?*b;V0 zI6XS@aYUX@NjW4fFdGG&EvdS(hZ+f-0 ztRNIjR1TV!Dk$r!e$ll=_HR$!)-6}Ju3hx`g@sj4(T}??OnzN^)F}Td``5?0riOoh z3(Ng^e=pV9qkpcn^Zl19;s-)Yk{{ID^|e_tENhFsUC7tq-n{Ou4f}zz^Wr}|PH&k$ zt!(bPjqiSiTQYq6%QWqxd_+C%O)}>q+Q_6OO%%{lC3p=GdE1V zv!{q5gx%tf)DOSaxqrK3PH&9+a_~ZZl@c5QY;gYV|b=g)S<%h^sDq4&7MYsHKXFpc@5o;m(~;P`WJLOGPV+iM~@h1J_cL z+?$-_X3osX_rt$T%9$^GxjFYF?Q{qsgb+dqA%qY@2$>_J(WookmL5uvrQf7~rT+@8 zuI)^EBt4LB7hV}3_rJvV$@Z0A19_>f~6F+VKovSna7_m+l!IX*Ac4R{+CmFTH!^u@6=ZA&YiA0vJ@U{O**; z@2yBj*|g&gz<=#*G#qblTSr;7;|aiob{d|iEgfaojwb-Ru*V6{wXBX@Xvdp^6v9JY z@SNYaSyV@EwBzwj_>V$Jc+ONExzdi;%g|Nn$engPe-LY1M=rJFeJf%S9i2zgPK3?4 zR2}uIfrrpel-g^>dDBh_H|0~Wj$95u`l*PSI`XQWl8&X+>d3QpN;?-cRYwtq zU(&&>OC3efPN^s36vCtG2LAv6d5$Iyqx}vkXF~x10000000000002w9PcU|0H!VNX;~^KDxI(A~**41A*fdA^v^7KA&}FAV*%`tMve zJC>0@cw72@&2^+Fx!;-(e@sWa)f@Banp~pl8c! + + + + + + + + + + + From 4dcbbd3df23f246de41b6e1c2fcb6b748d9595f6 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 9 Feb 2017 16:29:46 +0100 Subject: [PATCH 22/48] wear cleanup --- wear/src/main/AndroidManifest.xml | 17 ---- .../actions/ActionsDefinitions.java | 5 -- .../actions/bolus/BolusActivity.java | 26 ------ .../actions/bolus/GridActivity.java | 80 ------------------- wear/src/main/res/layout/activity_bolus.xml | 11 --- .../main/res/layout/rect_activity_bolus.xml | 54 ------------- .../main/res/layout/round_activity_bolus.xml | 16 ---- 7 files changed, 209 deletions(-) delete mode 100644 wear/src/main/java/info/nightscout/androidaps/actions/bolus/BolusActivity.java delete mode 100644 wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java delete mode 100644 wear/src/main/res/layout/activity_bolus.xml delete mode 100644 wear/src/main/res/layout/rect_activity_bolus.xml delete mode 100644 wear/src/main/res/layout/round_activity_bolus.xml diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index 2c1a9f01eb..a530067e91 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -112,23 +112,6 @@ - - - - - - - - - - - - - diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java index 150edb7d66..7b814bf48d 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java +++ b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java @@ -5,8 +5,6 @@ import android.content.Intent; import info.nightscout.androidaps.ListenerService; import info.nightscout.androidaps.NWPreferences; -import info.nightscout.androidaps.actions.bolus.BolusActivity; -import info.nightscout.androidaps.actions.bolus.GridActivity; import info.nightscout.androidaps.actions.wizard.WizardActivity; /** @@ -55,9 +53,6 @@ final class ActionsDefinitions { ListenerService.initiateAction(ctx, "fillpreset 3"); break; case 7: - intent = new Intent(ctx, GridActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - ctx.startActivity(intent); break; } diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/bolus/BolusActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/bolus/BolusActivity.java deleted file mode 100644 index 9157468562..0000000000 --- a/wear/src/main/java/info/nightscout/androidaps/actions/bolus/BolusActivity.java +++ /dev/null @@ -1,26 +0,0 @@ -package info.nightscout.androidaps.actions.bolus; - -import android.app.Activity; -import android.os.Bundle; -import android.support.wearable.view.WatchViewStub; -import android.widget.TextView; - -import info.nightscout.androidaps.R; - -public class BolusActivity extends Activity { - - private TextView mTextView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_bolus); - final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub); - stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() { - @Override - public void onLayoutInflated(WatchViewStub stub) { - //bmTextView = (TextView) stub.findViewById(R.id.text); - } - }); - } -} diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java deleted file mode 100644 index e18d2e839e..0000000000 --- a/wear/src/main/java/info/nightscout/androidaps/actions/bolus/GridActivity.java +++ /dev/null @@ -1,80 +0,0 @@ -package info.nightscout.androidaps.actions.bolus; - - -import android.app.Activity; -import android.content.res.Resources; -import android.os.Bundle; -import android.support.wearable.view.DotsPageIndicator; -import android.support.wearable.view.GridPagerAdapter; -import android.support.wearable.view.GridViewPager; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import info.nightscout.androidaps.R; - -/** - * Created by adrian on 09/02/17. - */ - - -public class GridActivity extends Activity { - - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.grid_layout); - final Resources res = getResources(); - final GridViewPager pager = (GridViewPager) findViewById(R.id.pager); - - pager.setAdapter(new MyGridViewPagerAdapter()); - DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator); - dotsPageIndicator.setPager(pager); - - } - - - - @Override - protected void onPause() { - super.onPause(); - finish(); - } - - - private class MyGridViewPagerAdapter extends GridPagerAdapter { - @Override - public int getColumnCount(int arg0) { - return 3; - } - - @Override - public int getRowCount() { - return 1; - } - - @Override - public Object instantiateItem(ViewGroup container, int row, int col) { - final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); - final TextView textView = (TextView) view.findViewById(R.id.label); - textView.setText("label: " + col); - container.addView(view); - return view; - } - - @Override - public void destroyItem(ViewGroup container, int row, int col, Object view) { - container.removeView((View)view); - } - - @Override - public boolean isViewFromObject(View view, Object object) { - return view==object; - } - - - } -} \ No newline at end of file diff --git a/wear/src/main/res/layout/activity_bolus.xml b/wear/src/main/res/layout/activity_bolus.xml deleted file mode 100644 index 33eb156f99..0000000000 --- a/wear/src/main/res/layout/activity_bolus.xml +++ /dev/null @@ -1,11 +0,0 @@ - - diff --git a/wear/src/main/res/layout/rect_activity_bolus.xml b/wear/src/main/res/layout/rect_activity_bolus.xml deleted file mode 100644 index 90d343ba4f..0000000000 --- a/wear/src/main/res/layout/rect_activity_bolus.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - - - - - diff --git a/wear/src/main/res/layout/round_activity_bolus.xml b/wear/src/main/res/layout/round_activity_bolus.xml deleted file mode 100644 index eead135de3..0000000000 --- a/wear/src/main/res/layout/round_activity_bolus.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - From dc476a660034b2059be980bc0072d74f6365d2f1 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 9 Feb 2017 17:40:26 +0100 Subject: [PATCH 23/48] wear menu restructuring and status --- .../plugins/Wear/ActionStringHandler.java | 22 ++++++ wear/src/main/AndroidManifest.xml | 17 ++--- .../info/nightscout/androidaps/BIGChart.java | 4 +- .../androidaps/CircleWatchface.java | 4 +- .../java/info/nightscout/androidaps/Home.java | 4 +- .../info/nightscout/androidaps/LargeHome.java | 4 +- .../actions/ActionsDefinitions.java | 67 ------------------- .../androidaps/actions/FillMenuActivity.java | 39 +++++++++++ .../androidaps/actions/MainMenuActivity.java | 60 +++++++++++++++++ .../actions/StatusMenuActivity.java | 39 +++++++++++ .../MenuListActivity.java} | 12 ++-- 11 files changed, 185 insertions(+), 87 deletions(-) delete mode 100644 wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java create mode 100644 wear/src/main/java/info/nightscout/androidaps/actions/FillMenuActivity.java create mode 100644 wear/src/main/java/info/nightscout/androidaps/actions/MainMenuActivity.java create mode 100644 wear/src/main/java/info/nightscout/androidaps/actions/StatusMenuActivity.java rename wear/src/main/java/info/nightscout/androidaps/actions/{ActionsListActivity.java => utils/MenuListActivity.java} (92%) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index bc6f470229..56afc45f0c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -57,6 +57,7 @@ public class ActionStringHandler { String[] act = actionstring.split("\\s+"); if ("fillpreset".equals(act[0])) { + ///////////////////////////////////// PRIME/FILL double amount = 0d; if ("1".equals(act[1])) { amount = SafeParse.stringToDouble(DecimalFormatter.to2Decimal(SafeParse.stringToDouble(sp.getString("fill_button1", "0.3")))); @@ -74,6 +75,27 @@ public class ActionStringHandler { rAction += "fill " + insulinAfterConstraints; + } else if ("status".equals(act[0])) { + ///////////////////////////////////// STATUS + rTitle = "STATUS"; + rAction = "statusmessage"; + //TODO: add meaningfull status + + if("general".equals(act[1])){ + rMessage = "Today is going to be a good day!"; + } else if("pump".equals(act[1])){ + rTitle += " PUMP"; + rMessage = "I'm feeling pumped!"; + } else if("loop".equals(act[1])){ + rTitle += " LOOP"; + rMessage = "A loop di loop di loop!"; + + } else if("targets".equals(act[1])){ + rTitle += " TARGETS"; + rMessage = "Always on target!"; + } + rMessage += "\n\n\nTODO:\nAdd some meaningful status."; + } else if ("wizard".equals(act[0])) { Integer carbsBeforeConstraints = SafeParse.stringToInt(act[1]); Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(carbsBeforeConstraints); diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index a530067e91..b8856d4818 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -99,27 +99,28 @@ android:label="@string/label_xdrip_activity"> - - - - - - - + + + + \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/BIGChart.java b/wear/src/main/java/info/nightscout/androidaps/BIGChart.java index af69c8f546..9ead9cecfd 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BIGChart.java +++ b/wear/src/main/java/info/nightscout/androidaps/BIGChart.java @@ -39,7 +39,7 @@ import com.ustwo.clockwise.common.WatchShape; import java.util.ArrayList; import java.util.Date; -import info.nightscout.androidaps.actions.ActionsListActivity; +import info.nightscout.androidaps.actions.MainMenuActivity; import lecho.lib.hellocharts.view.LineChartView; /** @@ -162,7 +162,7 @@ public class BIGChart extends WatchFace implements SharedPreferences.OnSharedPre y >= mSgv.getTop() && y <= mSgv.getBottom()){ if (eventTime - sgvTapTime < 800){ - Intent intent = new Intent(this, ActionsListActivity.class); + Intent intent = new Intent(this, MainMenuActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } diff --git a/wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java b/wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java index 968e29e7bc..6bf669283e 100644 --- a/wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java +++ b/wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java @@ -36,7 +36,7 @@ import java.util.Date; import java.util.HashSet; import java.util.TreeSet; -import info.nightscout.androidaps.actions.ActionsListActivity; +import info.nightscout.androidaps.actions.MainMenuActivity; public class CircleWatchface extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener { @@ -717,7 +717,7 @@ public class CircleWatchface extends WatchFace implements SharedPreferences.OnSh y >= mSgv.getTop() && y <= mSgv.getBottom()){ if (eventTime - sgvTapTime < 800){ - Intent intent = new Intent(this, ActionsListActivity.class); + Intent intent = new Intent(this, MainMenuActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } diff --git a/wear/src/main/java/info/nightscout/androidaps/Home.java b/wear/src/main/java/info/nightscout/androidaps/Home.java index 45803e8b47..2d73ef0661 100644 --- a/wear/src/main/java/info/nightscout/androidaps/Home.java +++ b/wear/src/main/java/info/nightscout/androidaps/Home.java @@ -8,7 +8,7 @@ import android.view.LayoutInflater; import com.ustwo.clockwise.common.WatchMode; -import info.nightscout.androidaps.actions.ActionsListActivity; +import info.nightscout.androidaps.actions.MainMenuActivity; public class Home extends BaseWatchFace { @@ -43,7 +43,7 @@ public class Home extends BaseWatchFace { y >= mSgv.getTop() && y <= mSgv.getBottom()){ if (eventTime - sgvTapTime < 800){ - Intent intent = new Intent(this, ActionsListActivity.class); + Intent intent = new Intent(this, MainMenuActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } diff --git a/wear/src/main/java/info/nightscout/androidaps/LargeHome.java b/wear/src/main/java/info/nightscout/androidaps/LargeHome.java index b3a342f2d8..ecb0735af3 100644 --- a/wear/src/main/java/info/nightscout/androidaps/LargeHome.java +++ b/wear/src/main/java/info/nightscout/androidaps/LargeHome.java @@ -8,7 +8,7 @@ import android.view.LayoutInflater; import com.ustwo.clockwise.common.WatchMode; -import info.nightscout.androidaps.actions.ActionsListActivity; +import info.nightscout.androidaps.actions.MainMenuActivity; public class LargeHome extends BaseWatchFace { @@ -33,7 +33,7 @@ public class LargeHome extends BaseWatchFace { y >= mSgv.getTop() && y <= mSgv.getBottom()){ if (eventTime - sgvTapTime < 800){ - Intent intent = new Intent(this, ActionsListActivity.class); + Intent intent = new Intent(this, MainMenuActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java b/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java deleted file mode 100644 index 7b814bf48d..0000000000 --- a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsDefinitions.java +++ /dev/null @@ -1,67 +0,0 @@ -package info.nightscout.androidaps.actions; - -import android.content.Context; -import android.content.Intent; - -import info.nightscout.androidaps.ListenerService; -import info.nightscout.androidaps.NWPreferences; -import info.nightscout.androidaps.actions.wizard.WizardActivity; - -/** - * Created by adrian on 08/02/17. - */ - -final class ActionsDefinitions { - - private static final String[] ACTION_NAMES = { - "Temp Target", - "Wizard", - "Settings", - "Resend Data", - "Fillpreset 1", - "Fillpreset 2", - "Fillpreset 3", - "009"}; - - - public static void doAction(int position, Context ctx) { - - Intent intent; - switch (position) { - case 0: - break; - case 1: - intent = new Intent(ctx, WizardActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - ctx.startActivity(intent); - break; - case 2: - intent = new Intent(ctx, NWPreferences.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - ctx.startActivity(intent); - break; - case 3: - ListenerService.requestData(ctx); - break; - case 4: - ListenerService.initiateAction(ctx, "fillpreset 1"); - break; - case 5: - ListenerService.initiateAction(ctx, "fillpreset 2"); - break; - case 6: - ListenerService.initiateAction(ctx, "fillpreset 3"); - break; - case 7: - break; - } - - } - - - public static String[] getActionNames() { - //posibility for later i18n - return ACTION_NAMES; - } - -} diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/FillMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/FillMenuActivity.java new file mode 100644 index 0000000000..b1ee084ec7 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/actions/FillMenuActivity.java @@ -0,0 +1,39 @@ +package info.nightscout.androidaps.actions; + +import android.content.Intent; + +import info.nightscout.androidaps.ListenerService; +import info.nightscout.androidaps.NWPreferences; +import info.nightscout.androidaps.actions.utils.MenuListActivity; +import info.nightscout.androidaps.actions.wizard.WizardActivity; + +/** + * Created by adrian on 09/02/17. + */ + +public class FillMenuActivity extends MenuListActivity { + + @Override + protected String[] getElements() { + return new String[] { + "Preset 1", + "Preset 2", + "Preset 3"}; + } + + @Override + protected void doAction(int position) { + switch (position) { + case 0: + ListenerService.initiateAction(this, "fillpreset 1"); + break; + case 1: + ListenerService.initiateAction(this, "fillpreset 2"); + break; + case 2: + ListenerService.initiateAction(this, "fillpreset 3"); + break; + } + + } +} diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/MainMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/MainMenuActivity.java new file mode 100644 index 0000000000..ab73ad769b --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/actions/MainMenuActivity.java @@ -0,0 +1,60 @@ +package info.nightscout.androidaps.actions; + +import android.content.Intent; + +import info.nightscout.androidaps.ListenerService; +import info.nightscout.androidaps.NWPreferences; +import info.nightscout.androidaps.actions.utils.MenuListActivity; +import info.nightscout.androidaps.actions.wizard.WizardActivity; + +/** + * Created by adrian on 09/02/17. + */ + +public class MainMenuActivity extends MenuListActivity { + + @Override + protected String[] getElements() { + return new String[] { + "TTarget", + "Wizard", + "Settings", + "Re-Sync", + "Status", + "Prime/Fill"}; + } + + @Override + protected void doAction(int position) { + + Intent intent; + switch (position) { + case 0: + break; + case 1: + intent = new Intent(this, WizardActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + this.startActivity(intent); + break; + case 2: + intent = new Intent(this, NWPreferences.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + this.startActivity(intent); + break; + case 3: + ListenerService.requestData(this); + break; + case 4: + intent = new Intent(this, StatusMenuActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + this.startActivity(intent); + break; + case 5: + intent = new Intent(this, FillMenuActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + this.startActivity(intent); + break; + } + + } +} diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/StatusMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/StatusMenuActivity.java new file mode 100644 index 0000000000..fa18b3f2d8 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/actions/StatusMenuActivity.java @@ -0,0 +1,39 @@ +package info.nightscout.androidaps.actions; + +import info.nightscout.androidaps.ListenerService; +import info.nightscout.androidaps.actions.utils.MenuListActivity; + +/** + * Created by adrian on 09/02/17. + */ + +public class StatusMenuActivity extends MenuListActivity { + + @Override + protected String[] getElements() { + return new String[] { + "General", + "Pump", + "Loop", + "Targets"}; + } + + @Override + protected void doAction(int position) { + switch (position) { + case 0: + ListenerService.initiateAction(this, "status general"); + break; + case 1: + ListenerService.initiateAction(this, "status pump"); + break; + case 2: + ListenerService.initiateAction(this, "status loop"); + break; + case 3: + ListenerService.initiateAction(this, "status targets"); + break; + } + + } +} diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsListActivity.java b/wear/src/main/java/info/nightscout/androidaps/actions/utils/MenuListActivity.java similarity index 92% rename from wear/src/main/java/info/nightscout/androidaps/actions/ActionsListActivity.java rename to wear/src/main/java/info/nightscout/androidaps/actions/utils/MenuListActivity.java index f1202797d4..21898e155d 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/ActionsListActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/actions/utils/MenuListActivity.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.actions; +package info.nightscout.androidaps.actions.utils; import android.app.Activity; import android.content.Context; @@ -15,10 +15,14 @@ import info.nightscout.androidaps.R; * Created by adrian on 08/02/17. */ -public class ActionsListActivity extends Activity +public abstract class MenuListActivity extends Activity implements WearableListView.ClickListener { - String[] elements = ActionsDefinitions.getActionNames(); + String[] elements = getElements(); + + protected abstract String[] getElements(); + + protected abstract void doAction(int position); @Override protected void onCreate(Bundle savedInstanceState) { @@ -40,7 +44,7 @@ public class ActionsListActivity extends Activity @Override public void onClick(WearableListView.ViewHolder v) { Integer tag = (Integer) v.itemView.getTag(); - ActionsDefinitions.doAction(tag, this); + doAction(tag); //ActionsDefinitions.doAction(v.getAdapterPosition(), this); finish(); } From 3ff41af939b9c4a812861ef942e0af0dae0e3a4f Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 9 Feb 2017 20:54:41 +0100 Subject: [PATCH 24/48] wear bolus activity and refactoring --- .../androidaps/plugins/Wear/WearFragment.java | 10 +- wear/src/main/AndroidManifest.xml | 34 ++--- .../androidaps/{ => data}/BasalWatchData.java | 2 +- .../androidaps/{ => data}/BgWatchData.java | 2 +- .../{ => data}/ListenerService.java | 6 +- .../androidaps/{ => data}/TempWatchData.java | 2 +- .../{ => interaction}/NWPreferences.java | 2 +- .../interaction/actions/BolusActivity.java | 117 ++++++++++++++++++ .../actions}/WizardActivity.java | 8 +- .../menus}/FillMenuActivity.java | 10 +- .../menus}/MainMenuActivity.java | 25 ++-- .../menus}/StatusMenuActivity.java | 6 +- .../utils/MenuListActivity.java | 2 +- .../utils/PlusMinusEditText.java | 2 +- .../utils/SafeParse.java | 2 +- .../utils}/WearableListItemLayout.java | 2 +- .../androidaps/{ => watchfaces}/BIGChart.java | 9 +- .../{ => watchfaces}/BaseWatchFace.java | 7 +- .../{ => watchfaces}/BgGraphBuilder.java | 6 +- .../{ => watchfaces}/CircleWatchface.java | 6 +- .../androidaps/{ => watchfaces}/Home.java | 5 +- .../{ => watchfaces}/LargeHome.java | 5 +- .../src/main/res/layout/activity_bigchart.xml | 2 +- wear/src/main/res/layout/activity_home.xml | 2 +- .../main/res/layout/activity_home_large.xml | 2 +- wear/src/main/res/layout/list_item.xml | 4 +- .../res/layout/rect_activity_bigchart.xml | 2 +- .../main/res/layout/rect_activity_home.xml | 2 +- .../res/layout/rect_activity_home_large.xml | 2 +- .../res/layout/round_activity_bigchart.xml | 2 +- .../main/res/layout/round_activity_home.xml | 2 +- .../res/layout/round_activity_home_large.xml | 2 +- wear/src/main/res/values/strings.xml | 4 +- wear/src/main/res/xml/preferences.xml | 9 ++ 34 files changed, 222 insertions(+), 83 deletions(-) rename wear/src/main/java/info/nightscout/androidaps/{ => data}/BasalWatchData.java (78%) rename wear/src/main/java/info/nightscout/androidaps/{ => data}/BgWatchData.java (95%) rename wear/src/main/java/info/nightscout/androidaps/{ => data}/ListenerService.java (99%) rename wear/src/main/java/info/nightscout/androidaps/{ => data}/TempWatchData.java (83%) rename wear/src/main/java/info/nightscout/androidaps/{ => interaction}/NWPreferences.java (89%) create mode 100644 wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java rename wear/src/main/java/info/nightscout/androidaps/{actions/wizard => interaction/actions}/WizardActivity.java (96%) rename wear/src/main/java/info/nightscout/androidaps/{actions => interaction/menus}/FillMenuActivity.java (70%) rename wear/src/main/java/info/nightscout/androidaps/{actions => interaction/menus}/MainMenuActivity.java (71%) rename wear/src/main/java/info/nightscout/androidaps/{actions => interaction/menus}/StatusMenuActivity.java (82%) rename wear/src/main/java/info/nightscout/androidaps/{actions => interaction}/utils/MenuListActivity.java (98%) rename wear/src/main/java/info/nightscout/androidaps/{actions => interaction}/utils/PlusMinusEditText.java (99%) rename wear/src/main/java/info/nightscout/androidaps/{actions => interaction}/utils/SafeParse.java (93%) rename wear/src/main/java/info/nightscout/androidaps/{actions => interaction/utils}/WearableListItemLayout.java (97%) rename wear/src/main/java/info/nightscout/androidaps/{ => watchfaces}/BIGChart.java (98%) rename wear/src/main/java/info/nightscout/androidaps/{ => watchfaces}/BaseWatchFace.java (98%) rename wear/src/main/java/info/nightscout/androidaps/{ => watchfaces}/BgGraphBuilder.java (98%) rename wear/src/main/java/info/nightscout/androidaps/{ => watchfaces}/CircleWatchface.java (99%) rename wear/src/main/java/info/nightscout/androidaps/{ => watchfaces}/Home.java (98%) rename wear/src/main/java/info/nightscout/androidaps/{ => watchfaces}/LargeHome.java (97%) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java index 26a67957c5..8f4e7f9be2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/WearFragment.java @@ -42,15 +42,7 @@ public class WearFragment extends Fragment implements FragmentBase { view.findViewById(R.id.wear_opensettings).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - //TODO: revert after debugging! - //getPlugin(getContext()).openSettings(); - String title = "CONFIRM"; //TODO: i18n - String message = "Insulin: 7.0U \n" + - "Carbs: 26 \n" + - "CONSTRAINTS APPLIED!!!"; //TODO: apply constraints - String actionstring = "Bolus 7.0 Carbs 26"; //TODO: to be returned by watch if confirmed - getPlugin(getContext()).requestActionConfirmation(title, message, actionstring); - + getPlugin(getContext()).openSettings(); } }); diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index b8856d4818..283e78e897 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -17,7 +17,7 @@ android:value="@integer/google_play_services_version" /> @@ -35,7 +35,7 @@ @@ -53,7 +53,7 @@ @@ -71,7 +71,7 @@ @@ -88,22 +88,14 @@ - + - - - - - - @@ -111,16 +103,24 @@ + + + + \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/BasalWatchData.java b/wear/src/main/java/info/nightscout/androidaps/data/BasalWatchData.java similarity index 78% rename from wear/src/main/java/info/nightscout/androidaps/BasalWatchData.java rename to wear/src/main/java/info/nightscout/androidaps/data/BasalWatchData.java index 46b913aa7e..ebed526ec8 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BasalWatchData.java +++ b/wear/src/main/java/info/nightscout/androidaps/data/BasalWatchData.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps; +package info.nightscout.androidaps.data; /** * Created by adrian on 18/11/16. diff --git a/wear/src/main/java/info/nightscout/androidaps/BgWatchData.java b/wear/src/main/java/info/nightscout/androidaps/data/BgWatchData.java similarity index 95% rename from wear/src/main/java/info/nightscout/androidaps/BgWatchData.java rename to wear/src/main/java/info/nightscout/androidaps/data/BgWatchData.java index 5e6df3c3da..48d106a116 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BgWatchData.java +++ b/wear/src/main/java/info/nightscout/androidaps/data/BgWatchData.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps; +package info.nightscout.androidaps.data; /** * Created by emmablack on 1/7/15. diff --git a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java similarity index 99% rename from wear/src/main/java/info/nightscout/androidaps/ListenerService.java rename to wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java index d1cb44093d..7ed19e513e 100644 --- a/wear/src/main/java/info/nightscout/androidaps/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java @@ -1,9 +1,8 @@ -package info.nightscout.androidaps; +package info.nightscout.androidaps.data; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; -import android.graphics.Color; import android.os.AsyncTask; import android.os.Bundle; import android.preference.PreferenceManager; @@ -25,6 +24,9 @@ import com.google.android.gms.wearable.WearableListenerService; import java.util.concurrent.TimeUnit; +import info.nightscout.androidaps.interaction.NWPreferences; +import info.nightscout.androidaps.R; + /** * Created by emmablack on 12/26/14. */ diff --git a/wear/src/main/java/info/nightscout/androidaps/TempWatchData.java b/wear/src/main/java/info/nightscout/androidaps/data/TempWatchData.java similarity index 83% rename from wear/src/main/java/info/nightscout/androidaps/TempWatchData.java rename to wear/src/main/java/info/nightscout/androidaps/data/TempWatchData.java index 4b0854c3fc..a7a23962eb 100644 --- a/wear/src/main/java/info/nightscout/androidaps/TempWatchData.java +++ b/wear/src/main/java/info/nightscout/androidaps/data/TempWatchData.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps; +package info.nightscout.androidaps.data; /** * Created by adrian on 17/11/16. diff --git a/wear/src/main/java/info/nightscout/androidaps/NWPreferences.java b/wear/src/main/java/info/nightscout/androidaps/interaction/NWPreferences.java similarity index 89% rename from wear/src/main/java/info/nightscout/androidaps/NWPreferences.java rename to wear/src/main/java/info/nightscout/androidaps/interaction/NWPreferences.java index a6e23c23cd..40f7b08c8f 100644 --- a/wear/src/main/java/info/nightscout/androidaps/NWPreferences.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/NWPreferences.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps; +package info.nightscout.androidaps.interaction; import android.os.Bundle; diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java new file mode 100644 index 0000000000..33e07b071b --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java @@ -0,0 +1,117 @@ +package info.nightscout.androidaps.interaction.actions; + + +import android.app.Activity; +import android.content.res.Resources; +import android.os.Bundle; +import android.support.wearable.view.DotsPageIndicator; +import android.support.wearable.view.GridPagerAdapter; +import android.support.wearable.view.GridViewPager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import java.text.DecimalFormat; + +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.data.ListenerService; +import info.nightscout.androidaps.interaction.utils.PlusMinusEditText; +import info.nightscout.androidaps.interaction.utils.SafeParse; + +/** + * Created by adrian on 09/02/17. + */ + + +public class BolusActivity extends Activity { + + PlusMinusEditText editCarbs; + PlusMinusEditText editInsulin; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.grid_layout); + final Resources res = getResources(); + final GridViewPager pager = (GridViewPager) findViewById(R.id.pager); + + pager.setAdapter(new MyGridViewPagerAdapter()); + DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator); + dotsPageIndicator.setPager(pager); + } + + + @Override + protected void onPause() { + super.onPause(); + finish(); + } + + + private class MyGridViewPagerAdapter extends GridPagerAdapter { + @Override + public int getColumnCount(int arg0) { + return 3; + } + + @Override + public int getRowCount() { + return 1; + } + + @Override + public Object instantiateItem(ViewGroup container, int row, int col) { + + if(col == 0){ + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); + final TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText("insulin"); + editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false); + container.addView(view); + return view; + } else if(col == 1){ + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); + final TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText("carbs"); + editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 100d, 1d, new DecimalFormat("0"), false); + container.addView(view); + return view; + } else { + + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false); + final ImageView confirmbutton = (ImageView) view.findViewById(R.id.confirmbutton); + confirmbutton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + //check if it can happen that the fagment is never created that hold data? + // (you have to swipe past them anyways - but still) + + String actionstring = "bolus " +SafeParse.stringToDouble(editInsulin.editText.getText().toString()) + + " " + SafeParse.stringToInt(editCarbs.editText.getText().toString()); + ListenerService.initiateAction(BolusActivity.this, actionstring); + finish(); + } + }); + container.addView(view); + return view; + } + } + + @Override + public void destroyItem(ViewGroup container, int row, int col, Object view) { + // Handle this to get the data before the view is destroyed? + // Object should still be kept by this, just setup for reinit? + container.removeView((View)view); + } + + @Override + public boolean isViewFromObject(View view, Object object) { + return view==object; + } + + + } +} \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/wizard/WizardActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java similarity index 96% rename from wear/src/main/java/info/nightscout/androidaps/actions/wizard/WizardActivity.java rename to wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java index a01439a639..50f77bb4b8 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/wizard/WizardActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.actions.wizard; +package info.nightscout.androidaps.interaction.actions; import android.app.Activity; @@ -15,10 +15,10 @@ import android.widget.TextView; import java.text.DecimalFormat; -import info.nightscout.androidaps.ListenerService; +import info.nightscout.androidaps.data.ListenerService; import info.nightscout.androidaps.R; -import info.nightscout.androidaps.actions.utils.PlusMinusEditText; -import info.nightscout.androidaps.actions.utils.SafeParse; +import info.nightscout.androidaps.interaction.utils.PlusMinusEditText; +import info.nightscout.androidaps.interaction.utils.SafeParse; /** * Created by adrian on 09/02/17. diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/FillMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java similarity index 70% rename from wear/src/main/java/info/nightscout/androidaps/actions/FillMenuActivity.java rename to wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java index b1ee084ec7..fddefda3d3 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/FillMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java @@ -1,11 +1,7 @@ -package info.nightscout.androidaps.actions; +package info.nightscout.androidaps.interaction.menus; -import android.content.Intent; - -import info.nightscout.androidaps.ListenerService; -import info.nightscout.androidaps.NWPreferences; -import info.nightscout.androidaps.actions.utils.MenuListActivity; -import info.nightscout.androidaps.actions.wizard.WizardActivity; +import info.nightscout.androidaps.data.ListenerService; +import info.nightscout.androidaps.interaction.utils.MenuListActivity; /** * Created by adrian on 09/02/17. diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/MainMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java similarity index 71% rename from wear/src/main/java/info/nightscout/androidaps/actions/MainMenuActivity.java rename to wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java index ab73ad769b..ff3d7348f4 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/MainMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java @@ -1,11 +1,12 @@ -package info.nightscout.androidaps.actions; +package info.nightscout.androidaps.interaction.menus; import android.content.Intent; -import info.nightscout.androidaps.ListenerService; -import info.nightscout.androidaps.NWPreferences; -import info.nightscout.androidaps.actions.utils.MenuListActivity; -import info.nightscout.androidaps.actions.wizard.WizardActivity; +import info.nightscout.androidaps.data.ListenerService; +import info.nightscout.androidaps.interaction.NWPreferences; +import info.nightscout.androidaps.interaction.actions.BolusActivity; +import info.nightscout.androidaps.interaction.utils.MenuListActivity; +import info.nightscout.androidaps.interaction.actions.WizardActivity; /** * Created by adrian on 09/02/17. @@ -17,6 +18,7 @@ public class MainMenuActivity extends MenuListActivity { protected String[] getElements() { return new String[] { "TTarget", + "Bolus", "Wizard", "Settings", "Re-Sync", @@ -32,24 +34,29 @@ public class MainMenuActivity extends MenuListActivity { case 0: break; case 1: - intent = new Intent(this, WizardActivity.class); + intent = new Intent(this, BolusActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); this.startActivity(intent); break; case 2: - intent = new Intent(this, NWPreferences.class); + intent = new Intent(this, WizardActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); this.startActivity(intent); break; case 3: - ListenerService.requestData(this); + intent = new Intent(this, NWPreferences.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + this.startActivity(intent); break; case 4: + ListenerService.requestData(this); + break; + case 5: intent = new Intent(this, StatusMenuActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); this.startActivity(intent); break; - case 5: + case 6: intent = new Intent(this, FillMenuActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); this.startActivity(intent); diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/StatusMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java similarity index 82% rename from wear/src/main/java/info/nightscout/androidaps/actions/StatusMenuActivity.java rename to wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java index fa18b3f2d8..85cab526c9 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/StatusMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java @@ -1,7 +1,7 @@ -package info.nightscout.androidaps.actions; +package info.nightscout.androidaps.interaction.menus; -import info.nightscout.androidaps.ListenerService; -import info.nightscout.androidaps.actions.utils.MenuListActivity; +import info.nightscout.androidaps.data.ListenerService; +import info.nightscout.androidaps.interaction.utils.MenuListActivity; /** * Created by adrian on 09/02/17. diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/utils/MenuListActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java similarity index 98% rename from wear/src/main/java/info/nightscout/androidaps/actions/utils/MenuListActivity.java rename to wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java index 21898e155d..6855505c0a 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/utils/MenuListActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.actions.utils; +package info.nightscout.androidaps.interaction.utils; import android.app.Activity; import android.content.Context; diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/utils/PlusMinusEditText.java b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.java similarity index 99% rename from wear/src/main/java/info/nightscout/androidaps/actions/utils/PlusMinusEditText.java rename to wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.java index b92603c567..0cbae9fecf 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/utils/PlusMinusEditText.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/PlusMinusEditText.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.actions.utils; +package info.nightscout.androidaps.interaction.utils; import android.os.Handler; import android.os.Message; diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/utils/SafeParse.java b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/SafeParse.java similarity index 93% rename from wear/src/main/java/info/nightscout/androidaps/actions/utils/SafeParse.java rename to wear/src/main/java/info/nightscout/androidaps/interaction/utils/SafeParse.java index 2f896155fb..0d654567b0 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/utils/SafeParse.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/SafeParse.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.actions.utils; +package info.nightscout.androidaps.interaction.utils; /** * Created by mike on 23.06.2016. diff --git a/wear/src/main/java/info/nightscout/androidaps/actions/WearableListItemLayout.java b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/WearableListItemLayout.java similarity index 97% rename from wear/src/main/java/info/nightscout/androidaps/actions/WearableListItemLayout.java rename to wear/src/main/java/info/nightscout/androidaps/interaction/utils/WearableListItemLayout.java index bb027ba438..a97305d7e2 100644 --- a/wear/src/main/java/info/nightscout/androidaps/actions/WearableListItemLayout.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/WearableListItemLayout.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps.actions; +package info.nightscout.androidaps.interaction.utils; import android.content.Context; import android.graphics.drawable.GradientDrawable; diff --git a/wear/src/main/java/info/nightscout/androidaps/BIGChart.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BIGChart.java similarity index 98% rename from wear/src/main/java/info/nightscout/androidaps/BIGChart.java rename to wear/src/main/java/info/nightscout/androidaps/watchfaces/BIGChart.java index 9ead9cecfd..866f559a9f 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BIGChart.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BIGChart.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps; +package info.nightscout.androidaps.watchfaces; import android.content.BroadcastReceiver; import android.content.Context; @@ -39,7 +39,12 @@ import com.ustwo.clockwise.common.WatchShape; import java.util.ArrayList; import java.util.Date; -import info.nightscout.androidaps.actions.MainMenuActivity; +import info.nightscout.androidaps.data.BasalWatchData; +import info.nightscout.androidaps.data.BgWatchData; +import info.nightscout.androidaps.data.ListenerService; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.data.TempWatchData; +import info.nightscout.androidaps.interaction.menus.MainMenuActivity; import lecho.lib.hellocharts.view.LineChartView; /** diff --git a/wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java similarity index 98% rename from wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java rename to wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java index ce594f1d2f..d3d1b47c78 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps; +package info.nightscout.androidaps.watchfaces; import android.content.BroadcastReceiver; import android.content.Context; @@ -34,6 +34,11 @@ import com.ustwo.clockwise.common.WatchShape; import java.util.ArrayList; import java.util.Date; +import info.nightscout.androidaps.data.BasalWatchData; +import info.nightscout.androidaps.data.BgWatchData; +import info.nightscout.androidaps.data.ListenerService; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.data.TempWatchData; import lecho.lib.hellocharts.view.LineChartView; /** diff --git a/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.java similarity index 98% rename from wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java rename to wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.java index 825c256678..6a0f9679a7 100644 --- a/wear/src/main/java/info/nightscout/androidaps/BgGraphBuilder.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BgGraphBuilder.java @@ -1,9 +1,8 @@ -package info.nightscout.androidaps; +package info.nightscout.androidaps.watchfaces; import android.content.Context; import android.graphics.DashPathEffect; import android.preference.PreferenceManager; -import android.support.v4.content.ContextCompat; import android.text.format.DateFormat; import java.text.SimpleDateFormat; @@ -14,6 +13,9 @@ import java.util.GregorianCalendar; import java.util.List; import java.util.TimeZone; +import info.nightscout.androidaps.data.BasalWatchData; +import info.nightscout.androidaps.data.BgWatchData; +import info.nightscout.androidaps.data.TempWatchData; import lecho.lib.hellocharts.model.Axis; import lecho.lib.hellocharts.model.AxisValue; import lecho.lib.hellocharts.model.Line; diff --git a/wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/CircleWatchface.java similarity index 99% rename from wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java rename to wear/src/main/java/info/nightscout/androidaps/watchfaces/CircleWatchface.java index 6bf669283e..795a1221b3 100644 --- a/wear/src/main/java/info/nightscout/androidaps/CircleWatchface.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/CircleWatchface.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps; +package info.nightscout.androidaps.watchfaces; import android.content.BroadcastReceiver; import android.content.Context; @@ -36,7 +36,9 @@ import java.util.Date; import java.util.HashSet; import java.util.TreeSet; -import info.nightscout.androidaps.actions.MainMenuActivity; +import info.nightscout.androidaps.data.BgWatchData; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.interaction.menus.MainMenuActivity; public class CircleWatchface extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener { diff --git a/wear/src/main/java/info/nightscout/androidaps/Home.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home.java similarity index 98% rename from wear/src/main/java/info/nightscout/androidaps/Home.java rename to wear/src/main/java/info/nightscout/androidaps/watchfaces/Home.java index 2d73ef0661..ba557f200b 100644 --- a/wear/src/main/java/info/nightscout/androidaps/Home.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps; +package info.nightscout.androidaps.watchfaces; import android.content.Intent; import android.graphics.Color; @@ -8,7 +8,8 @@ import android.view.LayoutInflater; import com.ustwo.clockwise.common.WatchMode; -import info.nightscout.androidaps.actions.MainMenuActivity; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.interaction.menus.MainMenuActivity; public class Home extends BaseWatchFace { diff --git a/wear/src/main/java/info/nightscout/androidaps/LargeHome.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/LargeHome.java similarity index 97% rename from wear/src/main/java/info/nightscout/androidaps/LargeHome.java rename to wear/src/main/java/info/nightscout/androidaps/watchfaces/LargeHome.java index ecb0735af3..2cb09c9b7b 100644 --- a/wear/src/main/java/info/nightscout/androidaps/LargeHome.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/LargeHome.java @@ -1,4 +1,4 @@ -package info.nightscout.androidaps; +package info.nightscout.androidaps.watchfaces; import android.content.Intent; import android.graphics.Color; @@ -8,7 +8,8 @@ import android.view.LayoutInflater; import com.ustwo.clockwise.common.WatchMode; -import info.nightscout.androidaps.actions.MainMenuActivity; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.interaction.menus.MainMenuActivity; public class LargeHome extends BaseWatchFace { diff --git a/wear/src/main/res/layout/activity_bigchart.xml b/wear/src/main/res/layout/activity_bigchart.xml index 1fa3cdad8d..719b803c5e 100644 --- a/wear/src/main/res/layout/activity_bigchart.xml +++ b/wear/src/main/res/layout/activity_bigchart.xml @@ -8,5 +8,5 @@ android:layout_height="match_parent" app:rectLayout="@layout/rect_activity_bigchart" app:roundLayout="@layout/round_activity_bigchart" - tools:context=".Home" + tools:context=".watchfaces.Home" tools:deviceIds="wear"/> diff --git a/wear/src/main/res/layout/activity_home.xml b/wear/src/main/res/layout/activity_home.xml index 152f7869a6..a536938f68 100644 --- a/wear/src/main/res/layout/activity_home.xml +++ b/wear/src/main/res/layout/activity_home.xml @@ -8,5 +8,5 @@ android:layout_height="match_parent" app:rectLayout="@layout/rect_activity_home" app:roundLayout="@layout/round_activity_home" - tools:context=".Home" + tools:context=".watchfaces.Home" tools:deviceIds="wear"/> diff --git a/wear/src/main/res/layout/activity_home_large.xml b/wear/src/main/res/layout/activity_home_large.xml index 3af188265c..adff439ea1 100644 --- a/wear/src/main/res/layout/activity_home_large.xml +++ b/wear/src/main/res/layout/activity_home_large.xml @@ -8,5 +8,5 @@ android:layout_height="match_parent" app:rectLayout="@layout/rect_activity_home_large" app:roundLayout="@layout/round_activity_home_large" - tools:context=".Home" + tools:context=".watchfaces.Home" tools:deviceIds="wear"/> diff --git a/wear/src/main/res/layout/list_item.xml b/wear/src/main/res/layout/list_item.xml index 4ca65adaa6..6bb172b3d9 100644 --- a/wear/src/main/res/layout/list_item.xml +++ b/wear/src/main/res/layout/list_item.xml @@ -1,4 +1,4 @@ - - + diff --git a/wear/src/main/res/layout/rect_activity_bigchart.xml b/wear/src/main/res/layout/rect_activity_bigchart.xml index 9fa101227c..8db4a3dd15 100644 --- a/wear/src/main/res/layout/rect_activity_bigchart.xml +++ b/wear/src/main/res/layout/rect_activity_bigchart.xml @@ -1,7 +1,7 @@ diff --git a/wear/src/main/res/layout/rect_activity_home.xml b/wear/src/main/res/layout/rect_activity_home.xml index 344321fea6..a069b5ed28 100644 --- a/wear/src/main/res/layout/rect_activity_home.xml +++ b/wear/src/main/res/layout/rect_activity_home.xml @@ -1,7 +1,7 @@ diff --git a/wear/src/main/res/layout/rect_activity_home_large.xml b/wear/src/main/res/layout/rect_activity_home_large.xml index 20cc6ee40f..a6da174128 100644 --- a/wear/src/main/res/layout/rect_activity_home_large.xml +++ b/wear/src/main/res/layout/rect_activity_home_large.xml @@ -1,7 +1,7 @@ diff --git a/wear/src/main/res/layout/round_activity_bigchart.xml b/wear/src/main/res/layout/round_activity_bigchart.xml index 9fa101227c..8db4a3dd15 100644 --- a/wear/src/main/res/layout/round_activity_bigchart.xml +++ b/wear/src/main/res/layout/round_activity_bigchart.xml @@ -1,7 +1,7 @@ diff --git a/wear/src/main/res/layout/round_activity_home.xml b/wear/src/main/res/layout/round_activity_home.xml index 231a0910b8..e647175bf4 100644 --- a/wear/src/main/res/layout/round_activity_home.xml +++ b/wear/src/main/res/layout/round_activity_home.xml @@ -1,7 +1,7 @@ diff --git a/wear/src/main/res/layout/round_activity_home_large.xml b/wear/src/main/res/layout/round_activity_home_large.xml index 6217af3a5c..9569d5d1ab 100644 --- a/wear/src/main/res/layout/round_activity_home_large.xml +++ b/wear/src/main/res/layout/round_activity_home_large.xml @@ -1,7 +1,7 @@ diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml index 4ef81f535e..3df2ef00e3 100644 --- a/wear/src/main/res/values/strings.xml +++ b/wear/src/main/res/values/strings.xml @@ -1,8 +1,8 @@ - AAPS Prefs. - AAPS Actions + AAPS + AAPS 1 hour diff --git a/wear/src/main/res/xml/preferences.xml b/wear/src/main/res/xml/preferences.xml index d5c8503423..f19fe60110 100644 --- a/wear/src/main/res/xml/preferences.xml +++ b/wear/src/main/res/xml/preferences.xml @@ -9,6 +9,15 @@ app:wear_iconOff="@drawable/settings_off" app:wear_iconOn="@drawable/settings_on" /> + + Date: Thu, 9 Feb 2017 21:40:00 +0100 Subject: [PATCH 25/48] wear temp target activity --- wear/src/main/AndroidManifest.xml | 12 +- .../androidaps/data/ListenerService.java | 4 +- ...WPreferences.java => AAPSPreferences.java} | 8 +- .../interaction/actions/FillActivity.java | 108 +++++++++++++ .../actions/TempTargetActivity.java | 149 ++++++++++++++++++ .../interaction/menus/FillMenuActivity.java | 12 +- .../interaction/menus/MainMenuActivity.java | 8 +- .../interaction/utils/MenuListActivity.java | 6 + 8 files changed, 299 insertions(+), 8 deletions(-) rename wear/src/main/java/info/nightscout/androidaps/interaction/{NWPreferences.java => AAPSPreferences.java} (71%) create mode 100644 wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java create mode 100644 wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java diff --git a/wear/src/main/AndroidManifest.xml b/wear/src/main/AndroidManifest.xml index 283e78e897..8909f8a3f8 100644 --- a/wear/src/main/AndroidManifest.xml +++ b/wear/src/main/AndroidManifest.xml @@ -103,8 +103,8 @@ + android:name=".interaction.AAPSPreferences" + android:label="SETTINGS"> + + + + \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java index 7ed19e513e..d16f0d4324 100644 --- a/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java @@ -24,7 +24,7 @@ import com.google.android.gms.wearable.WearableListenerService; import java.util.concurrent.TimeUnit; -import info.nightscout.androidaps.interaction.NWPreferences; +import info.nightscout.androidaps.interaction.AAPSPreferences; import info.nightscout.androidaps.R; /** @@ -227,7 +227,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp String path = event.getDataItem().getUri().getPath(); if (path.equals(OPEN_SETTINGS)) { - Intent intent = new Intent(this, NWPreferences.class); + Intent intent = new Intent(this, AAPSPreferences.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } else if (path.equals(BOLUS_PROGRESS_PATH)) { diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/NWPreferences.java b/wear/src/main/java/info/nightscout/androidaps/interaction/AAPSPreferences.java similarity index 71% rename from wear/src/main/java/info/nightscout/androidaps/interaction/NWPreferences.java rename to wear/src/main/java/info/nightscout/androidaps/interaction/AAPSPreferences.java index 40f7b08c8f..6142937206 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/NWPreferences.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/AAPSPreferences.java @@ -7,7 +7,7 @@ import android.preference.PreferenceActivity; import info.nightscout.androidaps.R; import preference.WearPreferenceActivity; -public class NWPreferences extends WearPreferenceActivity { +public class AAPSPreferences extends WearPreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { @@ -15,4 +15,10 @@ public class NWPreferences extends WearPreferenceActivity { addPreferencesFromResource(R.xml.preferences); } + @Override + protected void onPause(){ + super.onPause(); + finish(); + } + } \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java new file mode 100644 index 0000000000..9f88cc318d --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java @@ -0,0 +1,108 @@ +package info.nightscout.androidaps.interaction.actions; + + +import android.app.Activity; +import android.content.res.Resources; +import android.os.Bundle; +import android.support.wearable.view.DotsPageIndicator; +import android.support.wearable.view.GridPagerAdapter; +import android.support.wearable.view.GridViewPager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import java.text.DecimalFormat; + +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.data.ListenerService; +import info.nightscout.androidaps.interaction.utils.PlusMinusEditText; +import info.nightscout.androidaps.interaction.utils.SafeParse; + +/** + * Created by adrian on 09/02/17. + */ + + +public class FillActivity extends Activity { + + PlusMinusEditText editInsulin; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.grid_layout); + final Resources res = getResources(); + final GridViewPager pager = (GridViewPager) findViewById(R.id.pager); + + pager.setAdapter(new MyGridViewPagerAdapter()); + DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator); + dotsPageIndicator.setPager(pager); + } + + + @Override + protected void onPause() { + super.onPause(); + finish(); + } + + + private class MyGridViewPagerAdapter extends GridPagerAdapter { + @Override + public int getColumnCount(int arg0) { + return 3; + } + + @Override + public int getRowCount() { + return 1; + } + + @Override + public Object instantiateItem(ViewGroup container, int row, int col) { + + if(col == 0){ + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); + final TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText("insulin"); + editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false); + container.addView(view); + return view; + } else { + + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false); + final ImageView confirmbutton = (ImageView) view.findViewById(R.id.confirmbutton); + confirmbutton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + //check if it can happen that the fagment is never created that hold data? + // (you have to swipe past them anyways - but still) + + String actionstring = "fill " +SafeParse.stringToDouble(editInsulin.editText.getText().toString()); + ListenerService.initiateAction(FillActivity.this, actionstring); + finish(); + } + }); + container.addView(view); + return view; + } + } + + @Override + public void destroyItem(ViewGroup container, int row, int col, Object view) { + // Handle this to get the data before the view is destroyed? + // Object should still be kept by this, just setup for reinit? + container.removeView((View)view); + } + + @Override + public boolean isViewFromObject(View view, Object object) { + return view==object; + } + + + } +} \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java new file mode 100644 index 0000000000..5598893eaf --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java @@ -0,0 +1,149 @@ +package info.nightscout.androidaps.interaction.actions; + + +import android.app.Activity; +import android.content.SharedPreferences; +import android.content.res.Resources; +import android.os.Bundle; +import android.preference.PreferenceManager; +import android.support.wearable.view.DotsPageIndicator; +import android.support.wearable.view.GridPagerAdapter; +import android.support.wearable.view.GridViewPager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import java.text.DecimalFormat; + +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.data.ListenerService; +import info.nightscout.androidaps.interaction.utils.PlusMinusEditText; +import info.nightscout.androidaps.interaction.utils.SafeParse; + +import static android.preference.PreferenceManager.getDefaultSharedPreferences; + +/** + * Created by adrian on 09/02/17. + */ + + +public class TempTargetActivity extends Activity { + + PlusMinusEditText lowRange; + PlusMinusEditText highRange; + PlusMinusEditText time; + boolean isMGDL; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.grid_layout); + final Resources res = getResources(); + final GridViewPager pager = (GridViewPager) findViewById(R.id.pager); + + pager.setAdapter(new MyGridViewPagerAdapter()); + DotsPageIndicator dotsPageIndicator = (DotsPageIndicator) findViewById(R.id.page_indicator); + dotsPageIndicator.setPager(pager); + + SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); + isMGDL = sp.getBoolean("units_mgdl", true); + } + + + @Override + protected void onPause() { + super.onPause(); + finish(); + } + + + private class MyGridViewPagerAdapter extends GridPagerAdapter { + @Override + public int getColumnCount(int arg0) { + return 4; + } + + @Override + public int getRowCount() { + return 1; + } + + @Override + public Object instantiateItem(ViewGroup container, int row, int col) { + + if(col == 0){ + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); + final TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText("duration"); + time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 24*60d, 1d, new DecimalFormat("0"), false); + container.addView(view); + return view; + + } else if(col == 1){ + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); + final TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText("low"); + if (isMGDL){ + lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 100d, 72d, 180d, 1d, new DecimalFormat("0"), false); + } else { + lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 5.5, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false); + } + + container.addView(view); + return view; + } else if(col == 2){ + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); + final TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText("high"); + if (isMGDL){ + highRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 100d, 72d, 180d, 1d, new DecimalFormat("0"), false); + } else { + highRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 5.5, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false); + } + + container.addView(view); + return view; + }else { + + final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false); + final ImageView confirmbutton = (ImageView) view.findViewById(R.id.confirmbutton); + confirmbutton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + //check if it can happen that the fagment is never created that hold data? + // (you have to swipe past them anyways - but still) + + String actionstring = "temptarget " + + SafeParse.stringToInt(time.editText.getText().toString()) + + " " + isMGDL + + " " + SafeParse.stringToDouble(lowRange.editText.getText().toString()) + + " " + SafeParse.stringToDouble(highRange.editText.getText().toString()) + ; + + ListenerService.initiateAction(TempTargetActivity.this, actionstring); + finish(); + } + }); + container.addView(view); + return view; + } + } + + @Override + public void destroyItem(ViewGroup container, int row, int col, Object view) { + // Handle this to get the data before the view is destroyed? + // Object should still be kept by this, just setup for reinit? + container.removeView((View)view); + } + + @Override + public boolean isViewFromObject(View view, Object object) { + return view==object; + } + + + } +} \ No newline at end of file diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java index fddefda3d3..da8daa80cb 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/FillMenuActivity.java @@ -1,6 +1,9 @@ package info.nightscout.androidaps.interaction.menus; +import android.content.Intent; + import info.nightscout.androidaps.data.ListenerService; +import info.nightscout.androidaps.interaction.actions.FillActivity; import info.nightscout.androidaps.interaction.utils.MenuListActivity; /** @@ -14,7 +17,9 @@ public class FillMenuActivity extends MenuListActivity { return new String[] { "Preset 1", "Preset 2", - "Preset 3"}; + "Preset 3", + "Free amount" + }; } @Override @@ -29,6 +34,11 @@ public class FillMenuActivity extends MenuListActivity { case 2: ListenerService.initiateAction(this, "fillpreset 3"); break; + case 3: + Intent intent = new Intent(this, FillActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + this.startActivity(intent); + break; } } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java index ff3d7348f4..a6ef6666db 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java @@ -3,8 +3,9 @@ package info.nightscout.androidaps.interaction.menus; import android.content.Intent; import info.nightscout.androidaps.data.ListenerService; -import info.nightscout.androidaps.interaction.NWPreferences; +import info.nightscout.androidaps.interaction.AAPSPreferences; import info.nightscout.androidaps.interaction.actions.BolusActivity; +import info.nightscout.androidaps.interaction.actions.TempTargetActivity; import info.nightscout.androidaps.interaction.utils.MenuListActivity; import info.nightscout.androidaps.interaction.actions.WizardActivity; @@ -32,6 +33,9 @@ public class MainMenuActivity extends MenuListActivity { Intent intent; switch (position) { case 0: + intent = new Intent(this, TempTargetActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + this.startActivity(intent); break; case 1: intent = new Intent(this, BolusActivity.class); @@ -44,7 +48,7 @@ public class MainMenuActivity extends MenuListActivity { this.startActivity(intent); break; case 3: - intent = new Intent(this, NWPreferences.class); + intent = new Intent(this, AAPSPreferences.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); this.startActivity(intent); break; diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java index 6855505c0a..681ceb134a 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java @@ -24,6 +24,12 @@ public abstract class MenuListActivity extends Activity protected abstract void doAction(int position); + @Override + protected void onPause(){ + super.onPause(); + finish(); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); From aff82642af23ab44e5097f41bf34f5445ec93164 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 9 Feb 2017 23:39:23 +0100 Subject: [PATCH 26/48] wear multiple watch situation and disable fillbolus for wider testing --- .../plugins/Wear/ActionStringHandler.java | 13 ++++++++++++- .../nightscout/androidaps/data/ListenerService.java | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index 56afc45f0c..280de7291e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -75,6 +75,17 @@ public class ActionStringHandler { rAction += "fill " + insulinAfterConstraints; + } else if ("fill".equals(act[0])) { + ///////////////////////////////////// PRIME/FILL + double amount = SafeParse.stringToDouble(act[1]); + + Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(amount); + rMessage += MainApp.instance().getString(R.string.primefill) + ": " + insulinAfterConstraints + "U"; + if (insulinAfterConstraints - amount != 0) + rMessage += "\n" + MainApp.instance().getString(R.string.constraintapllied); + + rAction += "fill " + insulinAfterConstraints; + } else if ("status".equals(act[0])) { ///////////////////////////////////// STATUS rTitle = "STATUS"; @@ -130,7 +141,7 @@ public class ActionStringHandler { // do the parsing, check constraints and enact! String[] act = actionString.split("\\s+"); - if ("fill".equals(act[0])){ + if (false && "fill".equals(act[0])){ Double amount = SafeParse.stringToDouble(act[1]); Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(amount); if(amount - insulinAfterConstraints != 0){ diff --git a/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java index d16f0d4324..00fddef72d 100644 --- a/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java @@ -290,6 +290,8 @@ public class ListenerService extends WearableListenerService implements GoogleAp NotificationManagerCompat.from(this); notificationManager.notify(BOLUS_PROGRESS_NOTIF_ID, notificationBuilder.build()); + notificationManager.cancel(CONFIRM_NOTIF_ID); // multiple watch setup + if (progresspercent == 100){ scheduleDismiss(BOLUS_PROGRESS_NOTIF_ID, 5); From 93de296113974d842c712d3c4f720ab940e1ad0a Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 9 Feb 2017 23:46:41 +0100 Subject: [PATCH 27/48] update wear.iml --- wear/wear.iml | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/wear/wear.iml b/wear/wear.iml index 33cd39a6c1..ff2d500409 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -106,14 +106,6 @@ - - - - - - - - @@ -122,7 +114,14 @@ - + + + + + + + + @@ -135,14 +134,10 @@ - - - - @@ -158,4 +153,4 @@ - \ No newline at end of file + From 9785d507a8fdebe8947aeae59873d335e0ec22de Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Fri, 10 Feb 2017 02:36:38 +0100 Subject: [PATCH 28/48] wear temp targets working --- .../plugins/Wear/ActionStringHandler.java | 112 +++++++++++++++++- .../actions/TempTargetActivity.java | 4 +- wear/wear.iml | 23 ++-- 3 files changed, 124 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index 280de7291e..dcc805ed7e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -5,22 +5,32 @@ import android.content.SharedPreferences; import android.os.Handler; import android.os.HandlerThread; import android.preference.PreferenceManager; +import android.support.annotation.BoolRes; import android.support.v7.app.AlertDialog; import android.view.View; +import com.j256.ormlite.dao.Dao; + import org.json.JSONException; import org.json.JSONObject; +import java.sql.SQLException; import java.text.DecimalFormat; import java.util.Date; +import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.db.BgReading; +import info.nightscout.androidaps.db.TempTarget; +import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.QuickWizard; +import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin; +import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange; import info.nightscout.client.data.NSProfile; import info.nightscout.utils.BolusWizard; import info.nightscout.utils.DateUtil; @@ -76,7 +86,7 @@ public class ActionStringHandler { rAction += "fill " + insulinAfterConstraints; } else if ("fill".equals(act[0])) { - ///////////////////////////////////// PRIME/FILL + ////////////////////////////////////////////// PRIME/FILL double amount = SafeParse.stringToDouble(act[1]); Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(amount); @@ -86,11 +96,68 @@ public class ActionStringHandler { rAction += "fill " + insulinAfterConstraints; + } else if ("bolus".equals(act[0])) { + ////////////////////////////////////////////// BOLUS + double insulin = SafeParse.stringToDouble(act[1]); + int carbs = SafeParse.stringToInt(act[2]); + Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(insulin); + Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(carbs); + rMessage += MainApp.instance().getString(R.string.bolus) + ": " + insulinAfterConstraints + "U\n"; + rMessage += MainApp.instance().getString(R.string.carbs) + ": " + carbsAfterConstraints + "g"; + + if ((insulinAfterConstraints - insulin != 0) || (carbsAfterConstraints - carbs != 0)) { + rMessage += "\n" + MainApp.instance().getString(R.string.constraintapllied); + } + rAction += "bolus " + insulinAfterConstraints + " " + carbsAfterConstraints; + + } else if ("temptarget".equals(act[0])) { + ///////////////////////////////////////////////////////// TEMPTARGET + boolean isMGDL = Boolean.parseBoolean(act[1]); + + NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile(); + TempTargetRangePlugin tempTargetRangePlugin = (TempTargetRangePlugin) MainApp.getSpecificPlugin(TempTargetRangePlugin.class); + if (!(Config.APS && tempTargetRangePlugin != null && tempTargetRangePlugin.isEnabled(PluginBase.GENERAL))) { + sendError("TempTargets not possible! Please check your configuration."); + return; + } + if (profile == null) { + sendError("No profile found!"); + return; + } + if(profile.getUnits().equals(Constants.MGDL) != isMGDL){ + sendError("Different units used on watch and phone!"); + return; + } + + int duration = SafeParse.stringToInt(act[2]); + if (duration == 0){ + rMessage += "Zero-Temp-Target - cancelling running Temp-Targets?"; + rAction = "temptarget true 0 0 0"; + } else { + double low = SafeParse.stringToDouble(act[3]); + double high = SafeParse.stringToDouble(act[4]); + if(!isMGDL){ + low *= Constants.MMOLL_TO_MGDL; + high *= Constants.MMOLL_TO_MGDL; + } + if (low < Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[0] || low > Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[1]) { + sendError("Min-BG out of range!"); + return; + } + if (high < Constants.VERY_HARD_LIMIT_TEMP_MAX_BG[0] || high > Constants.VERY_HARD_LIMIT_TEMP_MAX_BG[1]) { + sendError("Max-BG out of range!"); + return; + } + rMessage += "Temptarget:\nMin: " + act[3] + "\nMax: " + act[4] + "\nDuration: " + act[2]; + rAction = actionstring; + + } + } else if ("status".equals(act[0])) { - ///////////////////////////////////// STATUS + ////////////////////////////////////////////// STATUS rTitle = "STATUS"; rAction = "statusmessage"; - //TODO: add meaningfull status + //TODO: add meaningful status if("general".equals(act[1])){ rMessage = "Today is going to be a good day!"; @@ -108,6 +175,7 @@ public class ActionStringHandler { rMessage += "\n\n\nTODO:\nAdd some meaningful status."; } else if ("wizard".equals(act[0])) { + ////////////////////////////////////////////// WIZARD Integer carbsBeforeConstraints = SafeParse.stringToInt(act[1]); Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(carbsBeforeConstraints); //TODO: wizard calculation @@ -141,7 +209,7 @@ public class ActionStringHandler { // do the parsing, check constraints and enact! String[] act = actionString.split("\\s+"); - if (false && "fill".equals(act[0])){ + if ("fill".equals(act[0])){ Double amount = SafeParse.stringToDouble(act[1]); Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(amount); if(amount - insulinAfterConstraints != 0){ @@ -150,12 +218,48 @@ public class ActionStringHandler { return; } doFillBolus(amount); + } else if ("temptarget".equals(act[0])) { + int duration = SafeParse.stringToInt(act[2]); + double low = SafeParse.stringToDouble(act[3]); + double high = SafeParse.stringToDouble(act[4]); + boolean isMGDL = Boolean.parseBoolean(act[1]); + if(!isMGDL){ + low *= Constants.MMOLL_TO_MGDL; + high *= Constants.MMOLL_TO_MGDL; + } + generateTempTarget(duration, low, high); } } + private static void generateTempTarget(int duration, double low, double high) { + TempTarget tempTarget = new TempTarget(); + tempTarget.timeStart = new Date(); + tempTarget.duration = duration; + tempTarget.reason = "WearPlugin"; + if(tempTarget.duration != 0) { + tempTarget.low = low; + tempTarget.high = high; + } else { + tempTarget.low = 0; + tempTarget.high = 0; + } + tempTarget.setTimeIndex(tempTarget.getTimeIndex()); + Dao dao = null; + try { + dao = MainApp.getDbHelper().getDaoTempTargets(); + dao.createIfNotExists(tempTarget); + MainApp.bus().post(new EventTempTargetRangeChange()); + + //TODO: Nightscout-Treatment for Temp-Target! + //ConfigBuilderPlugin.uploadCareportalEntryToNS(data); + } catch (SQLException e) { + e.printStackTrace(); + } + } + private static void doFillBolus(final Double amount) { Handler handler = new Handler(handlerThread.getLooper()); handler.post(new Runnable() { diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java index 5598893eaf..72acea3aaf 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java @@ -77,7 +77,7 @@ public class TempTargetActivity extends Activity { final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); final TextView textView = (TextView) view.findViewById(R.id.label); textView.setText("duration"); - time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 24*60d, 1d, new DecimalFormat("0"), false); + time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 60d, 0d, 24*60d, 1d, new DecimalFormat("0"), false); container.addView(view); return view; @@ -117,8 +117,8 @@ public class TempTargetActivity extends Activity { // (you have to swipe past them anyways - but still) String actionstring = "temptarget " - + SafeParse.stringToInt(time.editText.getText().toString()) + " " + isMGDL + + " " + SafeParse.stringToInt(time.editText.getText().toString()) + " " + SafeParse.stringToDouble(lowRange.editText.getText().toString()) + " " + SafeParse.stringToDouble(highRange.editText.getText().toString()) ; diff --git a/wear/wear.iml b/wear/wear.iml index ff2d500409..33cd39a6c1 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -106,14 +106,6 @@ - - - - - - - - @@ -122,6 +114,15 @@ + + + + + + + + + @@ -134,10 +135,14 @@ + + + + @@ -153,4 +158,4 @@ - + \ No newline at end of file From 4220d7712ad516b9ac45da31ede2e8ac1c92e9ac Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Fri, 10 Feb 2017 06:07:31 +0100 Subject: [PATCH 29/48] wear wizard working --- .../plugins/Wear/ActionStringHandler.java | 89 ++++++++++++++++--- .../info/nightscout/utils/BolusWizard.java | 2 +- .../interaction/actions/FillActivity.java | 2 +- wear/wear.iml | 14 +-- 4 files changed, 87 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index dcc805ed7e..ec24efa7dc 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -48,6 +48,8 @@ public class ActionStringHandler { private static long lastSentTimestamp = 0; private static String lastConfirmActionString = null; + private static BolusWizard lastBolusWizard = null; + private static SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); @@ -58,6 +60,8 @@ public class ActionStringHandler { public synchronized static void handleInitiate(String actionstring){ + lastBolusWizard = null; + String rTitle = "CONFIRM"; //TODO: i18n String rMessage = ""; String rAction = ""; @@ -178,19 +182,59 @@ public class ActionStringHandler { ////////////////////////////////////////////// WIZARD Integer carbsBeforeConstraints = SafeParse.stringToInt(act[1]); Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(carbsBeforeConstraints); - //TODO: wizard calculation - return; - } + if(carbsAfterConstraints - carbsBeforeConstraints !=0){ + sendError("Carb constraint violation!"); return; + } - else if(false){ - //... add more actions + boolean useBG = Boolean.parseBoolean(act[2]); + boolean useBolusIOB = Boolean.parseBoolean(act[3]); + boolean useBasalIOB = Boolean.parseBoolean(act[4]); + + NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile(); + if (profile == null) { + sendError("No profile found!"); return; + } + + BgReading bgReading = MainApp.getDbHelper().actualBg(); + if(bgReading==null && useBG){ + sendError("No recent BG to base calculation on!"); return; + } + + BolusWizard bolusWizard = new BolusWizard(); + bolusWizard.doCalc(profile.getDefaultProfile(), carbsAfterConstraints, useBG?bgReading.valueToUnits(profile.getUnits()):0d, 0d, useBolusIOB, useBasalIOB); + + Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(bolusWizard.calculatedTotalInsulin); + if(insulinAfterConstraints - bolusWizard.calculatedTotalInsulin !=0){ + sendError("Insulin contraint violation!"); return; + } + + + double insulin = bolusWizard.calculatedTotalInsulin; + if(bolusWizard.calculatedTotalInsulin < 0) { + bolusWizard.calculatedTotalInsulin = 0d; + } + + if(bolusWizard.calculatedTotalInsulin <=0 && bolusWizard.carbs <=0){ + rAction = "info"; + rTitle = "INFO"; + } + rAction = actionstring; + + DecimalFormat format = new DecimalFormat("0.00"); + rMessage += "Bolus: " + format.format(bolusWizard.calculatedTotalInsulin) + "U"; + rMessage += "\nWizard: " + format.format(insulin) + "U"; + rMessage += "\nCarb: " + format.format(bolusWizard.insulinFromCarbs) + "U"; + if(useBG)rMessage += "\nBG: " + format.format(bolusWizard.insulinFromBG) + "U"; + if(useBolusIOB)rMessage += "\nBolus IOB: " + format.format(bolusWizard.insulingFromBolusIOB) + "U"; + if(useBasalIOB)rMessage += "\nBasal IOB: " + format.format(bolusWizard.insulingFromBasalsIOB) + "U"; + rMessage += "\nIC:" + DecimalFormatter.to1Decimal(bolusWizard.ic); + if(useBG)rMessage += " ISF:" + DecimalFormatter.to1Decimal(bolusWizard.sens); + + lastBolusWizard = bolusWizard; } else return; - - - // send result WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation(rTitle, rMessage, rAction); lastSentTimestamp = System.currentTimeMillis(); @@ -228,10 +272,17 @@ public class ActionStringHandler { high *= Constants.MMOLL_TO_MGDL; } generateTempTarget(duration, low, high); + } else if ("wizard".equals(act[0])){ + //use last calculation as confirmed string matches + + doBolus(lastBolusWizard.calculatedTotalInsulin, lastBolusWizard.carbs); + lastBolusWizard = null; + } else if ("bolus".equals(act[0])) { + double insulin = SafeParse.stringToDouble(act[1]); + int carbs = SafeParse.stringToInt(act[2]); + doBolus(insulin, carbs); } - - - + lastBolusWizard = null; } private static void generateTempTarget(int duration, double low, double high) { @@ -275,9 +326,25 @@ public class ActionStringHandler { }); } + private static void doBolus(final Double amount, final Integer carbs) { + Handler handler = new Handler(handlerThread.getLooper()); + handler.post(new Runnable() { + @Override + public void run() { + PumpEnactResult result = MainApp.getConfigBuilder().deliverTreatment(amount, carbs, null, true); + if (!result.success) { + sendError(MainApp.sResources.getString(R.string.treatmentdeliveryerror) + + "\n" + + result.comment); + } + } + }); + } + private synchronized static void sendError(String errormessage){ WearFragment.getPlugin(MainApp.instance()).requestActionConfirmation("ERROR", errormessage, "error"); lastSentTimestamp = System.currentTimeMillis(); lastConfirmActionString = null; + lastBolusWizard = null; } } diff --git a/app/src/main/java/info/nightscout/utils/BolusWizard.java b/app/src/main/java/info/nightscout/utils/BolusWizard.java index 61ca2ab2cb..80e907bb6f 100644 --- a/app/src/main/java/info/nightscout/utils/BolusWizard.java +++ b/app/src/main/java/info/nightscout/utils/BolusWizard.java @@ -15,7 +15,7 @@ import info.nightscout.client.data.NSProfile; public class BolusWizard { // Inputs JSONObject specificProfile = null; - Integer carbs = 0; + public Integer carbs = 0; Double bg = 0d; Double correction; Boolean includeBolusIOB = true; diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java index 9f88cc318d..46352f7209 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java @@ -52,7 +52,7 @@ public class FillActivity extends Activity { private class MyGridViewPagerAdapter extends GridPagerAdapter { @Override public int getColumnCount(int arg0) { - return 3; + return 2; } @Override diff --git a/wear/wear.iml b/wear/wear.iml index 33cd39a6c1..ce3df746e7 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -43,13 +43,6 @@ - - - - - - - @@ -58,6 +51,13 @@ + + + + + + + From bdcff12b012c1489824db098b5be8c504da69954 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Fri, 10 Feb 2017 12:00:38 +0100 Subject: [PATCH 30/48] wear keep data when looking/swiping back --- .../interaction/actions/BolusActivity.java | 12 +++++-- .../interaction/actions/FillActivity.java | 6 +++- .../actions/TempTargetActivity.java | 31 ++++++++++++++++--- .../interaction/actions/WizardActivity.java | 23 +++++++++++++- wear/wear.iml | 30 +++++++++--------- 5 files changed, 78 insertions(+), 24 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java index 33e07b071b..78bf406b1c 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java @@ -68,14 +68,22 @@ public class BolusActivity extends Activity { final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); final TextView textView = (TextView) view.findViewById(R.id.label); textView.setText("insulin"); - editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false); + double def = 0; + if (editInsulin != null){ + def = SafeParse.stringToDouble(editInsulin.editText.getText().toString()); + } + editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false); container.addView(view); return view; } else if(col == 1){ final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); final TextView textView = (TextView) view.findViewById(R.id.label); textView.setText("carbs"); - editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 100d, 1d, new DecimalFormat("0"), false); + double def = 0; + if (editCarbs != null){ + def = SafeParse.stringToDouble(editCarbs.editText.getText().toString()); + } + editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 100d, 1d, new DecimalFormat("0"), false); container.addView(view); return view; } else { diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java index 46352f7209..bb926ed584 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java @@ -67,7 +67,11 @@ public class FillActivity extends Activity { final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); final TextView textView = (TextView) view.findViewById(R.id.label); textView.setText("insulin"); - editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false); + double def = 0d; + if (editInsulin != null){ + def = SafeParse.stringToDouble(editInsulin.editText.getText().toString()); + } + editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false); container.addView(view); return view; } else { diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java index 72acea3aaf..f3fef6c102 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java @@ -77,7 +77,12 @@ public class TempTargetActivity extends Activity { final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); final TextView textView = (TextView) view.findViewById(R.id.label); textView.setText("duration"); - time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 60d, 0d, 24*60d, 1d, new DecimalFormat("0"), false); + if (time == null) { + time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 60d, 0d, 24 * 60d, 1d, new DecimalFormat("0"), false); + } else { + double def = SafeParse.stringToDouble(time.editText.getText().toString()); + time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 24 * 60d, 1d, new DecimalFormat("0"), false); + } container.addView(view); return view; @@ -86,9 +91,17 @@ public class TempTargetActivity extends Activity { final TextView textView = (TextView) view.findViewById(R.id.label); textView.setText("low"); if (isMGDL){ - lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 100d, 72d, 180d, 1d, new DecimalFormat("0"), false); + double def = 100; + if (lowRange != null){ + def = SafeParse.stringToDouble(lowRange.editText.getText().toString()); + } + lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 72d, 180d, 1d, new DecimalFormat("0"), false); } else { - lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 5.5, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false); + double def = 5.5; + if (lowRange != null){ + def = SafeParse.stringToDouble(lowRange.editText.getText().toString()); + } + lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false); } container.addView(view); @@ -98,9 +111,17 @@ public class TempTargetActivity extends Activity { final TextView textView = (TextView) view.findViewById(R.id.label); textView.setText("high"); if (isMGDL){ - highRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 100d, 72d, 180d, 1d, new DecimalFormat("0"), false); + double def = 100; + if (highRange != null){ + def = SafeParse.stringToDouble(highRange.editText.getText().toString()); + } + highRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 72d, 180d, 1d, new DecimalFormat("0"), false); } else { - highRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 5.5, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false); + double def = 5.5; + if (highRange != null){ + def = SafeParse.stringToDouble(highRange.editText.getText().toString()); + } + highRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false); } container.addView(view); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java index 50f77bb4b8..0e930174ae 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java @@ -71,7 +71,13 @@ public class WizardActivity extends Activity { final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); final TextView textView = (TextView) view.findViewById(R.id.label); textView.setText("carbs"); - editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 100d, 1d, new DecimalFormat("0"), false); + if (editCarbs == null) { + editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 100d, 1d, new DecimalFormat("0"), false); + } else { + double def = SafeParse.stringToDouble(editCarbs.editText.getText().toString()); + editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 100d, 1d, new DecimalFormat("0"), false); + + } container.addView(view); return view; } else if(col == 1){ @@ -80,6 +86,11 @@ public class WizardActivity extends Activity { textView.setText("include BG?"); final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton); + if(useBG){ + togglebutton.setImageResource(R.drawable.ic_toggle_on); + } else { + togglebutton.setImageResource(R.drawable.ic_toggle_off); + } togglebutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -99,6 +110,11 @@ public class WizardActivity extends Activity { textView.setText("Bolus IOB?"); final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton); + if(includeBolusIOB){ + togglebutton.setImageResource(R.drawable.ic_toggle_on); + } else { + togglebutton.setImageResource(R.drawable.ic_toggle_off); + } togglebutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -118,6 +134,11 @@ public class WizardActivity extends Activity { textView.setText("Basal IOB?"); final ImageView togglebutton = (ImageView) view.findViewById(R.id.togglebutton); + if(includeBasalIOB){ + togglebutton.setImageResource(R.drawable.ic_toggle_on); + } else { + togglebutton.setImageResource(R.drawable.ic_toggle_off); + } togglebutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/wear/wear.iml b/wear/wear.iml index ce3df746e7..f2951e6bcf 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -43,6 +43,13 @@ + + + + + + + @@ -51,13 +58,6 @@ - - - - - - - @@ -66,14 +66,6 @@ - - - - - - - - @@ -82,6 +74,14 @@ + + + + + + + + From 384e36a1f35126d1e6ab1e1fbef8f21095503f6a Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Fri, 10 Feb 2017 12:52:54 +0100 Subject: [PATCH 31/48] wear remove bolus enaction for testing --- .../nightscout/androidaps/plugins/Wear/ActionStringHandler.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index ec24efa7dc..dc3bd3d489 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -312,6 +312,7 @@ public class ActionStringHandler { } private static void doFillBolus(final Double amount) { + if(1==1)return; Handler handler = new Handler(handlerThread.getLooper()); handler.post(new Runnable() { @Override @@ -327,6 +328,7 @@ public class ActionStringHandler { } private static void doBolus(final Double amount, final Integer carbs) { + if(1==1)return; Handler handler = new Handler(handlerThread.getLooper()); handler.post(new Runnable() { @Override From 108095ad778b4f073991500bb6cc027b17e8c366 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Fri, 10 Feb 2017 21:20:47 +0100 Subject: [PATCH 32/48] wear confirmation timeout and larger text for editplusminus --- .../androidaps/data/ListenerService.java | 75 ++++++++++++++----- .../res/layout/action_editplusminus_item.xml | 5 +- wear/wear.iml | 16 ++-- 3 files changed, 68 insertions(+), 28 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java index 00fddef72d..c85566512f 100644 --- a/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java @@ -57,6 +57,8 @@ public class ListenerService extends WearableListenerService implements GoogleAp private static final String ACTION_RESEND_BULK = "com.dexdrip.stephenblack.nightwatch.RESEND_BULK_DATA"; GoogleApiClient googleApiClient; private long lastRequest = 0; + private DismissThread confirmThread; + private DismissThread bolusprogressThread; public class DataRequester extends AsyncTask { @@ -289,17 +291,24 @@ public class ListenerService extends WearableListenerService implements GoogleAp NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); + if(confirmThread != null){ + confirmThread.invalidate(); + } notificationManager.notify(BOLUS_PROGRESS_NOTIF_ID, notificationBuilder.build()); notificationManager.cancel(CONFIRM_NOTIF_ID); // multiple watch setup if (progresspercent == 100){ - scheduleDismiss(BOLUS_PROGRESS_NOTIF_ID, 5); + scheduleDismissBolusprogress(5); } } private void showConfirmationDialog(String title, String message, String actionstring) { + if(confirmThread != null){ + confirmThread.invalidate(); + } + Intent actionIntent = new Intent(this, ListenerService.class); actionIntent.setAction(ACTION_CONFIRMATION); actionIntent.putExtra("actionstring", actionstring); @@ -323,29 +332,59 @@ public class ListenerService extends WearableListenerService implements GoogleAp notificationManager.notify(CONFIRM_NOTIF_ID, notificationBuilder.build()); // keep the confirmation dialog open for one minute. - scheduleDismiss(CONFIRM_NOTIF_ID, 60); + scheduleDismissConfirm(60); } - private void scheduleDismiss(final int notificationId, final int seconds) { - Thread t = new Thread(new Runnable() { - @Override - public void run() { - try { - Thread.sleep(seconds * 1000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - NotificationManagerCompat notificationManager = - NotificationManagerCompat.from(ListenerService.this); - notificationManager.cancel(notificationId); + private void scheduleDismissConfirm(final int seconds) { + if(confirmThread != null){ + confirmThread.invalidate(); + } + confirmThread = new DismissThread(CONFIRM_NOTIF_ID, seconds); + confirmThread.start(); + } + + private void scheduleDismissBolusprogress(final int seconds) { + if(confirmThread != null){ + confirmThread.invalidate(); + } + bolusprogressThread = new DismissThread(BOLUS_PROGRESS_NOTIF_ID, seconds); + bolusprogressThread.start(); + } + + + + private class DismissThread extends Thread{ + private final int notificationID; + private final int seconds; + private boolean valid = true; + + DismissThread(int notificationID, int seconds){ + this.notificationID = notificationID; + this.seconds = seconds; + } + + public synchronized void invalidate(){ + valid = false; + } + + @Override + public void run() { + try { + Thread.sleep(seconds * 1000); + } catch (InterruptedException e) { + //e.printStackTrace(); } - }); - t.start(); + synchronized (this) { + if(valid) { + NotificationManagerCompat notificationManager = + NotificationManagerCompat.from(ListenerService.this); + notificationManager.cancel(notificationID); + } + } + } } - - public static void requestData(Context context) { Intent intent = new Intent(context, ListenerService.class); intent.setAction(ACTION_RESEND); diff --git a/wear/src/main/res/layout/action_editplusminus_item.xml b/wear/src/main/res/layout/action_editplusminus_item.xml index 6e12ad857b..38336ff903 100644 --- a/wear/src/main/res/layout/action_editplusminus_item.xml +++ b/wear/src/main/res/layout/action_editplusminus_item.xml @@ -35,8 +35,8 @@ android:minWidth="50dp" android:padding="10dp" android:text="112" + android:textSize="45sp" android:cursorVisible="false" - android:textAppearance="?android:attr/textAppearanceLarge" android:gravity="center_horizontal" /> + android:gravity="center" + android:textSize="25sp" /> - - - - - - - - @@ -82,6 +74,14 @@ + + + + + + + + From 705f563f2f2293cff776da34020f78af7dd0a678 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Fri, 10 Feb 2017 21:27:50 +0100 Subject: [PATCH 33/48] wear TTarget -> TempT --- .../androidaps/interaction/menus/MainMenuActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java index a6ef6666db..a97c165792 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java @@ -18,7 +18,7 @@ public class MainMenuActivity extends MenuListActivity { @Override protected String[] getElements() { return new String[] { - "TTarget", + "TempT", "Bolus", "Wizard", "Settings", From 9dae8b4e56a7819c36b3fdbf186c6638aa74157f Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 11 Feb 2017 00:32:45 +0100 Subject: [PATCH 34/48] wear don't enact 0carbs/0bolus on wizard result --- .idea/misc.xml | 2 +- .../plugins/Wear/ActionStringHandler.java | 4 ++-- wear/wear.iml | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 5d19981032..fbb68289f4 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index dc3bd3d489..f2abf45b02 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -218,9 +218,9 @@ public class ActionStringHandler { if(bolusWizard.calculatedTotalInsulin <=0 && bolusWizard.carbs <=0){ rAction = "info"; rTitle = "INFO"; + } else { + rAction = actionstring; } - rAction = actionstring; - DecimalFormat format = new DecimalFormat("0.00"); rMessage += "Bolus: " + format.format(bolusWizard.calculatedTotalInsulin) + "U"; rMessage += "\nWizard: " + format.format(insulin) + "U"; diff --git a/wear/wear.iml b/wear/wear.iml index 33cd39a6c1..ce3df746e7 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -43,13 +43,6 @@ - - - - - - - @@ -58,6 +51,13 @@ + + + + + + + From c8dc7bf9c8757f80b9e7fdcdf2e607080bfe75ad Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 11 Feb 2017 02:50:18 +0100 Subject: [PATCH 35/48] wear menu list layout --- .idea/misc.xml | 2 +- .../interaction/utils/WearableListItemLayout.java | 8 ++++---- wear/src/main/res/layout/list_item.xml | 9 +++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index fbb68289f4..5d19981032 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/WearableListItemLayout.java b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/WearableListItemLayout.java index a97305d7e2..89925cc9b8 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/WearableListItemLayout.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/WearableListItemLayout.java @@ -17,7 +17,7 @@ import info.nightscout.androidaps.R; public class WearableListItemLayout extends LinearLayout implements WearableListView.OnCenterProximityListener { - private ImageView mCircle; + //private ImageView mCircle; private TextView mName; private final float mFadedTextAlpha; @@ -45,19 +45,19 @@ public class WearableListItemLayout extends LinearLayout @Override protected void onFinishInflate() { super.onFinishInflate(); - mCircle = (ImageView) findViewById(R.id.circle); + //mCircle = (ImageView) findViewById(R.id.circle); mName = (TextView) findViewById(R.id.actionitem); } @Override public void onCenterPosition(boolean animate) { mName.setAlpha(1f); - ((GradientDrawable) mCircle.getDrawable()).setColor(mChosenCircleColor); + //((GradientDrawable) mCircle.getDrawable()).setColor(mChosenCircleColor); } @Override public void onNonCenterPosition(boolean animate) { - ((GradientDrawable) mCircle.getDrawable()).setColor(mFadedCircleColor); + //((GradientDrawable) mCircle.getDrawable()).setColor(mFadedCircleColor); mName.setAlpha(mFadedTextAlpha); } } diff --git a/wear/src/main/res/layout/list_item.xml b/wear/src/main/res/layout/list_item.xml index 6bb172b3d9..a6193efc3e 100644 --- a/wear/src/main/res/layout/list_item.xml +++ b/wear/src/main/res/layout/list_item.xml @@ -3,17 +3,18 @@ android:gravity="center_vertical" android:layout_width="match_parent" android:layout_height="80dp"> - + android:src="@drawable/wl_circle"/--> Date: Sat, 11 Feb 2017 02:54:54 +0100 Subject: [PATCH 36/48] update wear.iml --- wear/wear.iml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/wear/wear.iml b/wear/wear.iml index ce3df746e7..644912a66c 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -106,14 +106,6 @@ - - - - - - - - @@ -122,6 +114,14 @@ + + + + + + + + @@ -158,4 +158,4 @@ - \ No newline at end of file + From 5ea7913a41953d04bb292ead24cb9ccb947bfda3 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 11 Feb 2017 02:58:22 +0100 Subject: [PATCH 37/48] wear actionstringhandler use correct actualBG() --- .../androidaps/plugins/Wear/ActionStringHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index f2abf45b02..12f7122a8b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -22,6 +22,7 @@ import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.TempTarget; @@ -196,7 +197,7 @@ public class ActionStringHandler { sendError("No profile found!"); return; } - BgReading bgReading = MainApp.getDbHelper().actualBg(); + BgReading bgReading = GlucoseStatus.actualBg(); if(bgReading==null && useBG){ sendError("No recent BG to base calculation on!"); return; } From b57253af5eebc0d5b4b37b2b094def05c9dfb5fd Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 11 Feb 2017 17:54:47 +0100 Subject: [PATCH 38/48] wear add carbs to bolus-wizard confirmation --- .idea/misc.xml | 2 +- .../plugins/Wear/ActionStringHandler.java | 4 ++- wear/wear.iml | 32 +++++++++---------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 5d19981032..fbb68289f4 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index 12f7122a8b..bebf692389 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -223,7 +223,9 @@ public class ActionStringHandler { rAction = actionstring; } DecimalFormat format = new DecimalFormat("0.00"); - rMessage += "Bolus: " + format.format(bolusWizard.calculatedTotalInsulin) + "U"; + rMessage += "Carbs: " + bolusWizard.carbs + "g"; + rMessage += "\nBolus: " + format.format(bolusWizard.calculatedTotalInsulin) + "U"; + rMessage += "\nCalculation: "; rMessage += "\nWizard: " + format.format(insulin) + "U"; rMessage += "\nCarb: " + format.format(bolusWizard.insulinFromCarbs) + "U"; if(useBG)rMessage += "\nBG: " + format.format(bolusWizard.insulinFromBG) + "U"; diff --git a/wear/wear.iml b/wear/wear.iml index 644912a66c..610fad9b6a 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -43,6 +43,13 @@ + + + + + + + @@ -51,13 +58,6 @@ - - - - - - - @@ -66,14 +66,6 @@ - - - - - - - - @@ -82,6 +74,14 @@ + + + + + + + + @@ -158,4 +158,4 @@ - + \ No newline at end of file From d9103b6823671878daae29b86f010bf46ac9aed6 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 11 Feb 2017 19:51:33 +0100 Subject: [PATCH 39/48] wear wizard confirm reformat, connection stability, prime not in menu per default --- .../plugins/Wear/ActionStringHandler.java | 21 +++++++-------- .../androidaps/data/ListenerService.java | 16 ++++++++++-- .../interaction/menus/MainMenuActivity.java | 26 ++++++++++++++++--- .../interaction/utils/MenuListActivity.java | 3 ++- wear/src/main/res/xml/preferences.xml | 9 ++++++- 5 files changed, 56 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index bebf692389..887021afc4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -201,13 +201,15 @@ public class ActionStringHandler { if(bgReading==null && useBG){ sendError("No recent BG to base calculation on!"); return; } - + DecimalFormat format = new DecimalFormat("0.00"); BolusWizard bolusWizard = new BolusWizard(); bolusWizard.doCalc(profile.getDefaultProfile(), carbsAfterConstraints, useBG?bgReading.valueToUnits(profile.getUnits()):0d, 0d, useBolusIOB, useBasalIOB); Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(bolusWizard.calculatedTotalInsulin); if(insulinAfterConstraints - bolusWizard.calculatedTotalInsulin !=0){ - sendError("Insulin contraint violation!"); return; + sendError("Insulin contraint violation!" + + "\nCannot deliver " + format.format(bolusWizard.calculatedTotalInsulin) +"!"); + return; } @@ -222,17 +224,14 @@ public class ActionStringHandler { } else { rAction = actionstring; } - DecimalFormat format = new DecimalFormat("0.00"); rMessage += "Carbs: " + bolusWizard.carbs + "g"; rMessage += "\nBolus: " + format.format(bolusWizard.calculatedTotalInsulin) + "U"; - rMessage += "\nCalculation: "; - rMessage += "\nWizard: " + format.format(insulin) + "U"; - rMessage += "\nCarb: " + format.format(bolusWizard.insulinFromCarbs) + "U"; - if(useBG)rMessage += "\nBG: " + format.format(bolusWizard.insulinFromBG) + "U"; + rMessage += "\n_____________"; + rMessage += "\nCalc (IC:" + DecimalFormatter.to1Decimal(bolusWizard.ic) + ", " + "ISF:" + DecimalFormatter.to1Decimal(bolusWizard.sens) + "): "; + rMessage += "\nFrom Carbs: " + format.format(bolusWizard.insulinFromCarbs) + "U"; + if(useBG)rMessage += "\nFrom BG: " + format.format(bolusWizard.insulinFromBG) + "U"; if(useBolusIOB)rMessage += "\nBolus IOB: " + format.format(bolusWizard.insulingFromBolusIOB) + "U"; if(useBasalIOB)rMessage += "\nBasal IOB: " + format.format(bolusWizard.insulingFromBasalsIOB) + "U"; - rMessage += "\nIC:" + DecimalFormatter.to1Decimal(bolusWizard.ic); - if(useBG)rMessage += " ISF:" + DecimalFormatter.to1Decimal(bolusWizard.sens); lastBolusWizard = bolusWizard; @@ -315,7 +314,7 @@ public class ActionStringHandler { } private static void doFillBolus(final Double amount) { - if(1==1)return; + //if(1==1)return; Handler handler = new Handler(handlerThread.getLooper()); handler.post(new Runnable() { @Override @@ -331,7 +330,7 @@ public class ActionStringHandler { } private static void doBolus(final Double amount, final Integer carbs) { - if(1==1)return; + //if(1==1)return; Handler handler = new Handler(handlerThread.getLooper()); handler.post(new Runnable() { @Override diff --git a/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java b/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java index c85566512f..88c334d07a 100644 --- a/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java +++ b/wear/src/main/java/info/nightscout/androidaps/data/ListenerService.java @@ -80,8 +80,20 @@ public class ListenerService extends WearableListenerService implements GoogleAp Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), WEARABLE_RESEND_PATH, null); } } - } else - googleApiClient.connect(); + } else { + googleApiClient.blockingConnect(15, TimeUnit.SECONDS); + if (googleApiClient.isConnected()) { + if (System.currentTimeMillis() - lastRequest > 20 * 1000) { // enforce 20-second debounce period + lastRequest = System.currentTimeMillis(); + + NodeApi.GetConnectedNodesResult nodes = + Wearable.NodeApi.getConnectedNodes(googleApiClient).await(); + for (Node node : nodes.getNodes()) { + Wearable.MessageApi.sendMessage(googleApiClient, node.getId(), WEARABLE_RESEND_PATH, null); + } + } + } + } return null; } } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java index a97c165792..71e3b48d5c 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java @@ -1,6 +1,9 @@ package info.nightscout.androidaps.interaction.menus; import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.PreferenceManager; import info.nightscout.androidaps.data.ListenerService; import info.nightscout.androidaps.interaction.AAPSPreferences; @@ -15,8 +18,20 @@ import info.nightscout.androidaps.interaction.actions.WizardActivity; public class MainMenuActivity extends MenuListActivity { + SharedPreferences sp; + + @Override + protected void onCreate(Bundle savedInstanceState) { + sp = PreferenceManager.getDefaultSharedPreferences(this); + super.onCreate(savedInstanceState); + ListenerService.requestData(this); + } + @Override protected String[] getElements() { + + boolean showPrimeFill = sp.getBoolean("primefill", false); + return new String[] { "TempT", "Bolus", @@ -24,7 +39,7 @@ public class MainMenuActivity extends MenuListActivity { "Settings", "Re-Sync", "Status", - "Prime/Fill"}; + showPrimeFill?"Prime/Fill":""}; } @Override @@ -61,9 +76,12 @@ public class MainMenuActivity extends MenuListActivity { this.startActivity(intent); break; case 6: - intent = new Intent(this, FillMenuActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - this.startActivity(intent); + boolean showPrimeFill = sp.getBoolean("primefill", false); + if(showPrimeFill) { + intent = new Intent(this, FillMenuActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + this.startActivity(intent); + } break; } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java index 681ceb134a..d151196091 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/utils/MenuListActivity.java @@ -18,7 +18,7 @@ import info.nightscout.androidaps.R; public abstract class MenuListActivity extends Activity implements WearableListView.ClickListener { - String[] elements = getElements(); + String[] elements; protected abstract String[] getElements(); @@ -33,6 +33,7 @@ public abstract class MenuListActivity extends Activity @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + elements = getElements(); setContentView(R.layout.actions_list_activity); // Get the list component from the layout of the activity diff --git a/wear/src/main/res/xml/preferences.xml b/wear/src/main/res/xml/preferences.xml index f19fe60110..28ab0eb621 100644 --- a/wear/src/main/res/xml/preferences.xml +++ b/wear/src/main/res/xml/preferences.xml @@ -105,7 +105,6 @@ app:wear_iconOff="@drawable/settings_off" app:wear_iconOn="@drawable/settings_on"/> - + + From 6c5028b4be274e07f71f520b011144da3552c054 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 11 Feb 2017 22:18:28 +0100 Subject: [PATCH 40/48] CPP dismiss info when focus is lost --- .../CircadianPercentageProfileFragment.java | 23 ++++++++++++++----- .../circadianpercentageprofile_fragment.xml | 2 +- app/src/main/res/values/strings.xml | 1 + 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java index 6dbc27c2c5..0b31f360bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/CircadianPercentageProfile/CircadianPercentageProfileFragment.java @@ -43,6 +43,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag private static Logger log = LoggerFactory.getLogger(CircadianPercentageProfileFragment.class); private static CircadianPercentageProfilePlugin circadianPercentageProfilePlugin = new CircadianPercentageProfilePlugin(); + private Object snackbarCaller; public static CircadianPercentageProfilePlugin getPlugin() { return circadianPercentageProfilePlugin; @@ -68,6 +69,7 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag ImageView isfeditIcon; BasalEditDialog basalEditDialog; LinearLayout ll; + Snackbar mSnackBar; static Boolean percentageViewHint = true; static Boolean timeshiftViewHint = true; @@ -197,12 +199,15 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag @Override public void onFocusChange(View view, boolean hasFocus) { if (!hasFocus) { + if(mSnackBar!=null && snackbarCaller == timeshiftView){ + mSnackBar.dismiss(); + } timeshiftView.clearFocus(); ll.requestFocusFromTouch(); } else { if (timeshiftViewHint) { - customSnackbar(view, getString(R.string.timeshift_hint)); + customSnackbar(view, getString(R.string.timeshift_hint), timeshiftView); } } } @@ -213,12 +218,15 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag @Override public void onFocusChange(View view, boolean hasFocus) { if (!hasFocus) { + if(mSnackBar!=null && snackbarCaller == percentageView){ + mSnackBar.dismiss(); + } percentageView.clearFocus(); ll.requestFocusFromTouch(); } else { if (percentageViewHint) { - customSnackbar(view, getString(R.string.percentagefactor_hint)); + customSnackbar(view, getString(R.string.percentagefactor_hint), percentageView); } } } @@ -312,14 +320,17 @@ public class CircadianPercentageProfileFragment extends Fragment implements Frag return layout; } - private void customSnackbar(View view, final String Msg) { + private void customSnackbar(View view, final String Msg, Object snackbarCaller) { + if(mSnackBar!= null) mSnackBar.dismiss(); + + this.snackbarCaller = snackbarCaller; if (timeshiftViewHint || percentageViewHint) { - Snackbar mSnackBar = Snackbar.make(view, + mSnackBar = Snackbar.make(view, Msg, Snackbar.LENGTH_LONG) - .setDuration(7000) + .setDuration(Snackbar.LENGTH_LONG) .setActionTextColor(getResources().getColor(R.color.notificationInfo)) - .setAction(getString(R.string.dismiss), new View.OnClickListener() { + .setAction(getString(R.string.dont_show_again), new View.OnClickListener() { @Override public void onClick(View v) { if (Msg.equals(getString(R.string.percentagefactor_hint))) { diff --git a/app/src/main/res/layout/circadianpercentageprofile_fragment.xml b/app/src/main/res/layout/circadianpercentageprofile_fragment.xml index 99bf9f0235..347695c413 100644 --- a/app/src/main/res/layout/circadianpercentageprofile_fragment.xml +++ b/app/src/main/res/layout/circadianpercentageprofile_fragment.xml @@ -278,7 +278,7 @@ Remote calibration not allowed Calibration sent xDrip is not receiving calibrations + Don\'t show again From 5e96124a2d60bfde6730536985d961b48a26ac58 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 11 Feb 2017 22:26:16 +0100 Subject: [PATCH 41/48] mmol/l fix --- app/src/main/res/layout/circadianpercentageprofile_fragment.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/layout/circadianpercentageprofile_fragment.xml b/app/src/main/res/layout/circadianpercentageprofile_fragment.xml index 347695c413..fbf85c7c59 100644 --- a/app/src/main/res/layout/circadianpercentageprofile_fragment.xml +++ b/app/src/main/res/layout/circadianpercentageprofile_fragment.xml @@ -290,7 +290,7 @@ Date: Sun, 12 Feb 2017 17:32:53 +0100 Subject: [PATCH 42/48] wear target statusO --- .../plugins/Wear/ActionStringHandler.java | 62 +++++++++++++++++-- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index 887021afc4..3e9f6789e0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -2,10 +2,12 @@ package info.nightscout.androidaps.plugins.Wear; import android.content.DialogInterface; import android.content.SharedPreferences; +import android.graphics.Color; import android.os.Handler; import android.os.HandlerThread; import android.preference.PreferenceManager; import android.support.annotation.BoolRes; +import android.support.annotation.NonNull; import android.support.v7.app.AlertDialog; import android.view.View; @@ -165,17 +167,17 @@ public class ActionStringHandler { //TODO: add meaningful status if("general".equals(act[1])){ - rMessage = "Today is going to be a good day!"; + rMessage = getGeneralStatus(); } else if("pump".equals(act[1])){ rTitle += " PUMP"; - rMessage = "I'm feeling pumped!"; + rMessage = getPumpStatus(); } else if("loop".equals(act[1])){ rTitle += " LOOP"; - rMessage = "A loop di loop di loop!"; + rMessage = getLoopStatus(); } else if("targets".equals(act[1])){ rTitle += " TARGETS"; - rMessage = "Always on target!"; + rMessage = getTargetsStatus(); } rMessage += "\n\n\nTODO:\nAdd some meaningful status."; @@ -243,6 +245,58 @@ public class ActionStringHandler { lastConfirmActionString = rAction; } + @NonNull + private static String getGeneralStatus() { + return "Today is going to be a good day!"; + } + + @NonNull + private static String getPumpStatus() { + return "I'm feeling pumped!"; + } + + @NonNull + private static String getLoopStatus() { + return "A loop di loop di loop!"; + } + + @NonNull + private static String getTargetsStatus() { + String ret = ""; + if (!Config.APS){ + return "Targets only apply in APS mode!"; + } + NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile(); + if (profile == null){ + return "No profile set :("; + } + + //Check for Temp-Target: + TempTargetRangePlugin tempTargetRangePlugin = (TempTargetRangePlugin) MainApp.getSpecificPlugin(TempTargetRangePlugin.class); + if (Config.APS && tempTargetRangePlugin != null && tempTargetRangePlugin.isEnabled(PluginBase.GENERAL)) { + TempTarget tempTarget = tempTargetRangePlugin.getTempTargetInProgress(new Date().getTime()); + if (tempTarget != null) { + ret += "Temp Target: " + NSProfile.toUnitsString(tempTarget.low, NSProfile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + NSProfile.toUnitsString(tempTarget.high, NSProfile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits()); + ret += "\nuntil: " + DateUtil.timeString(tempTarget.getPlannedTimeEnd()); + ret += "\n\n"; + } + } + + //Default Range/Target + String maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL; + String minBgDefault = Constants.MIN_BG_DEFAULT_MGDL; + String targetBgDefault = Constants.TARGET_BG_DEFAULT_MGDL; + if (!profile.getUnits().equals(Constants.MGDL)) { + maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL; + minBgDefault = Constants.MIN_BG_DEFAULT_MMOL; + targetBgDefault = Constants.TARGET_BG_DEFAULT_MMOL; + } + ret += "DEFAULT RANGE: "; + ret += sp.getString("openapsma_min_bg", minBgDefault) + " - " + sp.getString("openapsma_max_bg", maxBgDefault); + ret += " target: " + sp.getString("openapsma_target_bg", targetBgDefault); + return ret; + } + public synchronized static void handleConfirmation(String actionString){ From 65d1624a5fc0d3931ecb5f3a885a38cd1951cfd1 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sun, 12 Feb 2017 19:50:25 +0100 Subject: [PATCH 43/48] wear carb restriction --- .../androidaps/interaction/actions/BolusActivity.java | 2 +- .../androidaps/interaction/actions/WizardActivity.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java index 78bf406b1c..4b3d0e36cb 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java @@ -83,7 +83,7 @@ public class BolusActivity extends Activity { if (editCarbs != null){ def = SafeParse.stringToDouble(editCarbs.editText.getText().toString()); } - editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 100d, 1d, new DecimalFormat("0"), false); + editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), false); container.addView(view); return view; } else { diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java index 0e930174ae..b252c7fbcf 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java @@ -72,10 +72,10 @@ public class WizardActivity extends Activity { final TextView textView = (TextView) view.findViewById(R.id.label); textView.setText("carbs"); if (editCarbs == null) { - editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 100d, 1d, new DecimalFormat("0"), false); + editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 150d, 1d, new DecimalFormat("0"), false); } else { double def = SafeParse.stringToDouble(editCarbs.editText.getText().toString()); - editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 100d, 1d, new DecimalFormat("0"), false); + editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), false); } container.addView(view); From 6fcee9ea3f8bfa2fe74ee640645ee0f29fa378b9 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 13 Feb 2017 00:15:02 +0100 Subject: [PATCH 44/48] pump shortStatus String in interface --- .../androidaps/interfaces/PumpInterface.java | 2 ++ .../ConfigBuilder/ConfigBuilderPlugin.java | 9 +++++++++ .../androidaps/plugins/DanaR/DanaRPlugin.java | 5 ++++- .../plugins/DanaRKorean/DanaRKoreanPlugin.java | 5 ++++- .../androidaps/plugins/MDI/MDIPlugin.java | 5 +++++ .../SmsCommunicator/SmsCommunicatorPlugin.java | 16 ++++++++-------- .../plugins/VirtualPump/VirtualPumpPlugin.java | 5 +++++ 7 files changed, 37 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java index b580dc9b38..f1d4de5257 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java @@ -51,4 +51,6 @@ public interface PumpInterface { String deviceID(); PumpDescription getPumpDescription(); + + public String shortStatus(boolean veryShort); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index f34e08ec49..005e78cb2d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -674,6 +674,15 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain } } + @Override + public String shortStatus(boolean veryShort) { + if (activePump != null) { + return activePump.shortStatus(veryShort); + } else { + return "No Pump active!"; + } + } + /** * Constraints interface **/ diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java index 4af029b558..3eb8e2c881 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/DanaRPlugin.java @@ -828,7 +828,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf } // Reply for sms communicator - public String shortStatus() { + public String shortStatus(boolean veryShort) { String ret = ""; if (getDanaRPump().lastConnection.getTime() != 0) { Long agoMsec = new Date().getTime() - getDanaRPump().lastConnection.getTime(); @@ -844,6 +844,9 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf if (isExtendedBoluslInProgress()) { ret += "Extended: " + getExtendedBolus().toString() + "\n"; } + if (!veryShort){ + ret += "TDD: " + DecimalFormatter.to0Decimal(getDanaRPump().dailyTotalUnits) + " / " + getDanaRPump().maxDailyTotalUnits + " U\n"; + } ret += "IOB: " + getDanaRPump().iob + "U\n"; ret += "Reserv: " + DecimalFormatter.to0Decimal(getDanaRPump().reservoirRemainingUnits) + "U\n"; ret += "Batt: " + getDanaRPump().batteryRemaining + "\n"; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java index 5c12ab3000..6876e5f9f8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaRKorean/DanaRKoreanPlugin.java @@ -828,7 +828,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints } // Reply for sms communicator - public String shortStatus() { + public String shortStatus(boolean veryShort) { String ret = ""; if (getDanaRPump().lastConnection.getTime() != 0) { Long agoMsec = new Date().getTime() - getDanaRPump().lastConnection.getTime(); @@ -844,6 +844,9 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints if (isExtendedBoluslInProgress()) { ret += "Extended: " + getExtendedBolus().toString() + "\n"; } + if (!veryShort){ + ret += "TDD: " + DecimalFormatter.to0Decimal(getDanaRPump().dailyTotalUnits) + " / " + getDanaRPump().maxDailyTotalUnits + " U\n"; + } ret += "IOB: " + getDanaRPump().iob + "U\n"; ret += "Reserv: " + DecimalFormatter.to0Decimal(getDanaRPump().reservoirRemainingUnits) + "U\n"; ret += "Batt: " + getDanaRPump().batteryRemaining + "\n"; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/MDI/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/MDI/MDIPlugin.java index cc63428349..377468f43a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/MDI/MDIPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/MDI/MDIPlugin.java @@ -272,4 +272,9 @@ public class MDIPlugin implements PluginBase, PumpInterface { return pumpDescription; } + @Override + public String shortStatus(boolean veryShort) { + return deviceID(); + } + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java index 8133350720..4097efcdf9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java @@ -307,12 +307,12 @@ public class SmsCommunicatorPlugin implements PluginBase { case "DANAR": DanaRPlugin danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class); if (danaRPlugin != null && danaRPlugin.isEnabled(PluginBase.PUMP)) { - reply = danaRPlugin.shortStatus(); + reply = danaRPlugin.shortStatus(true); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); } DanaRKoreanPlugin danaRKoreanPlugin = (DanaRKoreanPlugin) MainApp.getSpecificPlugin(DanaRKoreanPlugin.class); if (danaRKoreanPlugin != null && danaRKoreanPlugin.isEnabled(PluginBase.PUMP)) { - reply = danaRKoreanPlugin.shortStatus(); + reply = danaRKoreanPlugin.shortStatus(true); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); } receivedSms.processed = true; @@ -396,12 +396,12 @@ public class SmsCommunicatorPlugin implements PluginBase { PumpEnactResult result = pumpInterface.deliverTreatment(bolusWaitingForConfirmation.bolusRequested, 0, null); if (result.success) { reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_bolusdelivered), result.bolusDelivered); - if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(); + if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(true); lastRemoteBolusTime = new Date(); sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date())); } else { reply = MainApp.sResources.getString(R.string.smscommunicator_bolusfailed); - if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(); + if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(true); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); } } @@ -414,11 +414,11 @@ public class SmsCommunicatorPlugin implements PluginBase { PumpEnactResult result = pumpInterface.setTempBasalAbsolute(tempBasalWaitingForConfirmation.tempBasal, 30); if (result.success) { reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_tempbasalset), result.absolute, result.duration); - if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(); + if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(true); sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date())); } else { reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalfailed); - if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(); + if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(true); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); } } @@ -431,11 +431,11 @@ public class SmsCommunicatorPlugin implements PluginBase { PumpEnactResult result = pumpInterface.cancelTempBasal(); if (result.success) { reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_tempbasalcanceled)); - if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(); + if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(true); sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date())); } else { reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcancelfailed); - if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(); + if (danaRPlugin != null) reply += "\n" + danaRPlugin.shortStatus(true); sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date())); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/VirtualPump/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/VirtualPump/VirtualPumpPlugin.java index ac4e1a8c13..4e9ee89a9a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/VirtualPump/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/VirtualPump/VirtualPumpPlugin.java @@ -430,4 +430,9 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface { return pumpDescription; } + @Override + public String shortStatus(boolean veryShort) { + return "Virtual Pump"; + } + } From e85e651c564b5359ca087f4664ef16dc14da4906 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 13 Feb 2017 01:55:35 +0100 Subject: [PATCH 45/48] wear full status support and product flavour with/without controls on wear --- app/build.gradle | 12 ++++- .../plugins/Wear/ActionStringHandler.java | 51 +++++++++++++----- wear/build.gradle | 14 +++++ .../interaction/menus/MainMenuActivity.java | 25 ++++++++- .../menus/MainMenuRestrictedActivity.java | 53 +++++++++++++++++++ .../interaction/menus/StatusMenuActivity.java | 9 ++-- 6 files changed, 143 insertions(+), 21 deletions(-) create mode 100644 wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuRestrictedActivity.java diff --git a/app/build.gradle b/app/build.gradle index 85a6e5deab..a8fd84511e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -97,10 +97,18 @@ android { wear { dimension "wear" buildConfigField "boolean", "WEAR", "true" + buildConfigField "boolean", "WEAR_CONTROL", "false" + + } + wearcontrol { + dimension "wear" + buildConfigField "boolean", "WEAR", "true" + buildConfigField "boolean", "WEAR_CONTROL", "true" } nowear { dimension "wear" buildConfigField "boolean", "WEAR", "false" + buildConfigField "boolean", "WEAR_CONTROL", "false" } } } @@ -115,7 +123,9 @@ allprojects { } dependencies { - wearWearApp project(path: ':wear', configuration: 'fullRelease') + wearWearApp project(path: ':wear', configuration: 'restrictedRelease') + wearcontrolWearApp project(path: ':wear', configuration: 'fullRelease') + compile fileTree(include: ['*.jar'], dir: 'libs') compile('com.crashlytics.sdk.android:crashlytics:2.5.7@aar') { transitive = true; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index 3e9f6789e0..8b24be7979 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -20,6 +20,7 @@ import java.sql.SQLException; import java.text.DecimalFormat; import java.util.Date; +import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; @@ -28,9 +29,11 @@ import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.TempTarget; +import info.nightscout.androidaps.interfaces.APSInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; +import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Overview.QuickWizard; import info.nightscout.androidaps.plugins.TempTargetRange.TempTargetRangePlugin; import info.nightscout.androidaps.plugins.TempTargetRange.events.EventTempTargetRangeChange; @@ -63,6 +66,9 @@ public class ActionStringHandler { public synchronized static void handleInitiate(String actionstring){ + if(!BuildConfig.WEAR_CONTROL) return; + + lastBolusWizard = null; String rTitle = "CONFIRM"; //TODO: i18n @@ -164,11 +170,7 @@ public class ActionStringHandler { ////////////////////////////////////////////// STATUS rTitle = "STATUS"; rAction = "statusmessage"; - //TODO: add meaningful status - - if("general".equals(act[1])){ - rMessage = getGeneralStatus(); - } else if("pump".equals(act[1])){ + if("pump".equals(act[1])){ rTitle += " PUMP"; rMessage = getPumpStatus(); } else if("loop".equals(act[1])){ @@ -179,7 +181,6 @@ public class ActionStringHandler { rTitle += " TARGETS"; rMessage = getTargetsStatus(); } - rMessage += "\n\n\nTODO:\nAdd some meaningful status."; } else if ("wizard".equals(act[0])) { ////////////////////////////////////////////// WIZARD @@ -245,19 +246,40 @@ public class ActionStringHandler { lastConfirmActionString = rAction; } - @NonNull - private static String getGeneralStatus() { - return "Today is going to be a good day!"; - } - @NonNull private static String getPumpStatus() { - return "I'm feeling pumped!"; + return MainApp.getConfigBuilder().shortStatus(false); } @NonNull private static String getLoopStatus() { - return "A loop di loop di loop!"; + String ret = ""; + // decide if enabled/disabled closed/open; what Plugin as APS? + final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop(); + if(activeloop != null && activeloop.isEnabled(activeloop.getType())) { + if (MainApp.getConfigBuilder().isClosedModeEnabled()) { + ret += "CLOSED LOOP\n"; + } else { + ret += "OPEN LOOP\n"; + } + final APSInterface aps = MainApp.getConfigBuilder().getActiveAPS(); + ret += "APS: " + ((aps==null)?"NO APS SELECTED!":((PluginBase) aps).getName()); + if(activeloop.lastRun != null){ + if(activeloop.lastRun.lastAPSRun != null) + ret += "\nLast Run: " + DateUtil.timeString(activeloop.lastRun.lastAPSRun); + + if(activeloop.lastRun.lastEnact != null) + ret += "\nLast Enact: " + DateUtil.timeString(activeloop.lastRun.lastEnact); + + } + + + + } else { + ret += "LOOP DISABLED\n"; + } + return ret; + } @NonNull @@ -300,6 +322,9 @@ public class ActionStringHandler { public synchronized static void handleConfirmation(String actionString){ + if(!BuildConfig.WEAR_CONTROL) return; + + //Guard from old or duplicate confirmations if (lastConfirmActionString == null) return; if (!lastConfirmActionString.equals(actionString)) return; diff --git a/wear/build.gradle b/wear/build.gradle index 97fb7b78c0..1bffedf90b 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -30,6 +30,20 @@ android { resValue "string", "label_xdrip_circle", "AAPS(Circle)" resValue "string", "label_xdrip_activity", "AAPS Prefs." resValue "string", "app_settings", "AAPS Settings" + buildConfigField "boolean", "WEAR_CONTROL", "true" + + } + + restricted { + applicationId = "info.nightscout.androidaps" + resValue "string", "label_xdrip", "AAPS" + resValue "string", "label_xdrip_large", "AAPS(Large)" + resValue "string", "label_xdrip_big_chart", "AAPS(BigChart)" + resValue "string", "label_xdrip_circle", "AAPS(Circle)" + resValue "string", "label_xdrip_activity", "AAPS Prefs." + resValue "string", "app_settings", "AAPS Settings" + buildConfigField "boolean", "WEAR_CONTROL", "false" + } } } diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java index 71e3b48d5c..aeea844f42 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuActivity.java @@ -5,6 +5,7 @@ import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; +import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.data.ListenerService; import info.nightscout.androidaps.interaction.AAPSPreferences; import info.nightscout.androidaps.interaction.actions.BolusActivity; @@ -30,8 +31,14 @@ public class MainMenuActivity extends MenuListActivity { @Override protected String[] getElements() { - boolean showPrimeFill = sp.getBoolean("primefill", false); + if(!BuildConfig.WEAR_CONTROL){ + return new String[] { + "Settings", + "Re-Sync"}; + } + + boolean showPrimeFill = sp.getBoolean("primefill", false); return new String[] { "TempT", "Bolus", @@ -46,6 +53,22 @@ public class MainMenuActivity extends MenuListActivity { protected void doAction(int position) { Intent intent; + + if(!BuildConfig.WEAR_CONTROL) { + switch (position) { + case 0: + intent = new Intent(this, AAPSPreferences.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + this.startActivity(intent); + break; + case 1: + ListenerService.requestData(this); + break; + } + return; + } + + switch (position) { case 0: intent = new Intent(this, TempTargetActivity.class); diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuRestrictedActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuRestrictedActivity.java new file mode 100644 index 0000000000..779e9611d2 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/MainMenuRestrictedActivity.java @@ -0,0 +1,53 @@ +package info.nightscout.androidaps.interaction.menus; + +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.preference.PreferenceManager; + +import info.nightscout.androidaps.data.ListenerService; +import info.nightscout.androidaps.interaction.AAPSPreferences; +import info.nightscout.androidaps.interaction.actions.BolusActivity; +import info.nightscout.androidaps.interaction.actions.TempTargetActivity; +import info.nightscout.androidaps.interaction.actions.WizardActivity; +import info.nightscout.androidaps.interaction.utils.MenuListActivity; + +/** + * Created by adrian on 09/02/17. + */ + +public class MainMenuRestrictedActivity extends MenuListActivity { + + SharedPreferences sp; + + @Override + protected void onCreate(Bundle savedInstanceState) { + sp = PreferenceManager.getDefaultSharedPreferences(this); + super.onCreate(savedInstanceState); + ListenerService.requestData(this); + } + + @Override + protected String[] getElements() { + return new String[] { + "Settings", + "Re-Sync"}; + } + + @Override + protected void doAction(int position) { + + Intent intent; + switch (position) { + case 0: + intent = new Intent(this, AAPSPreferences.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + this.startActivity(intent); + break; + case 1: + ListenerService.requestData(this); + break; + } + + } +} diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java index 85cab526c9..b8301400e2 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/menus/StatusMenuActivity.java @@ -12,7 +12,6 @@ public class StatusMenuActivity extends MenuListActivity { @Override protected String[] getElements() { return new String[] { - "General", "Pump", "Loop", "Targets"}; @@ -21,16 +20,14 @@ public class StatusMenuActivity extends MenuListActivity { @Override protected void doAction(int position) { switch (position) { + case 0: - ListenerService.initiateAction(this, "status general"); - break; - case 1: ListenerService.initiateAction(this, "status pump"); break; - case 2: + case 1: ListenerService.initiateAction(this, "status loop"); break; - case 3: + case 2: ListenerService.initiateAction(this, "status targets"); break; } From 05d40e4af04a8cd898beb805a4deb721af6c7589 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 13 Feb 2017 14:18:23 +0100 Subject: [PATCH 46/48] wear better toasts --- .../plugins/Wear/wearintegration/WatchUpdaterService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index f61df0c15b..fc08941cd3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -163,13 +163,13 @@ public class WatchUpdaterService extends WearableListenerService implements if (event != null && event.getPath().equals(WEARABLE_INITIATE_ACTIONSTRING_PATH)) { String actionstring = new String(event.getData()); - ToastUtils.showToastInUiThread(this, "INITIATE: " + actionstring); + ToastUtils.showToastInUiThread(this, "Wear: " + actionstring); ActionStringHandler.handleInitiate(actionstring); } if (event != null && event.getPath().equals(WEARABLE_CONFIRM_ACTIONSTRING_PATH)) { String actionstring = new String(event.getData()); - ToastUtils.showToastInUiThread(this, "CONFIRM: " + actionstring); + ToastUtils.showToastInUiThread(this, "Wear Confirm: " + actionstring); ActionStringHandler.handleConfirmation(actionstring); } } @@ -488,7 +488,7 @@ public class WatchUpdaterService extends WearableListenerService implements dataMapRequest.getDataMap().putString("message", message); dataMapRequest.getDataMap().putString("actionstring", actionstring); - ToastUtils.showToastInUiThread(this, "SENT: " + actionstring); + ToastUtils.showToastInUiThread(this, "Requesting confirmation from wear: " + actionstring); PutDataRequest putDataRequest = dataMapRequest.asPutDataRequest(); Wearable.DataApi.putDataItem(googleApiClient, putDataRequest); From 56e5fae27dbf0966f233e00bbb1ecef57b9515f1 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Mon, 13 Feb 2017 16:54:06 +0100 Subject: [PATCH 47/48] wear allow multiple input layouts --- .../interaction/actions/BolusActivity.java | 12 ++-- .../interaction/actions/FillActivity.java | 7 +- .../actions/TempTargetActivity.java | 19 +++--- .../actions/ViewSelectorActivity.java | 51 ++++++++++++++ .../interaction/actions/WizardActivity.java | 7 +- .../action_editplusminus_item_below.xml | 68 +++++++++++++++++++ .../action_editplusminus_item_quicklefty.xml | 65 ++++++++++++++++++ .../action_editplusminus_item_quickrighty.xml | 64 +++++++++++++++++ wear/src/main/res/values/strings.xml | 20 ++++++ wear/src/main/res/xml/preferences.xml | 8 +++ 10 files changed, 295 insertions(+), 26 deletions(-) create mode 100644 wear/src/main/java/info/nightscout/androidaps/interaction/actions/ViewSelectorActivity.java create mode 100644 wear/src/main/res/layout/action_editplusminus_item_below.xml create mode 100644 wear/src/main/res/layout/action_editplusminus_item_quicklefty.xml create mode 100644 wear/src/main/res/layout/action_editplusminus_item_quickrighty.xml diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java index 4b3d0e36cb..814020d742 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/BolusActivity.java @@ -25,7 +25,7 @@ import info.nightscout.androidaps.interaction.utils.SafeParse; */ -public class BolusActivity extends Activity { +public class BolusActivity extends ViewSelectorActivity { PlusMinusEditText editCarbs; PlusMinusEditText editInsulin; @@ -65,25 +65,23 @@ public class BolusActivity extends Activity { public Object instantiateItem(ViewGroup container, int row, int col) { if(col == 0){ - final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); - final TextView textView = (TextView) view.findViewById(R.id.label); - textView.setText("insulin"); + final View view = getInflatedPlusMinusView(container); double def = 0; if (editInsulin != null){ def = SafeParse.stringToDouble(editInsulin.editText.getText().toString()); } editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false); + setLabelToPlusMinusView(view, "insulin"); container.addView(view); return view; } else if(col == 1){ - final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); - final TextView textView = (TextView) view.findViewById(R.id.label); - textView.setText("carbs"); + final View view = getInflatedPlusMinusView(container); double def = 0; if (editCarbs != null){ def = SafeParse.stringToDouble(editCarbs.editText.getText().toString()); } editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), false); + setLabelToPlusMinusView(view, "carbs"); container.addView(view); return view; } else { diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java index bb926ed584..694dc0283c 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/FillActivity.java @@ -25,7 +25,7 @@ import info.nightscout.androidaps.interaction.utils.SafeParse; */ -public class FillActivity extends Activity { +public class FillActivity extends ViewSelectorActivity { PlusMinusEditText editInsulin; @@ -64,14 +64,13 @@ public class FillActivity extends Activity { public Object instantiateItem(ViewGroup container, int row, int col) { if(col == 0){ - final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); - final TextView textView = (TextView) view.findViewById(R.id.label); - textView.setText("insulin"); + final View view = getInflatedPlusMinusView(container); double def = 0d; if (editInsulin != null){ def = SafeParse.stringToDouble(editInsulin.editText.getText().toString()); } editInsulin = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 30d, 0.1d, new DecimalFormat("#0.0"), false); + setLabelToPlusMinusView(view, "insulin"); container.addView(view); return view; } else { diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java index f3fef6c102..b636869b60 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/TempTargetActivity.java @@ -29,7 +29,7 @@ import static android.preference.PreferenceManager.getDefaultSharedPreferences; */ -public class TempTargetActivity extends Activity { +public class TempTargetActivity extends ViewSelectorActivity { PlusMinusEditText lowRange; PlusMinusEditText highRange; @@ -74,7 +74,7 @@ public class TempTargetActivity extends Activity { public Object instantiateItem(ViewGroup container, int row, int col) { if(col == 0){ - final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); + final View view = getInflatedPlusMinusView(container); final TextView textView = (TextView) view.findViewById(R.id.label); textView.setText("duration"); if (time == null) { @@ -83,13 +83,12 @@ public class TempTargetActivity extends Activity { double def = SafeParse.stringToDouble(time.editText.getText().toString()); time = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 24 * 60d, 1d, new DecimalFormat("0"), false); } - container.addView(view); + setLabelToPlusMinusView(view, "duration"); + container.addView(view); return view; } else if(col == 1){ - final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); - final TextView textView = (TextView) view.findViewById(R.id.label); - textView.setText("low"); + final View view = getInflatedPlusMinusView(container); if (isMGDL){ double def = 100; if (lowRange != null){ @@ -103,13 +102,11 @@ public class TempTargetActivity extends Activity { } lowRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false); } - + setLabelToPlusMinusView(view, "low"); container.addView(view); return view; } else if(col == 2){ - final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); - final TextView textView = (TextView) view.findViewById(R.id.label); - textView.setText("high"); + final View view = getInflatedPlusMinusView(container); if (isMGDL){ double def = 100; if (highRange != null){ @@ -123,7 +120,7 @@ public class TempTargetActivity extends Activity { } highRange = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 4d, 10d, 0.1d, new DecimalFormat("#0.0"), false); } - + setLabelToPlusMinusView(view, "high"); container.addView(view); return view; }else { diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ViewSelectorActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ViewSelectorActivity.java new file mode 100644 index 0000000000..3b2b678ad2 --- /dev/null +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ViewSelectorActivity.java @@ -0,0 +1,51 @@ +package info.nightscout.androidaps.interaction.actions; + +import android.app.Activity; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import info.nightscout.androidaps.R; + +/** + * Created by adrian on 13/02/17. + */ +public class ViewSelectorActivity extends Activity { + + + View getInflatedPlusMinusView(ViewGroup container) { + SharedPreferences sharedPrefs = PreferenceManager + .getDefaultSharedPreferences(this); + int design = Integer.parseInt(sharedPrefs.getString("input_design", "1")); + + if (design == 2){ + return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item_quickrighty, container, false); + } else if (design == 3) { + return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item_quicklefty, container, false); + } else if (design == 4) { + //TODO: LadyViktoria: Add your design + return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); + } + + //default + return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); + } + + void setLabelToPlusMinusView(View view, String labelText){ + SharedPreferences sharedPrefs = PreferenceManager + .getDefaultSharedPreferences(this); + int design = Integer.parseInt(sharedPrefs.getString("input_design", "1")); + + if (design == 4){ + //TODO: LadyViktoria: Add your design label + + } else { + final TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText(labelText); + } + } + +} diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java index b252c7fbcf..7aa663b341 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/WizardActivity.java @@ -25,7 +25,7 @@ import info.nightscout.androidaps.interaction.utils.SafeParse; */ -public class WizardActivity extends Activity { +public class WizardActivity extends ViewSelectorActivity { PlusMinusEditText editCarbs; @@ -68,9 +68,7 @@ public class WizardActivity extends Activity { public Object instantiateItem(ViewGroup container, int row, int col) { if(col == 0){ - final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); - final TextView textView = (TextView) view.findViewById(R.id.label); - textView.setText("carbs"); + final View view = getInflatedPlusMinusView(container); if (editCarbs == null) { editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 0d, 0d, 150d, 1d, new DecimalFormat("0"), false); } else { @@ -78,6 +76,7 @@ public class WizardActivity extends Activity { editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), false); } + setLabelToPlusMinusView(view, "carbs"); container.addView(view); return view; } else if(col == 1){ diff --git a/wear/src/main/res/layout/action_editplusminus_item_below.xml b/wear/src/main/res/layout/action_editplusminus_item_below.xml new file mode 100644 index 0000000000..2f2beb50dc --- /dev/null +++ b/wear/src/main/res/layout/action_editplusminus_item_below.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/wear/src/main/res/layout/action_editplusminus_item_quicklefty.xml b/wear/src/main/res/layout/action_editplusminus_item_quicklefty.xml new file mode 100644 index 0000000000..89eedd569b --- /dev/null +++ b/wear/src/main/res/layout/action_editplusminus_item_quicklefty.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + diff --git a/wear/src/main/res/layout/action_editplusminus_item_quickrighty.xml b/wear/src/main/res/layout/action_editplusminus_item_quickrighty.xml new file mode 100644 index 0000000000..305aa32d40 --- /dev/null +++ b/wear/src/main/res/layout/action_editplusminus_item_quickrighty.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml index 3df2ef00e3..6edfaa4993 100644 --- a/wear/src/main/res/values/strings.xml +++ b/wear/src/main/res/values/strings.xml @@ -19,6 +19,26 @@ 4 5 + + + + + Default + Quick righty + Quick lefty + Modern Sparse + + + + 1 + 2 + 3 + 4 + + + + + BolusActivity Hello Round World! Hello Square World! diff --git a/wear/src/main/res/xml/preferences.xml b/wear/src/main/res/xml/preferences.xml index 28ab0eb621..3e528e27f9 100644 --- a/wear/src/main/res/xml/preferences.xml +++ b/wear/src/main/res/xml/preferences.xml @@ -18,6 +18,14 @@ app:wear_iconOff="@drawable/settings_off" app:wear_iconOn="@drawable/settings_on" /> + + Date: Mon, 13 Feb 2017 17:48:11 +0100 Subject: [PATCH 48/48] wear added viktoria's design --- .../actions/ViewSelectorActivity.java | 8 +-- .../action_editplusminus_item_viktoria.xml | 69 +++++++++++++++++++ 2 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 wear/src/main/res/layout/action_editplusminus_item_viktoria.xml diff --git a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ViewSelectorActivity.java b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ViewSelectorActivity.java index 3b2b678ad2..c5100d5a03 100644 --- a/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ViewSelectorActivity.java +++ b/wear/src/main/java/info/nightscout/androidaps/interaction/actions/ViewSelectorActivity.java @@ -26,8 +26,7 @@ public class ViewSelectorActivity extends Activity { } else if (design == 3) { return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item_quicklefty, container, false); } else if (design == 4) { - //TODO: LadyViktoria: Add your design - return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item, container, false); + return LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_editplusminus_item_viktoria, container, false); } //default @@ -40,8 +39,9 @@ public class ViewSelectorActivity extends Activity { int design = Integer.parseInt(sharedPrefs.getString("input_design", "1")); if (design == 4){ - //TODO: LadyViktoria: Add your design label - + //@LadyViktoria: Here the label can be set differently, if you like. + final TextView textView = (TextView) view.findViewById(R.id.label); + textView.setText(labelText); } else { final TextView textView = (TextView) view.findViewById(R.id.label); textView.setText(labelText); diff --git a/wear/src/main/res/layout/action_editplusminus_item_viktoria.xml b/wear/src/main/res/layout/action_editplusminus_item_viktoria.xml new file mode 100644 index 0000000000..cef730a62d --- /dev/null +++ b/wear/src/main/res/layout/action_editplusminus_item_viktoria.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file