Singleton & Crashlytics logging part 2

This commit is contained in:
Milos Kozak 2017-10-07 17:48:03 +02:00
parent 0e763724f6
commit d6fb912ff9
36 changed files with 388 additions and 351 deletions

View file

@ -42,13 +42,12 @@ import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugi
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
import info.nightscout.androidaps.plugins.Persistentnotification.PersistentNotificationPlugin;
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfileFragment;
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfileFragment;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfileFragment;
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfileFragment;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfilePlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
@ -60,12 +59,12 @@ import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorFragment;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin;
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin;
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.androidaps.plugins.Wear.WearFragment;
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
import info.nightscout.androidaps.receivers.DataReceiver;
@ -131,12 +130,12 @@ public class MainApp extends Application {
if (Config.LOOPENABLED) pluginsList.add(LoopPlugin.getPlugin());
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSMAPlugin.getPlugin());
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSAMAPlugin.getPlugin());
pluginsList.add(NSProfileFragment.getPlugin());
if (Config.OTHERPROFILES) pluginsList.add(SimpleProfileFragment.getPlugin());
pluginsList.add(NSProfilePlugin.getPlugin());
if (Config.OTHERPROFILES) pluginsList.add(SimpleProfilePlugin.getPlugin());
if (Config.OTHERPROFILES) pluginsList.add(LocalProfileFragment.getPlugin());
if (Config.OTHERPROFILES)
pluginsList.add(CircadianPercentageProfileFragment.getPlugin());
pluginsList.add(TreatmentsFragment.getPlugin());
pluginsList.add(TreatmentsPlugin.getPlugin());
if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin());
if (Config.APS) pluginsList.add(ObjectivesPlugin.getPlugin());
if (!Config.NSCLIENT)
@ -146,7 +145,7 @@ public class MainApp extends Application {
pluginsList.add(SourceMM640gPlugin.getPlugin());
if (!Config.NSCLIENT)
pluginsList.add(SourceGlimpPlugin.getPlugin());
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorFragment.getPlugin());
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorPlugin.getPlugin());
if (Config.WEAR) pluginsList.add(WearFragment.getPlugin(this));
pluginsList.add(StatuslinePlugin.getPlugin(this));

View file

