wear confirmation timeout and larger text for editplusminus
This commit is contained in:
parent
384e36a1f3
commit
108095ad77
3 changed files with 68 additions and 28 deletions
|
@ -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";
|
private static final String ACTION_RESEND_BULK = "com.dexdrip.stephenblack.nightwatch.RESEND_BULK_DATA";
|
||||||
GoogleApiClient googleApiClient;
|
GoogleApiClient googleApiClient;
|
||||||
private long lastRequest = 0;
|
private long lastRequest = 0;
|
||||||
|
private DismissThread confirmThread;
|
||||||
|
private DismissThread bolusprogressThread;
|
||||||
|
|
||||||
|
|
||||||
public class DataRequester extends AsyncTask<Void, Void, Void> {
|
public class DataRequester extends AsyncTask<Void, Void, Void> {
|
||||||
|
@ -289,17 +291,24 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
NotificationManagerCompat notificationManager =
|
NotificationManagerCompat notificationManager =
|
||||||
NotificationManagerCompat.from(this);
|
NotificationManagerCompat.from(this);
|
||||||
|
|
||||||
|
if(confirmThread != null){
|
||||||
|
confirmThread.invalidate();
|
||||||
|
}
|
||||||
notificationManager.notify(BOLUS_PROGRESS_NOTIF_ID, notificationBuilder.build());
|
notificationManager.notify(BOLUS_PROGRESS_NOTIF_ID, notificationBuilder.build());
|
||||||
notificationManager.cancel(CONFIRM_NOTIF_ID); // multiple watch setup
|
notificationManager.cancel(CONFIRM_NOTIF_ID); // multiple watch setup
|
||||||
|
|
||||||
|
|
||||||
if (progresspercent == 100){
|
if (progresspercent == 100){
|
||||||
scheduleDismiss(BOLUS_PROGRESS_NOTIF_ID, 5);
|
scheduleDismissBolusprogress(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showConfirmationDialog(String title, String message, String actionstring) {
|
private void showConfirmationDialog(String title, String message, String actionstring) {
|
||||||
|
|
||||||
|
if(confirmThread != null){
|
||||||
|
confirmThread.invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
Intent actionIntent = new Intent(this, ListenerService.class);
|
Intent actionIntent = new Intent(this, ListenerService.class);
|
||||||
actionIntent.setAction(ACTION_CONFIRMATION);
|
actionIntent.setAction(ACTION_CONFIRMATION);
|
||||||
actionIntent.putExtra("actionstring", actionstring);
|
actionIntent.putExtra("actionstring", actionstring);
|
||||||
|
@ -323,29 +332,59 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
||||||
notificationManager.notify(CONFIRM_NOTIF_ID, notificationBuilder.build());
|
notificationManager.notify(CONFIRM_NOTIF_ID, notificationBuilder.build());
|
||||||
|
|
||||||
// keep the confirmation dialog open for one minute.
|
// keep the confirmation dialog open for one minute.
|
||||||
scheduleDismiss(CONFIRM_NOTIF_ID, 60);
|
scheduleDismissConfirm(60);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scheduleDismiss(final int notificationId, final int seconds) {
|
private void scheduleDismissConfirm(final int seconds) {
|
||||||
Thread t = new Thread(new Runnable() {
|
if(confirmThread != null){
|
||||||
@Override
|
confirmThread.invalidate();
|
||||||
public void run() {
|
}
|
||||||
try {
|
confirmThread = new DismissThread(CONFIRM_NOTIF_ID, seconds);
|
||||||
Thread.sleep(seconds * 1000);
|
confirmThread.start();
|
||||||
} catch (InterruptedException e) {
|
}
|
||||||
e.printStackTrace();
|
|
||||||
}
|
private void scheduleDismissBolusprogress(final int seconds) {
|
||||||
NotificationManagerCompat notificationManager =
|
if(confirmThread != null){
|
||||||
NotificationManagerCompat.from(ListenerService.this);
|
confirmThread.invalidate();
|
||||||
notificationManager.cancel(notificationId);
|
}
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
});
|
synchronized (this) {
|
||||||
t.start();
|
if(valid) {
|
||||||
|
NotificationManagerCompat notificationManager =
|
||||||
|
NotificationManagerCompat.from(ListenerService.this);
|
||||||
|
notificationManager.cancel(notificationID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void requestData(Context context) {
|
public static void requestData(Context context) {
|
||||||
Intent intent = new Intent(context, ListenerService.class);
|
Intent intent = new Intent(context, ListenerService.class);
|
||||||
intent.setAction(ACTION_RESEND);
|
intent.setAction(ACTION_RESEND);
|
||||||
|
|
|
@ -35,8 +35,8 @@
|
||||||
android:minWidth="50dp"
|
android:minWidth="50dp"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:text="112"
|
android:text="112"
|
||||||
|
android:textSize="45sp"
|
||||||
android:cursorVisible="false"
|
android:cursorVisible="false"
|
||||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
|
||||||
android:gravity="center_horizontal" />
|
android:gravity="center_horizontal" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -46,7 +46,8 @@
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:text="label"
|
android:text="label"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:gravity="center" />
|
android:gravity="center"
|
||||||
|
android:textSize="25sp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/plusbutton"
|
android:id="@+id/plusbutton"
|
||||||
|
|
|
@ -66,14 +66,6 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/full/jni" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/full/jni" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/full/rs" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/full/rs" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/full/shaders" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src/full/shaders" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/res" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/resources" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/assets" type="java-test-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/aidl" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/java" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/jni" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/rs" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/testFull/shaders" isTestSource="true" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/res" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/res" type="java-test-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/resources" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/resources" type="java-test-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/assets" type="java-test-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/assets" type="java-test-resource" />
|
||||||
|
@ -82,6 +74,14 @@
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/jni" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/jni" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/rs" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/rs" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/shaders" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/src/androidTestFull/shaders" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/res" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/resources" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/assets" type="java-test-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/aidl" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/java" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/jni" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/rs" isTestSource="true" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/testFull/shaders" isTestSource="true" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
|
||||||
|
|
Loading…
Reference in a new issue