wear toggle setting to enable watch vibration on bolus
This commit is contained in:
parent
f4b553fe52
commit
5cff42cd92
2 changed files with 20 additions and 1 deletions
|
@ -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<Void, Void, Void> {
|
||||
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
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="vibrateOnBolus"
|
||||
android:title="Vibrate on Bolus"
|
||||
app:wear_iconOff="@drawable/settings_off"
|
||||
app:wear_iconOn="@drawable/settings_on" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="showExternalStatus"
|
||||
|
|
Loading…
Reference in a new issue