@ -10,8 +10,8 @@ import info.nightscout.androidaps.interfaces.PluginBase;
public class ActionsPlugin implements PluginBase {
boolean fragmentEnabled = true;
boolean fragmentVisible = true;
private boolean fragmentEnabled = true;
private boolean fragmentVisible = true;
@Override
public int getType() {

View file

@ -7,8 +7,8 @@ import info.nightscout.androidaps.interfaces.PluginBase;
public class CareportalPlugin implements PluginBase {
boolean fragmentEnabled = true;
boolean fragmentVisible = true;
private boolean fragmentEnabled = true;
private boolean fragmentVisible = true;
@Override
public int getType() {

View file

@ -14,8 +14,8 @@ import info.nightscout.androidaps.interfaces.PluginBase;
public class InsulinFastactingPlugin implements PluginBase, InsulinInterface {
private static boolean fragmentEnabled = true;
private static boolean fragmentVisible = false;
private boolean fragmentEnabled = true;
private boolean fragmentVisible = false;
private static InsulinFastactingPlugin plugin = null;

View file

@ -14,8 +14,8 @@ import info.nightscout.androidaps.interfaces.PluginBase;
public class InsulinFastactingProlongedPlugin implements PluginBase, InsulinInterface {
private static boolean fragmentEnabled = false;
private static boolean fragmentVisible = false;
private boolean fragmentEnabled = false;
private boolean fragmentVisible = false;
private static InsulinFastactingProlongedPlugin plugin = null;

View file

@ -10,8 +10,8 @@ import info.nightscout.utils.SP;
public class InsulinOrefFreePeakPlugin extends InsulinOrefBasePlugin {
private static boolean fragmentEnabled = false;
private static boolean fragmentVisible = false;
private boolean fragmentEnabled = false;
private boolean fragmentVisible = false;
private static InsulinOrefFreePeakPlugin plugin = null;

View file

@ -9,8 +9,8 @@ import info.nightscout.androidaps.R;
public class InsulinOrefRapidActingPlugin extends InsulinOrefBasePlugin {
private static boolean fragmentEnabled = false;
private static boolean fragmentVisible = false;
private boolean fragmentEnabled = false;
private boolean fragmentVisible = false;
private static InsulinOrefRapidActingPlugin plugin = null;

View file

@ -9,8 +9,8 @@ import info.nightscout.androidaps.R;
public class InsulinOrefUltraRapidActingPlugin extends InsulinOrefBasePlugin {
private static boolean fragmentEnabled = false;
private static boolean fragmentVisible = false;
private boolean fragmentEnabled = false;
private boolean fragmentVisible = false;
private static InsulinOrefUltraRapidActingPlugin plugin = null;

View file

@ -39,7 +39,7 @@ import info.nightscout.utils.DecimalFormatter;
public class PersistentNotificationPlugin implements PluginBase {
private static final int ONGOING_NOTIFICATION_ID = 4711;
static boolean fragmentEnabled = true;
private boolean fragmentEnabled = true;
private final Context ctx;
public PersistentNotificationPlugin(Context ctx) {

View file

@ -35,8 +35,8 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
public static final String SETTINGS_PREFIX = "CircadianPercentageProfile";
private static Logger log = LoggerFactory.getLogger(CircadianPercentageProfilePlugin.class);
private static boolean fragmentEnabled = false;
private static boolean fragmentVisible = true;
private boolean fragmentEnabled = false;
private boolean fragmentVisible = true;
private static ProfileStore convertedProfile = null;
private static String convertedProfileName = null;

View file

@ -24,8 +24,8 @@ import info.nightscout.utils.SP;
public class LocalProfilePlugin implements PluginBase, ProfileInterface {
private static Logger log = LoggerFactory.getLogger(LocalProfilePlugin.class);
private static boolean fragmentEnabled = false;
private static boolean fragmentVisible = true;
private boolean fragmentEnabled = false;
private boolean fragmentVisible = true;
private static ProfileStore convertedProfile = null;
private static String convertedProfileName = null;

View file

@ -2,12 +2,12 @@ package info.nightscout.androidaps.plugins.ProfileNS;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import com.squareup.otto.Subscribe;
import info.nightscout.androidaps.MainApp;
@ -18,12 +18,6 @@ import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateG
import info.nightscout.utils.DecimalFormatter;
public class NSProfileFragment extends SubscriberFragment {
private static NSProfilePlugin nsProfilePlugin = new NSProfilePlugin();
public static NSProfilePlugin getPlugin() {
return nsProfilePlugin;
}
private TextView noProfile;
private TextView units;
private TextView dia;
@ -36,19 +30,25 @@ public class NSProfileFragment extends SubscriberFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.nsprofileviewer_fragment, container, false);
try {
View layout = inflater.inflate(R.layout.nsprofileviewer_fragment, container, false);
noProfile = (TextView) layout.findViewById(R.id.profileview_noprofile);
units = (TextView) layout.findViewById(R.id.profileview_units);
dia = (TextView) layout.findViewById(R.id.profileview_dia);
activeProfile = (TextView) layout.findViewById(R.id.profileview_activeprofile);
ic = (TextView) layout.findViewById(R.id.profileview_ic);
isf = (TextView) layout.findViewById(R.id.profileview_isf);
basal = (TextView) layout.findViewById(R.id.profileview_basal);
target = (TextView) layout.findViewById(R.id.profileview_target);
noProfile = (TextView) layout.findViewById(R.id.profileview_noprofile);
units = (TextView) layout.findViewById(R.id.profileview_units);
dia = (TextView) layout.findViewById(R.id.profileview_dia);
activeProfile = (TextView) layout.findViewById(R.id.profileview_activeprofile);
ic = (TextView) layout.findViewById(R.id.profileview_ic);
isf = (TextView) layout.findViewById(R.id.profileview_isf);
basal = (TextView) layout.findViewById(R.id.profileview_basal);
target = (TextView) layout.findViewById(R.id.profileview_target);
updateGUI();
return layout;
updateGUI();
return layout;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@Subscribe

View file

@ -29,17 +29,25 @@ import info.nightscout.utils.SP;
public class NSProfilePlugin implements PluginBase, ProfileInterface {
private static Logger log = LoggerFactory.getLogger(NSProfilePlugin.class);
private static NSProfilePlugin nsProfilePlugin;
public static NSProfilePlugin getPlugin() {
if (nsProfilePlugin == null)
nsProfilePlugin = new NSProfilePlugin();
return nsProfilePlugin;
}
@Override
public String getFragmentClass() {
return NSProfileFragment.class.getName();
}
static boolean fragmentEnabled = true;
static boolean fragmentVisible = true;
private boolean fragmentEnabled = true;
private boolean fragmentVisible = true;
static ProfileStore profile = null;
private static ProfileStore profile = null;
public NSProfilePlugin() {
private NSProfilePlugin() {
MainApp.bus().register(this);
loadNSProfile();

View file

@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.ProfileSimple;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
@ -13,6 +12,7 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import com.crashlytics.android.Crashlytics;
import com.squareup.otto.Subscribe;
import org.slf4j.Logger;
@ -31,12 +31,6 @@ import info.nightscout.utils.SafeParse;
public class SimpleProfileFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(SimpleProfileFragment.class);
private static SimpleProfilePlugin simpleProfilePlugin = new SimpleProfilePlugin();
public static SimpleProfilePlugin getPlugin() {
return simpleProfilePlugin;
}
EditText diaView;
RadioButton mgdlView;
RadioButton mmolView;
@ -50,98 +44,104 @@ public class SimpleProfileFragment extends SubscriberFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View layout = inflater.inflate(R.layout.simpleprofile_fragment, container, false);
diaView = (EditText) layout.findViewById(R.id.simpleprofile_dia);
mgdlView = (RadioButton) layout.findViewById(R.id.simpleprofile_mgdl);
mmolView = (RadioButton) layout.findViewById(R.id.simpleprofile_mmol);
icView = (EditText) layout.findViewById(R.id.simpleprofile_ic);
isfView = (EditText) layout.findViewById(R.id.simpleprofile_isf);
basalView = (EditText) layout.findViewById(R.id.simpleprofile_basalrate);
targetlowView = (EditText) layout.findViewById(R.id.simpleprofile_targetlow);
targethighView = (EditText) layout.findViewById(R.id.simpleprofile_targethigh);
profileswitchButton = (Button) layout.findViewById(R.id.simpleprofile_profileswitch);
try {
View layout = inflater.inflate(R.layout.simpleprofile_fragment, container, false);
diaView = (EditText) layout.findViewById(R.id.simpleprofile_dia);
mgdlView = (RadioButton) layout.findViewById(R.id.simpleprofile_mgdl);
mmolView = (RadioButton) layout.findViewById(R.id.simpleprofile_mmol);
icView = (EditText) layout.findViewById(R.id.simpleprofile_ic);
isfView = (EditText) layout.findViewById(R.id.simpleprofile_isf);
basalView = (EditText) layout.findViewById(R.id.simpleprofile_basalrate);
targetlowView = (EditText) layout.findViewById(R.id.simpleprofile_targetlow);
targethighView = (EditText) layout.findViewById(R.id.simpleprofile_targethigh);
profileswitchButton = (Button) layout.findViewById(R.id.simpleprofile_profileswitch);
PumpInterface pump = MainApp.getConfigBuilder();
if (!pump.getPumpDescription().isTempBasalCapable) {
layout.findViewById(R.id.simpleprofile_basalrate).setVisibility(View.GONE);
layout.findViewById(R.id.simpleprofile_basalrate_label).setVisibility(View.GONE);
PumpInterface pump = MainApp.getConfigBuilder();
if (!pump.getPumpDescription().isTempBasalCapable) {
layout.findViewById(R.id.simpleprofile_basalrate).setVisibility(View.GONE);
layout.findViewById(R.id.simpleprofile_basalrate_label).setVisibility(View.GONE);
}
updateGUI();
mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
diaView.setText(SimpleProfilePlugin.getPlugin().dia.toString());
icView.setText(SimpleProfilePlugin.getPlugin().ic.toString());
isfView.setText(SimpleProfilePlugin.getPlugin().isf.toString());
basalView.setText(SimpleProfilePlugin.getPlugin().basal.toString());
targetlowView.setText(SimpleProfilePlugin.getPlugin().targetLow.toString());
targethighView.setText(SimpleProfilePlugin.getPlugin().targetHigh.toString());
mgdlView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SimpleProfilePlugin.getPlugin().mgdl = mgdlView.isChecked();
SimpleProfilePlugin.getPlugin().mmol = !SimpleProfilePlugin.getPlugin().mgdl;
mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
SimpleProfilePlugin.getPlugin().storeSettings();
}
});
mmolView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SimpleProfilePlugin.getPlugin().mmol = mmolView.isChecked();
SimpleProfilePlugin.getPlugin().mgdl = !SimpleProfilePlugin.getPlugin().mmol;
mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
SimpleProfilePlugin.getPlugin().storeSettings();
}
});
profileswitchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
}
});
TextWatcher textWatch = new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
SimpleProfilePlugin.getPlugin().dia = SafeParse.stringToDouble(diaView.getText().toString());
SimpleProfilePlugin.getPlugin().ic = SafeParse.stringToDouble(icView.getText().toString());
SimpleProfilePlugin.getPlugin().isf = SafeParse.stringToDouble(isfView.getText().toString());
SimpleProfilePlugin.getPlugin().basal = SafeParse.stringToDouble(basalView.getText().toString());
SimpleProfilePlugin.getPlugin().targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
SimpleProfilePlugin.getPlugin().targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
SimpleProfilePlugin.getPlugin().storeSettings();
}
};
diaView.addTextChangedListener(textWatch);
icView.addTextChangedListener(textWatch);
isfView.addTextChangedListener(textWatch);
basalView.addTextChangedListener(textWatch);
targetlowView.addTextChangedListener(textWatch);
targethighView.addTextChangedListener(textWatch);
updateGUI();
return layout;
} catch (Exception e) {
Crashlytics.logException(e);
}
updateGUI();
mgdlView.setChecked(simpleProfilePlugin.mgdl);
mmolView.setChecked(simpleProfilePlugin.mmol);
diaView.setText(simpleProfilePlugin.dia.toString());
icView.setText(simpleProfilePlugin.ic.toString());
isfView.setText(simpleProfilePlugin.isf.toString());
basalView.setText(simpleProfilePlugin.basal.toString());
targetlowView.setText(simpleProfilePlugin.targetLow.toString());
targethighView.setText(simpleProfilePlugin.targetHigh.toString());
mgdlView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
simpleProfilePlugin.mgdl = mgdlView.isChecked();
simpleProfilePlugin.mmol = !simpleProfilePlugin.mgdl;
mmolView.setChecked(simpleProfilePlugin.mmol);
simpleProfilePlugin.storeSettings();
}
});
mmolView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
simpleProfilePlugin.mmol = mmolView.isChecked();
simpleProfilePlugin.mgdl = !simpleProfilePlugin.mmol;
mgdlView.setChecked(simpleProfilePlugin.mgdl);
simpleProfilePlugin.storeSettings();
}
});
profileswitchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.profileswitch;
profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
}
});
TextWatcher textWatch = new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
simpleProfilePlugin.dia = SafeParse.stringToDouble(diaView.getText().toString());
simpleProfilePlugin.ic = SafeParse.stringToDouble(icView.getText().toString());
simpleProfilePlugin.isf = SafeParse.stringToDouble(isfView.getText().toString());
simpleProfilePlugin.basal = SafeParse.stringToDouble(basalView.getText().toString());
simpleProfilePlugin.targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
simpleProfilePlugin.targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
simpleProfilePlugin.storeSettings();
}
};
diaView.addTextChangedListener(textWatch);
icView.addTextChangedListener(textWatch);
isfView.addTextChangedListener(textWatch);
basalView.addTextChangedListener(textWatch);
targetlowView.addTextChangedListener(textWatch);
targethighView.addTextChangedListener(textWatch);
updateGUI();
return layout;
return null;
}
@Subscribe

