Source plugins injection
This commit is contained in:
parent
348936e1b8
commit
1242236821
|
@ -81,15 +81,15 @@ import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin;
|
|||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
|
||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
|
||||
import info.nightscout.androidaps.plugins.source.NSClientSourcePlugin;
|
||||
import info.nightscout.androidaps.plugins.source.RandomBgPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceEversensePlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceMM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceNSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourcePoctechPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceTomatoPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.DexcomPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.EversensePlugin;
|
||||
import info.nightscout.androidaps.plugins.source.GlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.MM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.PoctechPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.TomatoPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.XdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.receivers.DataReceiver;
|
||||
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
||||
|
@ -149,6 +149,14 @@ public class MainApp extends DaggerApplication {
|
|||
@Inject OpenAPSSMBPlugin openAPSSMBPlugin;
|
||||
@Inject OverviewPlugin overviewPlugin;
|
||||
@Inject RandomBgPlugin randomBgPlugin;
|
||||
@Inject DexcomPlugin dexcomPlugin;
|
||||
@Inject EversensePlugin eversensePlugin;
|
||||
@Inject GlimpPlugin glimpPlugin;
|
||||
@Inject MM640gPlugin mM640GPlugin;
|
||||
@Inject NSClientSourcePlugin nSClientSourcePlugin;
|
||||
@Inject PoctechPlugin poctechPlugin;
|
||||
@Inject TomatoPlugin tomatoPlugin;
|
||||
@Inject XdripPlugin xdripPlugin;
|
||||
@Inject StatusLinePlugin statusLinePlugin;
|
||||
@Inject TidepoolPlugin tidepoolPlugin;
|
||||
@Inject TreatmentsPlugin treatmentsPlugin;
|
||||
|
@ -239,14 +247,14 @@ public class MainApp extends DaggerApplication {
|
|||
if (Config.APS) pluginsList.add(StorageConstraintPlugin.getPlugin());
|
||||
if (Config.APS) pluginsList.add(SignatureVerifierPlugin.getPlugin());
|
||||
if (Config.APS) pluginsList.add(objectivesPlugin);
|
||||
pluginsList.add(SourceXdripPlugin.getPlugin());
|
||||
pluginsList.add(SourceNSClientPlugin.getPlugin());
|
||||
pluginsList.add(SourceMM640gPlugin.getPlugin());
|
||||
pluginsList.add(SourceGlimpPlugin.getPlugin());
|
||||
pluginsList.add(SourceDexcomPlugin.INSTANCE);
|
||||
pluginsList.add(SourcePoctechPlugin.getPlugin());
|
||||
pluginsList.add(SourceTomatoPlugin.getPlugin());
|
||||
pluginsList.add(SourceEversensePlugin.getPlugin());
|
||||
pluginsList.add(xdripPlugin);
|
||||
pluginsList.add(nSClientSourcePlugin);
|
||||
pluginsList.add(mM640GPlugin);
|
||||
pluginsList.add(glimpPlugin);
|
||||
pluginsList.add(dexcomPlugin);
|
||||
pluginsList.add(poctechPlugin);
|
||||
pluginsList.add(tomatoPlugin);
|
||||
pluginsList.add(eversensePlugin);
|
||||
pluginsList.add(randomBgPlugin);
|
||||
if (!Config.NSCLIENT) pluginsList.add(smsCommunicatorPlugin);
|
||||
pluginsList.add(FoodPlugin.getPlugin());
|
||||
|
|
|
@ -39,7 +39,11 @@ import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin;
|
|||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
|
||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.DexcomPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.EversensePlugin;
|
||||
import info.nightscout.androidaps.plugins.source.GlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.PoctechPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.TomatoPlugin;
|
||||
|
||||
/**
|
||||
* Created by adrian on 2019-12-23.
|
||||
|
@ -61,6 +65,11 @@ public class MyPreferenceFragment extends PreferenceFragment implements HasAndro
|
|||
@Inject OpenAPSMAPlugin openAPSMAPlugin;
|
||||
@Inject OpenAPSSMBPlugin openAPSSMBPlugin;
|
||||
@Inject SafetyPlugin safetyPlugin;
|
||||
@Inject DexcomPlugin dexcomPlugin;
|
||||
@Inject EversensePlugin eversensePlugin;
|
||||
@Inject GlimpPlugin glimpPlugin;
|
||||
@Inject PoctechPlugin poctechPlugin;
|
||||
@Inject TomatoPlugin tomatoPlugin;
|
||||
@Inject SmsCommunicatorPlugin smsCommunicatorPlugin;
|
||||
@Inject StatusLinePlugin statusLinePlugin;
|
||||
@Inject TidepoolPlugin tidepoolPlugin;
|
||||
|
@ -105,7 +114,11 @@ public class MyPreferenceFragment extends PreferenceFragment implements HasAndro
|
|||
|
||||
addPreferencesFromResource(R.xml.pref_overview);
|
||||
|
||||
addPreferencesFromResourceIfEnabled(SourceDexcomPlugin.INSTANCE, PluginType.BGSOURCE);
|
||||
addPreferencesFromResourceIfEnabled(eversensePlugin, PluginType.BGSOURCE);
|
||||
addPreferencesFromResourceIfEnabled(dexcomPlugin, PluginType.BGSOURCE);
|
||||
addPreferencesFromResourceIfEnabled(tomatoPlugin, PluginType.BGSOURCE);
|
||||
addPreferencesFromResourceIfEnabled(poctechPlugin, PluginType.BGSOURCE);
|
||||
addPreferencesFromResourceIfEnabled(glimpPlugin, PluginType.BGSOURCE);
|
||||
addPreferencesFromResourceIfEnabled(careportalPlugin, PluginType.GENERAL);
|
||||
addPreferencesFromResourceIfEnabled(safetyPlugin, PluginType.CONSTRAINTS);
|
||||
if (Config.APS) {
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
package info.nightscout.androidaps.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin
|
||||
import info.nightscout.androidaps.plugins.source.DexcomPlugin
|
||||
import javax.inject.Inject
|
||||
|
||||
class RequestDexcomPermissionActivity : NoSplashAppCompatActivity() {
|
||||
@Inject lateinit var dexcomPlugin: DexcomPlugin
|
||||
|
||||
private val requestCode = "AndroidAPS <3".map { it.toInt() }.sum()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
requestPermissions(arrayOf(SourceDexcomPlugin.PERMISSION), requestCode)
|
||||
requestPermissions(arrayOf(dexcomPlugin.PERMISSION), requestCode)
|
||||
}
|
||||
|
||||
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
|
||||
|
|
|
@ -25,7 +25,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SPImplementation
|
|||
import javax.inject.Singleton
|
||||
|
||||
@Module(includes = [AppModule.AppBindings::class])
|
||||
class AppModule {
|
||||
open class AppModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
|
|
|
@ -136,6 +136,7 @@ public class ProfileFunctions implements ProfileFunction {
|
|||
}
|
||||
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public static String getSystemUnits() {
|
||||
return SP.getString(R.string.key_units, Constants.MGDL);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,6 @@ import info.nightscout.androidaps.logging.LTag;
|
|||
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||
|
@ -106,8 +105,8 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
|||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress;
|
||||
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.DexcomPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.XdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.androidaps.utils.BolusWizard;
|
||||
|
@ -139,6 +138,8 @@ public class OverviewFragment extends DaggerFragment implements View.OnClickList
|
|||
@Inject ConfigBuilderPlugin configBuilderPlugin;
|
||||
@Inject TreatmentsPlugin treatmentsPlugin;
|
||||
@Inject IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
||||
@Inject DexcomPlugin dexcomPlugin;
|
||||
@Inject XdripPlugin xdripPlugin;
|
||||
@Inject NotificationStore notificationStore;
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
@ -818,8 +819,8 @@ public class OverviewFragment extends DaggerFragment implements View.OnClickList
|
|||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean xdrip = SourceXdripPlugin.getPlugin().isEnabled(PluginType.BGSOURCE);
|
||||
boolean dexcom = SourceDexcomPlugin.INSTANCE.isEnabled(PluginType.BGSOURCE);
|
||||
boolean xdrip = xdripPlugin.isEnabled(PluginType.BGSOURCE);
|
||||
boolean dexcom = dexcomPlugin.isEnabled(PluginType.BGSOURCE);
|
||||
|
||||
FragmentManager manager = getFragmentManager();
|
||||
// try to fix https://fabric.io/nightscout3/android/apps/info.nightscout.androidaps/issues/5aca7a1536c7b23527eb4be7?time=last-seven-days
|
||||
|
@ -843,7 +844,7 @@ public class OverviewFragment extends DaggerFragment implements View.OnClickList
|
|||
calibrationDialog.show(manager, "CalibrationDialog");
|
||||
} else if (dexcom) {
|
||||
try {
|
||||
String packageName = SourceDexcomPlugin.INSTANCE.findDexcomPackageName();
|
||||
String packageName = dexcomPlugin.findDexcomPackageName();
|
||||
if (packageName != null) {
|
||||
Intent i = new Intent("com.dexcom.cgm.activities.MeterEntryActivity");
|
||||
i.setPackage(packageName);
|
||||
|
@ -860,7 +861,7 @@ public class OverviewFragment extends DaggerFragment implements View.OnClickList
|
|||
if (xdrip)
|
||||
openCgmApp("com.eveningoutpost.dexdrip");
|
||||
else if (dexcom) {
|
||||
String packageName = SourceDexcomPlugin.INSTANCE.findDexcomPackageName();
|
||||
String packageName = dexcomPlugin.findDexcomPackageName();
|
||||
if (packageName != null) {
|
||||
openCgmApp(packageName);
|
||||
} else {
|
||||
|
@ -1139,8 +1140,8 @@ public class OverviewFragment extends DaggerFragment implements View.OnClickList
|
|||
}
|
||||
|
||||
// **** Calibration & CGM buttons ****
|
||||
boolean xDripIsBgSource = SourceXdripPlugin.getPlugin().isEnabled(PluginType.BGSOURCE);
|
||||
boolean dexcomIsSource = SourceDexcomPlugin.INSTANCE.isEnabled(PluginType.BGSOURCE);
|
||||
boolean xDripIsBgSource = xdripPlugin.isEnabled(PluginType.BGSOURCE);
|
||||
boolean dexcomIsSource = dexcomPlugin.isEnabled(PluginType.BGSOURCE);
|
||||
boolean bgAvailable = DatabaseHelper.actualBg() != null;
|
||||
if (calibrationButton != null) {
|
||||
if ((xDripIsBgSource || dexcomIsSource) && bgAvailable && sp.getBoolean(R.string.key_show_calibration_button, true)) {
|
||||
|
|
|
@ -1,150 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.source;
|
||||
|
||||
import android.graphics.Paint;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import dagger.android.support.DaggerFragment;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.OKDialog;
|
||||
import info.nightscout.androidaps.utils.T;
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
|
||||
/**
|
||||
* Created by mike on 16.10.2017.
|
||||
*/
|
||||
|
||||
public class BGSourceFragment extends DaggerFragment {
|
||||
@Inject RxBusWrapper rxBus;
|
||||
@Inject ResourceHelper resourceHelper;
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
private RecyclerView recyclerView;
|
||||
|
||||
private final long MILLS_TO_THE_PAST = T.hours(12).msecs();
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
try {
|
||||
View view = inflater.inflate(R.layout.bgsource_fragment, container, false);
|
||||
|
||||
recyclerView = view.findViewById(R.id.bgsource_recyclerview);
|
||||
recyclerView.setHasFixedSize(true);
|
||||
LinearLayoutManager llm = new LinearLayoutManager(view.getContext());
|
||||
recyclerView.setLayoutManager(llm);
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getDbHelper().getAllBgreadingsDataFromTime(now - MILLS_TO_THE_PAST, false));
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
return view;
|
||||
} catch (Exception e) {
|
||||
FabricPrivacy.logException(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onResume() {
|
||||
super.onResume();
|
||||
disposable.add(rxBus
|
||||
.toObservable(EventAutosensCalculationFinished.class)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(event -> updateGUI(), FabricPrivacy::logException)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onPause() {
|
||||
disposable.clear();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
protected void updateGUI() {
|
||||
long now = System.currentTimeMillis();
|
||||
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getDbHelper().getAllBgreadingsDataFromTime(now - MILLS_TO_THE_PAST, false)), true);
|
||||
}
|
||||
|
||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.BgReadingsViewHolder> {
|
||||
|
||||
List<BgReading> bgReadings;
|
||||
|
||||
RecyclerViewAdapter(List<BgReading> bgReadings) {
|
||||
this.bgReadings = bgReadings;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public BgReadingsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.bgsource_item, viewGroup, false);
|
||||
return new BgReadingsViewHolder(v);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull BgReadingsViewHolder holder, int position) {
|
||||
BgReading bgReading = bgReadings.get(position);
|
||||
holder.ns.setVisibility(NSUpload.isIdValid(bgReading._id) ? View.VISIBLE : View.GONE);
|
||||
holder.invalid.setVisibility(!bgReading.isValid ? View.VISIBLE : View.GONE);
|
||||
holder.date.setText(DateUtil.dateAndTimeString(bgReading.date));
|
||||
holder.value.setText(bgReading.valueToUnitsToString(ProfileFunctions.getSystemUnits()));
|
||||
holder.direction.setText(bgReading.directionToSymbol());
|
||||
holder.remove.setTag(bgReading);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return bgReadings.size();
|
||||
}
|
||||
|
||||
class BgReadingsViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView date;
|
||||
TextView value;
|
||||
TextView direction;
|
||||
TextView invalid;
|
||||
TextView ns;
|
||||
TextView remove;
|
||||
|
||||
BgReadingsViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
date = itemView.findViewById(R.id.bgsource_date);
|
||||
value = itemView.findViewById(R.id.bgsource_value);
|
||||
direction = itemView.findViewById(R.id.bgsource_direction);
|
||||
invalid = itemView.findViewById(R.id.invalid_sign);
|
||||
ns = itemView.findViewById(R.id.ns_sign);
|
||||
remove = itemView.findViewById(R.id.bgsource_remove);
|
||||
remove.setOnClickListener(v -> {
|
||||
final BgReading bgReading = (BgReading) v.getTag();
|
||||
OKDialog.showConfirmation(getContext(), resourceHelper.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(ProfileFunctions.getSystemUnits()), () -> {
|
||||
bgReading.isValid = false;
|
||||
MainApp.getDbHelper().update(bgReading);
|
||||
updateGUI();
|
||||
});
|
||||
});
|
||||
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package info.nightscout.androidaps.plugins.source
|
||||
|
||||
import android.graphics.Paint
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import dagger.android.support.DaggerFragment
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished
|
||||
import info.nightscout.androidaps.plugins.source.BGSourceFragment.RecyclerViewAdapter.BgReadingsViewHolder
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.OKDialog
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.android.synthetic.main.bgsource_fragment.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class BGSourceFragment : DaggerFragment() {
|
||||
@Inject lateinit var rxBus: RxBusWrapper
|
||||
@Inject lateinit var resourceHelper: ResourceHelper
|
||||
@Inject lateinit var profileFunction: ProfileFunction
|
||||
|
||||
private val disposable = CompositeDisposable()
|
||||
private val MILLS_TO_THE_PAST = T.hours(12).msecs()
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.bgsource_fragment, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
bgsource_recyclerview.setHasFixedSize(true)
|
||||
bgsource_recyclerview.layoutManager = LinearLayoutManager(view.context)
|
||||
val now = System.currentTimeMillis()
|
||||
bgsource_recyclerview.adapter = RecyclerViewAdapter(MainApp.getDbHelper().getAllBgreadingsDataFromTime(now - MILLS_TO_THE_PAST, false))
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
disposable.add(rxBus
|
||||
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ updateGUI() }) { FabricPrivacy.logException(it) }
|
||||
)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun onPause() {
|
||||
disposable.clear()
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
private fun updateGUI() {
|
||||
val now = System.currentTimeMillis()
|
||||
bgsource_recyclerview?.swapAdapter(RecyclerViewAdapter(MainApp.getDbHelper().getAllBgreadingsDataFromTime(now - MILLS_TO_THE_PAST, false)), true)
|
||||
}
|
||||
|
||||
inner class RecyclerViewAdapter internal constructor(private var bgReadings: List<BgReading>) : RecyclerView.Adapter<BgReadingsViewHolder>() {
|
||||
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): BgReadingsViewHolder {
|
||||
val v = LayoutInflater.from(viewGroup.context).inflate(R.layout.bgsource_item, viewGroup, false)
|
||||
return BgReadingsViewHolder(v)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: BgReadingsViewHolder, position: Int) {
|
||||
val bgReading = bgReadings[position]
|
||||
holder.ns.visibility = if (NSUpload.isIdValid(bgReading._id)) View.VISIBLE else View.GONE
|
||||
holder.invalid.visibility = if (!bgReading.isValid) View.VISIBLE else View.GONE
|
||||
holder.date.text = DateUtil.dateAndTimeString(bgReading.date)
|
||||
holder.value.text = bgReading.valueToUnitsToString(profileFunction.getUnits())
|
||||
holder.direction.text = bgReading.directionToSymbol()
|
||||
holder.remove.tag = bgReading
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return bgReadings.size
|
||||
}
|
||||
|
||||
inner class BgReadingsViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
var date: TextView = itemView.findViewById(R.id.bgsource_date)
|
||||
var value: TextView = itemView.findViewById(R.id.bgsource_value)
|
||||
var direction: TextView = itemView.findViewById(R.id.bgsource_direction)
|
||||
var invalid: TextView = itemView.findViewById(R.id.invalid_sign)
|
||||
var ns: TextView = itemView.findViewById(R.id.ns_sign)
|
||||
var remove: TextView = itemView.findViewById(R.id.bgsource_remove)
|
||||
|
||||
init {
|
||||
remove.setOnClickListener { v: View ->
|
||||
val bgReading = v.tag as BgReading
|
||||
activity?.let { activity ->
|
||||
val text = DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(profileFunction.getUnits())
|
||||
OKDialog.showConfirmation(activity, resourceHelper.gs(R.string.removerecord), text, Runnable {
|
||||
bgReading.isValid = false
|
||||
MainApp.getDbHelper().update(bgReading)
|
||||
updateGUI()
|
||||
})
|
||||
}
|
||||
}
|
||||
remove.paintFlags = remove.paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,30 +13,34 @@ import info.nightscout.androidaps.interfaces.BgSourceInterface
|
|||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.logging.L
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import org.json.JSONObject
|
||||
import org.slf4j.LoggerFactory
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
object SourceDexcomPlugin : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
.pluginName(R.string.dexcom_app_patched)
|
||||
.shortName(R.string.dexcom_short)
|
||||
.preferencesId(R.xml.pref_bgsource)
|
||||
.description(R.string.description_source_dexcom)), BgSourceInterface {
|
||||
|
||||
private val log = LoggerFactory.getLogger(L.BGSOURCE)
|
||||
@Singleton
|
||||
class DexcomPlugin @Inject constructor(
|
||||
private val aapsLogger: AAPSLogger,
|
||||
private val sp: SP,
|
||||
private val mainApp: MainApp
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
.pluginName(R.string.dexcom_app_patched)
|
||||
.shortName(R.string.dexcom_short)
|
||||
.preferencesId(R.xml.pref_bgsourcedexcom)
|
||||
.description(R.string.description_source_dexcom)), BgSourceInterface {
|
||||
|
||||
private val PACKAGE_NAMES = arrayOf("com.dexcom.cgm.region1.mgdl", "com.dexcom.cgm.region1.mmol",
|
||||
"com.dexcom.cgm.region2.mgdl", "com.dexcom.cgm.region2.mmol",
|
||||
"com.dexcom.g6.region1.mmol", "com.dexcom.g6.region2.mgdl",
|
||||
"com.dexcom.g6.region3.mgdl", "com.dexcom.g6.region3.mmol")
|
||||
"com.dexcom.cgm.region2.mgdl", "com.dexcom.cgm.region2.mmol",
|
||||
"com.dexcom.g6.region1.mmol", "com.dexcom.g6.region2.mgdl",
|
||||
"com.dexcom.g6.region3.mgdl", "com.dexcom.g6.region3.mmol")
|
||||
|
||||
const val PERMISSION = "com.dexcom.cgm.EXTERNAL_PERMISSION"
|
||||
val PERMISSION = "com.dexcom.cgm.EXTERNAL_PERMISSION"
|
||||
|
||||
override fun advancedFilteringSupported(): Boolean {
|
||||
return true
|
||||
|
@ -44,15 +48,15 @@ object SourceDexcomPlugin : PluginBase(PluginDescription()
|
|||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
if (ContextCompat.checkSelfPermission(MainApp.instance(), PERMISSION) != PackageManager.PERMISSION_GRANTED) {
|
||||
val intent = Intent(MainApp.instance(), RequestDexcomPermissionActivity::class.java)
|
||||
if (ContextCompat.checkSelfPermission(mainApp, PERMISSION) != PackageManager.PERMISSION_GRANTED) {
|
||||
val intent = Intent(mainApp, RequestDexcomPermissionActivity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
MainApp.instance().startActivity(intent)
|
||||
mainApp.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
fun findDexcomPackageName(): String? {
|
||||
val packageManager = MainApp.instance().packageManager
|
||||
val packageManager = mainApp.packageManager
|
||||
for (packageInfo in packageManager.getInstalledPackages(0)) {
|
||||
if (PACKAGE_NAMES.contains(packageInfo.packageName)) return packageInfo.packageName
|
||||
}
|
||||
|
@ -72,10 +76,10 @@ object SourceDexcomPlugin : PluginBase(PluginDescription()
|
|||
bgReading.date = glucoseValue.getLong("timestamp") * 1000
|
||||
bgReading.raw = 0.0
|
||||
if (MainApp.getDbHelper().createIfNotExists(bgReading, "Dexcom$sensorType")) {
|
||||
if (SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
if (sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-Dexcom$sensorType")
|
||||
}
|
||||
if (SP.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
if (sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading)
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +104,7 @@ object SourceDexcomPlugin : PluginBase(PluginDescription()
|
|||
}
|
||||
}
|
||||
}
|
||||
if (SP.getBoolean(R.string.key_dexcom_lognssensorchange, false) && intent.hasExtra("sensorInsertionTime")) {
|
||||
if (sp.getBoolean(R.string.key_dexcom_lognssensorchange, false) && intent.hasExtra("sensorInsertionTime")) {
|
||||
intent.extras?.let {
|
||||
val sensorInsertionTime = it.getLong("sensorInsertionTime") * 1000
|
||||
val now = DateUtil.now()
|
||||
|
@ -115,7 +119,7 @@ object SourceDexcomPlugin : PluginBase(PluginDescription()
|
|||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
log.error("Error while processing intent from Dexcom App", e)
|
||||
aapsLogger.error("Error while processing intent from Dexcom App", e)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package info.nightscout.androidaps.plugins.source
|
||||
|
||||
import android.content.Intent
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.db.CareportalEvent
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface
|
||||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.L
|
||||
import info.nightscout.androidaps.logging.L.isEnabled
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class EversensePlugin @Inject constructor(
|
||||
private val aapsLogger: AAPSLogger,
|
||||
private val sp: SP
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
.pluginName(R.string.eversense)
|
||||
.shortName(R.string.eversense_shortname)
|
||||
.preferencesId(R.xml.pref_bgsource)
|
||||
.description(R.string.description_source_eversense)
|
||||
), BgSourceInterface {
|
||||
|
||||
override fun advancedFilteringSupported(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun handleNewData(intent: Intent) {
|
||||
if (!isEnabled(PluginType.BGSOURCE)) return
|
||||
val bundle = intent.extras ?: return
|
||||
if (isEnabled(L.BGSOURCE)) {
|
||||
if (bundle.containsKey("currentCalibrationPhase")) aapsLogger.debug(LTag.BGSOURCE, "currentCalibrationPhase: " + bundle.getString("currentCalibrationPhase"))
|
||||
if (bundle.containsKey("placementModeInProgress")) aapsLogger.debug(LTag.BGSOURCE, "placementModeInProgress: " + bundle.getBoolean("placementModeInProgress"))
|
||||
if (bundle.containsKey("glucoseLevel")) aapsLogger.debug(LTag.BGSOURCE, "glucoseLevel: " + bundle.getInt("glucoseLevel"))
|
||||
if (bundle.containsKey("glucoseTrendDirection")) aapsLogger.debug(LTag.BGSOURCE, "glucoseTrendDirection: " + bundle.getString("glucoseTrendDirection"))
|
||||
if (bundle.containsKey("glucoseTimestamp")) aapsLogger.debug(LTag.BGSOURCE, "glucoseTimestamp: " + DateUtil.dateAndTimeFullString(bundle.getLong("glucoseTimestamp")))
|
||||
if (bundle.containsKey("batteryLevel")) aapsLogger.debug(LTag.BGSOURCE, "batteryLevel: " + bundle.getString("batteryLevel"))
|
||||
if (bundle.containsKey("signalStrength")) aapsLogger.debug(LTag.BGSOURCE, "signalStrength: " + bundle.getString("signalStrength"))
|
||||
if (bundle.containsKey("transmitterVersionNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber"))
|
||||
if (bundle.containsKey("isXLVersion")) aapsLogger.debug(LTag.BGSOURCE, "isXLVersion: " + bundle.getBoolean("isXLVersion"))
|
||||
if (bundle.containsKey("transmitterModelNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterModelNumber: " + bundle.getString("transmitterModelNumber"))
|
||||
if (bundle.containsKey("transmitterSerialNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterSerialNumber: " + bundle.getString("transmitterSerialNumber"))
|
||||
if (bundle.containsKey("transmitterAddress")) aapsLogger.debug(LTag.BGSOURCE, "transmitterAddress: " + bundle.getString("transmitterAddress"))
|
||||
if (bundle.containsKey("sensorInsertionTimestamp")) aapsLogger.debug(LTag.BGSOURCE, "sensorInsertionTimestamp: " + DateUtil.dateAndTimeFullString(bundle.getLong("sensorInsertionTimestamp")))
|
||||
if (bundle.containsKey("transmitterVersionNumber")) aapsLogger.debug(LTag.BGSOURCE, "transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber"))
|
||||
if (bundle.containsKey("transmitterConnectionState")) aapsLogger.debug(LTag.BGSOURCE, "transmitterConnectionState: " + bundle.getString("transmitterConnectionState"))
|
||||
}
|
||||
if (bundle.containsKey("glucoseLevels")) {
|
||||
val glucoseLevels = bundle.getIntArray("glucoseLevels")
|
||||
val glucoseRecordNumbers = bundle.getIntArray("glucoseRecordNumbers")
|
||||
val glucoseTimestamps = bundle.getLongArray("glucoseTimestamps")
|
||||
if (glucoseLevels != null && glucoseRecordNumbers != null && glucoseTimestamps != null) {
|
||||
if (isEnabled(L.BGSOURCE)) {
|
||||
aapsLogger.debug(LTag.BGSOURCE, "glucoseLevels" + Arrays.toString(glucoseLevels))
|
||||
aapsLogger.debug(LTag.BGSOURCE, "glucoseRecordNumbers" + Arrays.toString(glucoseRecordNumbers))
|
||||
aapsLogger.debug(LTag.BGSOURCE, "glucoseTimestamps" + Arrays.toString(glucoseTimestamps))
|
||||
}
|
||||
for (i in glucoseLevels.indices) {
|
||||
val bgReading = BgReading()
|
||||
bgReading.value = glucoseLevels[i].toDouble()
|
||||
bgReading.date = glucoseTimestamps[i]
|
||||
bgReading.raw = 0.0
|
||||
val isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Eversense")
|
||||
if (isNew && sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-Eversense")
|
||||
}
|
||||
if (isNew && sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bundle.containsKey("calibrationGlucoseLevels")) {
|
||||
val calibrationGlucoseLevels = bundle.getIntArray("calibrationGlucoseLevels")
|
||||
val calibrationTimestamps = bundle.getLongArray("calibrationTimestamps")
|
||||
val calibrationRecordNumbers = bundle.getLongArray("calibrationRecordNumbers")
|
||||
if (calibrationGlucoseLevels != null && calibrationTimestamps != null && calibrationRecordNumbers != null) {
|
||||
if (isEnabled(L.BGSOURCE)) {
|
||||
aapsLogger.debug(LTag.BGSOURCE, "calibrationGlucoseLevels" + Arrays.toString(calibrationGlucoseLevels))
|
||||
aapsLogger.debug(LTag.BGSOURCE, "calibrationTimestamps" + Arrays.toString(calibrationTimestamps))
|
||||
aapsLogger.debug(LTag.BGSOURCE, "calibrationRecordNumbers" + Arrays.toString(calibrationRecordNumbers))
|
||||
}
|
||||
for (i in calibrationGlucoseLevels.indices) {
|
||||
try {
|
||||
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(calibrationTimestamps[i]) == null) {
|
||||
val data = JSONObject()
|
||||
data.put("enteredBy", "AndroidAPS-Eversense")
|
||||
data.put("created_at", DateUtil.toISOString(calibrationTimestamps[i]))
|
||||
data.put("eventType", CareportalEvent.BGCHECK)
|
||||
data.put("glucoseType", "Finger")
|
||||
data.put("glucose", calibrationGlucoseLevels[i])
|
||||
data.put("units", Constants.MGDL)
|
||||
NSUpload.uploadCareportalEntryToNS(data)
|
||||
}
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Unhandled exception", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package info.nightscout.androidaps.plugins.source
|
||||
|
||||
import android.content.Intent
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface
|
||||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.BundleLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class GlimpPlugin @Inject constructor(
|
||||
private val aapsLogger: AAPSLogger
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
.pluginName(R.string.Glimp)
|
||||
.preferencesId(R.xml.pref_bgsource)
|
||||
.description(R.string.description_source_glimp)
|
||||
), BgSourceInterface {
|
||||
|
||||
override fun advancedFilteringSupported(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun handleNewData(intent: Intent) {
|
||||
if (!isEnabled(PluginType.BGSOURCE)) return
|
||||
val bundle = intent.extras ?: return
|
||||
aapsLogger.debug(LTag.BGSOURCE, "Received Glimp Data: ${BundleLogger.log(bundle)}")
|
||||
val bgReading = BgReading()
|
||||
bgReading.value = bundle.getDouble("mySGV")
|
||||
bgReading.direction = bundle.getString("myTrend")
|
||||
bgReading.date = bundle.getLong("myTimestamp")
|
||||
bgReading.raw = 0.0
|
||||
MainApp.getDbHelper().createIfNotExists(bgReading, "GLIMP")
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package info.nightscout.androidaps.plugins.source
|
||||
|
||||
import android.content.Intent
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface
|
||||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class MM640gPlugin @Inject constructor(
|
||||
private val aapsLogger: AAPSLogger
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
.pluginName(R.string.MM640g)
|
||||
.description(R.string.description_source_mm640g)
|
||||
), BgSourceInterface {
|
||||
|
||||
override fun advancedFilteringSupported(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun handleNewData(intent: Intent) {
|
||||
if (!isEnabled(PluginType.BGSOURCE)) return
|
||||
val bundle = intent.extras ?: return
|
||||
val collection = bundle.getString("collection") ?: return
|
||||
if (collection == "entries") {
|
||||
val data = bundle.getString("data")
|
||||
aapsLogger.debug(LTag.BGSOURCE, "Received MM640g Data: $data")
|
||||
if (data != null && data.isNotEmpty()) {
|
||||
try {
|
||||
val jsonArray = JSONArray(data)
|
||||
for (i in 0 until jsonArray.length()) {
|
||||
val json_object = jsonArray.getJSONObject(i)
|
||||
val type = json_object.getString("type")
|
||||
when (type) {
|
||||
"sgv" -> {
|
||||
val bgReading = BgReading()
|
||||
bgReading.value = json_object.getDouble("sgv")
|
||||
bgReading.direction = json_object.getString("direction")
|
||||
bgReading.date = json_object.getLong("date")
|
||||
bgReading.raw = json_object.getDouble("sgv")
|
||||
MainApp.getDbHelper().createIfNotExists(bgReading, "MM640g")
|
||||
}
|
||||
|
||||
else -> aapsLogger.debug(LTag.BGSOURCE, "Unknown entries type: $type")
|
||||
}
|
||||
}
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Exception: ", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package info.nightscout.androidaps.plugins.source
|
||||
|
||||
import android.content.Intent
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface
|
||||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSgv
|
||||
import info.nightscout.androidaps.utils.JsonHelper.safeGetLong
|
||||
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class NSClientSourcePlugin @Inject constructor(
|
||||
private val aapsLogger: AAPSLogger,
|
||||
private val sp: SP
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
.pluginName(R.string.nsclientbg)
|
||||
.description(R.string.description_source_ns_client)
|
||||
), BgSourceInterface {
|
||||
|
||||
private var lastBGTimeStamp: Long = 0
|
||||
private var isAdvancedFilteringEnabled = false
|
||||
|
||||
override fun advancedFilteringSupported(): Boolean {
|
||||
return isAdvancedFilteringEnabled
|
||||
}
|
||||
|
||||
override fun handleNewData(intent: Intent) {
|
||||
if (!isEnabled(PluginType.BGSOURCE) && !sp.getBoolean(R.string.key_ns_autobackfill, true)) return
|
||||
val bundles = intent.extras ?: return
|
||||
try {
|
||||
if (bundles.containsKey("sgv")) {
|
||||
val sgvstring = bundles.getString("sgv")
|
||||
aapsLogger.debug(LTag.BGSOURCE, "Received NS Data: $sgvstring")
|
||||
val sgvJson = JSONObject(sgvstring)
|
||||
storeSgv(sgvJson)
|
||||
}
|
||||
if (bundles.containsKey("sgvs")) {
|
||||
val sgvstring = bundles.getString("sgvs")
|
||||
aapsLogger.debug(LTag.BGSOURCE, "Received NS Data: $sgvstring")
|
||||
val jsonArray = JSONArray(sgvstring)
|
||||
for (i in 0 until jsonArray.length()) {
|
||||
val sgvJson = jsonArray.getJSONObject(i)
|
||||
storeSgv(sgvJson)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
aapsLogger.error("Unhandled exception", e)
|
||||
}
|
||||
// Objectives 0
|
||||
sp.putBoolean(R.string.key_ObjectivesbgIsAvailableInNS, true)
|
||||
}
|
||||
|
||||
private fun storeSgv(sgvJson: JSONObject) {
|
||||
val nsSgv = NSSgv(sgvJson)
|
||||
val bgReading = BgReading(nsSgv)
|
||||
MainApp.getDbHelper().createIfNotExists(bgReading, "NS")
|
||||
detectSource(safeGetString(sgvJson, "device", "none"), safeGetLong(sgvJson, "mills"))
|
||||
}
|
||||
|
||||
fun detectSource(source: String, timeStamp: Long) {
|
||||
if (timeStamp > lastBGTimeStamp) {
|
||||
isAdvancedFilteringEnabled = source.contains("G5 Native") || source.contains("G6 Native") || source.contains("AndroidAPS-DexcomG5") || source.contains("AndroidAPS-DexcomG6")
|
||||
lastBGTimeStamp = timeStamp
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package info.nightscout.androidaps.plugins.source
|
||||
|
||||
import android.content.Intent
|
||||
import info.nightscout.androidaps.Constants
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface
|
||||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class PoctechPlugin @Inject constructor(
|
||||
private val aapsLogger: AAPSLogger,
|
||||
private val sp: SP
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
.pluginName(R.string.poctech)
|
||||
.preferencesId(R.xml.pref_bgsource)
|
||||
.description(R.string.description_source_poctech)
|
||||
), BgSourceInterface {
|
||||
|
||||
override fun advancedFilteringSupported(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun handleNewData(intent: Intent) {
|
||||
if (!isEnabled(PluginType.BGSOURCE)) return
|
||||
val bundle = intent.extras ?: return
|
||||
val bgReading = BgReading()
|
||||
val data = bundle.getString("data")
|
||||
aapsLogger.debug(LTag.BGSOURCE, "Received Poctech Data $data")
|
||||
try {
|
||||
val jsonArray = JSONArray(data)
|
||||
aapsLogger.debug(LTag.BGSOURCE, "Received Poctech Data size:" + jsonArray.length())
|
||||
for (i in 0 until jsonArray.length()) {
|
||||
val json = jsonArray.getJSONObject(i)
|
||||
bgReading.value = json.getDouble("current")
|
||||
bgReading.direction = json.getString("direction")
|
||||
bgReading.date = json.getLong("date")
|
||||
bgReading.raw = json.getDouble("raw")
|
||||
if (safeGetString(json, "units", Constants.MGDL) == "mmol/L") bgReading.value = bgReading.value * Constants.MMOLL_TO_MGDL
|
||||
val isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Poctech")
|
||||
if (isNew && sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-Poctech")
|
||||
}
|
||||
if (isNew && sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading)
|
||||
}
|
||||
}
|
||||
} catch (e: JSONException) {
|
||||
aapsLogger.error("Exception: ", e)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,155 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.source;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 28.11.2017.
|
||||
*/
|
||||
|
||||
public class SourceEversensePlugin extends PluginBase implements BgSourceInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
|
||||
|
||||
private static SourceEversensePlugin plugin = null;
|
||||
|
||||
@Deprecated
|
||||
public static SourceEversensePlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceEversensePlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private SourceEversensePlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment.class.getName())
|
||||
.pluginName(R.string.eversense)
|
||||
.shortName(R.string.eversense_shortname)
|
||||
.preferencesId(R.xml.pref_poctech)
|
||||
.description(R.string.description_source_eversense)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleNewData(Intent intent) {
|
||||
|
||||
if (!isEnabled(PluginType.BGSOURCE)) return;
|
||||
|
||||
Bundle bundle = intent.getExtras();
|
||||
if (bundle == null) return;
|
||||
|
||||
if (L.isEnabled(L.BGSOURCE)) {
|
||||
if (bundle.containsKey("currentCalibrationPhase"))
|
||||
log.debug("currentCalibrationPhase: " + bundle.getString("currentCalibrationPhase"));
|
||||
if (bundle.containsKey("placementModeInProgress"))
|
||||
log.debug("placementModeInProgress: " + bundle.getBoolean("placementModeInProgress"));
|
||||
if (bundle.containsKey("glucoseLevel"))
|
||||
log.debug("glucoseLevel: " + bundle.getInt("glucoseLevel"));
|
||||
if (bundle.containsKey("glucoseTrendDirection"))
|
||||
log.debug("glucoseTrendDirection: " + bundle.getString("glucoseTrendDirection"));
|
||||
if (bundle.containsKey("glucoseTimestamp"))
|
||||
log.debug("glucoseTimestamp: " + DateUtil.dateAndTimeFullString(bundle.getLong("glucoseTimestamp")));
|
||||
if (bundle.containsKey("batteryLevel"))
|
||||
log.debug("batteryLevel: " + bundle.getString("batteryLevel"));
|
||||
if (bundle.containsKey("signalStrength"))
|
||||
log.debug("signalStrength: " + bundle.getString("signalStrength"));
|
||||
if (bundle.containsKey("transmitterVersionNumber"))
|
||||
log.debug("transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber"));
|
||||
if (bundle.containsKey("isXLVersion"))
|
||||
log.debug("isXLVersion: " + bundle.getBoolean("isXLVersion"));
|
||||
if (bundle.containsKey("transmitterModelNumber"))
|
||||
log.debug("transmitterModelNumber: " + bundle.getString("transmitterModelNumber"));
|
||||
if (bundle.containsKey("transmitterSerialNumber"))
|
||||
log.debug("transmitterSerialNumber: " + bundle.getString("transmitterSerialNumber"));
|
||||
if (bundle.containsKey("transmitterAddress"))
|
||||
log.debug("transmitterAddress: " + bundle.getString("transmitterAddress"));
|
||||
if (bundle.containsKey("sensorInsertionTimestamp"))
|
||||
log.debug("sensorInsertionTimestamp: " + DateUtil.dateAndTimeFullString(bundle.getLong("sensorInsertionTimestamp")));
|
||||
if (bundle.containsKey("transmitterVersionNumber"))
|
||||
log.debug("transmitterVersionNumber: " + bundle.getString("transmitterVersionNumber"));
|
||||
if (bundle.containsKey("transmitterConnectionState"))
|
||||
log.debug("transmitterConnectionState: " + bundle.getString("transmitterConnectionState"));
|
||||
}
|
||||
|
||||
if (bundle.containsKey("glucoseLevels")) {
|
||||
int[] glucoseLevels = bundle.getIntArray("glucoseLevels");
|
||||
int[] glucoseRecordNumbers = bundle.getIntArray("glucoseRecordNumbers");
|
||||
long[] glucoseTimestamps = bundle.getLongArray("glucoseTimestamps");
|
||||
|
||||
if (L.isEnabled(L.BGSOURCE)) {
|
||||
log.debug("glucoseLevels", Arrays.toString(glucoseLevels));
|
||||
log.debug("glucoseRecordNumbers", Arrays.toString(glucoseRecordNumbers));
|
||||
log.debug("glucoseTimestamps", Arrays.toString(glucoseTimestamps));
|
||||
}
|
||||
|
||||
for (int i = 0; i < glucoseLevels.length; i++) {
|
||||
BgReading bgReading = new BgReading();
|
||||
bgReading.value = glucoseLevels[i];
|
||||
bgReading.date = glucoseTimestamps[i];
|
||||
bgReading.raw = 0;
|
||||
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Eversense");
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-Eversense");
|
||||
}
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bundle.containsKey("calibrationGlucoseLevels")) {
|
||||
int[] calibrationGlucoseLevels = bundle.getIntArray("calibrationGlucoseLevels");
|
||||
long[] calibrationTimestamps = bundle.getLongArray("calibrationTimestamps");
|
||||
long[] calibrationRecordNumbers = bundle.getLongArray("calibrationRecordNumbers");
|
||||
|
||||
if (L.isEnabled(L.BGSOURCE)) {
|
||||
log.debug("calibrationGlucoseLevels", Arrays.toString(calibrationGlucoseLevels));
|
||||
log.debug("calibrationTimestamps", Arrays.toString(calibrationTimestamps));
|
||||
log.debug("calibrationRecordNumbers", Arrays.toString(calibrationRecordNumbers));
|
||||
}
|
||||
|
||||
for (int i = 0; i < calibrationGlucoseLevels.length; i++) {
|
||||
try {
|
||||
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(calibrationTimestamps[i]) == null) {
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("enteredBy", "AndroidAPS-Eversense");
|
||||
data.put("created_at", DateUtil.toISOString(calibrationTimestamps[i]));
|
||||
data.put("eventType", CareportalEvent.BGCHECK);
|
||||
data.put("glucoseType", "Finger");
|
||||
data.put("glucose", calibrationGlucoseLevels[i]);
|
||||
data.put("units", Constants.MGDL);
|
||||
NSUpload.uploadCareportalEntryToNS(data);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.source;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.BundleLogger;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceGlimpPlugin extends PluginBase implements BgSourceInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
|
||||
|
||||
private static SourceGlimpPlugin plugin = null;
|
||||
|
||||
@Deprecated
|
||||
public static SourceGlimpPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceGlimpPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private SourceGlimpPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment.class.getName())
|
||||
.pluginName(R.string.Glimp)
|
||||
.description(R.string.description_source_glimp)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleNewData(Intent intent) {
|
||||
|
||||
if (!isEnabled(PluginType.BGSOURCE)) return;
|
||||
|
||||
Bundle bundle = intent.getExtras();
|
||||
if (bundle == null) return;
|
||||
|
||||
if (L.isEnabled(L.BGSOURCE))
|
||||
log.debug("Received Glimp Data: " + BundleLogger.log(bundle));
|
||||
|
||||
BgReading bgReading = new BgReading();
|
||||
|
||||
bgReading.value = bundle.getDouble("mySGV");
|
||||
bgReading.direction = bundle.getString("myTrend");
|
||||
bgReading.date = bundle.getLong("myTimestamp");
|
||||
bgReading.raw = 0;
|
||||
|
||||
MainApp.getDbHelper().createIfNotExists(bgReading, "GLIMP");
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.source;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceMM640gPlugin extends PluginBase implements BgSourceInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
|
||||
|
||||
private static SourceMM640gPlugin plugin = null;
|
||||
|
||||
@Deprecated
|
||||
public static SourceMM640gPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceMM640gPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private SourceMM640gPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment.class.getName())
|
||||
.pluginName(R.string.MM640g)
|
||||
.description(R.string.description_source_mm640g)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleNewData(Intent intent) {
|
||||
|
||||
if (!isEnabled(PluginType.BGSOURCE)) return;
|
||||
|
||||
Bundle bundle = intent.getExtras();
|
||||
if (bundle == null) return;
|
||||
|
||||
final String collection = bundle.getString("collection");
|
||||
if (collection == null) return;
|
||||
|
||||
if (collection.equals("entries")) {
|
||||
final String data = bundle.getString("data");
|
||||
if (L.isEnabled(L.BGSOURCE))
|
||||
log.debug("Received MM640g Data: ", data);
|
||||
|
||||
if ((data != null) && (data.length() > 0)) {
|
||||
try {
|
||||
final JSONArray json_array = new JSONArray(data);
|
||||
for (int i = 0; i < json_array.length(); i++) {
|
||||
final JSONObject json_object = json_array.getJSONObject(i);
|
||||
final String type = json_object.getString("type");
|
||||
switch (type) {
|
||||
case "sgv":
|
||||
BgReading bgReading = new BgReading();
|
||||
|
||||
bgReading.value = json_object.getDouble("sgv");
|
||||
bgReading.direction = json_object.getString("direction");
|
||||
bgReading.date = json_object.getLong("date");
|
||||
bgReading.raw = json_object.getDouble("sgv");
|
||||
|
||||
MainApp.getDbHelper().createIfNotExists(bgReading, "MM640g");
|
||||
break;
|
||||
default:
|
||||
if (L.isEnabled(L.BGSOURCE))
|
||||
log.debug("Unknown entries type: " + type);
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
log.error("Exception: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,107 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.source;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSgv;
|
||||
import info.nightscout.androidaps.utils.JsonHelper;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceNSClientPlugin extends PluginBase implements BgSourceInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
|
||||
|
||||
private static SourceNSClientPlugin plugin = null;
|
||||
|
||||
@Deprecated
|
||||
public static SourceNSClientPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceNSClientPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private long lastBGTimeStamp = 0;
|
||||
private boolean isAdvancedFilteringEnabled = false;
|
||||
|
||||
private SourceNSClientPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment.class.getName())
|
||||
.pluginName(R.string.nsclientbg)
|
||||
.description(R.string.description_source_ns_client)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return isAdvancedFilteringEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleNewData(Intent intent) {
|
||||
|
||||
if (!isEnabled(PluginType.BGSOURCE) && !SP.getBoolean(R.string.key_ns_autobackfill, true))
|
||||
return;
|
||||
|
||||
Bundle bundles = intent.getExtras();
|
||||
|
||||
try {
|
||||
if (bundles.containsKey("sgv")) {
|
||||
String sgvstring = bundles.getString("sgv");
|
||||
if (L.isEnabled(L.BGSOURCE))
|
||||
log.debug("Received NS Data: " + sgvstring);
|
||||
|
||||
JSONObject sgvJson = new JSONObject(sgvstring);
|
||||
storeSgv(sgvJson);
|
||||
}
|
||||
|
||||
if (bundles.containsKey("sgvs")) {
|
||||
String sgvstring = bundles.getString("sgvs");
|
||||
if (L.isEnabled(L.BGSOURCE))
|
||||
log.debug("Received NS Data: " + sgvstring);
|
||||
JSONArray jsonArray = new JSONArray(sgvstring);
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject sgvJson = jsonArray.getJSONObject(i);
|
||||
storeSgv(sgvJson);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
|
||||
// Objectives 0
|
||||
SP.putBoolean(R.string.key_ObjectivesbgIsAvailableInNS, true);
|
||||
}
|
||||
|
||||
private void storeSgv(JSONObject sgvJson) {
|
||||
NSSgv nsSgv = new NSSgv(sgvJson);
|
||||
BgReading bgReading = new BgReading(nsSgv);
|
||||
MainApp.getDbHelper().createIfNotExists(bgReading, "NS");
|
||||
SourceNSClientPlugin.getPlugin().detectSource(JsonHelper.safeGetString(sgvJson, "device", "none"), JsonHelper.safeGetLong(sgvJson, "mills"));
|
||||
}
|
||||
|
||||
public void detectSource(String source, long timeStamp) {
|
||||
if (timeStamp > lastBGTimeStamp) {
|
||||
if (source.contains("G5 Native") || source.contains("G6 Native") || source.contains("AndroidAPS-DexcomG5") || source.contains("AndroidAPS-DexcomG6"))
|
||||
isAdvancedFilteringEnabled = true;
|
||||
else
|
||||
isAdvancedFilteringEnabled = false;
|
||||
lastBGTimeStamp = timeStamp;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.source;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.utils.JsonHelper;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourcePoctechPlugin extends PluginBase implements BgSourceInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
|
||||
|
||||
private static SourcePoctechPlugin plugin = null;
|
||||
|
||||
@Deprecated
|
||||
public static SourcePoctechPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourcePoctechPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private SourcePoctechPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment.class.getName())
|
||||
.pluginName(R.string.poctech)
|
||||
.preferencesId(R.xml.pref_poctech)
|
||||
.description(R.string.description_source_poctech)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleNewData(Intent intent) {
|
||||
|
||||
if (!isEnabled(PluginType.BGSOURCE)) return;
|
||||
|
||||
Bundle bundle = intent.getExtras();
|
||||
if (bundle == null) return;
|
||||
|
||||
BgReading bgReading = new BgReading();
|
||||
|
||||
String data = bundle.getString("data");
|
||||
if (L.isEnabled(L.BGSOURCE))
|
||||
log.debug("Received Poctech Data", data);
|
||||
|
||||
try {
|
||||
JSONArray jsonArray = new JSONArray(data);
|
||||
if (L.isEnabled(L.BGSOURCE))
|
||||
log.debug("Received Poctech Data size:" + jsonArray.length());
|
||||
for (int i = 0; i < jsonArray.length(); i++) {
|
||||
JSONObject json = jsonArray.getJSONObject(i);
|
||||
bgReading.value = json.getDouble("current");
|
||||
bgReading.direction = json.getString("direction");
|
||||
bgReading.date = json.getLong("date");
|
||||
bgReading.raw = json.getDouble("raw");
|
||||
if (JsonHelper.safeGetString(json, "units", Constants.MGDL).equals("mmol/L"))
|
||||
bgReading.value = bgReading.value * Constants.MMOLL_TO_MGDL;
|
||||
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Poctech");
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-Poctech");
|
||||
}
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
log.error("Exception: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.source;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceTomatoPlugin extends PluginBase implements BgSourceInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
|
||||
|
||||
private static SourceTomatoPlugin plugin = null;
|
||||
|
||||
@Deprecated
|
||||
public static SourceTomatoPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceTomatoPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private SourceTomatoPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment.class.getName())
|
||||
.pluginName(R.string.tomato)
|
||||
.preferencesId(R.xml.pref_poctech)
|
||||
.shortName(R.string.tomato_short)
|
||||
.description(R.string.description_source_tomato)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleNewData(Intent intent) {
|
||||
|
||||
if (!isEnabled(PluginType.BGSOURCE)) return;
|
||||
|
||||
Bundle bundle = intent.getExtras();
|
||||
if (bundle == null) return;
|
||||
|
||||
BgReading bgReading = new BgReading();
|
||||
|
||||
if (L.isEnabled(L.BGSOURCE))
|
||||
log.debug("Received Tomato Data");
|
||||
|
||||
bgReading.value = bundle.getDouble("com.fanqies.tomatofn.Extras.BgEstimate");
|
||||
bgReading.date = bundle.getLong("com.fanqies.tomatofn.Extras.Time");
|
||||
boolean isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Tomato");
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-Tomato");
|
||||
}
|
||||
if (isNew && SP.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.source;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.services.Intents;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.BundleLogger;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class SourceXdripPlugin extends PluginBase implements BgSourceInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(L.BGSOURCE);
|
||||
|
||||
private static SourceXdripPlugin plugin = null;
|
||||
|
||||
boolean advancedFiltering;
|
||||
|
||||
@Deprecated
|
||||
public static SourceXdripPlugin getPlugin() {
|
||||
if (plugin == null)
|
||||
plugin = new SourceXdripPlugin();
|
||||
return plugin;
|
||||
}
|
||||
|
||||
private SourceXdripPlugin() {
|
||||
super(new PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment.class.getName())
|
||||
.pluginName(R.string.xdrip)
|
||||
.description(R.string.description_source_xdrip)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean advancedFilteringSupported() {
|
||||
return advancedFiltering;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleNewData(Intent intent) {
|
||||
|
||||
if (!isEnabled(PluginType.BGSOURCE)) return;
|
||||
|
||||
Bundle bundle = intent.getExtras();
|
||||
if (bundle == null) return;
|
||||
|
||||
if (L.isEnabled(L.BGSOURCE))
|
||||
log.debug("Received xDrip data: " + BundleLogger.log(intent.getExtras()));
|
||||
|
||||
BgReading bgReading = new BgReading();
|
||||
|
||||
bgReading.value = bundle.getDouble(Intents.EXTRA_BG_ESTIMATE);
|
||||
bgReading.direction = bundle.getString(Intents.EXTRA_BG_SLOPE_NAME);
|
||||
bgReading.date = bundle.getLong(Intents.EXTRA_TIMESTAMP);
|
||||
bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW);
|
||||
String source = bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION, "no Source specified");
|
||||
SourceXdripPlugin.getPlugin().setSource(source);
|
||||
MainApp.getDbHelper().createIfNotExists(bgReading, "XDRIP");
|
||||
}
|
||||
|
||||
public void setSource(String source) {
|
||||
this.advancedFiltering = source.contains("G5 Native")||source.contains("G6 Native");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package info.nightscout.androidaps.plugins.source
|
||||
|
||||
import android.content.Intent
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface
|
||||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class TomatoPlugin @Inject constructor(
|
||||
private val aapsLogger: AAPSLogger,
|
||||
private val sp: SP
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
.pluginName(R.string.tomato)
|
||||
.preferencesId(R.xml.pref_bgsource)
|
||||
.shortName(R.string.tomato_short)
|
||||
.description(R.string.description_source_tomato)
|
||||
), BgSourceInterface {
|
||||
|
||||
override fun advancedFilteringSupported(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun handleNewData(intent: Intent) {
|
||||
if (!isEnabled(PluginType.BGSOURCE)) return
|
||||
val bundle = intent.extras ?: return
|
||||
val bgReading = BgReading()
|
||||
aapsLogger.debug(LTag.BGSOURCE, "Received Tomato Data")
|
||||
bgReading.value = bundle.getDouble("com.fanqies.tomatofn.Extras.BgEstimate")
|
||||
bgReading.date = bundle.getLong("com.fanqies.tomatofn.Extras.Time")
|
||||
val isNew = MainApp.getDbHelper().createIfNotExists(bgReading, "Tomato")
|
||||
if (isNew && sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||
NSUpload.uploadBg(bgReading, "AndroidAPS-Tomato")
|
||||
}
|
||||
if (isNew && sp.getBoolean(R.string.key_dexcomg5_xdripupload, false)) {
|
||||
NSUpload.sendToXdrip(bgReading)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package info.nightscout.androidaps.plugins.source
|
||||
|
||||
import android.content.Intent
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.db.BgReading
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface
|
||||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.logging.BundleLogger
|
||||
import info.nightscout.androidaps.logging.LTag
|
||||
import info.nightscout.androidaps.services.Intents
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class XdripPlugin @Inject constructor(
|
||||
private val aapsLogger: AAPSLogger
|
||||
) : PluginBase(PluginDescription()
|
||||
.mainType(PluginType.BGSOURCE)
|
||||
.fragmentClass(BGSourceFragment::class.java.name)
|
||||
.pluginName(R.string.xdrip)
|
||||
.description(R.string.description_source_xdrip)
|
||||
), BgSourceInterface {
|
||||
|
||||
var advancedFiltering = false
|
||||
|
||||
override fun advancedFilteringSupported(): Boolean {
|
||||
return advancedFiltering
|
||||
}
|
||||
|
||||
override fun handleNewData(intent: Intent) {
|
||||
if (!isEnabled(PluginType.BGSOURCE)) return
|
||||
val bundle = intent.extras ?: return
|
||||
aapsLogger.debug(LTag.BGSOURCE, "Received xDrip data: " + BundleLogger.log(intent.extras))
|
||||
val bgReading = BgReading()
|
||||
bgReading.value = bundle.getDouble(Intents.EXTRA_BG_ESTIMATE)
|
||||
bgReading.direction = bundle.getString(Intents.EXTRA_BG_SLOPE_NAME)
|
||||
bgReading.date = bundle.getLong(Intents.EXTRA_TIMESTAMP)
|
||||
bgReading.raw = bundle.getDouble(Intents.EXTRA_RAW)
|
||||
val source = bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION, "no Source specified")
|
||||
setSource(source)
|
||||
MainApp.getDbHelper().createIfNotExists(bgReading, "XDRIP")
|
||||
}
|
||||
|
||||
fun setSource(source: String) {
|
||||
advancedFiltering = source.contains("G5 Native") || source.contains("G6 Native")
|
||||
}
|
||||
}
|
|
@ -28,14 +28,14 @@ import info.nightscout.androidaps.plugins.general.overview.notifications.Notific
|
|||
import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRNSHistorySync;
|
||||
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceEversensePlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceMM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceNSClientPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourcePoctechPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceTomatoPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.DexcomPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.EversensePlugin;
|
||||
import info.nightscout.androidaps.plugins.source.GlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.MM640gPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.NSClientSourcePlugin;
|
||||
import info.nightscout.androidaps.plugins.source.PoctechPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.TomatoPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.XdripPlugin;
|
||||
import info.nightscout.androidaps.receivers.DataReceiver;
|
||||
import info.nightscout.androidaps.utils.JsonHelper;
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||
|
@ -46,6 +46,14 @@ public class DataService extends DaggerIntentService {
|
|||
@Inject SP sp;
|
||||
@Inject RxBusWrapper rxBus;
|
||||
@Inject SmsCommunicatorPlugin smsCommunicatorPlugin;
|
||||
@Inject DexcomPlugin dexcomPlugin;
|
||||
@Inject EversensePlugin eversensePlugin;
|
||||
@Inject GlimpPlugin glimpPlugin;
|
||||
@Inject MM640gPlugin mm640GPlugin;
|
||||
@Inject NSClientSourcePlugin nsClientSourcePlugin;
|
||||
@Inject PoctechPlugin poctechPlugin;
|
||||
@Inject TomatoPlugin tomatoPlugin;
|
||||
@Inject XdripPlugin xdripPlugin;
|
||||
|
||||
public DataService() {
|
||||
super("DataService");
|
||||
|
@ -63,21 +71,21 @@ public class DataService extends DaggerIntentService {
|
|||
|
||||
final String action = intent.getAction();
|
||||
if (Intents.ACTION_NEW_BG_ESTIMATE.equals(action)) {
|
||||
SourceXdripPlugin.getPlugin().handleNewData(intent);
|
||||
xdripPlugin.handleNewData(intent);
|
||||
} else if (Intents.NS_EMULATOR.equals(action)) {
|
||||
SourceMM640gPlugin.getPlugin().handleNewData(intent);
|
||||
mm640GPlugin.handleNewData(intent);
|
||||
} else if (Intents.GLIMP_BG.equals(action)) {
|
||||
SourceGlimpPlugin.getPlugin().handleNewData(intent);
|
||||
glimpPlugin.handleNewData(intent);
|
||||
} else if (Intents.DEXCOM_BG.equals(action)) {
|
||||
SourceDexcomPlugin.INSTANCE.handleNewData(intent);
|
||||
dexcomPlugin.handleNewData(intent);
|
||||
} else if (Intents.POCTECH_BG.equals(action)) {
|
||||
SourcePoctechPlugin.getPlugin().handleNewData(intent);
|
||||
poctechPlugin.handleNewData(intent);
|
||||
} else if (Intents.TOMATO_BG.equals(action)) {
|
||||
SourceTomatoPlugin.getPlugin().handleNewData(intent);
|
||||
tomatoPlugin.handleNewData(intent);
|
||||
} else if (Intents.EVERSENSE_BG.equals(action)) {
|
||||
SourceEversensePlugin.getPlugin().handleNewData(intent);
|
||||
eversensePlugin.handleNewData(intent);
|
||||
} else if (Intents.ACTION_NEW_SGV.equals(action)) {
|
||||
SourceNSClientPlugin.getPlugin().handleNewData(intent);
|
||||
nsClientSourcePlugin.handleNewData(intent);
|
||||
} else if (Intents.ACTION_NEW_PROFILE.equals(action)) {
|
||||
// always handle Profile if NSProfile is enabled without looking at nsUploadOnly
|
||||
NSProfilePlugin.getPlugin().handleNewData(intent);
|
||||
|
|
|
@ -14,12 +14,6 @@
|
|||
android:summary="@string/dexcomg5_xdripupload_summary"
|
||||
android:title="@string/dexcomg5_xdripupload_title" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_dexcom_lognssensorchange"
|
||||
android:summary="@string/dexcom_lognssensorchange_summary"
|
||||
android:title="@string/dexcom_lognssensorchange_title" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
|
@ -14,6 +14,12 @@
|
|||
android:summary="@string/dexcomg5_xdripupload_summary"
|
||||
android:title="@string/dexcomg5_xdripupload_title" />
|
||||
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/key_dexcom_lognssensorchange"
|
||||
android:summary="@string/dexcom_lognssensorchange_summary"
|
||||
android:title="@string/dexcom_lognssensorchange_title" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
|
@ -29,7 +29,7 @@ import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
|||
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.LocalInsightPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.GlimpPlugin;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
|
@ -109,7 +109,7 @@ public class ConstraintsCheckerTest {
|
|||
|
||||
@Test
|
||||
public void isAdvancedFilteringEnabledTest() {
|
||||
when(ConfigBuilderPlugin.getPlugin().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin());
|
||||
when(ConfigBuilderPlugin.getPlugin().getActiveBgSource()).thenReturn(GlimpPlugin.getPlugin());
|
||||
|
||||
Constraint<Boolean> c = constraintChecker.isAdvancedFilteringEnabled();
|
||||
Assert.assertEquals(true, c.getReasonList().size() == 1); // Safety
|
||||
|
|
|
@ -20,7 +20,7 @@ import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
|
|||
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.SourceGlimpPlugin;
|
||||
import info.nightscout.androidaps.plugins.source.GlimpPlugin;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
@ -91,7 +91,7 @@ public class SafetyPluginTest {
|
|||
|
||||
@Test
|
||||
public void bgSourceShouldPreventSMBAlways() {
|
||||
when(ConfigBuilderPlugin.getPlugin().getActiveBgSource()).thenReturn(SourceGlimpPlugin.getPlugin());
|
||||
when(ConfigBuilderPlugin.getPlugin().getActiveBgSource()).thenReturn(GlimpPlugin.getPlugin());
|
||||
|
||||
Constraint<Boolean> c = new Constraint<>(true);
|
||||
c = safetyPlugin.isAdvancedFilteringEnabled(c);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package info.nightscout.androidaps.plugins.insulin
|
||||
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelperImplementation
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import junit.framework.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
|
@ -31,15 +31,13 @@ class InsulinOrefFreePeakPluginTest {
|
|||
|
||||
lateinit var sut: InsulinOrefFreePeakPlugin
|
||||
|
||||
@Mock
|
||||
lateinit var sp: SP
|
||||
|
||||
@Mock
|
||||
lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var sp: SP
|
||||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var rxBus: RxBusWrapper
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
sut = InsulinOrefFreePeakPlugin(sp, resourceHelper)
|
||||
sut = InsulinOrefFreePeakPlugin(sp, resourceHelper, rxBus)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package info.nightscout.androidaps.plugins.source
|
||||
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mockito.Mock
|
||||
import org.mockito.junit.MockitoJUnit
|
||||
import org.mockito.junit.MockitoRule
|
||||
|
||||
class GlimpPluginTest {
|
||||
@get:Rule
|
||||
val mockitoRule: MockitoRule = MockitoJUnit.rule()
|
||||
|
||||
private lateinit var glimpPlugin: GlimpPlugin;
|
||||
|
||||
@Mock lateinit var aapsLogger: AAPSLogger
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
glimpPlugin = GlimpPlugin(aapsLogger)
|
||||
}
|
||||
|
||||
@Test fun advancedFilteringSupported() {
|
||||
Assert.assertEquals(false, glimpPlugin.advancedFilteringSupported())
|
||||
}
|
||||
}
|
|
@ -6,15 +6,15 @@ import org.junit.runner.RunWith;
|
|||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
public class SourceXdripPluginTest {
|
||||
public class MM640GPluginTest {
|
||||
|
||||
@Test
|
||||
public void getPlugin() {
|
||||
Assert.assertNotEquals(null, SourceXdripPlugin.getPlugin());
|
||||
Assert.assertNotEquals(null, MM640gPlugin.getPlugin());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void advancedFilteringSupported() {
|
||||
Assert.assertEquals(false, SourceXdripPlugin.getPlugin().advancedFilteringSupported());
|
||||
Assert.assertEquals(false, MM640gPlugin.getPlugin().advancedFilteringSupported());
|
||||
}
|
||||
}
|
|
@ -6,15 +6,15 @@ import org.junit.runner.RunWith;
|
|||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
public class SourceGlimpPluginTest {
|
||||
public class NSClientPluginTest {
|
||||
|
||||
@Test
|
||||
public void getPlugin() {
|
||||
Assert.assertNotEquals(null, SourceGlimpPlugin.getPlugin());
|
||||
Assert.assertNotEquals(null, NSClientPlugin.getPlugin());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void advancedFilteringSupported() {
|
||||
Assert.assertEquals(false, SourceGlimpPlugin.getPlugin().advancedFilteringSupported());
|
||||
Assert.assertEquals(false, NSClientPlugin.getPlugin().advancedFilteringSupported());
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.source;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
public class SourceNSClientPluginTest {
|
||||
|
||||
@Test
|
||||
public void getPlugin() {
|
||||
Assert.assertNotEquals(null, SourceNSClientPlugin.getPlugin());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void advancedFilteringSupported() {
|
||||
Assert.assertEquals(false, SourceNSClientPlugin.getPlugin().advancedFilteringSupported());
|
||||
}
|
||||
}
|
|
@ -6,15 +6,15 @@ import org.junit.runner.RunWith;
|
|||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
public class SourceMM640gPluginTest {
|
||||
public class XdripPluginTest {
|
||||
|
||||
@Test
|
||||
public void getPlugin() {
|
||||
Assert.assertNotEquals(null, SourceMM640gPlugin.getPlugin());
|
||||
Assert.assertNotEquals(null, XdripPlugin.getPlugin());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void advancedFilteringSupported() {
|
||||
Assert.assertEquals(false, SourceMM640gPlugin.getPlugin().advancedFilteringSupported());
|
||||
Assert.assertEquals(false, XdripPlugin.getPlugin().advancedFilteringSupported());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue