Merge pull request #250 from nightscout/fix/wear-bolusprogress-channels
bolusprogress channels
This commit is contained in:
commit
d538b88a05
|
@ -10,7 +10,7 @@
|
|||
|
||||
|
||||
<application
|
||||
android:name=".aaps"
|
||||
android:name=".Aaps"
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_icon"
|
||||
android:label="@string/app_name"
|
||||
|
|
|
@ -5,19 +5,16 @@ import android.app.Application;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import androidx.annotation.StringRes;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import info.nightscout.androidaps.interaction.utils.Persistence;
|
||||
|
||||
/**
|
||||
* Created for xDrip+ by Emma Black on 3/21/15.
|
||||
* Adapted for AAPS by dlvoy 2019-11-06.
|
||||
*/
|
||||
|
||||
public class aaps extends Application implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public class Aaps extends Application implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private static Context context;
|
||||
|
@ -26,7 +23,7 @@ public class aaps extends Application implements SharedPreferences.OnSharedPrefe
|
|||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
aaps.context = getApplicationContext();
|
||||
Aaps.context = getApplicationContext();
|
||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
sharedPrefs.registerOnSharedPreferenceChangeListener(this);
|
||||
updatePrefs(sharedPrefs);
|
||||
|
@ -39,19 +36,7 @@ public class aaps extends Application implements SharedPreferences.OnSharedPrefe
|
|||
}
|
||||
|
||||
public static Context getAppContext() {
|
||||
return aaps.context;
|
||||
}
|
||||
|
||||
private static boolean isWear2OrAbove() {
|
||||
return Build.VERSION.SDK_INT > 23;
|
||||
}
|
||||
|
||||
public static String gs(@StringRes final int id) {
|
||||
return getAppContext().getString(id);
|
||||
}
|
||||
|
||||
public static String gs(@StringRes final int id, String... args) {
|
||||
return getAppContext().getString(id, (Object[]) args);
|
||||
return Aaps.context;
|
||||
}
|
||||
|
||||
public static Boolean areComplicationsUnicode() {
|
|
@ -19,7 +19,7 @@ import java.util.Set;
|
|||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.Aaps;
|
||||
import info.nightscout.androidaps.data.RawDisplayData;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.utils.Constants;
|
||||
|
@ -94,11 +94,11 @@ public abstract class BaseComplicationProviderService extends ComplicationProvid
|
|||
}
|
||||
break;
|
||||
case ComplicationData.TYPE_LONG_TEXT:
|
||||
builder.setLongTitle(ComplicationText.plainText(aaps.gs(R.string.label_warning_sync)));
|
||||
builder.setLongTitle(ComplicationText.plainText(getString(R.string.label_warning_sync)));
|
||||
if (since > 0) {
|
||||
builder.setLongText(ComplicationText.plainText(String.format(aaps.gs(R.string.label_warning_since), DisplayFormat.shortTimeSince(since))));
|
||||
builder.setLongText(ComplicationText.plainText(String.format(getString(R.string.label_warning_since), DisplayFormat.shortTimeSince(since))));
|
||||
} else {
|
||||
builder.setLongText(ComplicationText.plainText(aaps.gs(R.string.label_warning_sync_aaps)));
|
||||
builder.setLongText(ComplicationText.plainText(getString(R.string.label_warning_sync_aaps)));
|
||||
}
|
||||
break;
|
||||
case ComplicationData.TYPE_LARGE_IMAGE:
|
||||
|
@ -143,11 +143,11 @@ public abstract class BaseComplicationProviderService extends ComplicationProvid
|
|||
}
|
||||
break;
|
||||
case ComplicationData.TYPE_LONG_TEXT:
|
||||
builder.setLongTitle(ComplicationText.plainText(aaps.gs(R.string.label_warning_old)));
|
||||
builder.setLongTitle(ComplicationText.plainText(getString(R.string.label_warning_old)));
|
||||
if (since > 0) {
|
||||
builder.setLongText(ComplicationText.plainText(String.format(aaps.gs(R.string.label_warning_since), DisplayFormat.shortTimeSince(since))));
|
||||
builder.setLongText(ComplicationText.plainText(String.format(getString(R.string.label_warning_since), DisplayFormat.shortTimeSince(since))));
|
||||
} else {
|
||||
builder.setLongText(ComplicationText.plainText(aaps.gs(R.string.label_warning_sync_aaps)));
|
||||
builder.setLongText(ComplicationText.plainText(getString(R.string.label_warning_sync_aaps)));
|
||||
}
|
||||
break;
|
||||
case ComplicationData.TYPE_LARGE_IMAGE:
|
||||
|
@ -223,7 +223,7 @@ public abstract class BaseComplicationProviderService extends ComplicationProvid
|
|||
// We pass the complication id, so we can only update the specific complication tapped.
|
||||
final PendingIntent complicationPendingIntent =
|
||||
ComplicationTapBroadcastReceiver.getTapActionIntent(
|
||||
aaps.getAppContext(), thisProvider, complicationId, getComplicationAction());
|
||||
Aaps.getAppContext(), thisProvider, complicationId, getComplicationAction());
|
||||
|
||||
final Persistence persistence = new Persistence();
|
||||
|
||||
|
@ -242,12 +242,12 @@ public abstract class BaseComplicationProviderService extends ComplicationProvid
|
|||
if (WearUtil.msSince(persistence.whenDataUpdated()) > Constants.STALE_MS) {
|
||||
// no new data arrived - probably configuration or connection error
|
||||
final PendingIntent infoToast = ComplicationTapBroadcastReceiver.getTapWarningSinceIntent(
|
||||
aaps.getAppContext(), thisProvider, complicationId, ComplicationAction.WARNING_SYNC, persistence.whenDataUpdated());
|
||||
Aaps.getAppContext(), thisProvider, complicationId, ComplicationAction.WARNING_SYNC, persistence.whenDataUpdated());
|
||||
complicationData = buildNoSyncComplicationData(dataType, raw, complicationPendingIntent, infoToast, persistence.whenDataUpdated());
|
||||
} else if (WearUtil.msSince(raw.datetime) > Constants.STALE_MS) {
|
||||
// data arriving from phone AAPS, but it is outdated (uploader/NS/xDrip/Sensor error)
|
||||
final PendingIntent infoToast = ComplicationTapBroadcastReceiver.getTapWarningSinceIntent(
|
||||
aaps.getAppContext(), thisProvider, complicationId, ComplicationAction.WARNING_OLD, raw.datetime);
|
||||
Aaps.getAppContext(), thisProvider, complicationId, ComplicationAction.WARNING_OLD, raw.datetime);
|
||||
complicationData = buildOutdatedComplicationData(dataType, raw, complicationPendingIntent, infoToast, raw.datetime);
|
||||
} else {
|
||||
// data is up-to-date, we can render standard complication
|
||||
|
@ -349,8 +349,8 @@ public abstract class BaseComplicationProviderService extends ComplicationProvid
|
|||
Inevitable.task("update-req-"+provider, 700, () -> {
|
||||
if (WearUtil.isBelowRateLimit("update-req-"+provider, 2)) {
|
||||
Log.d(TAG, "Requesting update of "+provider);
|
||||
final ComponentName componentName = new ComponentName(aaps.getAppContext(), provider);
|
||||
final ProviderUpdateRequester providerUpdateRequester = new ProviderUpdateRequester(aaps.getAppContext(), componentName);
|
||||
final ComponentName componentName = new ComponentName(Aaps.getAppContext(), provider);
|
||||
final ProviderUpdateRequester providerUpdateRequester = new ProviderUpdateRequester(Aaps.getAppContext(), componentName);
|
||||
providerUpdateRequester.requestUpdateAll();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -13,7 +13,7 @@ import android.widget.Toast;
|
|||
import androidx.annotation.StringRes;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.Aaps;
|
||||
import info.nightscout.androidaps.interaction.actions.BolusActivity;
|
||||
import info.nightscout.androidaps.interaction.actions.ECarbActivity;
|
||||
import info.nightscout.androidaps.interaction.actions.WizardActivity;
|
||||
|
@ -67,16 +67,16 @@ public class ComplicationTapBroadcastReceiver extends BroadcastReceiver {
|
|||
// do nothing
|
||||
return;
|
||||
case WIZARD:
|
||||
intentOpen = new Intent(aaps.getAppContext(), WizardActivity.class);
|
||||
intentOpen = new Intent(Aaps.getAppContext(), WizardActivity.class);
|
||||
break;
|
||||
case BOLUS:
|
||||
intentOpen = new Intent(aaps.getAppContext(), BolusActivity.class);
|
||||
intentOpen = new Intent(Aaps.getAppContext(), BolusActivity.class);
|
||||
break;
|
||||
case ECARB:
|
||||
intentOpen = new Intent(aaps.getAppContext(), ECarbActivity.class);
|
||||
intentOpen = new Intent(Aaps.getAppContext(), ECarbActivity.class);
|
||||
break;
|
||||
case STATUS:
|
||||
intentOpen = new Intent(aaps.getAppContext(), StatusMenuActivity.class);
|
||||
intentOpen = new Intent(Aaps.getAppContext(), StatusMenuActivity.class);
|
||||
break;
|
||||
case WARNING_OLD:
|
||||
case WARNING_SYNC:
|
||||
|
@ -84,23 +84,23 @@ public class ComplicationTapBroadcastReceiver extends BroadcastReceiver {
|
|||
long since = extras.getLong(EXTRA_COMPLICATION_SINCE, oneAndHalfMinuteAgo);
|
||||
@StringRes int labelId = (action == ComplicationAction.WARNING_SYNC) ?
|
||||
R.string.msg_warning_sync : R.string.msg_warning_old;
|
||||
String msg = String.format(aaps.gs(labelId), DisplayFormat.shortTimeSince(since));
|
||||
Toast.makeText(aaps.getAppContext(), msg, Toast.LENGTH_LONG).show();
|
||||
String msg = String.format(context.getString(labelId), DisplayFormat.shortTimeSince(since));
|
||||
Toast.makeText(Aaps.getAppContext(), msg, Toast.LENGTH_LONG).show();
|
||||
break;
|
||||
case MENU:
|
||||
default:
|
||||
intentOpen = new Intent(aaps.getAppContext(), MainMenuActivity.class);
|
||||
intentOpen = new Intent(Aaps.getAppContext(), MainMenuActivity.class);
|
||||
}
|
||||
|
||||
if (intentOpen != null) {
|
||||
// Perform intent - open dialog
|
||||
intentOpen.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
aaps.getAppContext().startActivity(intentOpen);
|
||||
Aaps.getAppContext().startActivity(intentOpen);
|
||||
}
|
||||
}
|
||||
|
||||
private ComplicationAction remapActionWithUserPreferences(ComplicationAction originalAction) {
|
||||
final String userPrefAction = aaps.getComplicationTapAction();
|
||||
final String userPrefAction = Aaps.getComplicationTapAction();
|
||||
switch (originalAction) {
|
||||
case WARNING_OLD:
|
||||
case WARNING_SYNC:
|
||||
|
|
|
@ -14,7 +14,7 @@ import android.view.WindowManager;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.Aaps;
|
||||
import info.nightscout.androidaps.data.RawDisplayData;
|
||||
|
||||
/*
|
||||
|
@ -33,7 +33,7 @@ public abstract class WallpaperComplication extends BaseComplicationProviderServ
|
|||
if (dataType == ComplicationData.TYPE_LARGE_IMAGE) {
|
||||
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
WindowManager windowManager = (WindowManager) aaps.getAppContext()
|
||||
WindowManager windowManager = (WindowManager) Aaps.getAppContext()
|
||||
.getSystemService(Context.WINDOW_SERVICE);
|
||||
windowManager.getDefaultDisplay().getMetrics(metrics);
|
||||
int width = metrics.widthPixels;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package info.nightscout.androidaps.data;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
|
@ -37,7 +38,6 @@ import com.google.android.gms.wearable.WearableListenerService;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interaction.AAPSPreferences;
|
||||
import info.nightscout.androidaps.interaction.actions.AcceptActivity;
|
||||
|
@ -82,7 +82,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 AAPS_NOTIFY_CHANNEL_ID_OPENLOOP = "AndroidAPS-Openloop";
|
||||
private static final String AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS = "AndroidAPS-bolus-progress";
|
||||
private static final String AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS = "bolus progress vibration";
|
||||
private static final String AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS_SILENT = "bolus progress silent";
|
||||
|
||||
|
||||
GoogleApiClient googleApiClient;
|
||||
|
@ -616,17 +617,7 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
|||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
CharSequence name = "AAPS Bolus Progress";
|
||||
String description = "Bolus progress and cancel";
|
||||
NotificationChannel channel = new NotificationChannel(AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS, name, NotificationManager.IMPORTANCE_HIGH);
|
||||
channel.setDescription(description);
|
||||
channel.enableVibration(true);
|
||||
channel.setVibrationPattern(vibratePattern);
|
||||
|
||||
// Register the channel with the system; you can't change the importance
|
||||
// or other notification behaviors after this
|
||||
NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
createBolusProgressChannels();
|
||||
}
|
||||
|
||||
Intent cancelIntent = new Intent(this, ListenerService.class);
|
||||
|
@ -634,15 +625,15 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
|||
PendingIntent cancelPendingIntent = PendingIntent.getService(this, 0, cancelIntent, 0);
|
||||
|
||||
NotificationCompat.Builder notificationBuilder =
|
||||
new NotificationCompat.Builder(this, AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS)
|
||||
new NotificationCompat.Builder(this, vibrate ? AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS: AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS_SILENT)
|
||||
.setSmallIcon(R.drawable.ic_icon)
|
||||
.setContentTitle(aaps.gs(R.string.bolus_progress))
|
||||
.setContentTitle(getString(R.string.bolus_progress))
|
||||
.setContentText(progresspercent + "% - " + progresstatus)
|
||||
.setSubText(aaps.gs(R.string.press_to_cancel))
|
||||
.setSubText(getString(R.string.press_to_cancel))
|
||||
.setContentIntent(cancelPendingIntent)
|
||||
.setPriority(NotificationCompat.PRIORITY_MAX)
|
||||
.setVibrate(vibratePattern)
|
||||
.addAction(R.drawable.ic_cancel, aaps.gs(R.string.cancel_bolus), cancelPendingIntent);
|
||||
.addAction(R.drawable.ic_cancel, getString(R.string.cancel_bolus), cancelPendingIntent);
|
||||
|
||||
NotificationManagerCompat notificationManager =
|
||||
NotificationManagerCompat.from(this);
|
||||
|
@ -656,6 +647,25 @@ public class ListenerService extends WearableListenerService implements GoogleAp
|
|||
}
|
||||
}
|
||||
|
||||
@TargetApi(value = 26)
|
||||
private void createBolusProgressChannels() {
|
||||
createNotificationChannel(new long[]{0, 50, 1000}, AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS, getString(R.string.bolus_progress_channel_name), getString(R.string.bolus_progress_channel_description));
|
||||
createNotificationChannel(new long[]{0, 1, 1000}, AAPS_NOTIFY_CHANNEL_ID_BOLUSPROGRESS_SILENT, getString(R.string.bolus_progress_silent_channel_name), getString(R.string.bolus_progress_silent_channel_description));
|
||||
}
|
||||
|
||||
@TargetApi(value = 26)
|
||||
private void createNotificationChannel(long[] vibratePattern, String channelID, CharSequence name, String description) {
|
||||
NotificationChannel channel = new NotificationChannel(channelID, name, NotificationManager.IMPORTANCE_HIGH);
|
||||
channel.setDescription(description);
|
||||
channel.enableVibration(true);
|
||||
channel.setVibrationPattern(vibratePattern);
|
||||
|
||||
// Register the channel with the system; you can't change the importance
|
||||
// or other notification behaviors after this
|
||||
NotificationManager notificationManager = getSystemService(NotificationManager.class);
|
||||
notificationManager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
private void showConfirmationDialog(String title, String message, String actionstring) {
|
||||
|
||||
Intent intent = new Intent(this, AcceptActivity.class);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
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;
|
||||
|
@ -11,12 +10,10 @@ 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;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
|
||||
import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||
|
@ -65,24 +62,24 @@ public class BolusActivity extends ViewSelectorActivity {
|
|||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||
|
||||
if(col == 0){
|
||||
if (col == 0) {
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
double def = 0;
|
||||
if (editInsulin != null){
|
||||
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, aaps.gs(R.string.action_insulin));
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_insulin));
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else if(col == 1){
|
||||
} else if (col == 1) {
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
double def = 0;
|
||||
if (editCarbs != null){
|
||||
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, aaps.gs(R.string.action_carbs));
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_carbs));
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else {
|
||||
|
@ -96,7 +93,7 @@ public class BolusActivity extends ViewSelectorActivity {
|
|||
//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())
|
||||
String actionstring = "bolus " + SafeParse.stringToDouble(editInsulin.editText.getText().toString())
|
||||
+ " " + SafeParse.stringToInt(editCarbs.editText.getText().toString());
|
||||
ListenerService.initiateAction(BolusActivity.this, actionstring);
|
||||
finish();
|
||||
|
@ -111,12 +108,12 @@ public class BolusActivity extends ViewSelectorActivity {
|
|||
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);
|
||||
container.removeView((View) view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view==object;
|
||||
return view == object;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import android.widget.ImageView;
|
|||
import java.text.DecimalFormat;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
|
||||
import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||
|
@ -40,11 +39,12 @@ public class CPPActivity extends ViewSelectorActivity {
|
|||
percentage = extras.getInt("percentage", -1);
|
||||
timeshift = extras.getInt("timeshift", -1);
|
||||
|
||||
if (percentage ==-1 || timeshift ==-25){
|
||||
finish(); return;
|
||||
if (percentage == -1 || timeshift == -25) {
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
|
||||
if(timeshift < 0) timeshift += 24;
|
||||
if (timeshift < 0) timeshift += 24;
|
||||
|
||||
setContentView(R.layout.grid_layout);
|
||||
final Resources res = getResources();
|
||||
|
@ -77,24 +77,24 @@ public class CPPActivity extends ViewSelectorActivity {
|
|||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||
|
||||
if(col == 0){
|
||||
if (col == 0) {
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
double def = timeshift;
|
||||
if (editTimeshift != null){
|
||||
if (editTimeshift != null) {
|
||||
def = SafeParse.stringToDouble(editTimeshift.editText.getText().toString());
|
||||
}
|
||||
editTimeshift = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 23d, 1d, new DecimalFormat("0"), true, true);
|
||||
setLabelToPlusMinusView(view, aaps.gs(R.string.action_timeshift));
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_timeshift));
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else if(col == 1){
|
||||
} else if (col == 1) {
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
double def = percentage;
|
||||
if (editPercentage != null){
|
||||
if (editPercentage != null) {
|
||||
def = SafeParse.stringToDouble(editPercentage.editText.getText().toString());
|
||||
}
|
||||
editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 30d, 250d, 1d, new DecimalFormat("0"), false);
|
||||
setLabelToPlusMinusView(view, aaps.gs(R.string.action_percentage));
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_percentage));
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else {
|
||||
|
@ -108,7 +108,7 @@ public class CPPActivity extends ViewSelectorActivity {
|
|||
//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 = "cppset " +SafeParse.stringToInt(editTimeshift.editText.getText().toString())
|
||||
String actionstring = "cppset " + SafeParse.stringToInt(editTimeshift.editText.getText().toString())
|
||||
+ " " + SafeParse.stringToInt(editPercentage.editText.getText().toString());
|
||||
ListenerService.initiateAction(CPPActivity.this, actionstring);
|
||||
finish();
|
||||
|
@ -123,12 +123,12 @@ public class CPPActivity extends ViewSelectorActivity {
|
|||
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);
|
||||
container.removeView((View) view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view==object;
|
||||
return view == object;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ import android.widget.ImageView;
|
|||
import java.text.DecimalFormat;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
|
||||
import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||
|
@ -72,7 +71,7 @@ public class ECarbActivity extends ViewSelectorActivity {
|
|||
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"), true);
|
||||
setLabelToPlusMinusView(view, aaps.gs(R.string.action_carbs));
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_carbs));
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else if(col == 1){
|
||||
|
@ -82,7 +81,7 @@ public class ECarbActivity extends ViewSelectorActivity {
|
|||
def = SafeParse.stringToDouble(editStartTime.editText.getText().toString());
|
||||
}
|
||||
editStartTime = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 300d, 15d, new DecimalFormat("0"), false);
|
||||
setLabelToPlusMinusView(view, aaps.gs(R.string.action_start_min));
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_start_min));
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else if(col == 2){
|
||||
|
@ -92,7 +91,7 @@ public class ECarbActivity extends ViewSelectorActivity {
|
|||
def = SafeParse.stringToDouble(editDuration.editText.getText().toString());
|
||||
}
|
||||
editDuration = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 8d, 1d, new DecimalFormat("0"), false);
|
||||
setLabelToPlusMinusView(view, aaps.gs(R.string.action_duration_h));
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_duration_h));
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
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;
|
||||
|
@ -11,12 +10,10 @@ 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.aaps;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
|
||||
import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||
|
@ -64,14 +61,14 @@ public class FillActivity extends ViewSelectorActivity {
|
|||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||
|
||||
if(col == 0){
|
||||
if (col == 0) {
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
double def = 0d;
|
||||
if (editInsulin != null){
|
||||
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, aaps.gs(R.string.action_insulin));
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_insulin));
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else {
|
||||
|
@ -85,7 +82,7 @@ public class FillActivity extends ViewSelectorActivity {
|
|||
//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());
|
||||
String actionstring = "fill " + SafeParse.stringToDouble(editInsulin.editText.getText().toString());
|
||||
ListenerService.initiateAction(FillActivity.this, actionstring);
|
||||
finish();
|
||||
}
|
||||
|
@ -99,12 +96,12 @@ public class FillActivity extends ViewSelectorActivity {
|
|||
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);
|
||||
container.removeView((View) view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view==object;
|
||||
return view == object;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import android.widget.TextView;
|
|||
import java.text.DecimalFormat;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.utils.PlusMinusEditText;
|
||||
import info.nightscout.androidaps.interaction.utils.SafeParse;
|
||||
|
@ -62,7 +61,7 @@ public class TempTargetActivity extends ViewSelectorActivity {
|
|||
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
||||
@Override
|
||||
public int getColumnCount(int arg0) {
|
||||
return isSingleTarget?3:4;
|
||||
return isSingleTarget ? 3 : 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -73,7 +72,7 @@ public class TempTargetActivity extends ViewSelectorActivity {
|
|||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||
|
||||
if(col == 0){
|
||||
if (col == 0) {
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
final TextView textView = view.findViewById(R.id.label);
|
||||
textView.setText("duration");
|
||||
|
@ -83,51 +82,51 @@ public class TempTargetActivity extends ViewSelectorActivity {
|
|||
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, 5d, new DecimalFormat("0"), false);
|
||||
}
|
||||
setLabelToPlusMinusView(view, aaps.gs(R.string.action_duration));
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_duration));
|
||||
container.addView(view);
|
||||
return view;
|
||||
|
||||
} else if(col == 1){
|
||||
} else if (col == 1) {
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
if (isMGDL){
|
||||
if (isMGDL) {
|
||||
double def = 100;
|
||||
if (lowRange != null){
|
||||
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 {
|
||||
double def = 5.5;
|
||||
if (lowRange != null){
|
||||
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);
|
||||
}
|
||||
if(isSingleTarget){
|
||||
setLabelToPlusMinusView(view, aaps.gs(R.string.action_target));
|
||||
if (isSingleTarget) {
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_target));
|
||||
} else {
|
||||
setLabelToPlusMinusView(view, aaps.gs(R.string.action_low));
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_low));
|
||||
}
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else if(col == 2 && ! isSingleTarget){
|
||||
} else if (col == 2 && !isSingleTarget) {
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
if (isMGDL){
|
||||
if (isMGDL) {
|
||||
double def = 100;
|
||||
if (highRange != null){
|
||||
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 {
|
||||
double def = 5.5;
|
||||
if (highRange != null){
|
||||
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);
|
||||
}
|
||||
setLabelToPlusMinusView(view, aaps.gs(R.string.action_high));
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_high));
|
||||
container.addView(view);
|
||||
return view;
|
||||
}else {
|
||||
} else {
|
||||
|
||||
final View view = LayoutInflater.from(getApplicationContext()).inflate(R.layout.action_send_item, container, false);
|
||||
final ImageView confirmbutton = view.findViewById(R.id.confirmbutton);
|
||||
|
@ -142,8 +141,7 @@ public class TempTargetActivity extends ViewSelectorActivity {
|
|||
+ " " + isMGDL
|
||||
+ " " + SafeParse.stringToInt(time.editText.getText().toString())
|
||||
+ " " + SafeParse.stringToDouble(lowRange.editText.getText().toString())
|
||||
+ " " + (isSingleTarget?SafeParse.stringToDouble(lowRange.editText.getText().toString()):SafeParse.stringToDouble(highRange.editText.getText().toString()))
|
||||
;
|
||||
+ " " + (isSingleTarget ? SafeParse.stringToDouble(lowRange.editText.getText().toString()) : SafeParse.stringToDouble(highRange.editText.getText().toString()));
|
||||
|
||||
ListenerService.initiateAction(TempTargetActivity.this, actionstring);
|
||||
finish();
|
||||
|
@ -158,12 +156,12 @@ public class TempTargetActivity extends ViewSelectorActivity {
|
|||
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);
|
||||
container.removeView((View) view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view==object;
|
||||
return view == object;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package info.nightscout.androidaps.interaction.actions;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
|
@ -13,13 +12,11 @@ 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.aaps;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
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;
|
||||
|
||||
|
@ -61,7 +58,7 @@ public class WizardActivity extends ViewSelectorActivity {
|
|||
private class MyGridViewPagerAdapter extends GridPagerAdapter {
|
||||
@Override
|
||||
public int getColumnCount(int arg0) {
|
||||
return hasPercentage?3:2;
|
||||
return hasPercentage ? 3 : 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,7 +69,7 @@ public class WizardActivity extends ViewSelectorActivity {
|
|||
@Override
|
||||
public Object instantiateItem(ViewGroup container, int row, int col) {
|
||||
|
||||
if(col == 0){
|
||||
if (col == 0) {
|
||||
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);
|
||||
|
@ -81,10 +78,10 @@ public class WizardActivity extends ViewSelectorActivity {
|
|||
editCarbs = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 0d, 150d, 1d, new DecimalFormat("0"), false);
|
||||
|
||||
}
|
||||
setLabelToPlusMinusView(view, aaps.gs(R.string.action_carbs));
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_carbs));
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else if(col == 1 && hasPercentage){
|
||||
} else if (col == 1 && hasPercentage) {
|
||||
final View view = getInflatedPlusMinusView(container);
|
||||
if (editPercentage == null) {
|
||||
editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, 100d, 50d, 150d, 1d, new DecimalFormat("0"), false);
|
||||
|
@ -92,7 +89,7 @@ public class WizardActivity extends ViewSelectorActivity {
|
|||
double def = SafeParse.stringToDouble(editPercentage.editText.getText().toString());
|
||||
editPercentage = new PlusMinusEditText(view, R.id.amountfield, R.id.plusbutton, R.id.minusbutton, def, 50d, 150d, 1d, new DecimalFormat("0"), false);
|
||||
}
|
||||
setLabelToPlusMinusView(view, aaps.gs(R.string.action_percentage));
|
||||
setLabelToPlusMinusView(view, getString(R.string.action_percentage));
|
||||
container.addView(view);
|
||||
return view;
|
||||
} else {
|
||||
|
@ -108,7 +105,8 @@ public class WizardActivity extends ViewSelectorActivity {
|
|||
|
||||
int percentage = 100;
|
||||
|
||||
if (editPercentage != null) percentage = SafeParse.stringToInt(editPercentage.editText.getText().toString());
|
||||
if (editPercentage != null)
|
||||
percentage = SafeParse.stringToInt(editPercentage.editText.getText().toString());
|
||||
|
||||
String actionstring = "wizard2 " + SafeParse.stringToInt(editCarbs.editText.getText().toString())
|
||||
+ " " + percentage;
|
||||
|
@ -125,12 +123,12 @@ public class WizardActivity extends ViewSelectorActivity {
|
|||
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);
|
||||
container.removeView((View) view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isViewFromObject(View view, Object object) {
|
||||
return view==object;
|
||||
return view == object;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.interaction.menus;
|
|||
import android.content.Intent;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.actions.FillActivity;
|
||||
import info.nightscout.androidaps.interaction.utils.MenuListActivity;
|
||||
|
@ -17,22 +16,22 @@ public class FillMenuActivity extends MenuListActivity {
|
|||
@Override
|
||||
protected String[] getElements() {
|
||||
return new String[]{
|
||||
aaps.gs(R.string.action_preset_1),
|
||||
aaps.gs(R.string.action_preset_2),
|
||||
aaps.gs(R.string.action_preset_3),
|
||||
aaps.gs(R.string.action_free_amount)
|
||||
getString(R.string.action_preset_1),
|
||||
getString(R.string.action_preset_2),
|
||||
getString(R.string.action_preset_3),
|
||||
getString(R.string.action_free_amount)
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doAction(String action) {
|
||||
if (aaps.gs(R.string.action_preset_1).equals(action)) {
|
||||
if (getString(R.string.action_preset_1).equals(action)) {
|
||||
ListenerService.initiateAction(this, "fillpreset 1");
|
||||
} else if (aaps.gs(R.string.action_preset_2).equals(action)) {
|
||||
} else if (getString(R.string.action_preset_2).equals(action)) {
|
||||
ListenerService.initiateAction(this, "fillpreset 2");
|
||||
} else if (aaps.gs(R.string.action_preset_3).equals(action)) {
|
||||
} else if (getString(R.string.action_preset_3).equals(action)) {
|
||||
ListenerService.initiateAction(this, "fillpreset 3");
|
||||
} else if (aaps.gs(R.string.action_free_amount).equals(action)) {
|
||||
} else if (getString(R.string.action_free_amount).equals(action)) {
|
||||
Intent intent = new Intent(this, FillActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
|
|
|
@ -8,10 +8,8 @@ import android.preference.PreferenceManager;
|
|||
import java.util.Vector;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.AAPSPreferences;
|
||||
import info.nightscout.androidaps.interaction.actions.AcceptActivity;
|
||||
import info.nightscout.androidaps.interaction.actions.BolusActivity;
|
||||
import info.nightscout.androidaps.interaction.actions.ECarbActivity;
|
||||
import info.nightscout.androidaps.interaction.actions.TempTargetActivity;
|
||||
|
@ -39,8 +37,8 @@ public class MainMenuActivity extends MenuListActivity {
|
|||
|
||||
if(!sharedPreferences.getBoolean("wearcontrol", false)){
|
||||
return new String[] {
|
||||
aaps.gs(R.string.menu_settings),
|
||||
aaps.gs(R.string.menu_resync)};
|
||||
getString(R.string.menu_settings),
|
||||
getString(R.string.menu_resync)};
|
||||
}
|
||||
|
||||
|
||||
|
@ -48,13 +46,13 @@ public class MainMenuActivity extends MenuListActivity {
|
|||
boolean showWizard = sp.getBoolean("showWizard", true);
|
||||
|
||||
Vector<String> menuitems = new Vector<String>();
|
||||
menuitems.add(aaps.gs(R.string.menu_tempt));
|
||||
if(showWizard) menuitems.add(aaps.gs(R.string.menu_wizard));
|
||||
menuitems.add(aaps.gs(R.string.menu_ecarb));
|
||||
menuitems.add(aaps.gs(R.string.menu_bolus));
|
||||
menuitems.add(aaps.gs(R.string.menu_settings));
|
||||
menuitems.add(aaps.gs(R.string.menu_status));
|
||||
if (showPrimeFill) menuitems.add(aaps.gs(R.string.menu_prime_fill));
|
||||
menuitems.add(getString(R.string.menu_tempt));
|
||||
if(showWizard) menuitems.add(getString(R.string.menu_wizard));
|
||||
menuitems.add(getString(R.string.menu_ecarb));
|
||||
menuitems.add(getString(R.string.menu_bolus));
|
||||
menuitems.add(getString(R.string.menu_settings));
|
||||
menuitems.add(getString(R.string.menu_status));
|
||||
if (showPrimeFill) menuitems.add(getString(R.string.menu_prime_fill));
|
||||
|
||||
return menuitems.toArray(new String[menuitems.size()]);
|
||||
}
|
||||
|
@ -64,33 +62,33 @@ public class MainMenuActivity extends MenuListActivity {
|
|||
|
||||
Intent intent;
|
||||
|
||||
if (aaps.gs(R.string.menu_settings).equals(action)) {
|
||||
if (getString(R.string.menu_settings).equals(action)) {
|
||||
intent = new Intent(this, AAPSPreferences.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
} else if ("Re-Sync".equals(action)) {
|
||||
ListenerService.requestData(this);
|
||||
} else if (aaps.gs(R.string.menu_tempt).equals(action)) {
|
||||
} else if (getString(R.string.menu_tempt).equals(action)) {
|
||||
intent = new Intent(this, TempTargetActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
} else if (aaps.gs(R.string.menu_bolus).equals(action)) {
|
||||
} else if (getString(R.string.menu_bolus).equals(action)) {
|
||||
intent = new Intent(this, BolusActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
} else if (aaps.gs(R.string.menu_wizard).equals(action)) {
|
||||
} else if (getString(R.string.menu_wizard).equals(action)) {
|
||||
intent = new Intent(this, WizardActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
} else if (aaps.gs(R.string.menu_status).equals(action)) {
|
||||
} else if (getString(R.string.menu_status).equals(action)) {
|
||||
intent = new Intent(this, StatusMenuActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
} else if (aaps.gs(R.string.menu_prime_fill).equals(action)) {
|
||||
} else if (getString(R.string.menu_prime_fill).equals(action)) {
|
||||
intent = new Intent(this, FillMenuActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
} else if (aaps.gs(R.string.menu_ecarb).equals(action)) {
|
||||
} else if (getString(R.string.menu_ecarb).equals(action)) {
|
||||
intent = new Intent(this, ECarbActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
this.startActivity(intent);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package info.nightscout.androidaps.interaction.menus;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.interaction.utils.MenuListActivity;
|
||||
|
||||
|
@ -14,23 +13,23 @@ public class StatusMenuActivity extends MenuListActivity {
|
|||
@Override
|
||||
protected String[] getElements() {
|
||||
return new String[] {
|
||||
aaps.gs(R.string.status_pump),
|
||||
aaps.gs(R.string.status_loop),
|
||||
aaps.gs(R.string.status_cpp),
|
||||
aaps.gs(R.string.status_tdd)};
|
||||
getString(R.string.status_pump),
|
||||
getString(R.string.status_loop),
|
||||
getString(R.string.status_cpp),
|
||||
getString(R.string.status_tdd)};
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doAction(String action) {
|
||||
if (aaps.gs(R.string.status_pump).equals(action)) {
|
||||
if (getString(R.string.status_pump).equals(action)) {
|
||||
ListenerService.initiateAction(this, "status pump");
|
||||
} else if (aaps.gs(R.string.status_loop).equals(action)) {
|
||||
} else if (getString(R.string.status_loop).equals(action)) {
|
||||
ListenerService.initiateAction(this, "status loop");
|
||||
} else if (aaps.gs(R.string.status_cpp).equals(action)) {
|
||||
} else if (getString(R.string.status_cpp).equals(action)) {
|
||||
ListenerService.initiateAction(this, "opencpp");
|
||||
} else if (aaps.gs(R.string.status_tdd).equals(action)) {
|
||||
} else if (getString(R.string.status_tdd).equals(action)) {
|
||||
ListenerService.initiateAction(this, "tddstats");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package info.nightscout.androidaps.interaction.utils;
|
||||
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.Aaps;
|
||||
import info.nightscout.androidaps.data.RawDisplayData;
|
||||
|
||||
public class DisplayFormat {
|
||||
|
@ -16,15 +16,15 @@ public class DisplayFormat {
|
|||
public static final int MIN_FIELD_LEN_IOB = 3; // IoB can range from like .1U to 99U
|
||||
|
||||
public static String deltaSymbol() {
|
||||
return aaps.areComplicationsUnicode() ? "\u0394" : "";
|
||||
return Aaps.areComplicationsUnicode() ? "\u0394" : "";
|
||||
}
|
||||
|
||||
public static String verticalSeparatorSymbol() {
|
||||
return aaps.areComplicationsUnicode() ? "\u205E" : "|";
|
||||
return Aaps.areComplicationsUnicode() ? "\u205E" : "|";
|
||||
}
|
||||
|
||||
public static String basalRateSymbol() {
|
||||
return aaps.areComplicationsUnicode() ? "\u238D\u2006" : "";
|
||||
return Aaps.areComplicationsUnicode() ? "\u238D\u2006" : "";
|
||||
}
|
||||
|
||||
public static String shortTimeSince(final long refTime) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import com.google.android.gms.wearable.DataMap;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.Aaps;
|
||||
|
||||
/**
|
||||
* Created by dlvoy on 2019-11-12
|
||||
|
@ -21,7 +21,7 @@ public class Persistence {
|
|||
"info.nightscout.androidaps.complications.COMPLICATION_PROVIDER_PREFERENCES_FILE_KEY";
|
||||
|
||||
public Persistence() {
|
||||
preferences = aaps.getAppContext().getSharedPreferences(COMPLICATION_PROVIDER_PREFERENCES_FILE_KEY, 0);
|
||||
preferences = Aaps.getAppContext().getSharedPreferences(COMPLICATION_PROVIDER_PREFERENCES_FILE_KEY, 0);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.gms.wearable.DataMap;
|
||||
|
@ -15,7 +14,7 @@ import java.util.HashSet;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.Aaps;
|
||||
|
||||
/**
|
||||
* Created by andy on 3/5/19.
|
||||
|
@ -66,7 +65,7 @@ public class WearUtil {
|
|||
}
|
||||
|
||||
public static PowerManager.WakeLock getWakeLock(final String name, int millis) {
|
||||
final PowerManager pm = (PowerManager) aaps.getAppContext().getSystemService(Context.POWER_SERVICE);
|
||||
final PowerManager pm = (PowerManager) Aaps.getAppContext().getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "AAPS::"+name);
|
||||
wl.acquire(millis);
|
||||
if (debug_wakelocks) Log.d(TAG, "getWakeLock: " + name + " " + wl.toString());
|
||||
|
@ -80,11 +79,11 @@ public class WearUtil {
|
|||
}
|
||||
|
||||
public static void startActivity(Class c) {
|
||||
aaps.getAppContext().startActivity(getStartActivityIntent(c));
|
||||
Aaps.getAppContext().startActivity(getStartActivityIntent(c));
|
||||
}
|
||||
|
||||
public static Intent getStartActivityIntent(Class c) {
|
||||
return new Intent(aaps.getAppContext(), c).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
return new Intent(Aaps.getAppContext(), c).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
}
|
||||
|
||||
public static void threadSleep(long millis) {
|
||||
|
|
|
@ -13,7 +13,6 @@ import android.graphics.Rect;
|
|||
import android.os.PowerManager;
|
||||
import android.os.Vibrator;
|
||||
import android.preference.PreferenceManager;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
import android.support.wearable.view.WatchViewStub;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.Log;
|
||||
|
@ -26,20 +25,21 @@ import android.widget.LinearLayout;
|
|||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.google.android.gms.wearable.DataMap;
|
||||
import com.ustwo.clockwise.common.WatchMode;
|
||||
import com.ustwo.clockwise.wearable.WatchFace;
|
||||
import com.ustwo.clockwise.common.WatchFaceTime;
|
||||
import com.ustwo.clockwise.common.WatchMode;
|
||||
import com.ustwo.clockwise.common.WatchShape;
|
||||
import com.ustwo.clockwise.wearable.WatchFace;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.complications.BaseComplicationProviderService;
|
||||
import info.nightscout.androidaps.data.RawDisplayData;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.complications.BaseComplicationProviderService;
|
||||
import info.nightscout.androidaps.data.ListenerService;
|
||||
import info.nightscout.androidaps.data.RawDisplayData;
|
||||
import lecho.lib.hellocharts.view.LineChartView;
|
||||
|
||||
/**
|
||||
|
@ -50,8 +50,17 @@ import lecho.lib.hellocharts.view.LineChartView;
|
|||
|
||||
public abstract class BaseWatchFace extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
public final static IntentFilter INTENT_FILTER;
|
||||
public static final long[] vibratePattern = {0,400,300,400,300,400};
|
||||
public TextView mTime, mHour, mMinute,mSgv, mDirection, mTimestamp, mUploaderBattery, mRigBattery, mDelta, mAvgDelta, mStatus, mBasalRate, mIOB1, mIOB2, mCOB1, mCOB2, mBgi, mLoop, mDay, mDayName, mMonth, isAAPSv2, mHighLight, mLowLight;
|
||||
public static final long[] vibratePattern = {0, 400, 300, 400, 300, 400};
|
||||
|
||||
static {
|
||||
INTENT_FILTER = new IntentFilter();
|
||||
INTENT_FILTER.addAction(Intent.ACTION_TIME_TICK);
|
||||
INTENT_FILTER.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||
INTENT_FILTER.addAction(Intent.ACTION_TIME_CHANGED);
|
||||
}
|
||||
|
||||
public final Point displaySize = new Point();
|
||||
public TextView mTime, mHour, mMinute, mSgv, mDirection, mTimestamp, mUploaderBattery, mRigBattery, mDelta, mAvgDelta, mStatus, mBasalRate, mIOB1, mIOB2, mCOB1, mCOB2, mBgi, mLoop, mDay, mDayName, mMonth, isAAPSv2, mHighLight, mLowLight;
|
||||
public ImageView mGlucoseDial, mDeltaGauge, mHourHand, mMinuteHand;
|
||||
public RelativeLayout mRelativeLayout;
|
||||
public LinearLayout mLinearLayout, mLinearLayout2, mDate, mChartTap, mMainMenuTap;
|
||||
|
@ -71,23 +80,17 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
public int pointSize = 2;
|
||||
public BgGraphBuilder bgGraphBuilder;
|
||||
public LineChartView chart;
|
||||
|
||||
|
||||
public RawDisplayData rawData = new RawDisplayData();
|
||||
|
||||
public PowerManager.WakeLock wakeLock;
|
||||
// related endTime manual layout
|
||||
public View layoutView;
|
||||
public final Point displaySize = new Point();
|
||||
public int specW, specH;
|
||||
private LocalBroadcastManager localBroadcastManager;
|
||||
private MessageReceiver messageReceiver;
|
||||
|
||||
protected SharedPreferences sharedPrefs;
|
||||
|
||||
public boolean forceSquareCanvas = false; //set to true by the Steampunk watch face.
|
||||
public String sMinute = "0";
|
||||
public String sHour = "0";
|
||||
protected SharedPreferences sharedPrefs;
|
||||
private LocalBroadcastManager localBroadcastManager;
|
||||
private MessageReceiver messageReceiver;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
@ -130,7 +133,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
mHour = stub.findViewById(R.id.hour);
|
||||
mMinute = stub.findViewById(R.id.minute);
|
||||
mDay = stub.findViewById(R.id.day);
|
||||
mDayName= stub.findViewById(R.id.dayname);
|
||||
mDayName = stub.findViewById(R.id.dayname);
|
||||
mMonth = stub.findViewById(R.id.month);
|
||||
mDate = stub.findViewById(R.id.date_time);
|
||||
mLoop = stub.findViewById(R.id.loop);
|
||||
|
@ -172,7 +175,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
}
|
||||
|
||||
public int ageLevel() {
|
||||
if(timeSince() <= (1000 * 60 * 12)) {
|
||||
if (timeSince() <= (1000 * 60 * 12)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -184,12 +187,14 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
}
|
||||
|
||||
public String readingAge(boolean shortString) {
|
||||
if (rawData.datetime == 0) { return shortString?"--'":"-- Minute ago"; }
|
||||
int minutesAgo = (int) Math.floor(timeSince()/(1000*60));
|
||||
if (minutesAgo == 1) {
|
||||
return minutesAgo + (shortString?"'":" Minute ago");
|
||||
if (rawData.datetime == 0) {
|
||||
return shortString ? "--'" : "-- Minute ago";
|
||||
}
|
||||
return minutesAgo + (shortString?"'":" Minutes ago");
|
||||
int minutesAgo = (int) Math.floor(timeSince() / (1000 * 60));
|
||||
if (minutesAgo == 1) {
|
||||
return minutesAgo + (shortString ? "'" : " Minute ago");
|
||||
}
|
||||
return minutesAgo + (shortString ? "'" : " Minutes ago");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -203,13 +208,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
super.onDestroy();
|
||||
}
|
||||
|
||||
static {
|
||||
INTENT_FILTER = new IntentFilter();
|
||||
INTENT_FILTER.addAction(Intent.ACTION_TIME_TICK);
|
||||
INTENT_FILTER.addAction(Intent.ACTION_TIMEZONE_CHANGED);
|
||||
INTENT_FILTER.addAction(Intent.ACTION_TIME_CHANGED);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
if (layoutSet) {
|
||||
|
@ -234,7 +232,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
setDataFields();
|
||||
setColor();
|
||||
missedReadingAlert();
|
||||
checkVibrateHourly(oldTime,newTime);
|
||||
checkVibrateHourly(oldTime, newTime);
|
||||
|
||||
mRelativeLayout.measure(specW, specH);
|
||||
if (forceSquareCanvas) {
|
||||
|
@ -246,7 +244,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
}
|
||||
}
|
||||
|
||||
private void checkVibrateHourly(WatchFaceTime oldTime, WatchFaceTime newTime){
|
||||
private void checkVibrateHourly(WatchFaceTime oldTime, WatchFaceTime newTime) {
|
||||
Boolean hourlyVibratePref = sharedPrefs.getBoolean("vibrate_Hourly", false);
|
||||
if (hourlyVibratePref && layoutSet && newTime.hasHourChanged(oldTime)) {
|
||||
Log.i("hourlyVibratePref", "true --> " + newTime.toString());
|
||||
|
@ -256,36 +254,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
}
|
||||
}
|
||||
|
||||
public class MessageReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
if (layoutSet) {
|
||||
final DataMap dataMap = rawData.updateDataFromMessage(intent, wakeLock);
|
||||
if (chart != null && dataMap != null) {
|
||||
rawData.addToWatchSet(dataMap);
|
||||
setupCharts();
|
||||
}
|
||||
rawData.updateStatusFromMessage(intent, wakeLock);
|
||||
}
|
||||
|
||||
setDataFields();
|
||||
setColor();
|
||||
|
||||
if (layoutSet) {
|
||||
rawData.updateBasalsFromMessage(intent, wakeLock);
|
||||
}
|
||||
|
||||
mRelativeLayout.measure(specW, specH);
|
||||
if (forceSquareCanvas) {
|
||||
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.x); //force a square for Steampunk watch face.
|
||||
} else {
|
||||
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y);
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void setDataFields() {
|
||||
|
||||
setDateAndTime();
|
||||
|
@ -357,7 +325,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
mIOB1.setText(rawData.sIOB1);
|
||||
mIOB2.setText(rawData.sIOB2);
|
||||
} else {
|
||||
mIOB1.setText(aaps.gs(R.string.activity_IOB));
|
||||
mIOB1.setText(getString(R.string.activity_IOB));
|
||||
mIOB2.setText(rawData.sIOB1);
|
||||
}
|
||||
} else {
|
||||
|
@ -483,14 +451,14 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
sHour = sdfHour.format(now);
|
||||
sMinute = sdfMinute.format(now);
|
||||
|
||||
if (mHour != null && mMinute != null ) {
|
||||
if (mHour != null && mMinute != null) {
|
||||
mHour.setText(sHour);
|
||||
mMinute.setText(sMinute);
|
||||
}
|
||||
|
||||
if (mDate != null && mDay != null && mMonth != null) {
|
||||
if (sharedPrefs.getBoolean("show_date", false)) {
|
||||
if (mDayName != null ) {
|
||||
if (mDayName != null) {
|
||||
SimpleDateFormat sdfDayName = new SimpleDateFormat("E");
|
||||
mDayName.setText(sdfDayName.format(now));
|
||||
}
|
||||
|
@ -508,7 +476,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
|
||||
public void setColor() {
|
||||
dividerMatchesBg = sharedPrefs.getBoolean("match_divider", false);
|
||||
if(lowResMode){
|
||||
if (lowResMode) {
|
||||
setColorLowRes();
|
||||
} else if (sharedPrefs.getBoolean("dark", true)) {
|
||||
setColorDark();
|
||||
|
@ -518,7 +486,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
}
|
||||
|
||||
public void strikeThroughSgvIfNeeded() {
|
||||
if (mSgv !=null) {
|
||||
if (mSgv != null) {
|
||||
if (sharedPrefs.getBoolean("showBG", true)) {
|
||||
if (ageLevel() <= 0) {
|
||||
mSgv.setPaintFlags(mSgv.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
|
@ -531,10 +499,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
|
||||
protected void onWatchModeChanged(WatchMode watchMode) {
|
||||
|
||||
if(lowResMode ^ isLowRes(watchMode)){ //if there was a change in lowResMode
|
||||
if (lowResMode ^ isLowRes(watchMode)) { //if there was a change in lowResMode
|
||||
lowResMode = isLowRes(watchMode);
|
||||
setColor();
|
||||
} else if (! sharedPrefs.getBoolean("dark", true)){
|
||||
} else if (!sharedPrefs.getBoolean("dark", true)) {
|
||||
//in bright mode: different colours if active:
|
||||
setColor();
|
||||
}
|
||||
|
@ -545,13 +513,13 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key){
|
||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
||||
|
||||
if("delta_granularity".equals(key)){
|
||||
if ("delta_granularity".equals(key)) {
|
||||
ListenerService.requestData(this);
|
||||
}
|
||||
|
||||
if(layoutSet){
|
||||
if (layoutSet) {
|
||||
setDataFields();
|
||||
setColor();
|
||||
}
|
||||
|
@ -559,18 +527,20 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
}
|
||||
|
||||
protected abstract void setColorDark();
|
||||
|
||||
protected abstract void setColorBright();
|
||||
|
||||
protected abstract void setColorLowRes();
|
||||
|
||||
public void missedReadingAlert() {
|
||||
int minutes_since = (int) Math.floor(timeSince()/(1000*60));
|
||||
if(minutes_since >= 16 && ((minutes_since - 16) % 5) == 0) {
|
||||
int minutes_since = (int) Math.floor(timeSince() / (1000 * 60));
|
||||
if (minutes_since >= 16 && ((minutes_since - 16) % 5) == 0) {
|
||||
ListenerService.requestData(this); // attempt endTime recover missing data
|
||||
}
|
||||
}
|
||||
|
||||
public void setupCharts() {
|
||||
if(rawData.bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things
|
||||
if (rawData.bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things
|
||||
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
|
||||
if (lowResMode) {
|
||||
bgGraphBuilder = new BgGraphBuilder(getApplicationContext(), rawData, pointSize, midColor, gridColor, basalBackgroundColor, basalCenterColor, bolusColor, Color.GREEN, timeframe);
|
||||
|
@ -584,4 +554,34 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
|||
}
|
||||
}
|
||||
|
||||
public class MessageReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
||||
if (layoutSet) {
|
||||
final DataMap dataMap = rawData.updateDataFromMessage(intent, wakeLock);
|
||||
if (chart != null && dataMap != null) {
|
||||
rawData.addToWatchSet(dataMap);
|
||||
setupCharts();
|
||||
}
|
||||
rawData.updateStatusFromMessage(intent, wakeLock);
|
||||
}
|
||||
|
||||
setDataFields();
|
||||
setColor();
|
||||
|
||||
if (layoutSet) {
|
||||
rawData.updateBasalsFromMessage(intent, wakeLock);
|
||||
}
|
||||
|
||||
mRelativeLayout.measure(specW, specH);
|
||||
if (forceSquareCanvas) {
|
||||
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.x); //force a square for Steampunk watch face.
|
||||
} else {
|
||||
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y);
|
||||
}
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -150,7 +150,10 @@
|
|||
<string name="digitalstyle_pref_your_color">Your color:</string>
|
||||
<string name="digitalstyle_pref_your_color_saturation">Your color saturation:</string>
|
||||
<string name="digitalstyle_pref_your_color_opacity">Your color opacity:</string>
|
||||
|
||||
<string name="bolus_progress_channel_name">AAPS Bolus Progress</string>
|
||||
<string name="bolus_progress_silent_channel_name">AAPS Bolus Progress Silent</string>
|
||||
<string name="bolus_progress_channel_description">Bolus progress and cancel</string>
|
||||
<string name="bolus_progress_silent_channel_description">Bolus progress and cancel with less vibrations</string>
|
||||
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.junit.runner.RunWith;
|
|||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.Aaps;
|
||||
import info.nightscout.androidaps.interaction.utils.Constants;
|
||||
import info.nightscout.androidaps.interaction.utils.Persistence;
|
||||
import info.nightscout.androidaps.interaction.utils.WearUtil;
|
||||
|
@ -28,7 +28,7 @@ import static org.hamcrest.CoreMatchers.is;
|
|||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest( { WearUtil.class, Log.class, SharedPreferences.class, Context.class, aaps.class, android.util.Base64.class, Intent.class } )
|
||||
@PrepareForTest( { WearUtil.class, Log.class, SharedPreferences.class, Context.class, Aaps.class, android.util.Base64.class, Intent.class } )
|
||||
public class RawDataSgvDisplayDataTest {
|
||||
|
||||
@Before
|
||||
|
|
|
@ -16,7 +16,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.Aaps;
|
||||
import info.nightscout.androidaps.interaction.utils.Constants;
|
||||
import info.nightscout.androidaps.interaction.utils.Persistence;
|
||||
import info.nightscout.androidaps.interaction.utils.WearUtil;
|
||||
|
@ -34,7 +34,7 @@ import static org.hamcrest.CoreMatchers.is;
|
|||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest( { WearUtil.class, Log.class, SharedPreferences.class, Context.class, aaps.class, android.util.Base64.class, Intent.class } )
|
||||
@PrepareForTest( { WearUtil.class, Log.class, SharedPreferences.class, Context.class, Aaps.class, android.util.Base64.class, Intent.class } )
|
||||
public class RawDisplayDataBasalsTest {
|
||||
|
||||
@Before
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.junit.runner.RunWith;
|
|||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.Aaps;
|
||||
import info.nightscout.androidaps.interaction.utils.Constants;
|
||||
import info.nightscout.androidaps.interaction.utils.Persistence;
|
||||
import info.nightscout.androidaps.interaction.utils.WearUtil;
|
||||
|
@ -30,7 +30,7 @@ import static org.hamcrest.CoreMatchers.is;
|
|||
import static org.junit.Assert.assertThat;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest( { WearUtil.class, Log.class, SharedPreferences.class, Context.class, aaps.class, android.util.Base64.class, Intent.class } )
|
||||
@PrepareForTest( { WearUtil.class, Log.class, SharedPreferences.class, Context.class, Aaps.class, android.util.Base64.class, Intent.class } )
|
||||
public class RawDisplayDataStatusTest {
|
||||
|
||||
@Before
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.junit.runner.RunWith;
|
|||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.Aaps;
|
||||
import info.nightscout.androidaps.data.RawDisplayData;
|
||||
import info.nightscout.androidaps.testing.mockers.AAPSMocker;
|
||||
import info.nightscout.androidaps.testing.mockers.WearUtilMocker;
|
||||
|
@ -30,7 +30,7 @@ import static org.junit.Assert.assertThat;
|
|||
*/
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest( { WearUtil.class, Log.class, SharedPreferences.class, Context.class, aaps.class } )
|
||||
@PrepareForTest( { WearUtil.class, Log.class, SharedPreferences.class, Context.class, Aaps.class } )
|
||||
public class DisplayFormatTest {
|
||||
|
||||
@Before
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.Aaps;
|
||||
import info.nightscout.androidaps.testing.mockers.AAPSMocker;
|
||||
import info.nightscout.androidaps.testing.mockers.AndroidMocker;
|
||||
import info.nightscout.androidaps.testing.mockers.LogMocker;
|
||||
|
@ -29,7 +29,7 @@ import static org.junit.Assert.assertThat;
|
|||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest( { WearUtil.class, Log.class, SharedPreferences.class, Context.class, aaps.class, android.util.Base64.class} )
|
||||
@PrepareForTest( { WearUtil.class, Log.class, SharedPreferences.class, Context.class, Aaps.class, android.util.Base64.class} )
|
||||
public class PersistenceTest {
|
||||
|
||||
@Before
|
||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.testing.mockers;
|
|||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
|
@ -11,7 +10,7 @@ import org.powermock.api.mockito.PowerMockito;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import info.nightscout.androidaps.aaps;
|
||||
import info.nightscout.androidaps.Aaps;
|
||||
import info.nightscout.androidaps.testing.mocks.SharedPreferencesMock;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -24,9 +23,9 @@ public class AAPSMocker {
|
|||
|
||||
public static void prepareMock() throws Exception {
|
||||
Context mockedContext = mock(Context.class);
|
||||
mockStatic(aaps.class, InvocationOnMock::callRealMethod);
|
||||
mockStatic(Aaps.class, InvocationOnMock::callRealMethod);
|
||||
|
||||
PowerMockito.when(aaps.class, "getAppContext").thenReturn(mockedContext);
|
||||
PowerMockito.when(Aaps.class, "getAppContext").thenReturn(mockedContext);
|
||||
PowerMockito.when(mockedContext, "getSharedPreferences", ArgumentMatchers.anyString(), ArgumentMatchers.anyInt()).thenAnswer(invocation -> {
|
||||
|
||||
final String key = invocation.getArgument(0);
|
||||
|
@ -38,7 +37,7 @@ public class AAPSMocker {
|
|||
return newPrefs;
|
||||
}
|
||||
});
|
||||
PowerMockito.when(aaps.class, "areComplicationsUnicode").thenAnswer(invocation -> unicodeComplicationsOn);
|
||||
PowerMockito.when(Aaps.class, "areComplicationsUnicode").thenAnswer(invocation -> unicodeComplicationsOn);
|
||||
|
||||
setMockedUnicodeComplicationsOn(true);
|
||||
resetMockedSharedPrefs();
|
||||
|
|
Loading…
Reference in a new issue