View file

@ -24,8 +24,16 @@ import info.nightscout.utils.SP;
public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
private static Logger log = LoggerFactory.getLogger(SimpleProfilePlugin.class);
private static boolean fragmentEnabled = false;
private static boolean fragmentVisible = true;
private static SimpleProfilePlugin simpleProfilePlugin;
public static SimpleProfilePlugin getPlugin() {
if (simpleProfilePlugin == null)
simpleProfilePlugin = new SimpleProfilePlugin();
return simpleProfilePlugin;
}
private boolean fragmentEnabled = false;
private boolean fragmentVisible = true;
private static ProfileStore convertedProfile = null;
@ -38,7 +46,7 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
Double targetLow;
Double targetHigh;
public SimpleProfilePlugin() {
private SimpleProfilePlugin() {
loadSettings();
}
@ -117,7 +125,7 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
editor.putString("SimpleProfile" + "targetlow", targetLow.toString());
editor.putString("SimpleProfile" + "targethigh", targetHigh.toString());
editor.commit();
editor.apply();
createConvertedProfile();
}
@ -174,7 +182,7 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
"created_at": "2016-06-16T08:34:41.256Z"
}
*/
void createConvertedProfile() {
private void createConvertedProfile() {
JSONObject json = new JSONObject();
JSONObject store = new JSONObject();
JSONObject profile = new JSONObject();

View file

@ -7,7 +7,6 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
@ -15,13 +14,12 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import com.squareup.otto.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventExtendedBolusChange;
@ -89,63 +87,69 @@ public class DanaRFragment extends SubscriberFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.danar_fragment, container, false);
btConnectionView = (TextView) view.findViewById(R.id.danar_btconnection);
lastConnectionView = (TextView) view.findViewById(R.id.danar_lastconnection);
lastBolusView = (TextView) view.findViewById(R.id.danar_lastbolus);
dailyUnitsView = (TextView) view.findViewById(R.id.danar_dailyunits);
basaBasalRateView = (TextView) view.findViewById(R.id.danar_basabasalrate);
tempBasalView = (TextView) view.findViewById(R.id.danar_tempbasal);
extendedBolusView = (TextView) view.findViewById(R.id.danar_extendedbolus);
batteryView = (TextView) view.findViewById(R.id.danar_battery);
reservoirView = (TextView) view.findViewById(R.id.danar_reservoir);
iobView = (TextView) view.findViewById(R.id.danar_iob);
firmwareView = (TextView) view.findViewById(R.id.danar_firmware);
viewProfileButton = (Button) view.findViewById(R.id.danar_viewprofile);
historyButton = (Button) view.findViewById(R.id.danar_history);
statsButton = (Button) view.findViewById(R.id.danar_stats);
basalStepView = (TextView) view.findViewById(R.id.danar_basalstep);
bolusStepView = (TextView) view.findViewById(R.id.danar_bolusstep);
try {
View view = inflater.inflate(R.layout.danar_fragment, container, false);
btConnectionView = (TextView) view.findViewById(R.id.danar_btconnection);
lastConnectionView = (TextView) view.findViewById(R.id.danar_lastconnection);
lastBolusView = (TextView) view.findViewById(R.id.danar_lastbolus);
dailyUnitsView = (TextView) view.findViewById(R.id.danar_dailyunits);
basaBasalRateView = (TextView) view.findViewById(R.id.danar_basabasalrate);
tempBasalView = (TextView) view.findViewById(R.id.danar_tempbasal);
extendedBolusView = (TextView) view.findViewById(R.id.danar_extendedbolus);
batteryView = (TextView) view.findViewById(R.id.danar_battery);
reservoirView = (TextView) view.findViewById(R.id.danar_reservoir);
iobView = (TextView) view.findViewById(R.id.danar_iob);
firmwareView = (TextView) view.findViewById(R.id.danar_firmware);
viewProfileButton = (Button) view.findViewById(R.id.danar_viewprofile);
historyButton = (Button) view.findViewById(R.id.danar_history);
statsButton = (Button) view.findViewById(R.id.danar_stats);
basalStepView = (TextView) view.findViewById(R.id.danar_basalstep);
bolusStepView = (TextView) view.findViewById(R.id.danar_bolusstep);
viewProfileButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentManager manager = getFragmentManager();
ProfileViewDialog profileViewDialog = new ProfileViewDialog();
profileViewDialog.show(manager, "ProfileViewDialog");
}
});
viewProfileButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentManager manager = getFragmentManager();
ProfileViewDialog profileViewDialog = new ProfileViewDialog();
profileViewDialog.show(manager, "ProfileViewDialog");
}
});
historyButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getContext(), DanaRHistoryActivity.class));
}
});
historyButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getContext(), DanaRHistoryActivity.class));
}
});
statsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getContext(), DanaRStatsActivity.class));
}
});
statsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getContext(), DanaRStatsActivity.class));
}
});
btConnectionView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sHandler.post(new Runnable() {
@Override
public void run() {
MainApp.getConfigBuilder().refreshDataFromPump("Connect request from GUI");
btConnectionView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
sHandler.post(new Runnable() {
@Override
public void run() {
MainApp.getConfigBuilder().refreshDataFromPump("Connect request from GUI");
}
}
}
);
}
});
);
}
});
updateGUI();
return view;
updateGUI();
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@Subscribe

