code cleanup
This commit is contained in:
parent
f370def798
commit
5f3aaf6b54
189 changed files with 495 additions and 527 deletions
|
@ -122,7 +122,7 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val bg = Profile.fromMgdlToUnits(GlucoseStatus(injector).getGlucoseStatusData()?.glucose
|
val bg = Profile.fromMgdlToUnits(GlucoseStatus(injector).glucoseStatusData?.glucose
|
||||||
?: 0.0, profileFunction.getUnits())
|
?: 0.0, profileFunction.getUnits())
|
||||||
val bgTextWatcher: TextWatcher = object : TextWatcher {
|
val bgTextWatcher: TextWatcher = object : TextWatcher {
|
||||||
override fun afterTextChanged(s: Editable) {}
|
override fun afterTextChanged(s: Editable) {}
|
||||||
|
|
|
@ -40,7 +40,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
|
||||||
public class DetermineBasalAdapterAMAJS {
|
public class DetermineBasalAdapterAMAJS {
|
||||||
private HasAndroidInjector injector;
|
private final HasAndroidInjector injector;
|
||||||
@Inject AAPSLogger aapsLogger;
|
@Inject AAPSLogger aapsLogger;
|
||||||
@Inject ConstraintChecker constraintChecker;
|
@Inject ConstraintChecker constraintChecker;
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
|
@ -48,7 +48,7 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
@Inject TreatmentsPlugin treatmentsPlugin;
|
@Inject TreatmentsPlugin treatmentsPlugin;
|
||||||
@Inject OpenHumansUploader openHumansUploader;
|
@Inject OpenHumansUploader openHumansUploader;
|
||||||
|
|
||||||
private ScriptReader mScriptReader;
|
private final ScriptReader mScriptReader;
|
||||||
|
|
||||||
private JSONObject mProfile;
|
private JSONObject mProfile;
|
||||||
private JSONObject mGlucoseStatus;
|
private JSONObject mGlucoseStatus;
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class DetermineBasalAdapterSMBJS {
|
||||||
@Inject OpenHumansUploader openHumansUploader;
|
@Inject OpenHumansUploader openHumansUploader;
|
||||||
|
|
||||||
|
|
||||||
private ScriptReader mScriptReader;
|
private final ScriptReader mScriptReader;
|
||||||
private JSONObject mProfile;
|
private JSONObject mProfile;
|
||||||
private JSONObject mGlucoseStatus;
|
private JSONObject mGlucoseStatus;
|
||||||
private JSONArray mIobData;
|
private JSONArray mIobData;
|
||||||
|
|
|
@ -2,5 +2,4 @@ package info.nightscout.androidaps.plugins.configBuilder.events
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.EventUpdateGui
|
import info.nightscout.androidaps.events.EventUpdateGui
|
||||||
|
|
||||||
class EventConfigBuilderUpdateGui : EventUpdateGui() {
|
class EventConfigBuilderUpdateGui : EventUpdateGui()
|
||||||
}
|
|
|
@ -26,9 +26,9 @@ public abstract class Objective {
|
||||||
@Inject public SP sp;
|
@Inject public SP sp;
|
||||||
@Inject public ResourceHelper resourceHelper;
|
@Inject public ResourceHelper resourceHelper;
|
||||||
|
|
||||||
private String spName;
|
private final String spName;
|
||||||
@StringRes private int objective;
|
@StringRes private final int objective;
|
||||||
@StringRes private int gate;
|
@StringRes private final int gate;
|
||||||
private long startedOn;
|
private long startedOn;
|
||||||
private long accomplishedOn;
|
private long accomplishedOn;
|
||||||
List<Task> tasks = new ArrayList<>();
|
List<Task> tasks = new ArrayList<>();
|
||||||
|
@ -116,7 +116,7 @@ public abstract class Objective {
|
||||||
|
|
||||||
public abstract class Task {
|
public abstract class Task {
|
||||||
@StringRes
|
@StringRes
|
||||||
private int task;
|
private final int task;
|
||||||
private Objective objective;
|
private Objective objective;
|
||||||
ArrayList<Hint> hints = new ArrayList<>();
|
ArrayList<Hint> hints = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -138,8 +138,6 @@ public abstract class Objective {
|
||||||
return isCompleted();
|
return isCompleted();
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
public String getProgress() {
|
public String getProgress() {
|
||||||
return resourceHelper.gs(isCompleted() ? R.string.completed_well_done : R.string.not_completed_yet);
|
return resourceHelper.gs(isCompleted() ? R.string.completed_well_done : R.string.not_completed_yet);
|
||||||
}
|
}
|
||||||
|
@ -160,7 +158,7 @@ public abstract class Objective {
|
||||||
|
|
||||||
public class MinimumDurationTask extends Task {
|
public class MinimumDurationTask extends Task {
|
||||||
|
|
||||||
private long minimumDuration;
|
private final long minimumDuration;
|
||||||
|
|
||||||
MinimumDurationTask(long minimumDuration) {
|
MinimumDurationTask(long minimumDuration) {
|
||||||
super(R.string.time_elapsed);
|
super(R.string.time_elapsed);
|
||||||
|
@ -197,7 +195,7 @@ public abstract class Objective {
|
||||||
@StringRes
|
@StringRes
|
||||||
int question;
|
int question;
|
||||||
ArrayList<Option> options = new ArrayList<>();
|
ArrayList<Option> options = new ArrayList<>();
|
||||||
private String spIdentifier;
|
private final String spIdentifier;
|
||||||
private boolean answered;
|
private boolean answered;
|
||||||
private long disabledTo;
|
private long disabledTo;
|
||||||
|
|
||||||
|
@ -274,8 +272,7 @@ public abstract class Objective {
|
||||||
public boolean evaluate() {
|
public boolean evaluate() {
|
||||||
boolean selection = cb.isChecked();
|
boolean selection = cb.isChecked();
|
||||||
if (selection && isCorrect) return true;
|
if (selection && isCorrect) return true;
|
||||||
if (!selection && !isCorrect) return true;
|
return !selection && !isCorrect;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,9 +78,7 @@ public class Objective0 extends Objective {
|
||||||
@Override
|
@Override
|
||||||
public boolean isCompleted() {
|
public boolean isCompleted() {
|
||||||
APSInterface usedAPS = activePlugin.getActiveAPS();
|
APSInterface usedAPS = activePlugin.getActiveAPS();
|
||||||
if (((PluginBase) usedAPS).isEnabled(PluginType.APS))
|
return ((PluginBase) usedAPS).isEnabled(PluginType.APS);
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tasks.add(new Task(R.string.activate_profile) {
|
tasks.add(new Task(R.string.activate_profile) {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import dagger.android.HasAndroidInjector;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin;
|
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSClientPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.general.nsclient.services.NSClientService;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
|
@ -50,7 +51,7 @@ public class Objective3 extends Objective {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean specialActionEnabled() {
|
public boolean specialActionEnabled() {
|
||||||
return nsClientPlugin.nsClientService.isConnected && nsClientPlugin.nsClientService.hasWriteAuth;
|
return NSClientService.isConnected && NSClientService.hasWriteAuth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -36,12 +36,12 @@ class PhoneCheckerPlugin @Inject constructor(
|
||||||
|
|
||||||
private fun isDevModeEnabled(): Boolean {
|
private fun isDevModeEnabled(): Boolean {
|
||||||
return android.provider.Settings.Secure.getInt(context.contentResolver,
|
return android.provider.Settings.Secure.getInt(context.contentResolver,
|
||||||
android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
|
android.provider.Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
phoneRooted = RootBeer(context).isRooted()
|
phoneRooted = RootBeer(context).isRooted
|
||||||
devMode = isDevModeEnabled()
|
devMode = isDevModeEnabled()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -46,7 +46,7 @@ class TriggerBg(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldRun(): Boolean {
|
override fun shouldRun(): Boolean {
|
||||||
val glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
|
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
|
||||||
if (glucoseStatus == null && comparator.value == Comparator.Compare.IS_NOT_AVAILABLE) {
|
if (glucoseStatus == null && comparator.value == Comparator.Compare.IS_NOT_AVAILABLE) {
|
||||||
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
|
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -58,7 +58,7 @@ class TriggerDelta(injector: HasAndroidInjector) : Trigger(injector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldRun(): Boolean {
|
override fun shouldRun(): Boolean {
|
||||||
val glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
|
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
|
||||||
?: return if (comparator.value == Comparator.Compare.IS_NOT_AVAILABLE) {
|
?: return if (comparator.value == Comparator.Compare.IS_NOT_AVAILABLE) {
|
||||||
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
|
aapsLogger.debug(LTag.AUTOMATION, "Ready for execution: " + friendlyDescription())
|
||||||
true
|
true
|
||||||
|
|
|
@ -105,9 +105,7 @@ public class Food {
|
||||||
return false;
|
return false;
|
||||||
if (!Objects.equals(subcategory, other.subcategory))
|
if (!Objects.equals(subcategory, other.subcategory))
|
||||||
return false;
|
return false;
|
||||||
if (!Objects.equals(units, other.units))
|
return Objects.equals(units, other.units);
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyFrom(Food other) {
|
public void copyFrom(Food other) {
|
||||||
|
|
|
@ -49,7 +49,7 @@ class FoodFragment : DaggerFragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
food_recyclerview.setHasFixedSize(true)
|
food_recyclerview.setHasFixedSize(true)
|
||||||
food_recyclerview.setLayoutManager(LinearLayoutManager(view.context))
|
food_recyclerview.layoutManager = LinearLayoutManager(view.context)
|
||||||
food_recyclerview.adapter = RecyclerViewAdapter(foodPlugin.service?.foodData ?: ArrayList())
|
food_recyclerview.adapter = RecyclerViewAdapter(foodPlugin.service?.foodData ?: ArrayList())
|
||||||
|
|
||||||
food_clearfilter.setOnClickListener {
|
food_clearfilter.setOnClickListener {
|
||||||
|
@ -69,7 +69,7 @@ class FoodFragment : DaggerFragment() {
|
||||||
filterData()
|
filterData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
food_subcategory.setOnItemSelectedListener(object : AdapterView.OnItemSelectedListener {
|
food_subcategory.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||||
filterData()
|
filterData()
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ class FoodFragment : DaggerFragment() {
|
||||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||||
filterData()
|
filterData()
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
food_filter.addTextChangedListener(object : TextWatcher {
|
food_filter.addTextChangedListener(object : TextWatcher {
|
||||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
||||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class FoodService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
@Inject RxBusWrapper rxBus;
|
@Inject RxBusWrapper rxBus;
|
||||||
@Inject FabricPrivacy fabricPrivacy;
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor();
|
private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor();
|
||||||
private static ScheduledFuture<?> scheduledFoodEventPost = null;
|
private static ScheduledFuture<?> scheduledFoodEventPost = null;
|
||||||
|
|
|
@ -208,10 +208,10 @@ class ImportExportPrefs @Inject constructor(
|
||||||
// import is OK when we do not have errors (warnings are allowed)
|
// import is OK when we do not have errors (warnings are allowed)
|
||||||
val importOkCheckedAgain = checkIfImportIsOk(prefsReloaded)
|
val importOkCheckedAgain = checkIfImportIsOk(prefsReloaded)
|
||||||
|
|
||||||
then(prefsReloaded, importOkCheckedAgain);
|
then(prefsReloaded, importOkCheckedAgain)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
then(prefs, importOk);
|
then(prefs, importOk)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +278,7 @@ class ImportExportPrefs @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public fun importSharedPreferences(activity: FragmentActivity, importFile: PrefsFile) {
|
fun importSharedPreferences(activity: FragmentActivity, importFile: PrefsFile) {
|
||||||
|
|
||||||
askToConfirmImport(activity, importFile) { password ->
|
askToConfirmImport(activity, importFile) { password ->
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ class ImportExportPrefs @Inject constructor(
|
||||||
|
|
||||||
for ((_, value) in prefs.metadata) {
|
for ((_, value) in prefs.metadata) {
|
||||||
if (value.status == PrefsStatus.ERROR)
|
if (value.status == PrefsStatus.ERROR)
|
||||||
importOk = false;
|
importOk = false
|
||||||
}
|
}
|
||||||
return importOk
|
return importOk
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,10 +167,10 @@ class PrefFileListProvider @Inject constructor(
|
||||||
|
|
||||||
meta[PrefsMetadataKey.CREATED_AT]?.let { createdAt ->
|
meta[PrefsMetadataKey.CREATED_AT]?.let { createdAt ->
|
||||||
try {
|
try {
|
||||||
val date1 = DateTime.parse(createdAt.value);
|
val date1 = DateTime.parse(createdAt.value)
|
||||||
val date2 = DateTime.now()
|
val date2 = DateTime.now()
|
||||||
|
|
||||||
val daysOld = Days.daysBetween(date1.toLocalDate(), date2.toLocalDate()).getDays()
|
val daysOld = Days.daysBetween(date1.toLocalDate(), date2.toLocalDate()).days
|
||||||
|
|
||||||
if (daysOld > IMPORT_AGE_NOT_YET_OLD_DAYS) {
|
if (daysOld > IMPORT_AGE_NOT_YET_OLD_DAYS) {
|
||||||
createdAt.status = PrefsStatus.WARN
|
createdAt.status = PrefsStatus.WARN
|
||||||
|
|
|
@ -244,7 +244,7 @@ class EncryptedPrefsFormat @Inject constructor(
|
||||||
metadata[PrefsMetadataKey.FILE_FORMAT] = PrefMetadata(resourceHelper.gs(R.string.prefdecrypt_wrong_json), PrefsStatus.ERROR)
|
metadata[PrefsMetadataKey.FILE_FORMAT] = PrefMetadata(resourceHelper.gs(R.string.prefdecrypt_wrong_json), PrefsStatus.ERROR)
|
||||||
}
|
}
|
||||||
|
|
||||||
return metadata;
|
return metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -37,7 +37,7 @@ public class NSClientFragment extends DaggerFragment implements View.OnClickList
|
||||||
@Inject UploadQueue uploadQueue;
|
@Inject UploadQueue uploadQueue;
|
||||||
@Inject FabricPrivacy fabricPrivacy;
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private TextView logTextView;
|
private TextView logTextView;
|
||||||
private TextView queueTextView;
|
private TextView queueTextView;
|
||||||
|
|
|
@ -51,7 +51,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class NSClientPlugin extends PluginBase {
|
public class NSClientPlugin extends PluginBase {
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private final AAPSLogger aapsLogger;
|
private final AAPSLogger aapsLogger;
|
||||||
private final RxBusWrapper rxBus;
|
private final RxBusWrapper rxBus;
|
||||||
|
@ -73,7 +73,7 @@ public class NSClientPlugin extends PluginBase {
|
||||||
|
|
||||||
public NSClientService nsClientService = null;
|
public NSClientService nsClientService = null;
|
||||||
|
|
||||||
private NsClientReceiverDelegate nsClientReceiverDelegate;
|
private final NsClientReceiverDelegate nsClientReceiverDelegate;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NSClientPlugin(
|
public NSClientPlugin(
|
||||||
|
@ -209,7 +209,7 @@ public class NSClientPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ServiceConnection mConnection = new ServiceConnection() {
|
private final ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
aapsLogger.debug(LTag.NSCLIENT, "Service is disconnected");
|
aapsLogger.debug(LTag.NSCLIENT, "Service is disconnected");
|
||||||
|
@ -276,7 +276,7 @@ public class NSClientPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasWritePermission() {
|
public boolean hasWritePermission() {
|
||||||
return nsClientService.hasWriteAuth;
|
return NSClientService.hasWriteAuth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleClearAlarm(NSAlarm originalAlarm, long silenceTimeInMsec) {
|
public void handleClearAlarm(NSAlarm originalAlarm, long silenceTimeInMsec) {
|
||||||
|
|
|
@ -389,7 +389,7 @@ public class NSDeviceStatus {
|
||||||
|
|
||||||
// ********* Uploader data ***********
|
// ********* Uploader data ***********
|
||||||
|
|
||||||
private static HashMap<String, Uploader> uploaders = new HashMap<>();
|
private static final HashMap<String, Uploader> uploaders = new HashMap<>();
|
||||||
|
|
||||||
static class Uploader {
|
static class Uploader {
|
||||||
long clock = 0L;
|
long clock = 0L;
|
||||||
|
|
|
@ -10,9 +10,9 @@ import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
|
|
||||||
public class NSTreatment {
|
public class NSTreatment {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
private static final Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
||||||
|
|
||||||
private JSONObject data;
|
private final JSONObject data;
|
||||||
private String action = null; // "update", "remove" or null (add)
|
private String action = null; // "update", "remove" or null (add)
|
||||||
|
|
||||||
public NSTreatment(JSONObject obj) {
|
public NSTreatment(JSONObject obj) {
|
||||||
|
|
|
@ -91,10 +91,10 @@ public class NSClientService extends DaggerService {
|
||||||
@Inject DateUtil dateUtil;
|
@Inject DateUtil dateUtil;
|
||||||
@Inject UploadQueue uploadQueue;
|
@Inject UploadQueue uploadQueue;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
static public PowerManager.WakeLock mWakeLock;
|
static public PowerManager.WakeLock mWakeLock;
|
||||||
private IBinder mBinder = new NSClientService.LocalBinder();
|
private final IBinder mBinder = new NSClientService.LocalBinder();
|
||||||
|
|
||||||
static ProfileStore profileStore;
|
static ProfileStore profileStore;
|
||||||
|
|
||||||
|
@ -123,9 +123,9 @@ public class NSClientService extends DaggerService {
|
||||||
private String nsAPIhashCode = "";
|
private String nsAPIhashCode = "";
|
||||||
|
|
||||||
private final ArrayList<Long> reconnections = new ArrayList<>();
|
private final ArrayList<Long> reconnections = new ArrayList<>();
|
||||||
private int WATCHDOG_INTERVAL_MINUTES = 2;
|
private final int WATCHDOG_INTERVAL_MINUTES = 2;
|
||||||
private int WATCHDOG_RECONNECT_IN = 15;
|
private final int WATCHDOG_RECONNECT_IN = 15;
|
||||||
private int WATCHDOG_MAXCONNECTIONS = 5;
|
private final int WATCHDOG_MAXCONNECTIONS = 5;
|
||||||
|
|
||||||
public NSClientService() {
|
public NSClientService() {
|
||||||
super();
|
super();
|
||||||
|
@ -322,7 +322,7 @@ public class NSClientService extends DaggerService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Emitter.Listener onConnect = new Emitter.Listener() {
|
private final Emitter.Listener onConnect = new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void call(Object... args) {
|
public void call(Object... args) {
|
||||||
connectCounter++;
|
connectCounter++;
|
||||||
|
@ -360,7 +360,7 @@ public class NSClientService extends DaggerService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Emitter.Listener onDisconnect = new Emitter.Listener() {
|
private final Emitter.Listener onDisconnect = new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void call(Object... args) {
|
public void call(Object... args) {
|
||||||
aapsLogger.debug(LTag.NSCLIENT, "disconnect reason: {}", args);
|
aapsLogger.debug(LTag.NSCLIENT, "disconnect reason: {}", args);
|
||||||
|
@ -412,7 +412,7 @@ public class NSClientService extends DaggerService {
|
||||||
nsDevice = sp.getString("careportal_enteredby", "");
|
nsDevice = sp.getString("careportal_enteredby", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private Emitter.Listener onError = new Emitter.Listener() {
|
private final Emitter.Listener onError = new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void call(final Object... args) {
|
public void call(final Object... args) {
|
||||||
String msg = "Unknown Error";
|
String msg = "Unknown Error";
|
||||||
|
@ -423,7 +423,7 @@ public class NSClientService extends DaggerService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private Emitter.Listener onPing = new Emitter.Listener() {
|
private final Emitter.Listener onPing = new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void call(final Object... args) {
|
public void call(final Object... args) {
|
||||||
rxBus.send(new EventNSClientNewLog("PING", "received"));
|
rxBus.send(new EventNSClientNewLog("PING", "received"));
|
||||||
|
@ -432,7 +432,7 @@ public class NSClientService extends DaggerService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private Emitter.Listener onAnnouncement = new Emitter.Listener() {
|
private final Emitter.Listener onAnnouncement = new Emitter.Listener() {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
"level":0,
|
"level":0,
|
||||||
|
@ -456,7 +456,7 @@ public class NSClientService extends DaggerService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private Emitter.Listener onAlarm = new Emitter.Listener() {
|
private final Emitter.Listener onAlarm = new Emitter.Listener() {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
"level":1,
|
"level":1,
|
||||||
|
@ -482,7 +482,7 @@ public class NSClientService extends DaggerService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private Emitter.Listener onUrgentAlarm = args -> {
|
private final Emitter.Listener onUrgentAlarm = args -> {
|
||||||
JSONObject data;
|
JSONObject data;
|
||||||
try {
|
try {
|
||||||
data = (JSONObject) args[0];
|
data = (JSONObject) args[0];
|
||||||
|
@ -492,7 +492,7 @@ public class NSClientService extends DaggerService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private Emitter.Listener onClearAlarm = new Emitter.Listener() {
|
private final Emitter.Listener onClearAlarm = new Emitter.Listener() {
|
||||||
/*
|
/*
|
||||||
{
|
{
|
||||||
"clear":true,
|
"clear":true,
|
||||||
|
@ -516,7 +516,7 @@ public class NSClientService extends DaggerService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private Emitter.Listener onDataUpdate = new Emitter.Listener() {
|
private final Emitter.Listener onDataUpdate = new Emitter.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void call(final Object... args) {
|
public void call(final Object... args) {
|
||||||
NSClientService.handler.post(() -> {
|
NSClientService.handler.post(() -> {
|
||||||
|
|
|
@ -33,7 +33,7 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
private inner class RecyclerViewAdapter internal constructor(internal var fragmentManager: FragmentManager) : RecyclerView.Adapter<RecyclerViewAdapter.QuickWizardEntryViewHolder>() {
|
private inner class RecyclerViewAdapter(var fragmentManager: FragmentManager) : RecyclerView.Adapter<RecyclerViewAdapter.QuickWizardEntryViewHolder>() {
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QuickWizardEntryViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QuickWizardEntryViewHolder {
|
||||||
return QuickWizardEntryViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.overview_quickwizardlist_item, parent, false), fragmentManager)
|
return QuickWizardEntryViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.overview_quickwizardlist_item, parent, false), fragmentManager)
|
||||||
|
@ -48,7 +48,7 @@ class QuickWizardListActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
override fun getItemCount(): Int = quickWizard.size()
|
override fun getItemCount(): Int = quickWizard.size()
|
||||||
|
|
||||||
private inner class QuickWizardEntryViewHolder internal constructor(itemView: View, internal var fragmentManager: FragmentManager) : RecyclerView.ViewHolder(itemView) {
|
private inner class QuickWizardEntryViewHolder(itemView: View, var fragmentManager: FragmentManager) : RecyclerView.ViewHolder(itemView) {
|
||||||
val buttonText: TextView = itemView.findViewById(R.id.overview_quickwizard_item_buttonText)
|
val buttonText: TextView = itemView.findViewById(R.id.overview_quickwizard_item_buttonText)
|
||||||
val carbs: TextView = itemView.findViewById(R.id.overview_quickwizard_item_carbs)
|
val carbs: TextView = itemView.findViewById(R.id.overview_quickwizard_item_carbs)
|
||||||
val from: TextView = itemView.findViewById(R.id.overview_quickwizard_item_from)
|
val from: TextView = itemView.findViewById(R.id.overview_quickwizard_item_from)
|
||||||
|
|
|
@ -315,7 +315,7 @@ public class AreaGraphSeries<E extends DoubleDataPoint> extends BaseSeries<E> {
|
||||||
canvas.drawPath(mPath, paint);
|
canvas.drawPath(mPath, paint);
|
||||||
canvas.drawPath(mSecondPath, paint);
|
canvas.drawPath(mSecondPath, paint);
|
||||||
if (mStyles.drawBackground) {
|
if (mStyles.drawBackground) {
|
||||||
canvas.drawRect((float)startX, (float)startY2, endX, endY1, mPaintBackground);
|
canvas.drawRect(startX, startY2, endX, endY1, mPaintBackground);
|
||||||
}
|
}
|
||||||
} else if (mStyles.drawDataPoints) {
|
} else if (mStyles.drawDataPoints) {
|
||||||
//fix: last value not drawn as datapoint. Draw first point here, and then on every step the end values (above)
|
//fix: last value not drawn as datapoint. Draw first point here, and then on every step the end values (above)
|
||||||
|
|
|
@ -11,9 +11,9 @@ import java.io.Serializable;
|
||||||
public class DoubleDataPoint implements DataPointInterface, Serializable {
|
public class DoubleDataPoint implements DataPointInterface, Serializable {
|
||||||
private static final long serialVersionUID=1428267322645L;
|
private static final long serialVersionUID=1428267322645L;
|
||||||
|
|
||||||
private double x;
|
private final double x;
|
||||||
private double y1;
|
private final double y1;
|
||||||
private double y2;
|
private final double y2;
|
||||||
|
|
||||||
public DoubleDataPoint(double x, double y1, double y2) {
|
public DoubleDataPoint(double x, double y1, double y2) {
|
||||||
this.x=x;
|
this.x=x;
|
||||||
|
|
|
@ -12,10 +12,10 @@ import java.util.Date;
|
||||||
public class ScaledDataPoint implements DataPointInterface, Serializable {
|
public class ScaledDataPoint implements DataPointInterface, Serializable {
|
||||||
private static final long serialVersionUID=1428263342645L;
|
private static final long serialVersionUID=1428263342645L;
|
||||||
|
|
||||||
private double x;
|
private final double x;
|
||||||
private double y;
|
private final double y;
|
||||||
|
|
||||||
private Scale scale;
|
private final Scale scale;
|
||||||
|
|
||||||
public ScaledDataPoint(double x, double y, Scale scale) {
|
public ScaledDataPoint(double x, double y, Scale scale) {
|
||||||
this.x=x;
|
this.x=x;
|
||||||
|
|
|
@ -137,7 +137,7 @@ class PersistentNotificationPlugin @Inject constructor(
|
||||||
var line1_aa: String
|
var line1_aa: String
|
||||||
val units = profileFunction.getUnits()
|
val units = profileFunction.getUnits()
|
||||||
val lastBG = iobCobCalculatorPlugin.lastBg()
|
val lastBG = iobCobCalculatorPlugin.lastBg()
|
||||||
val glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
|
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
|
||||||
if (lastBG != null) {
|
if (lastBG != null) {
|
||||||
line1_aa = lastBG.valueToUnitsToString(units)
|
line1_aa = lastBG.valueToUnitsToString(units)
|
||||||
line1 = line1_aa
|
line1 = line1_aa
|
||||||
|
|
|
@ -289,7 +289,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
val agoMin = (agoMsec / 60.0 / 1000.0).toInt()
|
val agoMin = (agoMsec / 60.0 / 1000.0).toInt()
|
||||||
reply = resourceHelper.gs(R.string.sms_lastbg) + " " + lastBG.valueToUnitsToString(units) + " " + String.format(resourceHelper.gs(R.string.sms_minago), agoMin) + ", "
|
reply = resourceHelper.gs(R.string.sms_lastbg) + " " + lastBG.valueToUnitsToString(units) + " " + String.format(resourceHelper.gs(R.string.sms_minago), agoMin) + ", "
|
||||||
}
|
}
|
||||||
val glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
|
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
|
||||||
if (glucoseStatus != null) reply += resourceHelper.gs(R.string.sms_delta) + " " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", "
|
if (glucoseStatus != null) reply += resourceHelper.gs(R.string.sms_delta) + " " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", "
|
||||||
activePlugin.activeTreatments.updateTotalIOBTreatments()
|
activePlugin.activeTreatments.updateTotalIOBTreatments()
|
||||||
val bolusIob = activePlugin.activeTreatments.lastCalculationTreatments.round()
|
val bolusIob = activePlugin.activeTreatments.lastCalculationTreatments.round()
|
||||||
|
@ -350,7 +350,7 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
|
|
||||||
"STATUS" -> {
|
"STATUS" -> {
|
||||||
val reply = if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
val reply = if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
if (loopPlugin.isSuspended()) String.format(resourceHelper.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend())
|
if (loopPlugin.isSuspended) String.format(resourceHelper.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend())
|
||||||
else resourceHelper.gs(R.string.smscommunicator_loopisenabled)
|
else resourceHelper.gs(R.string.smscommunicator_loopisenabled)
|
||||||
} else
|
} else
|
||||||
resourceHelper.gs(R.string.smscommunicator_loopisdisabled)
|
resourceHelper.gs(R.string.smscommunicator_loopisdisabled)
|
||||||
|
|
|
@ -35,7 +35,7 @@ class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
|
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
|
||||||
setContentView(R.layout.activity_smscommunicator_otp)
|
setContentView(R.layout.activity_smscommunicator_otp)
|
||||||
|
|
||||||
smscommunicator_otp_verify_edit.addTextChangedListener(object : TextWatcher {
|
smscommunicator_otp_verify_edit.addTextChangedListener(object : TextWatcher {
|
||||||
|
|
|
@ -19,10 +19,10 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||||
* Created by emmablack on 12/26/14.
|
* Created by emmablack on 12/26/14.
|
||||||
*/
|
*/
|
||||||
class SendToDataLayerThread extends AsyncTask<DataMap,Void,Void> {
|
class SendToDataLayerThread extends AsyncTask<DataMap,Void,Void> {
|
||||||
private GoogleApiClient googleApiClient;
|
private final GoogleApiClient googleApiClient;
|
||||||
private static final String TAG = "SendToDataLayerThread";
|
private static final String TAG = "SendToDataLayerThread";
|
||||||
private String path;
|
private final String path;
|
||||||
private String logPrefix = ""; // "WR: ";
|
private final String logPrefix = ""; // "WR: ";
|
||||||
private static int concurrency = 0;
|
private static int concurrency = 0;
|
||||||
private static int state = 0;
|
private static int state = 0;
|
||||||
private static final ReentrantLock lock = new ReentrantLock();
|
private static final ReentrantLock lock = new ReentrantLock();
|
||||||
|
|
|
@ -769,7 +769,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeTask(AsyncTask task, DataMap... parameters) {
|
private void executeTask(AsyncTask task, DataMap... parameters) {
|
||||||
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Object[]) parameters);
|
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, parameters);
|
||||||
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||||
// task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
// task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
// } else {
|
// } else {
|
||||||
|
|
|
@ -22,8 +22,8 @@ class InsulinFragment : DaggerFragment() {
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
insulin_name?.setText(activePlugin.activeInsulin.friendlyName)
|
insulin_name?.text = activePlugin.activeInsulin.friendlyName
|
||||||
insulin_comment?.setText(activePlugin.activeInsulin.comment)
|
insulin_comment?.text = activePlugin.activeInsulin.comment
|
||||||
insulin_dia?.text = resourceHelper.gs(R.string.dia) + ": " + activePlugin.activeInsulin.dia + "h"
|
insulin_dia?.text = resourceHelper.gs(R.string.dia) + ": " + activePlugin.activeInsulin.dia + "h"
|
||||||
insulin_graph?.show(activePlugin.activeInsulin)
|
insulin_graph?.show(activePlugin.activeInsulin)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class GlucoseStatus {
|
||||||
@Inject public AAPSLogger aapsLogger;
|
@Inject public AAPSLogger aapsLogger;
|
||||||
@Inject public IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
@Inject public IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
||||||
|
|
||||||
private HasAndroidInjector injector;
|
private final HasAndroidInjector injector;
|
||||||
|
|
||||||
public double glucose = 0d;
|
public double glucose = 0d;
|
||||||
public double noise = 0d;
|
public double noise = 0d;
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class IobCobCalculatorPlugin extends PluginBase implements IobCobCalculat
|
||||||
private final FabricPrivacy fabricPrivacy;
|
private final FabricPrivacy fabricPrivacy;
|
||||||
private final DateUtil dateUtil;
|
private final DateUtil dateUtil;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private LongSparseArray<IobTotal> iobTable = new LongSparseArray<>(); // oldest at index 0
|
private LongSparseArray<IobTotal> iobTable = new LongSparseArray<>(); // oldest at index 0
|
||||||
private LongSparseArray<IobTotal> absIobTable = new LongSparseArray<>(); // oldest at index 0, absolute insulin in the body
|
private LongSparseArray<IobTotal> absIobTable = new LongSparseArray<>(); // oldest at index 0, absolute insulin in the body
|
||||||
|
|
|
@ -73,10 +73,10 @@ public class IobCobOref1Thread extends Thread {
|
||||||
private final HasAndroidInjector injector;
|
private final HasAndroidInjector injector;
|
||||||
private final IobCobCalculatorPlugin iobCobCalculatorPlugin; // cannot be injected : HistoryBrowser uses different instance
|
private final IobCobCalculatorPlugin iobCobCalculatorPlugin; // cannot be injected : HistoryBrowser uses different instance
|
||||||
private final TreatmentsPlugin treatmentsPlugin; // cannot be injected : HistoryBrowser uses different instance
|
private final TreatmentsPlugin treatmentsPlugin; // cannot be injected : HistoryBrowser uses different instance
|
||||||
private boolean bgDataReload;
|
private final boolean bgDataReload;
|
||||||
private boolean limitDataToOldestAvailable;
|
private final boolean limitDataToOldestAvailable;
|
||||||
private String from;
|
private final String from;
|
||||||
private long end;
|
private final long end;
|
||||||
|
|
||||||
private PowerManager.WakeLock mWakeLock;
|
private PowerManager.WakeLock mWakeLock;
|
||||||
|
|
||||||
|
@ -300,10 +300,7 @@ public class IobCobOref1Thread extends Thread {
|
||||||
|
|
||||||
// If mealCOB is zero but all deviations since hitting COB=0 are positive, exclude from autosens
|
// If mealCOB is zero but all deviations since hitting COB=0 are positive, exclude from autosens
|
||||||
if (autosensData.cob > 0 || autosensData.absorbing || autosensData.mealCarbs > 0) {
|
if (autosensData.cob > 0 || autosensData.absorbing || autosensData.mealCarbs > 0) {
|
||||||
if (deviation > 0)
|
autosensData.absorbing = deviation > 0;
|
||||||
autosensData.absorbing = true;
|
|
||||||
else
|
|
||||||
autosensData.absorbing = false;
|
|
||||||
// stop excluding positive deviations as soon as mealCOB=0 if meal has been absorbing for >5h
|
// stop excluding positive deviations as soon as mealCOB=0 if meal has been absorbing for >5h
|
||||||
if (autosensData.mealStartCounter > 60 && autosensData.cob < 0.5) {
|
if (autosensData.mealStartCounter > 60 && autosensData.cob < 0.5) {
|
||||||
autosensData.absorbing = false;
|
autosensData.absorbing = false;
|
||||||
|
@ -329,10 +326,7 @@ public class IobCobOref1Thread extends Thread {
|
||||||
//if (iob.iob > currentBasal || uam ) {
|
//if (iob.iob > currentBasal || uam ) {
|
||||||
if (iob.iob > 2 * currentBasal || autosensData.uam || autosensData.mealStartCounter < 9) {
|
if (iob.iob > 2 * currentBasal || autosensData.uam || autosensData.mealStartCounter < 9) {
|
||||||
autosensData.mealStartCounter++;
|
autosensData.mealStartCounter++;
|
||||||
if (deviation > 0)
|
autosensData.uam = deviation > 0;
|
||||||
autosensData.uam = true;
|
|
||||||
else
|
|
||||||
autosensData.uam = false;
|
|
||||||
if (!autosensData.type.equals("uam")) {
|
if (!autosensData.type.equals("uam")) {
|
||||||
// process.stderr.write("u(");
|
// process.stderr.write("u(");
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,10 +70,10 @@ public class IobCobThread extends Thread {
|
||||||
private final HasAndroidInjector injector;
|
private final HasAndroidInjector injector;
|
||||||
private final IobCobCalculatorPlugin iobCobCalculatorPlugin; // cannot be injected : HistoryBrowser uses different instance
|
private final IobCobCalculatorPlugin iobCobCalculatorPlugin; // cannot be injected : HistoryBrowser uses different instance
|
||||||
private final TreatmentsPlugin treatmentsPlugin; // cannot be injected : HistoryBrowser uses different instance
|
private final TreatmentsPlugin treatmentsPlugin; // cannot be injected : HistoryBrowser uses different instance
|
||||||
private boolean bgDataReload;
|
private final boolean bgDataReload;
|
||||||
private boolean limitDataToOldestAvailable;
|
private final boolean limitDataToOldestAvailable;
|
||||||
private String from;
|
private final String from;
|
||||||
private long end;
|
private final long end;
|
||||||
|
|
||||||
private PowerManager.WakeLock mWakeLock;
|
private PowerManager.WakeLock mWakeLock;
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,4 @@ package info.nightscout.androidaps.plugins.profile.local.events
|
||||||
|
|
||||||
import info.nightscout.androidaps.events.Event
|
import info.nightscout.androidaps.events.Event
|
||||||
|
|
||||||
class EventLocalProfileChanged : Event() {
|
class EventLocalProfileChanged : Event()
|
||||||
}
|
|
|
@ -40,7 +40,7 @@ public class ComboFragment extends DaggerFragment implements View.OnClickListene
|
||||||
@Inject SP sp;
|
@Inject SP sp;
|
||||||
@Inject FabricPrivacy fabricPrivacy;
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private TextView stateView;
|
private TextView stateView;
|
||||||
private TextView activityView;
|
private TextView activityView;
|
||||||
|
|
|
@ -451,7 +451,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BolusProgressReporter bolusProgressReporter = (state, percent, delivered) -> {
|
private final BolusProgressReporter bolusProgressReporter = (state, percent, delivered) -> {
|
||||||
EventOverviewBolusProgress event = EventOverviewBolusProgress.INSTANCE;
|
EventOverviewBolusProgress event = EventOverviewBolusProgress.INSTANCE;
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case PROGRAMMING:
|
case PROGRAMMING:
|
||||||
|
@ -966,9 +966,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
||||||
checkPumpTime(preCheckResult.state);
|
checkPumpTime(preCheckResult.state);
|
||||||
checkBasalRate(preCheckResult.state);
|
checkBasalRate(preCheckResult.state);
|
||||||
CommandResult historyCheckError = checkHistory();
|
CommandResult historyCheckError = checkHistory();
|
||||||
if (historyCheckError != null) {
|
|
||||||
return historyCheckError;
|
return historyCheckError;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal aapsTbr = treatmentsPlugin.getTempBasalFromHistory(now);
|
TemporaryBasal aapsTbr = treatmentsPlugin.getTempBasalFromHistory(now);
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
|
|
||||||
private final Object screenlock = new Object();
|
private final Object screenlock = new Object();
|
||||||
|
|
||||||
private IRTHandler mHandler = new IRTHandler.Stub() {
|
private final IRTHandler mHandler = new IRTHandler.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void log(String message) {
|
public void log(String message) {
|
||||||
if (log.isTraceEnabled()) {
|
if (log.isTraceEnabled()) {
|
||||||
|
@ -667,7 +667,7 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
synchronized (screenlock) {
|
synchronized (screenlock) {
|
||||||
try {
|
try {
|
||||||
// updates usually come in every ~500, occasionally up to 1100ms
|
// updates usually come in every ~500, occasionally up to 1100ms
|
||||||
screenlock.wait((long) 2000);
|
screenlock.wait(2000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw new CommandException("Interrupted");
|
throw new CommandException("Interrupted");
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.Tbr;
|
||||||
import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.Tdd;
|
import info.nightscout.androidaps.plugins.pump.combo.ruffyscripter.history.Tdd;
|
||||||
|
|
||||||
public class ReadHistoryCommand extends BaseCommand {
|
public class ReadHistoryCommand extends BaseCommand {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(ReadHistoryCommand.class);
|
private static final Logger log = StacktraceLoggerWrapper.getLogger(ReadHistoryCommand.class);
|
||||||
|
|
||||||
private final PumpHistoryRequest request;
|
private final PumpHistoryRequest request;
|
||||||
private final PumpHistory history = new PumpHistory();
|
private final PumpHistory history = new PumpHistory();
|
||||||
|
|
|
@ -44,11 +44,11 @@ public class InsightAlertService extends DaggerService implements InsightConnect
|
||||||
|
|
||||||
private static final int NOTIFICATION_ID = 31345;
|
private static final int NOTIFICATION_ID = 31345;
|
||||||
|
|
||||||
private LocalBinder localBinder = new LocalBinder();
|
private final LocalBinder localBinder = new LocalBinder();
|
||||||
private boolean connectionRequested;
|
private boolean connectionRequested;
|
||||||
private final Object $alertLock = new Object[0];
|
private final Object $alertLock = new Object[0];
|
||||||
private Alert alert = null;
|
private Alert alert = null;
|
||||||
private MutableLiveData<Alert> alertLiveData = new MutableLiveData<>();
|
private final MutableLiveData<Alert> alertLiveData = new MutableLiveData<>();
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
private Vibrator vibrator;
|
private Vibrator vibrator;
|
||||||
private boolean vibrating;
|
private boolean vibrating;
|
||||||
|
@ -56,7 +56,7 @@ public class InsightAlertService extends DaggerService implements InsightConnect
|
||||||
private long ignoreTimestamp;
|
private long ignoreTimestamp;
|
||||||
private AlertType ignoreType;
|
private AlertType ignoreType;
|
||||||
|
|
||||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName name, IBinder binder) {
|
public void onServiceConnected(ComponentName name, IBinder binder) {
|
||||||
connectionService = ((InsightConnectionService.LocalBinder) binder).getService();
|
connectionService = ((InsightConnectionService.LocalBinder) binder).getService();
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class LocalInsightFragment extends DaggerFragment implements View.OnClick
|
||||||
@Inject FabricPrivacy fabricPrivacy;
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
@Inject DateUtil dateUtil;
|
@Inject DateUtil dateUtil;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private static final boolean ENABLE_OPERATING_MODE_BUTTON = false;
|
private static final boolean ENABLE_OPERATING_MODE_BUTTON = false;
|
||||||
|
|
||||||
|
|
|
@ -157,11 +157,11 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
||||||
|
|
||||||
public static final String ALERT_CHANNEL_ID = "AndroidAPS-InsightAlert";
|
public static final String ALERT_CHANNEL_ID = "AndroidAPS-InsightAlert";
|
||||||
|
|
||||||
private PumpDescription pumpDescription;
|
private final PumpDescription pumpDescription;
|
||||||
private InsightAlertService alertService;
|
private InsightAlertService alertService;
|
||||||
private InsightConnectionService connectionService;
|
private InsightConnectionService connectionService;
|
||||||
private long timeOffset;
|
private long timeOffset;
|
||||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName name, IBinder binder) {
|
public void onServiceConnected(ComponentName name, IBinder binder) {
|
||||||
if (binder instanceof InsightConnectionService.LocalBinder) {
|
if (binder instanceof InsightConnectionService.LocalBinder) {
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class InsightAlertActivity extends DaggerAppCompatActivity {
|
||||||
private Button mute;
|
private Button mute;
|
||||||
private Button confirm;
|
private Button confirm;
|
||||||
|
|
||||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName name, IBinder binder) {
|
public void onServiceConnected(ComponentName name, IBinder binder) {
|
||||||
alertService = ((InsightAlertService.LocalBinder) binder).getService();
|
alertService = ((InsightAlertService.LocalBinder) binder).getService();
|
||||||
|
|
|
@ -43,11 +43,11 @@ public class InsightPairingActivity extends NoSplashAppCompatActivity implements
|
||||||
private TextView code;
|
private TextView code;
|
||||||
private Button exit;
|
private Button exit;
|
||||||
private RecyclerView deviceList;
|
private RecyclerView deviceList;
|
||||||
private DeviceAdapter deviceAdapter = new DeviceAdapter();
|
private final DeviceAdapter deviceAdapter = new DeviceAdapter();
|
||||||
|
|
||||||
private InsightConnectionService service;
|
private InsightConnectionService service;
|
||||||
|
|
||||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName name, IBinder binder) {
|
public void onServiceConnected(ComponentName name, IBinder binder) {
|
||||||
service = ((InsightConnectionService.LocalBinder) binder).getService();
|
service = ((InsightConnectionService.LocalBinder) binder).getService();
|
||||||
|
@ -199,7 +199,7 @@ public class InsightPairingActivity extends NoSplashAppCompatActivity implements
|
||||||
service.pair(device.getAddress());
|
service.pair(device.getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
private BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
|
@ -214,7 +214,7 @@ public class InsightPairingActivity extends NoSplashAppCompatActivity implements
|
||||||
|
|
||||||
private class DeviceAdapter extends RecyclerView.Adapter<DeviceAdapter.ViewHolder> {
|
private class DeviceAdapter extends RecyclerView.Adapter<DeviceAdapter.ViewHolder> {
|
||||||
|
|
||||||
private List<BluetoothDevice> bluetoothDevices = new ArrayList<>();
|
private final List<BluetoothDevice> bluetoothDevices = new ArrayList<>();
|
||||||
|
|
||||||
public void addDevice(BluetoothDevice bluetoothDevice) {
|
public void addDevice(BluetoothDevice bluetoothDevice) {
|
||||||
if (!bluetoothDevices.contains(bluetoothDevice)) {
|
if (!bluetoothDevices.contains(bluetoothDevice)) {
|
||||||
|
@ -248,7 +248,7 @@ public class InsightPairingActivity extends NoSplashAppCompatActivity implements
|
||||||
|
|
||||||
public class ViewHolder extends RecyclerView.ViewHolder {
|
public class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
private TextView deviceName;
|
private final TextView deviceName;
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
public ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class InsightPairingInformationActivity extends NoSplashAppCompatActivity
|
||||||
private TextView systemIdAppendix;
|
private TextView systemIdAppendix;
|
||||||
private TextView manufacturingDate;
|
private TextView manufacturingDate;
|
||||||
|
|
||||||
private ServiceConnection serviceConnection = new ServiceConnection() {
|
private final ServiceConnection serviceConnection = new ServiceConnection() {
|
||||||
@Override
|
@Override
|
||||||
public void onServiceConnected(ComponentName name, IBinder binder) {
|
public void onServiceConnected(ComponentName name, IBinder binder) {
|
||||||
connectionService = ((InsightConnectionService.LocalBinder) binder).getService();
|
connectionService = ((InsightConnectionService.LocalBinder) binder).getService();
|
||||||
|
|
|
@ -9,7 +9,7 @@ public enum Service {
|
||||||
PARAMETER((short) 0x0200, null),
|
PARAMETER((short) 0x0200, null),
|
||||||
REMOTE_CONTROL((short) 0x0100, "MAbcV2X6PVjxuz+R");
|
REMOTE_CONTROL((short) 0x0100, "MAbcV2X6PVjxuz+R");
|
||||||
|
|
||||||
private short version;
|
private final short version;
|
||||||
private String servicePassword;
|
private String servicePassword;
|
||||||
|
|
||||||
Service(short version, String servicePassword) {
|
Service(short version, String servicePassword) {
|
||||||
|
|
|
@ -6,8 +6,8 @@ import info.nightscout.androidaps.plugins.pump.insight.app_layer.configuration.O
|
||||||
|
|
||||||
public class ConfigurationMessageRequest<T extends AppLayerMessage> extends MessageRequest<T> {
|
public class ConfigurationMessageRequest<T extends AppLayerMessage> extends MessageRequest<T> {
|
||||||
|
|
||||||
private MessageRequest<OpenConfigurationWriteSessionMessage> openRequest;
|
private final MessageRequest<OpenConfigurationWriteSessionMessage> openRequest;
|
||||||
private MessageRequest<CloseConfigurationWriteSessionMessage> closeRequest;
|
private final MessageRequest<CloseConfigurationWriteSessionMessage> closeRequest;
|
||||||
|
|
||||||
public ConfigurationMessageRequest(T request, MessageRequest<OpenConfigurationWriteSessionMessage> openRequest, MessageRequest<CloseConfigurationWriteSessionMessage> closeRequest) {
|
public ConfigurationMessageRequest(T request, MessageRequest<OpenConfigurationWriteSessionMessage> openRequest, MessageRequest<CloseConfigurationWriteSessionMessage> closeRequest) {
|
||||||
super(request);
|
super(request);
|
||||||
|
|
|
@ -95,29 +95,29 @@ public class InsightConnectionService extends DaggerService implements Connectio
|
||||||
private static final int TIMEOUT_DURING_HANDSHAKE_NOTIFICATION_THRESHOLD = 3;
|
private static final int TIMEOUT_DURING_HANDSHAKE_NOTIFICATION_THRESHOLD = 3;
|
||||||
private static final long RESPONSE_TIMEOUT = 6000;
|
private static final long RESPONSE_TIMEOUT = 6000;
|
||||||
|
|
||||||
private List<StateCallback> stateCallbacks = new ArrayList<>();
|
private final List<StateCallback> stateCallbacks = new ArrayList<>();
|
||||||
private final List<Object> connectionRequests = new ArrayList<>();
|
private final List<Object> connectionRequests = new ArrayList<>();
|
||||||
private List<ExceptionCallback> exceptionCallbacks = new ArrayList<>();
|
private final List<ExceptionCallback> exceptionCallbacks = new ArrayList<>();
|
||||||
private LocalBinder localBinder = new LocalBinder();
|
private final LocalBinder localBinder = new LocalBinder();
|
||||||
private PairingDataStorage pairingDataStorage;
|
private PairingDataStorage pairingDataStorage;
|
||||||
private InsightState state;
|
private InsightState state;
|
||||||
private PowerManager.WakeLock wakeLock;
|
private PowerManager.WakeLock wakeLock;
|
||||||
private DelayedActionThread disconnectTimer;
|
private DelayedActionThread disconnectTimer;
|
||||||
private DelayedActionThread recoveryTimer;
|
private DelayedActionThread recoveryTimer;
|
||||||
private DelayedActionThread timeoutTimer;
|
private DelayedActionThread timeoutTimer;
|
||||||
private BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
private final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
|
||||||
private BluetoothDevice bluetoothDevice;
|
private BluetoothDevice bluetoothDevice;
|
||||||
private BluetoothSocket bluetoothSocket;
|
private BluetoothSocket bluetoothSocket;
|
||||||
private ConnectionEstablisher connectionEstablisher;
|
private ConnectionEstablisher connectionEstablisher;
|
||||||
private InputStreamReader inputStreamReader;
|
private InputStreamReader inputStreamReader;
|
||||||
private OutputStreamWriter outputStreamWriter;
|
private OutputStreamWriter outputStreamWriter;
|
||||||
private KeyRequest keyRequest;
|
private KeyRequest keyRequest;
|
||||||
private ByteBuf buffer = new ByteBuf(BUFFER_SIZE);
|
private final ByteBuf buffer = new ByteBuf(BUFFER_SIZE);
|
||||||
private String verificationString;
|
private String verificationString;
|
||||||
private KeyPair keyPair;
|
private KeyPair keyPair;
|
||||||
private byte[] randomBytes;
|
private byte[] randomBytes;
|
||||||
private MessageQueue messageQueue = new MessageQueue();
|
private final MessageQueue messageQueue = new MessageQueue();
|
||||||
private List<info.nightscout.androidaps.plugins.pump.insight.app_layer.Service> activatedServices = new ArrayList<>();
|
private final List<info.nightscout.androidaps.plugins.pump.insight.app_layer.Service> activatedServices = new ArrayList<>();
|
||||||
private long lastDataTime;
|
private long lastDataTime;
|
||||||
private long lastConnected;
|
private long lastConnected;
|
||||||
private long recoveryDuration = 0;
|
private long recoveryDuration = 0;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.plugins.pump.insight.exceptions;
|
||||||
|
|
||||||
public class ConnectionFailedException extends InsightException {
|
public class ConnectionFailedException extends InsightException {
|
||||||
|
|
||||||
private long durationOfConnectionAttempt;
|
private final long durationOfConnectionAttempt;
|
||||||
|
|
||||||
public ConnectionFailedException(long durationOfConnectionAttempt) {
|
public ConnectionFailedException(long durationOfConnectionAttempt) {
|
||||||
this.durationOfConnectionAttempt = durationOfConnectionAttempt;
|
this.durationOfConnectionAttempt = durationOfConnectionAttempt;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import info.nightscout.androidaps.plugins.pump.insight.exceptions.AppLayerExcept
|
||||||
|
|
||||||
public abstract class AppLayerErrorException extends AppLayerException {
|
public abstract class AppLayerErrorException extends AppLayerException {
|
||||||
|
|
||||||
private int errorCode;
|
private final int errorCode;
|
||||||
|
|
||||||
public AppLayerErrorException(int errorCode) {
|
public AppLayerErrorException(int errorCode) {
|
||||||
this.errorCode = errorCode;
|
this.errorCode = errorCode;
|
||||||
|
|
|
@ -148,8 +148,7 @@ public abstract class SatlMessage {
|
||||||
|
|
||||||
public static boolean hasCompletePacket(ByteBuf byteBuf) {
|
public static boolean hasCompletePacket(ByteBuf byteBuf) {
|
||||||
if (byteBuf.getSize() < 37) return false;
|
if (byteBuf.getSize() < 37) return false;
|
||||||
if (byteBuf.getSize() < byteBuf.getUInt16LE(4) + 8) return false;
|
return byteBuf.getSize() >= byteBuf.getUInt16LE(4) + 8;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Nonce getNonce() {
|
public Nonce getNonce() {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
public class ByteBuf {
|
public class ByteBuf {
|
||||||
|
|
||||||
private byte[] bytes;
|
private final byte[] bytes;
|
||||||
private int size = 0;
|
private int size = 0;
|
||||||
|
|
||||||
public ByteBuf(int length) {
|
public ByteBuf(int length) {
|
||||||
|
|
|
@ -10,10 +10,10 @@ import java.util.UUID;
|
||||||
|
|
||||||
public class ConnectionEstablisher extends Thread {
|
public class ConnectionEstablisher extends Thread {
|
||||||
|
|
||||||
private Callback callback;
|
private final Callback callback;
|
||||||
private boolean forPairing;
|
private final boolean forPairing;
|
||||||
private BluetoothAdapter bluetoothAdapter;
|
private final BluetoothAdapter bluetoothAdapter;
|
||||||
private BluetoothDevice bluetoothDevice;
|
private final BluetoothDevice bluetoothDevice;
|
||||||
private BluetoothSocket socket;
|
private BluetoothSocket socket;
|
||||||
|
|
||||||
public ConnectionEstablisher(Callback callback, boolean forPairing, BluetoothAdapter bluetoothAdapter, BluetoothDevice bluetoothDevice, BluetoothSocket socket) {
|
public ConnectionEstablisher(Callback callback, boolean forPairing, BluetoothAdapter bluetoothAdapter, BluetoothDevice bluetoothDevice, BluetoothSocket socket) {
|
||||||
|
|
|
@ -2,8 +2,8 @@ package info.nightscout.androidaps.plugins.pump.insight.utils;
|
||||||
|
|
||||||
public class DelayedActionThread extends Thread {
|
public class DelayedActionThread extends Thread {
|
||||||
|
|
||||||
private long duration;
|
private final long duration;
|
||||||
private Runnable runnable;
|
private final Runnable runnable;
|
||||||
|
|
||||||
private DelayedActionThread(String name, long duration, Runnable runnable) {
|
private DelayedActionThread(String name, long duration, Runnable runnable) {
|
||||||
setName(name);
|
setName(name);
|
||||||
|
|
|
@ -5,8 +5,8 @@ import java.util.Map;
|
||||||
|
|
||||||
public class IDStorage<T, I> {
|
public class IDStorage<T, I> {
|
||||||
|
|
||||||
private Map<T, I> types = new HashMap<>();
|
private final Map<T, I> types = new HashMap<>();
|
||||||
private Map<I, T> ids = new HashMap<>();
|
private final Map<I, T> ids = new HashMap<>();
|
||||||
|
|
||||||
public void put(T type, I id) {
|
public void put(T type, I id) {
|
||||||
types.put(type, id);
|
types.put(type, id);
|
||||||
|
|
|
@ -7,8 +7,8 @@ public class InputStreamReader extends Thread {
|
||||||
|
|
||||||
private static final int BUFFER_SIZE = 1024;
|
private static final int BUFFER_SIZE = 1024;
|
||||||
|
|
||||||
private InputStream inputStream;
|
private final InputStream inputStream;
|
||||||
private Callback callback;
|
private final Callback callback;
|
||||||
|
|
||||||
public InputStreamReader(InputStream inputStream, Callback callback) {
|
public InputStreamReader(InputStream inputStream, Callback callback) {
|
||||||
setName(getClass().getSimpleName());
|
setName(getClass().getSimpleName());
|
||||||
|
|
|
@ -7,8 +7,8 @@ public class OutputStreamWriter extends Thread {
|
||||||
|
|
||||||
private static final int BUFFER_SIZE = 1024;
|
private static final int BUFFER_SIZE = 1024;
|
||||||
|
|
||||||
private OutputStream outputStream;
|
private final OutputStream outputStream;
|
||||||
private Callback callback;
|
private final Callback callback;
|
||||||
private final ByteBuf buffer = new ByteBuf(BUFFER_SIZE);
|
private final ByteBuf buffer = new ByteBuf(BUFFER_SIZE);
|
||||||
|
|
||||||
public OutputStreamWriter(OutputStream outputStream, Callback callback) {
|
public OutputStreamWriter(OutputStream outputStream, Callback callback) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import info.nightscout.androidaps.plugins.pump.insight.descriptors.SystemIdentif
|
||||||
|
|
||||||
public class PairingDataStorage {
|
public class PairingDataStorage {
|
||||||
|
|
||||||
private SharedPreferences preferences;
|
private final SharedPreferences preferences;
|
||||||
|
|
||||||
private boolean paired;
|
private boolean paired;
|
||||||
private String macAddress;
|
private String macAddress;
|
||||||
|
|
|
@ -43,8 +43,8 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class MDIPlugin extends PumpPluginBase implements PumpInterface {
|
public class MDIPlugin extends PumpPluginBase implements PumpInterface {
|
||||||
|
|
||||||
private TreatmentsPlugin treatmentsPlugin;
|
private final TreatmentsPlugin treatmentsPlugin;
|
||||||
private PumpDescription pumpDescription = new PumpDescription();
|
private final PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MDIPlugin(
|
public MDIPlugin(
|
||||||
|
|
|
@ -42,8 +42,8 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
|
public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
|
||||||
|
|
||||||
private ProfileFunction profileFunction;
|
private final ProfileFunction profileFunction;
|
||||||
private DateUtil dateUtil;
|
private final DateUtil dateUtil;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SensitivityAAPSPlugin(
|
public SensitivityAAPSPlugin(
|
||||||
|
|
|
@ -36,9 +36,9 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin {
|
public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin {
|
||||||
|
|
||||||
private SP sp;
|
private final SP sp;
|
||||||
private DateUtil dateUtil;
|
private final DateUtil dateUtil;
|
||||||
private ProfileFunction profileFunction;
|
private final ProfileFunction profileFunction;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SensitivityWeightedAveragePlugin(
|
public SensitivityWeightedAveragePlugin(
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
|
||||||
@Inject DatabaseHelperInterface databaseHelper;
|
@Inject DatabaseHelperInterface databaseHelper;
|
||||||
@Inject OpenHumansUploader openHumansUploader;
|
@Inject OpenHumansUploader openHumansUploader;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private static final ScheduledExecutorService treatmentEventWorker = Executors.newSingleThreadScheduledExecutor();
|
private static final ScheduledExecutorService treatmentEventWorker = Executors.newSingleThreadScheduledExecutor();
|
||||||
private static ScheduledFuture<?> scheduledTreatmentEventPost = null;
|
private static ScheduledFuture<?> scheduledTreatmentEventPost = null;
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
private final FabricPrivacy fabricPrivacy;
|
private final FabricPrivacy fabricPrivacy;
|
||||||
private final DateUtil dateUtil;
|
private final DateUtil dateUtil;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
protected TreatmentService service;
|
protected TreatmentService service;
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class TreatmentsTempTargetFragment extends DaggerFragment {
|
||||||
@Inject FabricPrivacy fabricPrivacy;
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
@Inject DateUtil dateUtil;
|
@Inject DateUtil dateUtil;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,12 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class QueueThread extends Thread {
|
public class QueueThread extends Thread {
|
||||||
private CommandQueue queue;
|
private final CommandQueue queue;
|
||||||
private AAPSLogger aapsLogger;
|
private final AAPSLogger aapsLogger;
|
||||||
private RxBusWrapper rxBus;
|
private final RxBusWrapper rxBus;
|
||||||
private ActivePluginProvider activePlugin;
|
private final ActivePluginProvider activePlugin;
|
||||||
private ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private SP sp;
|
private final SP sp;
|
||||||
|
|
||||||
private boolean connectLogged = false;
|
private boolean connectLogged = false;
|
||||||
boolean waitingForDisconnect = false;
|
boolean waitingForDisconnect = false;
|
||||||
|
|
|
@ -19,7 +19,7 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
* Created by mike on 11.07.2016.
|
* Created by mike on 11.07.2016.
|
||||||
*/
|
*/
|
||||||
public class JSONFormatter {
|
public class JSONFormatter {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(JSONFormatter.class);
|
private static final Logger log = StacktraceLoggerWrapper.getLogger(JSONFormatter.class);
|
||||||
|
|
||||||
public static Spanned format(final String jsonString) {
|
public static Spanned format(final String jsonString) {
|
||||||
final JsonVisitor visitor = new JsonVisitor(1, '\t');
|
final JsonVisitor visitor = new JsonVisitor(1, '\t');
|
||||||
|
|
|
@ -38,26 +38,26 @@ public class TimeListEdit {
|
||||||
|
|
||||||
private final int ONEHOURINSECONDS = 60 * 60;
|
private final int ONEHOURINSECONDS = 60 * 60;
|
||||||
|
|
||||||
private View[] intervals = new View[24];
|
private final View[] intervals = new View[24];
|
||||||
private SpinnerHelper[] spinners = new SpinnerHelper[24];
|
private final SpinnerHelper[] spinners = new SpinnerHelper[24];
|
||||||
private NumberPicker[] numberPickers1 = new NumberPicker[24];
|
private final NumberPicker[] numberPickers1 = new NumberPicker[24];
|
||||||
private NumberPicker[] numberPickers2 = new NumberPicker[24];
|
private final NumberPicker[] numberPickers2 = new NumberPicker[24];
|
||||||
private ImageView[] addButtons = new ImageView[24];
|
private final ImageView[] addButtons = new ImageView[24];
|
||||||
private ImageView[] removeButtons = new ImageView[24];
|
private final ImageView[] removeButtons = new ImageView[24];
|
||||||
private ImageView finalAdd;
|
private ImageView finalAdd;
|
||||||
|
|
||||||
private Context context;
|
private final Context context;
|
||||||
private View view;
|
private final View view;
|
||||||
private int resLayoutId;
|
private final int resLayoutId;
|
||||||
private String tagPrefix;
|
private final String tagPrefix;
|
||||||
private String label;
|
private String label;
|
||||||
private JSONArray data1;
|
private final JSONArray data1;
|
||||||
private JSONArray data2;
|
private final JSONArray data2;
|
||||||
private double step;
|
private final double step;
|
||||||
private double min;
|
private final double min;
|
||||||
private double max;
|
private final double max;
|
||||||
private NumberFormat formatter;
|
private final NumberFormat formatter;
|
||||||
private Runnable save;
|
private final Runnable save;
|
||||||
private LinearLayout layout;
|
private LinearLayout layout;
|
||||||
private TextView textlabel;
|
private TextView textlabel;
|
||||||
private int inflatedUntil = -1;
|
private int inflatedUntil = -1;
|
||||||
|
|
|
@ -53,7 +53,7 @@ object PrefImportSummaryDialog {
|
||||||
for ((metaKey, metaEntry) in prefs.metadata) {
|
for ((metaKey, metaEntry) in prefs.metadata) {
|
||||||
val rowLayout = LayoutInflater.from(themedCtx).inflate(R.layout.import_summary_item, null)
|
val rowLayout = LayoutInflater.from(themedCtx).inflate(R.layout.import_summary_item, null)
|
||||||
val label = (rowLayout.findViewById<View>(R.id.summary_text) as TextView)
|
val label = (rowLayout.findViewById<View>(R.id.summary_text) as TextView)
|
||||||
label.setText(metaKey.formatForDisplay(context, metaEntry.value))
|
label.text = metaKey.formatForDisplay(context, metaEntry.value)
|
||||||
(rowLayout.findViewById<View>(R.id.summary_icon) as ImageView).setImageResource(metaKey.icon)
|
(rowLayout.findViewById<View>(R.id.summary_icon) as ImageView).setImageResource(metaKey.icon)
|
||||||
(rowLayout.findViewById<View>(R.id.status_icon) as ImageView).setImageResource(metaEntry.status.icon)
|
(rowLayout.findViewById<View>(R.id.status_icon) as ImageView).setImageResource(metaEntry.status.icon)
|
||||||
|
|
||||||
|
@ -84,9 +84,9 @@ object PrefImportSummaryDialog {
|
||||||
detailsBtn.setOnClickListener {
|
detailsBtn.setOnClickListener {
|
||||||
val detailsLayout = LayoutInflater.from(context).inflate(R.layout.import_summary_details, null)
|
val detailsLayout = LayoutInflater.from(context).inflate(R.layout.import_summary_details, null)
|
||||||
val wview = detailsLayout.findViewById<View>(R.id.details_webview) as WebView
|
val wview = detailsLayout.findViewById<View>(R.id.details_webview) as WebView
|
||||||
wview.loadData("<!doctype html><html><head><meta charset=\"utf-8\"><style>body { color: white; }</style></head><body>" + details.joinToString("<hr>"), "text/html; charset=utf-8", "utf-8");
|
wview.loadData("<!doctype html><html><head><meta charset=\"utf-8\"><style>body { color: white; }</style></head><body>" + details.joinToString("<hr>"), "text/html; charset=utf-8", "utf-8")
|
||||||
wview.setBackgroundColor(Color.TRANSPARENT);
|
wview.setBackgroundColor(Color.TRANSPARENT)
|
||||||
wview.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null);
|
wview.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null)
|
||||||
|
|
||||||
AlertDialogHelper.Builder(context, R.style.AppTheme)
|
AlertDialogHelper.Builder(context, R.style.AppTheme)
|
||||||
.setCustomTitle(AlertDialogHelper.buildCustomTitle(
|
.setCustomTitle(AlertDialogHelper.buildCustomTitle(
|
||||||
|
|
|
@ -68,7 +68,7 @@ class TddCalculator @Inject constructor(
|
||||||
val absoluteRate = tbr?.tempBasalConvertedToAbsolute(t, profile) ?: profile.getBasal(t)
|
val absoluteRate = tbr?.tempBasalConvertedToAbsolute(t, profile) ?: profile.getBasal(t)
|
||||||
tdd.basal += absoluteRate / 60.0 * 5.0
|
tdd.basal += absoluteRate / 60.0 * 5.0
|
||||||
|
|
||||||
if (!activePlugin.activePump.isFakingTempsByExtendedBoluses()) {
|
if (!activePlugin.activePump.isFakingTempsByExtendedBoluses) {
|
||||||
// they are not included in TBRs
|
// they are not included in TBRs
|
||||||
val eb = getExtendedBolusFromHistory(t)
|
val eb = getExtendedBolusFromHistory(t)
|
||||||
val absoluteEbRate = eb?.absoluteRate() ?: 0.0
|
val absoluteEbRate = eb?.absoluteRate() ?: 0.0
|
||||||
|
|
|
@ -172,7 +172,7 @@ class BolusWizard @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insulin from 15 min trend
|
// Insulin from 15 min trend
|
||||||
glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
|
glucoseStatus = GlucoseStatus(injector).glucoseStatusData
|
||||||
glucoseStatus?.let {
|
glucoseStatus?.let {
|
||||||
if (useTrend) {
|
if (useTrend) {
|
||||||
trend = it.short_avgdelta
|
trend = it.short_avgdelta
|
||||||
|
|
|
@ -107,7 +107,7 @@ class QuickWizardEntry @Inject constructor(private val injector: HasAndroidInjec
|
||||||
}
|
}
|
||||||
if (loopPlugin.isEnabled(loopPlugin.getType()) && loopPlugin.isSuperBolus) superBolus = false
|
if (loopPlugin.isEnabled(loopPlugin.getType()) && loopPlugin.isSuperBolus) superBolus = false
|
||||||
// Trend
|
// Trend
|
||||||
val glucoseStatus = GlucoseStatus(injector).getGlucoseStatusData()
|
val glucoseStatus = GlucoseStatus(injector).glucoseStatusData
|
||||||
var trend = false
|
var trend = false
|
||||||
if (useTrend() == YES) {
|
if (useTrend() == YES) {
|
||||||
trend = true
|
trend = true
|
||||||
|
|
|
@ -19,8 +19,8 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Menu implements Parcelable{
|
public class Menu implements Parcelable{
|
||||||
private MenuType type;
|
private final MenuType type;
|
||||||
private Map<MenuAttribute,Object> attributes = new HashMap<>();
|
private final Map<MenuAttribute,Object> attributes = new HashMap<>();
|
||||||
|
|
||||||
public Menu(MenuType type)
|
public Menu(MenuType type)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ public class Menu implements Parcelable{
|
||||||
} else if (BolusType.class.toString().equals(clas)) {
|
} else if (BolusType.class.toString().equals(clas)) {
|
||||||
o = BolusType.valueOf(value);
|
o = BolusType.valueOf(value);
|
||||||
} else if (String.class.toString().equals(clas)) {
|
} else if (String.class.toString().equals(clas)) {
|
||||||
o = new String(value);
|
o = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (o != null) {
|
if (o != null) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class TDDStatsActivity extends NoSplashAppCompatActivity {
|
||||||
@Inject DatabaseHelperInterface databaseHelper;
|
@Inject DatabaseHelperInterface databaseHelper;
|
||||||
@Inject FabricPrivacy fabricPrivacy;
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
TextView statusView, statsMessage, totalBaseBasal2;
|
TextView statusView, statsMessage, totalBaseBasal2;
|
||||||
EditText totalBaseBasal;
|
EditText totalBaseBasal;
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class Profile {
|
||||||
@Inject public FabricPrivacy fabricPrivacy;
|
@Inject public FabricPrivacy fabricPrivacy;
|
||||||
@Inject public ConfigInterface configInterface;
|
@Inject public ConfigInterface configInterface;
|
||||||
|
|
||||||
private HasAndroidInjector injector;
|
private final HasAndroidInjector injector;
|
||||||
|
|
||||||
private JSONObject json;
|
private JSONObject json;
|
||||||
private String units;
|
private String units;
|
||||||
|
@ -138,7 +138,7 @@ public class Profile {
|
||||||
public String log() {
|
public String log() {
|
||||||
String ret = "\n";
|
String ret = "\n";
|
||||||
for (Integer hour = 0; hour < 24; hour++) {
|
for (Integer hour = 0; hour < 24; hour++) {
|
||||||
double value = getBasalTimeFromMidnight((Integer) (hour * 60 * 60));
|
double value = getBasalTimeFromMidnight(hour * 60 * 60);
|
||||||
ret += "NS basal value for " + hour + ":00 is " + value + "\n";
|
ret += "NS basal value for " + hour + ":00 is " + value + "\n";
|
||||||
}
|
}
|
||||||
ret += "NS units: " + getUnits();
|
ret += "NS units: " + getUnits();
|
||||||
|
|
|
@ -46,7 +46,7 @@ class DefaultProfile @Inject constructor(val injector: HasAndroidInjector) {
|
||||||
profile.put("dia", 5.0)
|
profile.put("dia", 5.0)
|
||||||
profile.put("carbs_hr", 20) // not used
|
profile.put("carbs_hr", 20) // not used
|
||||||
profile.put("delay", 5.0) // not used
|
profile.put("delay", 5.0) // not used
|
||||||
profile.put("timezone", TimeZone.getDefault().getID())
|
profile.put("timezone", TimeZone.getDefault().id)
|
||||||
profile.put("target_high", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
|
profile.put("target_high", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
|
||||||
profile.put("target_low", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
|
profile.put("target_low", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
|
||||||
profile.put("units", units)
|
profile.put("units", units)
|
||||||
|
|
|
@ -37,7 +37,7 @@ class DefaultProfileDPV @Inject constructor(val injector: HasAndroidInjector) {
|
||||||
profile.put("dia", 5.0)
|
profile.put("dia", 5.0)
|
||||||
profile.put("carbs_hr", 20) // not used
|
profile.put("carbs_hr", 20) // not used
|
||||||
profile.put("delay", 5.0) // not used
|
profile.put("delay", 5.0) // not used
|
||||||
profile.put("timezone", TimeZone.getDefault().getID())
|
profile.put("timezone", TimeZone.getDefault().id)
|
||||||
profile.put("target_high", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
|
profile.put("target_high", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
|
||||||
profile.put("target_low", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
|
profile.put("target_low", JSONArray().put(JSONObject().put("time", "00:00").put("value", Profile.fromMgdlToUnits(108.0, units))))
|
||||||
profile.put("units", units)
|
profile.put("units", units)
|
||||||
|
|
|
@ -14,8 +14,8 @@ public class Constraint<T extends Comparable<T>> {
|
||||||
private T value;
|
private T value;
|
||||||
private T originalValue;
|
private T originalValue;
|
||||||
|
|
||||||
private List<String> reasons = new ArrayList<>();
|
private final List<String> reasons = new ArrayList<>();
|
||||||
private List<String> mostLimiting = new ArrayList<>();
|
private final List<String> mostLimiting = new ArrayList<>();
|
||||||
|
|
||||||
public Constraint(T value) {
|
public Constraint(T value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
|
|
|
@ -192,7 +192,7 @@ public class APSResult {
|
||||||
|
|
||||||
protected void doClone(APSResult newResult) {
|
protected void doClone(APSResult newResult) {
|
||||||
newResult.date = date;
|
newResult.date = date;
|
||||||
newResult.reason = reason != null ? new String(reason) : null;
|
newResult.reason = reason != null ? reason : null;
|
||||||
newResult.rate = rate;
|
newResult.rate = rate;
|
||||||
newResult.duration = duration;
|
newResult.duration = duration;
|
||||||
newResult.tempBasalRequested = tempBasalRequested;
|
newResult.tempBasalRequested = tempBasalRequested;
|
||||||
|
|
|
@ -12,7 +12,7 @@ public enum ManufacturerType {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private String description;
|
private final String description;
|
||||||
|
|
||||||
ManufacturerType(String description) {
|
ManufacturerType(String description) {
|
||||||
|
|
||||||
|
|
|
@ -520,9 +520,7 @@ public class NSUpload {
|
||||||
public static boolean isIdValid(String _id) {
|
public static boolean isIdValid(String _id) {
|
||||||
if (_id == null)
|
if (_id == null)
|
||||||
return false;
|
return false;
|
||||||
if (_id.length() == 24)
|
return _id.length() == 24;
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateCareportalEvent(String eventType, long time, String notes) {
|
public void generateCareportalEvent(String eventType, long time, String notes) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import info.nightscout.androidaps.logging.LTag;
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
|
|
||||||
public class NSMbg {
|
public class NSMbg {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
private static final Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
||||||
public long date;
|
public long date;
|
||||||
public double mbg;
|
public double mbg;
|
||||||
public String json;
|
public String json;
|
||||||
|
|
|
@ -14,9 +14,9 @@ import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
||||||
* {"mgdl":105,"mills":1455136282375,"device":"xDrip-BluetoothWixel","direction":"Flat","filtered":98272,"unfiltered":98272,"noise":1,"rssi":100}
|
* {"mgdl":105,"mills":1455136282375,"device":"xDrip-BluetoothWixel","direction":"Flat","filtered":98272,"unfiltered":98272,"noise":1,"rssi":100}
|
||||||
*/
|
*/
|
||||||
public class NSSgv {
|
public class NSSgv {
|
||||||
private static Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
private static final Logger log = StacktraceLoggerWrapper.getLogger(LTag.NSCLIENT);
|
||||||
|
|
||||||
private JSONObject data;
|
private final JSONObject data;
|
||||||
|
|
||||||
public NSSgv(JSONObject obj) {
|
public NSSgv(JSONObject obj) {
|
||||||
this.data = obj;
|
this.data = obj;
|
||||||
|
|
|
@ -250,7 +250,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
Rect bounds = new Rect((int) endX, (int) endY + 3, (int) (xpluslength), (int) endY + 8);
|
Rect bounds = new Rect((int) endX, (int) endY + 3, (int) (xpluslength), (int) endY + 8);
|
||||||
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
canvas.drawRect(bounds, mPaint);
|
canvas.drawRect(bounds, mPaint);
|
||||||
mPaint.setTextSize((float) (scaledTextSize));
|
mPaint.setTextSize(scaledTextSize);
|
||||||
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
|
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
|
||||||
mPaint.setFakeBoldText(true);
|
mPaint.setFakeBoldText(true);
|
||||||
canvas.drawText(value.getLabel(), endX, endY, mPaint);
|
canvas.drawText(value.getLabel(), endX, endY, mPaint);
|
||||||
|
|
|
@ -6,7 +6,7 @@ package info.nightscout.androidaps.plugins.general.overview.graphExtensions;
|
||||||
|
|
||||||
public class Scale {
|
public class Scale {
|
||||||
private double multiplier;
|
private double multiplier;
|
||||||
private double shift;
|
private final double shift;
|
||||||
|
|
||||||
public Scale() {
|
public Scale() {
|
||||||
shift = 0;
|
shift = 0;
|
||||||
|
|
|
@ -52,7 +52,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
// When using this class, make sure that your first step is to create mConnection (see MedtronicPumpPlugin)
|
// When using this class, make sure that your first step is to create mConnection (see MedtronicPumpPlugin)
|
||||||
|
|
||||||
public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpInterface, ConstraintsInterface {
|
public abstract class PumpPluginAbstract extends PumpPluginBase implements PumpInterface, ConstraintsInterface {
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private final CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
protected HasAndroidInjector injector;
|
protected HasAndroidInjector injector;
|
||||||
protected AAPSLogger aapsLogger;
|
protected AAPSLogger aapsLogger;
|
||||||
|
|
|
@ -6,11 +6,11 @@ package info.nightscout.androidaps.plugins.pump.common.data;
|
||||||
|
|
||||||
public class DoseSettings {
|
public class DoseSettings {
|
||||||
|
|
||||||
private double step;
|
private final double step;
|
||||||
private int durationStep;
|
private final int durationStep;
|
||||||
private int maxDuration;
|
private final int maxDuration;
|
||||||
private double minDose;
|
private final double minDose;
|
||||||
private Double maxDose;
|
private final Double maxDose;
|
||||||
|
|
||||||
public DoseSettings(double step, int durationStep, int maxDuration, double minDose, Double maxDose)
|
public DoseSettings(double step, int durationStep, int maxDuration, double minDose, Double maxDose)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,7 @@ public enum PumpHistoryEntryGroup {
|
||||||
Unknown(R.string.history_group_unknown),
|
Unknown(R.string.history_group_unknown),
|
||||||
;
|
;
|
||||||
|
|
||||||
private int resourceId;
|
private final int resourceId;
|
||||||
private String translated;
|
private String translated;
|
||||||
|
|
||||||
private static List<PumpHistoryEntryGroup> translatedList;
|
private static List<PumpHistoryEntryGroup> translatedList;
|
||||||
|
|
|
@ -9,7 +9,7 @@ public enum PumpStatusType {
|
||||||
Suspended("suspended") //
|
Suspended("suspended") //
|
||||||
;
|
;
|
||||||
|
|
||||||
private String statusString;
|
private final String statusString;
|
||||||
|
|
||||||
|
|
||||||
PumpStatusType(String statusString) {
|
PumpStatusType(String statusString) {
|
||||||
|
|
|
@ -143,7 +143,7 @@ public enum PumpType {
|
||||||
MDI("MDI", ManufacturerType.AndroidAPS, "MDI");
|
MDI("MDI", ManufacturerType.AndroidAPS, "MDI");
|
||||||
|
|
||||||
|
|
||||||
private String description;
|
private final String description;
|
||||||
private ManufacturerType manufacturer;
|
private ManufacturerType manufacturer;
|
||||||
private String model;
|
private String model;
|
||||||
private double bolusSize;
|
private double bolusSize;
|
||||||
|
@ -160,7 +160,7 @@ public enum PumpType {
|
||||||
private boolean hasCustomUnreachableAlertCheck;
|
private boolean hasCustomUnreachableAlertCheck;
|
||||||
|
|
||||||
private PumpType parent;
|
private PumpType parent;
|
||||||
private static Map<String, PumpType> mapByDescription;
|
private static final Map<String, PumpType> mapByDescription;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
mapByDescription = new HashMap<>();
|
mapByDescription = new HashMap<>();
|
||||||
|
@ -454,7 +454,7 @@ public enum PumpType {
|
||||||
} else {
|
} else {
|
||||||
DoseStepSize specialBolusSize = getBaseBasalSpecialSteps();
|
DoseStepSize specialBolusSize = getBaseBasalSpecialSteps();
|
||||||
|
|
||||||
basalStepSize = specialBolusSize.getStepSizeForAmount((double) basalAmount);
|
basalStepSize = specialBolusSize.getStepSizeForAmount(basalAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (basalAmount > getTbrSettings().getMaxDose())
|
if (basalAmount > getTbrSettings().getMaxDose())
|
||||||
|
|
|
@ -145,7 +145,7 @@ public class ByteUtil {
|
||||||
|
|
||||||
|
|
||||||
public static String showPrintable(byte[] ra) {
|
public static String showPrintable(byte[] ra) {
|
||||||
String s = new String();
|
String s = "";
|
||||||
for (int i = 0; i < ra.length; i++) {
|
for (int i = 0; i < ra.length; i++) {
|
||||||
char c = (char) ra[i];
|
char c = (char) ra[i];
|
||||||
if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))) {
|
if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'Z')) || ((c >= 'a') && (c <= 'z'))) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class ProfileUtil {
|
||||||
stringBuilder.append(", ");
|
stringBuilder.append(", ");
|
||||||
}
|
}
|
||||||
if (stringBuilder.length() > 3)
|
if (stringBuilder.length() > 3)
|
||||||
return stringBuilder.toString().substring(0, stringBuilder.length() - 2);
|
return stringBuilder.substring(0, stringBuilder.length() - 2);
|
||||||
else
|
else
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class ProfileUtil {
|
||||||
stringBuilder.append(", ");
|
stringBuilder.append(", ");
|
||||||
}
|
}
|
||||||
if (stringBuilder.length() > 3)
|
if (stringBuilder.length() > 3)
|
||||||
return stringBuilder.toString().substring(0, stringBuilder.length() - 2);
|
return stringBuilder.substring(0, stringBuilder.length() - 2);
|
||||||
else
|
else
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.pump.common.utils;
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -23,7 +24,7 @@ public class StringUtil {
|
||||||
if (ra == null)
|
if (ra == null)
|
||||||
return "null array";
|
return "null array";
|
||||||
else
|
else
|
||||||
return new String(ra, Charset.forName("UTF-8"));
|
return new String(ra, StandardCharsets.UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ class AlarmSoundService : DaggerService() {
|
||||||
// TODO replace with VolumeShaper when min API level >= 26
|
// TODO replace with VolumeShaper when min API level >= 26
|
||||||
private val volumeUpdater = object : Runnable {
|
private val volumeUpdater = object : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
currentVolumeLevel++;
|
currentVolumeLevel++
|
||||||
|
|
||||||
val volumePercentage = 100.0.coerceAtMost(currentVolumeLevel / VOLUME_INCREASE_STEPS.toDouble() * 100)
|
val volumePercentage = 100.0.coerceAtMost(currentVolumeLevel / VOLUME_INCREASE_STEPS.toDouble() * 100)
|
||||||
val volume = (1 - (ln(1.0.coerceAtLeast(100.0 - volumePercentage)) / ln(100.0))).toFloat()
|
val volume = (1 - (ln(1.0.coerceAtLeast(100.0 - volumePercentage)) / ln(100.0))).toFloat()
|
||||||
|
|
|
@ -2,7 +2,7 @@ package info.nightscout.androidaps.utils;
|
||||||
|
|
||||||
public final class CRC {
|
public final class CRC {
|
||||||
|
|
||||||
private static int[] CRC16_TABLE = new int[]{
|
private static final int[] CRC16_TABLE = new int[]{
|
||||||
0, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad,
|
0, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad,
|
||||||
0xe1ce, 0xf1ef, 0x1231, 0x210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a,
|
0xe1ce, 0xf1ef, 0x1231, 0x210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a,
|
||||||
0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b,
|
0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 0xa56a, 0xb54b,
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class DateUtil {
|
||||||
/**
|
/**
|
||||||
* The date format in iso.
|
* The date format in iso.
|
||||||
*/
|
*/
|
||||||
private static String FORMAT_DATE_ISO_OUT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
private static final String FORMAT_DATE_ISO_OUT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes in an ISO date string of the following format:
|
* Takes in an ISO date string of the following format:
|
||||||
|
@ -222,7 +222,7 @@ public class DateUtil {
|
||||||
|
|
||||||
public static String minAgoShort(long time) {
|
public static String minAgoShort(long time) {
|
||||||
int mins = (int) ((time - now()) / 1000 / 60);
|
int mins = (int) ((time - now()) / 1000 / 60);
|
||||||
return (mins > 0 ? "+" : "") + Integer.toString(mins);
|
return (mins > 0 ? "+" : "") + mins;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String hourAgo(long time, ResourceHelper resourceHelper) {
|
public static String hourAgo(long time, ResourceHelper resourceHelper) {
|
||||||
|
@ -230,7 +230,7 @@ public class DateUtil {
|
||||||
return resourceHelper.gs(R.string.hoursago, hours);
|
return resourceHelper.gs(R.string.hoursago, hours);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LongSparseArray<String> timeStrings = new LongSparseArray<>();
|
private static final LongSparseArray<String> timeStrings = new LongSparseArray<>();
|
||||||
|
|
||||||
public String timeStringFromSeconds(int seconds) {
|
public String timeStringFromSeconds(int seconds) {
|
||||||
String cached = timeStrings.get(seconds);
|
String cached = timeStrings.get(seconds);
|
||||||
|
|
|
@ -10,10 +10,10 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
* Created by mike on 11.07.2016.
|
* Created by mike on 11.07.2016.
|
||||||
*/
|
*/
|
||||||
public class DecimalFormatter {
|
public class DecimalFormatter {
|
||||||
private static DecimalFormat format0dec = new DecimalFormat("0");
|
private static final DecimalFormat format0dec = new DecimalFormat("0");
|
||||||
private static DecimalFormat format1dec = new DecimalFormat("0.0");
|
private static final DecimalFormat format1dec = new DecimalFormat("0.0");
|
||||||
private static DecimalFormat format2dec = new DecimalFormat("0.00");
|
private static final DecimalFormat format2dec = new DecimalFormat("0.00");
|
||||||
private static DecimalFormat format3dec = new DecimalFormat("0.000");
|
private static final DecimalFormat format3dec = new DecimalFormat("0.000");
|
||||||
|
|
||||||
public static String to0Decimal(double value) {
|
public static String to0Decimal(double value) {
|
||||||
return format0dec.format(value);
|
return format0dec.format(value);
|
||||||
|
|
|
@ -25,7 +25,7 @@ object AlertDialogHelper {
|
||||||
val titleLayout = LayoutInflater.from(ContextThemeWrapper(context, themeResId)).inflate(layoutResource, null)
|
val titleLayout = LayoutInflater.from(ContextThemeWrapper(context, themeResId)).inflate(layoutResource, null)
|
||||||
(titleLayout.findViewById<View>(R.id.alertdialog_title) as TextView).text = title
|
(titleLayout.findViewById<View>(R.id.alertdialog_title) as TextView).text = title
|
||||||
(titleLayout.findViewById<View>(R.id.alertdialog_icon) as ImageView).setImageResource(iconResource)
|
(titleLayout.findViewById<View>(R.id.alertdialog_icon) as ImageView).setImageResource(iconResource)
|
||||||
titleLayout.findViewById<View>(R.id.alertdialog_title).setSelected(true)
|
titleLayout.findViewById<View>(R.id.alertdialog_title).isSelected = true
|
||||||
return titleLayout
|
return titleLayout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ fun String.hexStringToByteArray() : ByteArray {
|
||||||
|
|
||||||
val lowerCased = this.toLowerCase(Locale.getDefault())
|
val lowerCased = this.toLowerCase(Locale.getDefault())
|
||||||
for (i in 0 until length step 2) {
|
for (i in 0 until length step 2) {
|
||||||
val firstIndex = HEX_CHARS.indexOf(lowerCased[i]);
|
val firstIndex = HEX_CHARS.indexOf(lowerCased[i])
|
||||||
val secondIndex = HEX_CHARS.indexOf(lowerCased[i + 1]);
|
val secondIndex = HEX_CHARS.indexOf(lowerCased[i + 1])
|
||||||
|
|
||||||
val octet = firstIndex.shl(4).or(secondIndex)
|
val octet = firstIndex.shl(4).or(secondIndex)
|
||||||
result.set(i.shr(1), octet.toByte())
|
result.set(i.shr(1), octet.toByte())
|
||||||
|
|
|
@ -135,9 +135,9 @@ class PasswordCheck @Inject constructor(
|
||||||
passwordExplanation?.let { alertDialogBuilder.setMessage(it) }
|
passwordExplanation?.let { alertDialogBuilder.setMessage(it) }
|
||||||
|
|
||||||
passwordWarning?.let {
|
passwordWarning?.let {
|
||||||
val extraWarning: TextView = promptsView.findViewById<View>(R.id.password_prompt_extra_message) as TextView;
|
val extraWarning: TextView = promptsView.findViewById<View>(R.id.password_prompt_extra_message) as TextView
|
||||||
extraWarning.text = context.getString(it);
|
extraWarning.text = context.getString(it)
|
||||||
extraWarning.visibility = View.VISIBLE;
|
extraWarning.visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
|
|
||||||
val userInput = promptsView.findViewById<View>(R.id.password_prompt_pass) as EditText
|
val userInput = promptsView.findViewById<View>(R.id.password_prompt_pass) as EditText
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue