This commit is contained in:
Milos Kozak 2020-05-10 11:49:37 +02:00
parent 311f9dd119
commit 54e68ef248
15 changed files with 61 additions and 174 deletions

View file

@ -7,27 +7,21 @@ import android.content.res.Resources;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.net.wifi.WifiManager; import android.net.wifi.WifiManager;
import androidx.annotation.StringRes;
import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.j256.ormlite.android.apptools.OpenHelperManager; import com.j256.ormlite.android.apptools.OpenHelperManager;
import net.danlew.android.joda.JodaTimeAndroid; import net.danlew.android.joda.JodaTimeAndroid;
import org.jetbrains.annotations.NotNull;
import java.util.List; import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import dagger.android.AndroidInjector; import dagger.android.AndroidInjector;
import dagger.android.DaggerApplication; import dagger.android.DaggerApplication;
import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.db.DatabaseHelper;
import info.nightscout.androidaps.db.StaticInjector; import info.nightscout.androidaps.db.StaticInjector;
import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent; import info.nightscout.androidaps.dependencyInjection.DaggerAppComponent;
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.LTag;
@ -64,7 +58,7 @@ public class MainApp extends DaggerApplication {
@Inject KeepAliveReceiver.KeepAliveManager keepAliveManager; @Inject KeepAliveReceiver.KeepAliveManager keepAliveManager;
@Inject List<PluginBase> plugins; @Inject List<PluginBase> plugins;
@Inject StaticInjector staticInjector; // TODO remove , fake only to initialize @Inject StaticInjector staticInjector; // TODO avoid , here fake only to initialize
@Override @Override
public void onCreate() { public void onCreate() {
@ -109,7 +103,6 @@ public class MainApp extends DaggerApplication {
private void doMigrations() { private void doMigrations() {
} }
@Override @Override
@ -154,16 +147,6 @@ public class MainApp extends DaggerApplication {
registerReceiver(new BTReceiver(), filter); registerReceiver(new BTReceiver(), filter);
} }
@Deprecated
public static String gs(@StringRes int id) {
return sResources.getString(id);
}
@Deprecated
public static MainApp instance() {
return sInstance;
}
public static DatabaseHelper getDbHelper() { public static DatabaseHelper getDbHelper() {
return sDatabaseHelper; return sDatabaseHelper;
} }

View file

@ -34,7 +34,6 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.dana.comm.RecordTypes; import info.nightscout.androidaps.dana.comm.RecordTypes;
import info.nightscout.androidaps.data.NonOverlappingIntervals; import info.nightscout.androidaps.data.NonOverlappingIntervals;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.interfaces.ProfileStore;
import info.nightscout.androidaps.events.EventCareportalEventChange; import info.nightscout.androidaps.events.EventCareportalEventChange;
import info.nightscout.androidaps.events.EventExtendedBolusChange; import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventNewBG; import info.nightscout.androidaps.events.EventNewBG;
@ -47,6 +46,7 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTempTargetChange; import info.nightscout.androidaps.events.EventTempTargetChange;
import info.nightscout.androidaps.interfaces.ActivePluginProvider; import info.nightscout.androidaps.interfaces.ActivePluginProvider;
import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.interfaces.ProfileStore;
import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
@ -61,7 +61,6 @@ import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
import info.nightscout.androidaps.utils.JsonHelper; import info.nightscout.androidaps.utils.JsonHelper;
import info.nightscout.androidaps.utils.PercentageSplitter; import info.nightscout.androidaps.utils.PercentageSplitter;
import info.nightscout.androidaps.utils.T; import info.nightscout.androidaps.utils.T;
import info.nightscout.androidaps.utils.ToastUtils;
/** /**
* This Helper contains all resource to provide a central DB management functionality. Only methods handling * This Helper contains all resource to provide a central DB management functionality. Only methods handling
@ -483,7 +482,6 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
Dao<TDD, String> dao = getDaoTDD(); Dao<TDD, String> dao = getDaoTDD();
dao.createOrUpdate(tdd); dao.createOrUpdate(tdd);
} catch (SQLException e) { } catch (SQLException e) {
ToastUtils.showToastInUiThread(MainApp.instance(), "createOrUpdate-Exception");
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
} }
} }
@ -1008,7 +1006,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
public void createTempBasalFromJsonIfNotExists(JSONObject trJson) { public void createTempBasalFromJsonIfNotExists(JSONObject trJson) {
try { try {
if (trJson.has("originalExtendedAmount")) { // extended bolus uploaded as temp basal if (trJson.has("originalExtendedAmount")) { // extended bolus uploaded as temp basal
ExtendedBolus extendedBolus = new ExtendedBolus(MainApp.instance()) ExtendedBolus extendedBolus = new ExtendedBolus(StaticInjector.Companion.getInstance())
.source(Source.NIGHTSCOUT) .source(Source.NIGHTSCOUT)
.date(trJson.getLong("mills")) .date(trJson.getLong("mills"))
.pumpId(trJson.has("pumpId") ? trJson.getLong("pumpId") : 0) .pumpId(trJson.has("pumpId") ? trJson.getLong("pumpId") : 0)
@ -1023,7 +1021,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
createOrUpdate(extendedBolus); createOrUpdate(extendedBolus);
} else if (trJson.has("isFakedTempBasal")) { // extended bolus end uploaded as temp basal end } else if (trJson.has("isFakedTempBasal")) { // extended bolus end uploaded as temp basal end
ExtendedBolus extendedBolus = new ExtendedBolus(MainApp.instance()); ExtendedBolus extendedBolus = new ExtendedBolus(StaticInjector.Companion.getInstance());
extendedBolus.source = Source.NIGHTSCOUT; extendedBolus.source = Source.NIGHTSCOUT;
extendedBolus.date = trJson.getLong("mills"); extendedBolus.date = trJson.getLong("mills");
extendedBolus.pumpId = trJson.has("pumpId") ? trJson.getLong("pumpId") : 0; extendedBolus.pumpId = trJson.has("pumpId") ? trJson.getLong("pumpId") : 0;
@ -1038,7 +1036,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
} }
createOrUpdate(extendedBolus); createOrUpdate(extendedBolus);
} else { } else {
TemporaryBasal tempBasal = new TemporaryBasal( MainApp.instance()) TemporaryBasal tempBasal = new TemporaryBasal(StaticInjector.Companion.getInstance())
.date(trJson.getLong("mills")) .date(trJson.getLong("mills"))
.source(Source.NIGHTSCOUT) .source(Source.NIGHTSCOUT)
.pumpId(trJson.has("pumpId") ? trJson.getLong("pumpId") : 0); .pumpId(trJson.has("pumpId") ? trJson.getLong("pumpId") : 0);
@ -1313,7 +1311,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
*/ */
public void createExtendedBolusFromJsonIfNotExists(JSONObject json) { public void createExtendedBolusFromJsonIfNotExists(JSONObject json) {
ExtendedBolus extendedBolus = ExtendedBolus.createFromJson(MainApp.instance(), json); ExtendedBolus extendedBolus = ExtendedBolus.createFromJson(StaticInjector.Companion.getInstance(), json);
if (extendedBolus != null) if (extendedBolus != null)
createOrUpdate(extendedBolus); createOrUpdate(extendedBolus);
} }
@ -1505,7 +1503,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
List<CareportalEvent> list = getDaoCareportalEvents().query(preparedQuery); List<CareportalEvent> list = getDaoCareportalEvents().query(preparedQuery);
CareportalEvent careportalEvent; CareportalEvent careportalEvent;
if (list.size() == 0) { if (list.size() == 0) {
careportalEvent = new CareportalEvent(MainApp.instance()); careportalEvent = new CareportalEvent(StaticInjector.Companion.getInstance());
careportalEvent.source = Source.NIGHTSCOUT; careportalEvent.source = Source.NIGHTSCOUT;
if (L.isEnabled(LTag.DATABASE)) if (L.isEnabled(LTag.DATABASE))
log.debug("Adding CareportalEvent record to database: " + trJson.toString()); log.debug("Adding CareportalEvent record to database: " + trJson.toString());
@ -1735,7 +1733,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
public void createProfileSwitchFromJsonIfNotExists(ActivePluginProvider activePluginProvider, NSUpload nsUpload, JSONObject trJson) { public void createProfileSwitchFromJsonIfNotExists(ActivePluginProvider activePluginProvider, NSUpload nsUpload, JSONObject trJson) {
try { try {
ProfileSwitch profileSwitch = new ProfileSwitch(MainApp.instance()); ProfileSwitch profileSwitch = new ProfileSwitch(StaticInjector.Companion.getInstance());
profileSwitch.date = trJson.getLong("mills"); profileSwitch.date = trJson.getLong("mills");
if (trJson.has("duration")) if (trJson.has("duration"))
profileSwitch.durationInMinutes = trJson.getInt("duration"); profileSwitch.durationInMinutes = trJson.getInt("duration");

View file

@ -4,7 +4,7 @@ import org.mozilla.javascript.ScriptableObject;
import javax.inject.Inject; import javax.inject.Inject;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.db.StaticInjector;
import info.nightscout.androidaps.logging.AAPSLogger; import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag; import info.nightscout.androidaps.logging.LTag;
@ -26,7 +26,7 @@ public class LoggerCallback extends ScriptableObject {
//empty constructor needed for Rhino //empty constructor needed for Rhino
errorBuffer = new StringBuffer(); errorBuffer = new StringBuffer();
logBuffer = new StringBuffer(); logBuffer = new StringBuffer();
MainApp.instance().androidInjector().inject(this); StaticInjector.Companion.getInstance().androidInjector().inject(this);
} }
@Override @Override

View file

@ -3,8 +3,8 @@ package info.nightscout.androidaps.plugins.pump.common.defs;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
/** /**
@ -16,58 +16,49 @@ import info.nightscout.androidaps.R;
public enum PumpHistoryEntryGroup { public enum PumpHistoryEntryGroup {
All(R.string.medtronic_history_group_all), // All(R.string.medtronic_history_group_all),
Bolus(R.string.danar_history_bolus), // Bolus(R.string.danar_history_bolus),
Basal(R.string.medtronic_history_group_basal), // Basal(R.string.medtronic_history_group_basal),
Prime(R.string.danar_history_prime), // Prime(R.string.danar_history_prime),
Configuration(R.string.medtronic_history_group_configuration), // Configuration(R.string.medtronic_history_group_configuration),
Alarm(R.string.danar_history_alarm), // Alarm(R.string.danar_history_alarm),
Glucose(R.string.danar_history_glucose), // Glucose(R.string.danar_history_glucose),
Notification(R.string.medtronic_history_group_notification), // Notification(R.string.medtronic_history_group_notification),
Statistic(R.string.medtronic_history_group_statistic), Statistic(R.string.medtronic_history_group_statistic),
Unknown(R.string.medtronic_history_group_unknown), // Unknown(R.string.medtronic_history_group_unknown),
; ;
private int resourceId; private int resourceId;
private String translated; private String translated;
public static boolean doNotTranslate = false; private static List<PumpHistoryEntryGroup> translatedList;
private static List<PumpHistoryEntryGroup> list;
static {
list = new ArrayList<>();
for (PumpHistoryEntryGroup pumpHistoryEntryGroup : values()) {
//if (doNotTranslate) {
pumpHistoryEntryGroup.translated = MainApp.gs(pumpHistoryEntryGroup.resourceId);
//}
list.add(pumpHistoryEntryGroup);
}
}
PumpHistoryEntryGroup(int resourceId) { PumpHistoryEntryGroup(int resourceId) {
this.resourceId = resourceId; this.resourceId = resourceId;
// this.translated = MainApp.gs(resourceId);
} }
private static void doTranslation(ResourceHelper resourceHelper) {
translatedList = new ArrayList<>();
public static List<PumpHistoryEntryGroup> getList() { for (PumpHistoryEntryGroup pumpHistoryEntryGroup : values()) {
return list; pumpHistoryEntryGroup.translated = resourceHelper.gs(pumpHistoryEntryGroup.resourceId);
translatedList.add(pumpHistoryEntryGroup);
}
} }
public static List<PumpHistoryEntryGroup> getTranslatedList(ResourceHelper resourceHelper) {
if (translatedList == null) doTranslation(resourceHelper);
return translatedList;
}
public int getResourceId() { public int getResourceId() {
return resourceId; return resourceId;
} }
public String getTranslated() { public String getTranslated() {
return translated; return translated;
} }
public String toString() { public String toString() {
return this.translated; return this.translated;
} }

View file

@ -5,6 +5,7 @@ import java.util.Map;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
public enum RileyLinkEncodingType { public enum RileyLinkEncodingType {
@ -20,33 +21,31 @@ public enum RileyLinkEncodingType {
private static Map<String, RileyLinkEncodingType> encodingTypeMap; private static Map<String, RileyLinkEncodingType> encodingTypeMap;
static {
encodingTypeMap = new HashMap<>();
for (RileyLinkEncodingType encType : values()) {
if (encType.resourceId!=null) {
encodingTypeMap.put(MainApp.gs(encType.resourceId), encType);
}
}
}
RileyLinkEncodingType(int value) { RileyLinkEncodingType(int value) {
this.value = (byte)value; this.value = (byte)value;
} }
RileyLinkEncodingType(int value, Integer resourceId) { RileyLinkEncodingType(int value, Integer resourceId) {
this.value = (byte)value; this.value = (byte)value;
this.resourceId = resourceId; this.resourceId = resourceId;
} }
public static RileyLinkEncodingType getByDescription(String description) { private static void doTranslation(ResourceHelper resourceHelper) {
encodingTypeMap = new HashMap<>();
for (RileyLinkEncodingType encType : values()) {
if (encType.resourceId!=null) {
encodingTypeMap.put(resourceHelper.gs(encType.resourceId), encType);
}
}
}
public static RileyLinkEncodingType getByDescription(String description, ResourceHelper resourceHelper) {
if (encodingTypeMap == null) doTranslation(resourceHelper);
if (encodingTypeMap.containsKey(description)) { if (encodingTypeMap.containsKey(description)) {
return encodingTypeMap.get(description); return encodingTypeMap.get(description);
} }
return RileyLinkEncodingType.FourByteSixByteLocal; return RileyLinkEncodingType.FourByteSixByteLocal;
} }
} }

View file

@ -23,11 +23,13 @@ import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup; import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup;
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry; import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData; import info.nightscout.androidaps.plugins.pump.medtronic.data.MedtronicHistoryData;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
public class MedtronicHistoryActivity extends NoSplashAppCompatActivity { public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
@Inject MedtronicHistoryData medtronicHistoryData; @Inject MedtronicHistoryData medtronicHistoryData;
@Inject ResourceHelper resourceHelper;
Spinner historyTypeSpinner; Spinner historyTypeSpinner;
TextView statusView; TextView statusView;
@ -119,7 +121,7 @@ public class MedtronicHistoryActivity extends NoSplashAppCompatActivity {
statusView.setVisibility(View.GONE); statusView.setVisibility(View.GONE);
typeListFull = getTypeList(PumpHistoryEntryGroup.getList()); typeListFull = getTypeList(PumpHistoryEntryGroup.getTranslatedList(resourceHelper));
ArrayAdapter<TypeList> spinnerAdapter = new ArrayAdapter<>(this, R.layout.spinner_centered, typeListFull); ArrayAdapter<TypeList> spinnerAdapter = new ArrayAdapter<>(this, R.layout.spinner_centered, typeListFull);
historyTypeSpinner.setAdapter(spinnerAdapter); historyTypeSpinner.setAdapter(spinnerAdapter);

View file

@ -319,7 +319,7 @@ public class RileyLinkMedtronicService extends RileyLinkService {
return false; return false;
} }
RileyLinkEncodingType newEncodingType = RileyLinkEncodingType.getByDescription(encodingTypeStr); RileyLinkEncodingType newEncodingType = RileyLinkEncodingType.getByDescription(encodingTypeStr, resourceHelper);
if (encodingType == null) { if (encodingType == null) {
encodingType = newEncodingType; encodingType = newEncodingType;

View file

@ -100,7 +100,7 @@ class OmnipodFragment : DaggerFragment() {
omnipod_refresh.setOnClickListener { omnipod_refresh.setOnClickListener {
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() != true) { if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() != true) {
OmnipodUtil.displayNotConfiguredDialog(context) displayNotConfiguredDialog()
} else { } else {
omnipod_refresh.isEnabled = false omnipod_refresh.isEnabled = false
omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequest.GetPodState); omnipodPumpPlugin.addPodStatusRequest(OmnipodStatusRequest.GetPodState);

View file

@ -148,7 +148,7 @@ public class PodHistoryActivity extends NoSplashAppCompatActivity {
statusView.setVisibility(View.GONE); statusView.setVisibility(View.GONE);
typeListFull = getTypeList(PumpHistoryEntryGroup.getList()); typeListFull = getTypeList(PumpHistoryEntryGroup.getTranslatedList(resourceHelper));
ArrayAdapter<TypeList> spinnerAdapter = new ArrayAdapter<>(this, R.layout.spinner_centered, typeListFull); ArrayAdapter<TypeList> spinnerAdapter = new ArrayAdapter<>(this, R.layout.spinner_centered, typeListFull);
historyTypeSpinner.setAdapter(spinnerAdapter); historyTypeSpinner.setAdapter(spinnerAdapter);

View file

@ -425,7 +425,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
pumpStatus.tempBasalEnd = DateTimeUtil.getTimeInFutureFromMinutes(time, tempBasalPair.getDurationMinutes()); pumpStatus.tempBasalEnd = DateTimeUtil.getTimeInFutureFromMinutes(time, tempBasalPair.getDurationMinutes());
pumpStatus.tempBasalPumpId = pumpId; pumpStatus.tempBasalPumpId = pumpId;
TemporaryBasal tempStart = new TemporaryBasal() // TemporaryBasal tempStart = new TemporaryBasal(injector) //
.date(time) // .date(time) //
.duration(tempBasalPair.getDurationMinutes()) // .duration(tempBasalPair.getDurationMinutes()) //
.absolute(tempBasalPair.getInsulinRate()) // .absolute(tempBasalPair.getInsulinRate()) //
@ -561,7 +561,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
addSuccessToHistory(time, PodHistoryEntryType.CancelTemporaryBasal, null); addSuccessToHistory(time, PodHistoryEntryType.CancelTemporaryBasal, null);
TemporaryBasal temporaryBasal = new TemporaryBasal() // TemporaryBasal temporaryBasal = new TemporaryBasal(injector) //
.date(time) // .date(time) //
.duration(0) // .duration(0) //
.pumpId(pumpStatus.tempBasalPumpId) .pumpId(pumpStatus.tempBasalPumpId)
@ -709,7 +709,7 @@ public class AapsOmnipodManager implements OmnipodCommunicationManagerInterface
Intent intent = new Intent(context, ErrorHelperActivity.class); Intent intent = new Intent(context, ErrorHelperActivity.class);
intent.putExtra("soundid", sound == null ? 0 : sound); intent.putExtra("soundid", sound == null ? 0 : sound);
intent.putExtra("status", message); intent.putExtra("status", message);
intent.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror)); intent.putExtra("title", resourceHelper.gs(R.string.treatmentdeliveryerror));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent); context.startActivity(intent);
} }

View file

@ -35,6 +35,7 @@ import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodDriverState
import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus; import info.nightscout.androidaps.plugins.pump.omnipod.driver.OmnipodPumpStatus;
import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange; import info.nightscout.androidaps.plugins.pump.omnipod.events.EventOmnipodDeviceStatusChange;
import info.nightscout.androidaps.utils.alertDialogs.OKDialog; import info.nightscout.androidaps.utils.alertDialogs.OKDialog;
import info.nightscout.androidaps.utils.resources.ResourceHelper;
import info.nightscout.androidaps.utils.sharedPreferences.SP; import info.nightscout.androidaps.utils.sharedPreferences.SP;
/** /**
@ -49,6 +50,7 @@ public class OmnipodUtil {
private final OmnipodPumpStatus omnipodPumpStatus; private final OmnipodPumpStatus omnipodPumpStatus;
private final ActivePluginProvider activePlugins; private final ActivePluginProvider activePlugins;
private final SP sp; private final SP sp;
private final ResourceHelper resourceHelper;
private final HasAndroidInjector injector; private final HasAndroidInjector injector;
private boolean lowLevelDebug = true; private boolean lowLevelDebug = true;
@ -67,6 +69,7 @@ public class OmnipodUtil {
RileyLinkUtil rileyLinkUtil, RileyLinkUtil rileyLinkUtil,
OmnipodPumpStatus omnipodPumpStatus, OmnipodPumpStatus omnipodPumpStatus,
SP sp, SP sp,
ResourceHelper resourceHelper,
ActivePluginProvider activePlugins, ActivePluginProvider activePlugins,
HasAndroidInjector injector HasAndroidInjector injector
) { ) {
@ -75,6 +78,7 @@ public class OmnipodUtil {
this.rileyLinkUtil = rileyLinkUtil; this.rileyLinkUtil = rileyLinkUtil;
this.omnipodPumpStatus = omnipodPumpStatus; this.omnipodPumpStatus = omnipodPumpStatus;
this.sp = sp; this.sp = sp;
this.resourceHelper = resourceHelper;
this.activePlugins = activePlugins; this.activePlugins = activePlugins;
this.injector = injector; this.injector = injector;
} }
@ -102,11 +106,6 @@ public class OmnipodUtil {
rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(currentCommand)); rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(currentCommand));
} }
public static void displayNotConfiguredDialog(Context context) {
OKDialog.showConfirmation(context, MainApp.gs(R.string.combo_warning),
MainApp.gs(R.string.omnipod_error_operation_not_possible_no_configuration), (Runnable) null);
}
public OmnipodDriverState getDriverState() { public OmnipodDriverState getDriverState() {
return driverState; return driverState;

View file

@ -539,37 +539,6 @@ public class TreatmentService extends OrmLiteBaseService<DatabaseHelper> {
return (Math.abs(diff) <= 0.00001); return (Math.abs(diff) <= 0.00001);
} }
@Deprecated
private void treatmentCopy(Treatment oldTreatment, Treatment newTreatment, boolean fromNightScout) {
aapsLogger.debug(LTag.DATATREATMENTS, "treatmentCopy [old={}, new={}]", oldTreatment.toString(), newTreatment.toString());
if (fromNightScout) {
long pumpId_old = oldTreatment.pumpId;
boolean isSMB = (oldTreatment.isSMB || newTreatment.isSMB);
oldTreatment.copyFrom(newTreatment);
if (pumpId_old != 0) {
oldTreatment.pumpId = pumpId_old;
}
if (oldTreatment.pumpId != 0 && oldTreatment.source != Source.PUMP) {
oldTreatment.source = Source.PUMP;
}
oldTreatment.isSMB = isSMB;
} else {
oldTreatment.copyFrom(newTreatment);
}
aapsLogger.debug(LTag.DATATREATMENTS, "treatmentCopy [newAfterChange={}]", oldTreatment.toString());
}
public Treatment getRecord(long pumpId, long date) { public Treatment getRecord(long pumpId, long date) {
Treatment record = null; Treatment record = null;

View file

@ -1,50 +0,0 @@
package info.nightscout.androidaps.utils;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import java.util.Map;
import info.nightscout.androidaps.MainApp;
/**
* Created by mike on 17.02.2017.
*/
public class SP {
private static SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
@Deprecated
static public Map<String, ?> getAll() {
return sharedPreferences.getAll();
}
@Deprecated
static public String getString(String key, String defaultValue) {
return sharedPreferences.getString(key, defaultValue);
}
@Deprecated
static public boolean getBoolean(int resourceID, Boolean defaultValue) {
try {
return sharedPreferences.getBoolean(MainApp.gs(resourceID), defaultValue);
} catch (Exception e) {
return defaultValue;
}
}
@Deprecated
static public void putString(int resourceID, String value) {
sharedPreferences.edit().putString(MainApp.gs(resourceID), value).apply();
}
@Deprecated
static public void putString(String key, String value) {
sharedPreferences.edit().putString(key, value).apply();
}
@Deprecated
static public void remove(String key) {
sharedPreferences.edit().remove(key).apply();
}
}

View file

@ -2,18 +2,13 @@ package info.nightscout.androidaps.utils;
import android.app.backup.BackupAgentHelper; import android.app.backup.BackupAgentHelper;
import android.app.backup.SharedPreferencesBackupHelper; import android.app.backup.SharedPreferencesBackupHelper;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import info.nightscout.androidaps.MainApp;
public class SPBackupAgent extends BackupAgentHelper { public class SPBackupAgent extends BackupAgentHelper {
// API 24 // API 24
//static final String PREFS = PreferenceManager.getDefaultSharedPreferencesName(MainApp.instance().getApplicationContext()); final String PREFS = getApplicationContext().getPackageName() + "_preferences";
static final String PREFS = MainApp.instance().getApplicationContext().getPackageName() + "_preferences";
static final String PREFS_BACKUP_KEY = "SP"; final String PREFS_BACKUP_KEY = "SP";
@Override @Override
public void onCreate() { public void onCreate() {

View file

@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.pump.danaRv2.comm
import android.content.Context import android.content.Context
import info.nightscout.androidaps.danaRv2.DanaRv2Plugin import info.nightscout.androidaps.danaRv2.DanaRv2Plugin
import info.nightscout.androidaps.danaRv2.comm.MsgHistoryEvents_v2
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage import info.nightscout.androidaps.plugins.pump.common.bolusInfo.DetailedBolusInfoStorage
import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase import info.nightscout.androidaps.plugins.pump.danaR.comm.DanaRTestBase
@ -24,7 +25,7 @@ class MsgHistoryEvents_v2Test : DanaRTestBase() {
@Mock lateinit var danaRv2Plugin: DanaRv2Plugin @Mock lateinit var danaRv2Plugin: DanaRv2Plugin
@Test @Throws(Exception::class) fun runTest() { @Test @Throws(Exception::class) fun runTest() {
val packet = info.nightscout.androidaps.danaRv2.comm.MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, RxBusWrapper(), activePluginProvider, injector, DateUtil(context, resourceHelper), 0) val packet = MsgHistoryEvents_v2(aapsLogger, resourceHelper, detailedBolusInfoStorage, danaRv2Plugin, RxBusWrapper(), activePluginProvider, injector, DateUtil(context, resourceHelper), 0)
// test message decoding // test message decoding
val array = ByteArray(100) val array = ByteArray(100)