View file

@ -59,11 +59,11 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
return DanaRFragment.class.getName();
}
static boolean fragmentPumpEnabled = false;
static boolean fragmentProfileEnabled = false;
static boolean fragmentPumpVisible = true;
private static boolean fragmentPumpEnabled = false;
private static boolean fragmentProfileEnabled = false;
private static boolean fragmentPumpVisible = true;
public static DanaRExecutionService sExecutionService;
private static DanaRExecutionService sExecutionService;
private static DanaRPump pump = DanaRPump.getInstance();
@ -199,22 +199,22 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
@Override
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
if (type == PluginBase.PROFILE)
this.fragmentProfileEnabled = fragmentEnabled;
fragmentProfileEnabled = fragmentEnabled;
else if (type == PluginBase.PUMP)
this.fragmentPumpEnabled = fragmentEnabled;
fragmentPumpEnabled = fragmentEnabled;
// if pump profile was enabled need to switch to another too
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
if (type == PluginBase.PUMP && !fragmentEnabled && fragmentProfileEnabled) {
setFragmentEnabled(PluginBase.PROFILE, false);
setFragmentVisible(PluginBase.PROFILE, false);
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentEnabled(PluginBase.PROFILE, true);
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentVisible(PluginBase.PROFILE, true);
NSProfilePlugin.getPlugin().setFragmentEnabled(PluginBase.PROFILE, true);
NSProfilePlugin.getPlugin().setFragmentVisible(PluginBase.PROFILE, true);
}
}
@Override
public void setFragmentVisible(int type, boolean fragmentVisible) {
if (type == PluginBase.PUMP)
this.fragmentPumpVisible = fragmentVisible;
fragmentPumpVisible = fragmentVisible;
}
@Override

View file

@ -61,15 +61,15 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
return DanaRFragment.class.getName();
}
static boolean fragmentPumpEnabled = false;
static boolean fragmentProfileEnabled = false;
static boolean fragmentPumpVisible = true;
private boolean fragmentPumpEnabled = false;
private boolean fragmentProfileEnabled = false;
private boolean fragmentPumpVisible = true;
public static DanaRKoreanExecutionService sExecutionService;
private static DanaRKoreanExecutionService sExecutionService;
private static DanaRPump pump = DanaRPump.getInstance();
private static boolean useExtendedBoluses = false;
private DanaRPump pump = DanaRPump.getInstance();
private boolean useExtendedBoluses = false;
private static DanaRKoreanPlugin plugin = null;
@ -208,8 +208,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
setFragmentEnabled(PluginBase.PROFILE, false);
setFragmentVisible(PluginBase.PROFILE, false);
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentEnabled(PluginBase.PROFILE, true);
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentVisible(PluginBase.PROFILE, true);
NSProfilePlugin.getPlugin().setFragmentEnabled(PluginBase.PROFILE, true);
NSProfilePlugin.getPlugin().setFragmentVisible(PluginBase.PROFILE, true);
}
}

View file

@ -60,11 +60,11 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
return DanaRFragment.class.getName();
}
static boolean fragmentPumpEnabled = false;
static boolean fragmentProfileEnabled = false;
static boolean fragmentPumpVisible = false;
private boolean fragmentPumpEnabled = false;
private boolean fragmentProfileEnabled = false;
private boolean fragmentPumpVisible = false;
public static DanaRv2ExecutionService sExecutionService;
private static DanaRv2ExecutionService sExecutionService;
private static DanaRv2Plugin plugin = null;
@ -77,9 +77,9 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
private static DanaRPump pump = DanaRPump.getInstance();
public static PumpDescription pumpDescription = new PumpDescription();
private static PumpDescription pumpDescription = new PumpDescription();
public DanaRv2Plugin() {
private DanaRv2Plugin() {
Context context = MainApp.instance().getApplicationContext();
Intent intent = new Intent(context, DanaRv2ExecutionService.class);
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
@ -192,8 +192,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
setFragmentEnabled(PluginBase.PROFILE, false);
setFragmentVisible(PluginBase.PROFILE, false);
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentEnabled(PluginBase.PROFILE, true);
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentVisible(PluginBase.PROFILE, true);
NSProfilePlugin.getPlugin().setFragmentEnabled(PluginBase.PROFILE, true);
NSProfilePlugin.getPlugin().setFragmentVisible(PluginBase.PROFILE, true);
}
}

View file

@ -25,12 +25,12 @@ import info.nightscout.utils.DateUtil;
public class MDIPlugin implements PluginBase, PumpInterface {
private static Logger log = LoggerFactory.getLogger(MDIPlugin.class);
boolean fragmentEnabled = false;
boolean fragmentVisible = false;
private boolean fragmentEnabled = false;
private boolean fragmentVisible = false;
PumpDescription pumpDescription = new PumpDescription();
private PumpDescription pumpDescription = new PumpDescription();
static MDIPlugin plugin = null;
private static MDIPlugin plugin = null;
public static MDIPlugin getPlugin() {
if (plugin == null)
@ -38,7 +38,7 @@ public class MDIPlugin implements PluginBase, PumpInterface {
return plugin;
}
public MDIPlugin() {
private MDIPlugin() {
pumpDescription.isBolusCapable = true;
pumpDescription.bolusStep = 0.5d;

View file

@ -10,6 +10,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import com.squareup.otto.Subscribe;
import org.slf4j.Logger;
@ -50,14 +51,20 @@ public class VirtualPumpFragment extends SubscriberFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.vitualpump_fragment, container, false);
basaBasalRateView = (TextView) view.findViewById(R.id.virtualpump_basabasalrate);
tempBasalView = (TextView) view.findViewById(R.id.virtualpump_tempbasal);
extendedBolusView = (TextView) view.findViewById(R.id.virtualpump_extendedbolus);
batteryView = (TextView) view.findViewById(R.id.virtualpump_battery);
reservoirView = (TextView) view.findViewById(R.id.virtualpump_reservoir);
try {
View view = inflater.inflate(R.layout.vitualpump_fragment, container, false);
basaBasalRateView = (TextView) view.findViewById(R.id.virtualpump_basabasalrate);
tempBasalView = (TextView) view.findViewById(R.id.virtualpump_tempbasal);
extendedBolusView = (TextView) view.findViewById(R.id.virtualpump_extendedbolus);
batteryView = (TextView) view.findViewById(R.id.virtualpump_battery);
reservoirView = (TextView) view.findViewById(R.id.virtualpump_reservoir);
return view;
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@Subscribe

View file

@ -39,19 +39,19 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
public static Double defaultBasalValue = 0.2d;
public static Integer batteryPercent = 50;
public static Integer reservoirInUnits = 50;
static Integer batteryPercent = 50;
static Integer reservoirInUnits = 50;
Date lastDataTime = new Date(0);
private Date lastDataTime = new Date(0);
boolean fragmentEnabled = true;
boolean fragmentVisible = true;
private boolean fragmentEnabled = true;
private boolean fragmentVisible = true;
private static boolean fromNSAreCommingFakedExtendedBoluses = false;
PumpDescription pumpDescription = new PumpDescription();
private PumpDescription pumpDescription = new PumpDescription();
static void loadFakingStatus() {
private static void loadFakingStatus() {
fromNSAreCommingFakedExtendedBoluses = SP.getBoolean("fromNSAreCommingFakedExtendedBoluses", false);
}
@ -64,7 +64,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
return fromNSAreCommingFakedExtendedBoluses;
}
static VirtualPumpPlugin instance = null;
private static VirtualPumpPlugin instance = null;
public static VirtualPumpPlugin getInstance() {
loadFakingStatus();
if (instance == null)
@ -72,7 +72,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
return instance;
}
public VirtualPumpPlugin() {
private VirtualPumpPlugin() {
pumpDescription.isBolusCapable = true;
pumpDescription.bolusStep = 0.1d;

View file

@ -30,8 +30,8 @@ import info.nightscout.utils.SafeParse;
public class SensitivityAAPSPlugin implements PluginBase, SensitivityInterface{
private static Logger log = LoggerFactory.getLogger(SensitivityAAPSPlugin.class);
private static boolean fragmentEnabled = true;
private static boolean fragmentVisible = false;
private boolean fragmentEnabled = true;
private boolean fragmentVisible = false;
static SensitivityAAPSPlugin plugin = null;

View file

@ -28,8 +28,8 @@ import info.nightscout.utils.SafeParse;
public class SensitivityOref0Plugin implements PluginBase, SensitivityInterface {
private static Logger log = LoggerFactory.getLogger(IobCobCalculatorPlugin.class);
private static boolean fragmentEnabled = true;
private static boolean fragmentVisible = false;
private boolean fragmentEnabled = true;
private boolean fragmentVisible = false;
static SensitivityOref0Plugin plugin = null;

View file

@ -29,8 +29,8 @@ import info.nightscout.utils.SafeParse;
public class SensitivityWeightedAveragePlugin implements PluginBase, SensitivityInterface {
private static Logger log = LoggerFactory.getLogger(SensitivityWeightedAveragePlugin.class);
private static boolean fragmentEnabled = true;
private static boolean fragmentVisible = false;
private boolean fragmentEnabled = true;
private boolean fragmentVisible = false;
static SensitivityWeightedAveragePlugin plugin = null;

View file

@ -10,6 +10,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import com.squareup.otto.Subscribe;
import org.slf4j.Logger;
@ -18,7 +19,6 @@ import org.slf4j.LoggerFactory;
import java.util.Collections;
import java.util.Comparator;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui;
@ -30,16 +30,6 @@ import info.nightscout.utils.DateUtil;
public class SmsCommunicatorFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(SmsCommunicatorFragment.class);
private static SmsCommunicatorPlugin smsCommunicatorPlugin;
public static SmsCommunicatorPlugin getPlugin() {
if(smsCommunicatorPlugin==null){
smsCommunicatorPlugin = new SmsCommunicatorPlugin();
}
return smsCommunicatorPlugin;
}
TextView logView;
public SmsCommunicatorFragment() {
@ -49,12 +39,18 @@ public class SmsCommunicatorFragment extends SubscriberFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.smscommunicator_fragment, container, false);
try {
View view = inflater.inflate(R.layout.smscommunicator_fragment, container, false);
logView = (TextView) view.findViewById(R.id.smscommunicator_log);
logView = (TextView) view.findViewById(R.id.smscommunicator_log);
updateGUI();
return view;
updateGUI();
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@Subscribe
@ -75,14 +71,14 @@ public class SmsCommunicatorFragment extends SubscriberFragment {
return (int) (object1.date.getTime() - object2.date.getTime());
}
}
Collections.sort(getPlugin().messages, new CustomComparator());
Collections.sort(SmsCommunicatorPlugin.getPlugin().messages, new CustomComparator());
int messagesToShow = 40;
int start = Math.max(0, getPlugin().messages.size() - messagesToShow);
int start = Math.max(0, SmsCommunicatorPlugin.getPlugin().messages.size() - messagesToShow);
String logText = "";
for (int x = start; x < getPlugin().messages.size(); x++) {
SmsCommunicatorPlugin.Sms sms = getPlugin().messages.get(x);
for (int x = start; x < SmsCommunicatorPlugin.getPlugin().messages.size(); x++) {
SmsCommunicatorPlugin.Sms sms = SmsCommunicatorPlugin.getPlugin().messages.get(x);
if (sms.received) {
logText += DateUtil.timeString(sms.date) + " &lt;&lt;&lt; " + (sms.processed ? "" : "") + sms.phoneNumber + " <b>" + sms.text + "</b><br>";
} else if (sms.sent) {

View file

@ -53,12 +53,22 @@ import info.nightscout.utils.XdripCalibrations;
public class SmsCommunicatorPlugin implements PluginBase {
private static Logger log = LoggerFactory.getLogger(SmsCommunicatorPlugin.class);
private static boolean fragmentEnabled = false;
private static boolean fragmentVisible = true;
private static SmsCommunicatorPlugin smsCommunicatorPlugin;
public static SmsCommunicatorPlugin getPlugin() {
if (smsCommunicatorPlugin == null) {
smsCommunicatorPlugin = new SmsCommunicatorPlugin();
}
return smsCommunicatorPlugin;
}
private boolean fragmentEnabled = false;
private boolean fragmentVisible = true;
private final long CONFIRM_TIMEOUT = 5 * 60 * 1000L;
private List<String> allowedNumbers = new ArrayList<String>();
private List<String> allowedNumbers = new ArrayList<>();
class Sms {
String phoneNumber;
@ -110,7 +120,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
ArrayList<Sms> messages = new ArrayList<>();
public SmsCommunicatorPlugin() {
private SmsCommunicatorPlugin() {
MainApp.bus().register(this);
processSettings(null);
}
@ -274,8 +284,8 @@ public class SmsCommunicatorPlugin implements PluginBase {
loopPlugin.setFragmentEnabled(PluginBase.LOOP, false);
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_STOP"));
reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled)+ " " +
MainApp.sResources.getString(result.success?R.string.smscommunicator_tempbasalcanceled:R.string.smscommunicator_tempbasalcancelfailed);
reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled) + " " +
MainApp.sResources.getString(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
}
receivedSms.processed = true;
@ -539,7 +549,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60);
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
reply = MainApp.sResources.getString(R.string.smscommunicator_loopsuspended) + " " +
MainApp.sResources.getString(result.success?R.string.smscommunicator_tempbasalcanceled:R.string.smscommunicator_tempbasalcancelfailed);
MainApp.sResources.getString(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
} else {
sendSMS(new Sms(receivedSms.phoneNumber, MainApp.sResources.getString(R.string.smscommunicator_unknowncommand), new Date()));

View file

@ -9,9 +9,9 @@ import info.nightscout.androidaps.interfaces.PluginBase;
* Created by mike on 05.08.2016.
*/
public class SourceGlimpPlugin implements PluginBase, BgSourceInterface {
boolean fragmentEnabled = false;
private boolean fragmentEnabled = false;
static SourceGlimpPlugin plugin = null;
private static SourceGlimpPlugin plugin = null;
public static SourceGlimpPlugin getPlugin() {
if (plugin == null)

View file

@ -9,9 +9,9 @@ import info.nightscout.androidaps.interfaces.PluginBase;
* Created by mike on 05.08.2016.
*/
public class SourceMM640gPlugin implements PluginBase, BgSourceInterface {
boolean fragmentEnabled = false;
private boolean fragmentEnabled = false;
static SourceMM640gPlugin plugin = null;
private static SourceMM640gPlugin plugin = null;
public static SourceMM640gPlugin getPlugin() {
if (plugin == null)

View file

@ -10,9 +10,9 @@ import info.nightscout.androidaps.interfaces.PluginBase;
* Created by mike on 05.08.2016.
*/
public class SourceNSClientPlugin implements PluginBase, BgSourceInterface {
boolean fragmentEnabled = true;
private boolean fragmentEnabled = true;
static SourceNSClientPlugin plugin = null;
private static SourceNSClientPlugin plugin = null;
public static SourceNSClientPlugin getPlugin() {
if (plugin == null)

View file

@ -10,7 +10,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
*/
public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
static SourceXdripPlugin plugin = null;
private static SourceXdripPlugin plugin = null;
public static SourceXdripPlugin getPlugin() {
if (plugin == null)
@ -23,7 +23,7 @@ public class SourceXdripPlugin implements PluginBase, BgSourceInterface {
return null;
}
private static boolean fragmentEnabled = false;
private boolean fragmentEnabled = false;
@Override
public int getType() {

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps.plugins.Treatments;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
@ -9,6 +8,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -23,12 +24,6 @@ import info.nightscout.androidaps.plugins.Treatments.fragments.TreatmentsTempora
public class TreatmentsFragment extends Fragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(TreatmentsFragment.class);
private static TreatmentsPlugin treatmentsPlugin = new TreatmentsPlugin();
public static TreatmentsPlugin getPlugin() {
return treatmentsPlugin;
}
TextView treatmentsTab;
TextView extendedBolusesTab;
TextView tempBasalsTab;
@ -38,23 +33,30 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.treatments_fragment, container, false);
try {
View view = inflater.inflate(R.layout.treatments_fragment, container, false);
treatmentsTab = (TextView) view.findViewById(R.id.treatments_treatments);
extendedBolusesTab = (TextView) view.findViewById(R.id.treatments_extendedboluses);
tempBasalsTab = (TextView) view.findViewById(R.id.treatments_tempbasals);
tempTargetTab = (TextView) view.findViewById(R.id.treatments_temptargets);
profileSwitchTab = (TextView) view.findViewById(R.id.treatments_profileswitches);
treatmentsTab.setOnClickListener(this);
extendedBolusesTab.setOnClickListener(this);
tempBasalsTab.setOnClickListener(this);
tempTargetTab.setOnClickListener(this);
profileSwitchTab.setOnClickListener(this);
treatmentsTab = (TextView) view.findViewById(R.id.treatments_treatments);
extendedBolusesTab = (TextView) view.findViewById(R.id.treatments_extendedboluses);
tempBasalsTab = (TextView) view.findViewById(R.id.treatments_tempbasals);
tempTargetTab = (TextView) view.findViewById(R.id.treatments_temptargets);
profileSwitchTab = (TextView) view.findViewById(R.id.treatments_profileswitches);
treatmentsTab.setOnClickListener(this);
extendedBolusesTab.setOnClickListener(this);
tempBasalsTab.setOnClickListener(this);
tempTargetTab.setOnClickListener(this);
profileSwitchTab.setOnClickListener(this);
setFragment(new TreatmentsBolusFragment());
setBackgroundColorOnSelected(treatmentsTab);
setFragment(new TreatmentsBolusFragment());
setBackgroundColorOnSelected(treatmentsTab);
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
return view;
}
@Override

View file

@ -45,17 +45,25 @@ import info.nightscout.utils.SP;
public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
private static Logger log = LoggerFactory.getLogger(TreatmentsPlugin.class);
public static IobTotal lastTreatmentCalculation;
public static IobTotal lastTempBasalsCalculation;
private static TreatmentsPlugin treatmentsPlugin;
public static TreatmentsPlugin getPlugin() {
if (treatmentsPlugin == null)
treatmentsPlugin = new TreatmentsPlugin();
return treatmentsPlugin;
}
private IobTotal lastTreatmentCalculation;
private IobTotal lastTempBasalsCalculation;
public static List<Treatment> treatments;
private static Intervals<TemporaryBasal> tempBasals = new NonOverlappingIntervals<TemporaryBasal>();
private static Intervals<ExtendedBolus> extendedBoluses = new NonOverlappingIntervals<ExtendedBolus>();
private static Intervals<TempTarget> tempTargets = new OverlappingIntervals<TempTarget>();
private static Intervals<TemporaryBasal> tempBasals = new NonOverlappingIntervals<>();
private static Intervals<ExtendedBolus> extendedBoluses = new NonOverlappingIntervals<>();
private static Intervals<TempTarget> tempTargets = new OverlappingIntervals<>();
private static ProfileIntervals<ProfileSwitch> profiles = new ProfileIntervals<>();
private static boolean fragmentEnabled = true;
private static boolean fragmentVisible = true;
private boolean fragmentEnabled = true;
private boolean fragmentVisible = true;
@Override
public String getFragmentClass() {
@ -118,7 +126,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
return PluginBase.TREATMENT;
}
public TreatmentsPlugin() {
private TreatmentsPlugin() {
MainApp.bus().register(this);
initializeTempBasalData();
initializeTreatmentData();
@ -127,7 +135,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
initializeProfileSwitchData();
}
public static void initializeTreatmentData() {
private static void initializeTreatmentData() {
// Treatments
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
@ -135,7 +143,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
treatments = MainApp.getDbHelper().getTreatmentDataFromTime(fromMills, false);
}
public static void initializeTempBasalData() {
private static void initializeTempBasalData() {
// Treatments
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
@ -144,7 +152,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
}
public static void initializeExtendedBolusData() {
private static void initializeExtendedBolusData() {
// Treatments
double dia = MainApp.getConfigBuilder() == null ? Constants.defaultDIA : MainApp.getConfigBuilder().getProfile().getDia();
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
@ -153,12 +161,12 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
}
public void initializeTempTargetData() {
private void initializeTempTargetData() {
long fromMills = System.currentTimeMillis() - 60 * 60 * 1000L * 24;
tempTargets.reset().add(MainApp.getDbHelper().getTemptargetsDataFromTime(fromMills, false));
}
public void initializeProfileSwitchData() {
private void initializeProfileSwitchData() {
profiles.reset().add(MainApp.getDbHelper().getProfileSwitchData(false));
}
@ -211,9 +219,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override
public void updateTotalIOBTreatments() {
IobTotal total = getCalculationToTimeTreatments(System.currentTimeMillis());
lastTreatmentCalculation = total;
lastTreatmentCalculation = getCalculationToTimeTreatments(System.currentTimeMillis());
}
@Override
@ -224,7 +230,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
if (profile == null) return result;
long now = System.currentTimeMillis();
long dia_ago = now - (new Double(1.5d * profile.getDia() * 60 * 60 * 1000l)).longValue();
long dia_ago = now - (Double.valueOf(1.5d * profile.getDia() * 60 * 60 * 1000l)).longValue();
for (Treatment treatment : treatments) {
if (!treatment.isValid)
@ -340,9 +346,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override
public void updateTotalIOBTempBasals() {
IobTotal total = getCalculationToTimeTempBasals(System.currentTimeMillis());
lastTempBasalsCalculation = total;
lastTempBasalsCalculation = getCalculationToTimeTempBasals(System.currentTimeMillis());
}
@Nullable

View file

@ -6,7 +6,6 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Paint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
@ -25,18 +24,17 @@ import com.squareup.otto.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.data.Iob;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.db.Treatment;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
@ -232,10 +230,10 @@ public class TreatmentsBolusFragment extends SubscriberFragment implements View.
@Override
public void run() {
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.treatments), false);
if (TreatmentsPlugin.lastTreatmentCalculation != null)
iobTotal.setText(DecimalFormatter.to2Decimal(TreatmentsPlugin.lastTreatmentCalculation.iob) + " U");
if (TreatmentsPlugin.lastTreatmentCalculation != null)
activityTotal.setText(DecimalFormatter.to3Decimal(TreatmentsPlugin.lastTreatmentCalculation.activity) + " U");
if (TreatmentsPlugin.getPlugin().getLastCalculationTreatments() != null) {
iobTotal.setText(DecimalFormatter.to2Decimal(TreatmentsPlugin.getPlugin().getLastCalculationTreatments().iob) + " U");
activityTotal.setText(DecimalFormatter.to3Decimal(TreatmentsPlugin.getPlugin().getLastCalculationTreatments().activity) + " U");
}
}
});
}

View file

@ -29,8 +29,8 @@ import info.nightscout.utils.SP;
public class WearPlugin implements PluginBase {
static boolean fragmentEnabled = Config.WEAR;
static boolean fragmentVisible = true;
private static boolean fragmentEnabled = Config.WEAR;
private boolean fragmentVisible = true;
private static WatchUpdaterService watchUS;
private final Context ctx;

View file

@ -23,6 +23,7 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.utils.DecimalFormatter;
@ -33,16 +34,16 @@ import info.nightscout.utils.DecimalFormatter;
public class StatuslinePlugin implements PluginBase {
//broadcast related constants
public static final String EXTRA_STATUSLINE = "com.eveningoutpost.dexdrip.Extras.Statusline";
public static final String ACTION_NEW_EXTERNAL_STATUSLINE = "com.eveningoutpost.dexdrip.ExternalStatusline";
public static final String RECEIVER_PERMISSION = "com.eveningoutpost.dexdrip.permissions.RECEIVE_EXTERNAL_STATUSLINE";
private static final String EXTRA_STATUSLINE = "com.eveningoutpost.dexdrip.Extras.Statusline";
private static final String ACTION_NEW_EXTERNAL_STATUSLINE = "com.eveningoutpost.dexdrip.ExternalStatusline";
private static final String RECEIVER_PERMISSION = "com.eveningoutpost.dexdrip.permissions.RECEIVE_EXTERNAL_STATUSLINE";
static boolean fragmentEnabled = false;
private static boolean lastLoopStatus;
private boolean fragmentEnabled = false;
private boolean lastLoopStatus;
private final Context ctx;
SharedPreferences mPrefs;
private SharedPreferences mPrefs;
private static StatuslinePlugin statuslinePlugin;
@ -55,7 +56,7 @@ public class StatuslinePlugin implements PluginBase {
return statuslinePlugin;
}
StatuslinePlugin(Context ctx) {
private StatuslinePlugin(Context ctx) {
this.ctx = ctx;
this.mPrefs = PreferenceManager.getDefaultSharedPreferences(ctx);
}
@ -160,7 +161,7 @@ public class StatuslinePlugin implements PluginBase {
@NonNull
private String buildStatusString() {
String status = "";
LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
if (activeloop != null && !activeloop.isEnabled(PluginBase.LOOP)) {
status += ctx.getString(R.string.disabledloop) + "\n";
@ -239,7 +240,7 @@ public class StatuslinePlugin implements PluginBase {
//Filter events where loop is (de)activated
LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
if (activeloop == null) return;
if ((lastLoopStatus != activeloop.isEnabled(PluginBase.LOOP))) {
@ -248,7 +249,7 @@ public class StatuslinePlugin implements PluginBase {
}
public static boolean isEnabled() {
public boolean isEnabled() {
return fragmentEnabled;
}