Singleton & Crashlytics logging part 1
This commit is contained in:
parent
4db82fd275
commit
0e763724f6
17 changed files with 519 additions and 442 deletions
|
@ -29,7 +29,7 @@ import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesFragment;
|
import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Insulin.InsulinFastactingPlugin;
|
import info.nightscout.androidaps.plugins.Insulin.InsulinFastactingPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Insulin.InsulinFastactingProlongedPlugin;
|
import info.nightscout.androidaps.plugins.Insulin.InsulinFastactingProlongedPlugin;
|
||||||
|
@ -37,12 +37,13 @@ import info.nightscout.androidaps.plugins.Insulin.InsulinOrefFreePeakPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin;
|
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefUltraRapidActingPlugin;
|
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefUltraRapidActingPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopFragment;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalFragment;
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver;
|
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAFragment;
|
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAFragment;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
|
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.Persistentnotification.PersistentNotificationPlugin;
|
||||||
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfileFragment;
|
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfileFragment;
|
||||||
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfileFragment;
|
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfileFragment;
|
||||||
|
@ -110,7 +111,7 @@ public class MainApp extends Application {
|
||||||
if (pluginsList == null) {
|
if (pluginsList == null) {
|
||||||
pluginsList = new ArrayList<>();
|
pluginsList = new ArrayList<>();
|
||||||
// Register all tabs in app here
|
// Register all tabs in app here
|
||||||
pluginsList.add(OverviewFragment.getPlugin());
|
pluginsList.add(OverviewPlugin.getPlugin());
|
||||||
pluginsList.add(IobCobCalculatorPlugin.getPlugin());
|
pluginsList.add(IobCobCalculatorPlugin.getPlugin());
|
||||||
if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin());
|
if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin());
|
||||||
pluginsList.add(InsulinFastactingPlugin.getPlugin());
|
pluginsList.add(InsulinFastactingPlugin.getPlugin());
|
||||||
|
@ -127,9 +128,9 @@ public class MainApp extends Application {
|
||||||
pluginsList.add(CareportalFragment.getPlugin());
|
pluginsList.add(CareportalFragment.getPlugin());
|
||||||
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
|
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
|
||||||
if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getInstance());
|
if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getInstance());
|
||||||
if (Config.LOOPENABLED) pluginsList.add(LoopFragment.getPlugin());
|
if (Config.LOOPENABLED) pluginsList.add(LoopPlugin.getPlugin());
|
||||||
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSMAFragment.getPlugin());
|
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSMAPlugin.getPlugin());
|
||||||
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSAMAFragment.getPlugin());
|
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSAMAPlugin.getPlugin());
|
||||||
pluginsList.add(NSProfileFragment.getPlugin());
|
pluginsList.add(NSProfileFragment.getPlugin());
|
||||||
if (Config.OTHERPROFILES) pluginsList.add(SimpleProfileFragment.getPlugin());
|
if (Config.OTHERPROFILES) pluginsList.add(SimpleProfileFragment.getPlugin());
|
||||||
if (Config.OTHERPROFILES) pluginsList.add(LocalProfileFragment.getPlugin());
|
if (Config.OTHERPROFILES) pluginsList.add(LocalProfileFragment.getPlugin());
|
||||||
|
@ -137,7 +138,7 @@ public class MainApp extends Application {
|
||||||
pluginsList.add(CircadianPercentageProfileFragment.getPlugin());
|
pluginsList.add(CircadianPercentageProfileFragment.getPlugin());
|
||||||
pluginsList.add(TreatmentsFragment.getPlugin());
|
pluginsList.add(TreatmentsFragment.getPlugin());
|
||||||
if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin());
|
if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin());
|
||||||
if (Config.APS) pluginsList.add(ObjectivesFragment.getPlugin());
|
if (Config.APS) pluginsList.add(ObjectivesPlugin.getPlugin());
|
||||||
if (!Config.NSCLIENT)
|
if (!Config.NSCLIENT)
|
||||||
pluginsList.add(SourceXdripPlugin.getPlugin());
|
pluginsList.add(SourceXdripPlugin.getPlugin());
|
||||||
pluginsList.add(SourceNSClientPlugin.getPlugin());
|
pluginsList.add(SourceNSClientPlugin.getPlugin());
|
||||||
|
@ -150,7 +151,7 @@ public class MainApp extends Application {
|
||||||
if (Config.WEAR) pluginsList.add(WearFragment.getPlugin(this));
|
if (Config.WEAR) pluginsList.add(WearFragment.getPlugin(this));
|
||||||
pluginsList.add(StatuslinePlugin.getPlugin(this));
|
pluginsList.add(StatuslinePlugin.getPlugin(this));
|
||||||
pluginsList.add(new PersistentNotificationPlugin(this));
|
pluginsList.add(new PersistentNotificationPlugin(this));
|
||||||
pluginsList.add(NSClientInternalFragment.getPlugin());
|
pluginsList.add(NSClientInternalPlugin.getPlugin());
|
||||||
|
|
||||||
pluginsList.add(sConfigBuilder = ConfigBuilderFragment.getPlugin());
|
pluginsList.add(sConfigBuilder = ConfigBuilderFragment.getPlugin());
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
@ -69,26 +70,32 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.actions_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.actions_fragment, container, false);
|
||||||
|
|
||||||
profileSwitch = (Button) view.findViewById(R.id.actions_profileswitch);
|
profileSwitch = (Button) view.findViewById(R.id.actions_profileswitch);
|
||||||
tempTarget = (Button) view.findViewById(R.id.actions_temptarget);
|
tempTarget = (Button) view.findViewById(R.id.actions_temptarget);
|
||||||
extendedBolus = (Button) view.findViewById(R.id.actions_extendedbolus);
|
extendedBolus = (Button) view.findViewById(R.id.actions_extendedbolus);
|
||||||
extendedBolusCancel = (Button) view.findViewById(R.id.actions_extendedbolus_cancel);
|
extendedBolusCancel = (Button) view.findViewById(R.id.actions_extendedbolus_cancel);
|
||||||
tempBasal = (Button) view.findViewById(R.id.actions_settempbasal);
|
tempBasal = (Button) view.findViewById(R.id.actions_settempbasal);
|
||||||
tempBasalCancel = (Button) view.findViewById(R.id.actions_canceltempbasal);
|
tempBasalCancel = (Button) view.findViewById(R.id.actions_canceltempbasal);
|
||||||
fill = (Button) view.findViewById(R.id.actions_fill);
|
fill = (Button) view.findViewById(R.id.actions_fill);
|
||||||
|
|
||||||
profileSwitch.setOnClickListener(this);
|
profileSwitch.setOnClickListener(this);
|
||||||
tempTarget.setOnClickListener(this);
|
tempTarget.setOnClickListener(this);
|
||||||
extendedBolus.setOnClickListener(this);
|
extendedBolus.setOnClickListener(this);
|
||||||
extendedBolusCancel.setOnClickListener(this);
|
extendedBolusCancel.setOnClickListener(this);
|
||||||
tempBasal.setOnClickListener(this);
|
tempBasal.setOnClickListener(this);
|
||||||
tempBasalCancel.setOnClickListener(this);
|
tempBasalCancel.setOnClickListener(this);
|
||||||
fill.setOnClickListener(this);
|
fill.setOnClickListener(this);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
|
|
|
@ -12,6 +12,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
|
@ -71,53 +72,59 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.careportal_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.careportal_fragment, container, false);
|
||||||
|
|
||||||
view.findViewById(R.id.careportal_bgcheck).setOnClickListener(this);
|
view.findViewById(R.id.careportal_bgcheck).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_announcement).setOnClickListener(this);
|
view.findViewById(R.id.careportal_announcement).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_cgmsensorinsert).setOnClickListener(this);
|
view.findViewById(R.id.careportal_cgmsensorinsert).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_cgmsensorstart).setOnClickListener(this);
|
view.findViewById(R.id.careportal_cgmsensorstart).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_combobolus).setOnClickListener(this);
|
view.findViewById(R.id.careportal_combobolus).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_correctionbolus).setOnClickListener(this);
|
view.findViewById(R.id.careportal_correctionbolus).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_carbscorrection).setOnClickListener(this);
|
view.findViewById(R.id.careportal_carbscorrection).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_exercise).setOnClickListener(this);
|
view.findViewById(R.id.careportal_exercise).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_insulincartridgechange).setOnClickListener(this);
|
view.findViewById(R.id.careportal_insulincartridgechange).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_pumpbatterychange).setOnClickListener(this);
|
view.findViewById(R.id.careportal_pumpbatterychange).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_mealbolus).setOnClickListener(this);
|
view.findViewById(R.id.careportal_mealbolus).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_note).setOnClickListener(this);
|
view.findViewById(R.id.careportal_note).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_profileswitch).setOnClickListener(this);
|
view.findViewById(R.id.careportal_profileswitch).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_pumpsitechange).setOnClickListener(this);
|
view.findViewById(R.id.careportal_pumpsitechange).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_question).setOnClickListener(this);
|
view.findViewById(R.id.careportal_question).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_snackbolus).setOnClickListener(this);
|
view.findViewById(R.id.careportal_snackbolus).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_tempbasalend).setOnClickListener(this);
|
view.findViewById(R.id.careportal_tempbasalend).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_tempbasalstart).setOnClickListener(this);
|
view.findViewById(R.id.careportal_tempbasalstart).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_openapsoffline).setOnClickListener(this);
|
view.findViewById(R.id.careportal_openapsoffline).setOnClickListener(this);
|
||||||
view.findViewById(R.id.careportal_temporarytarget).setOnClickListener(this);
|
view.findViewById(R.id.careportal_temporarytarget).setOnClickListener(this);
|
||||||
|
|
||||||
iage = (TextView) view.findViewById(R.id.careportal_insulinage);
|
iage = (TextView) view.findViewById(R.id.careportal_insulinage);
|
||||||
cage = (TextView) view.findViewById(R.id.careportal_canulaage);
|
cage = (TextView) view.findViewById(R.id.careportal_canulaage);
|
||||||
sage = (TextView) view.findViewById(R.id.careportal_sensorage);
|
sage = (TextView) view.findViewById(R.id.careportal_sensorage);
|
||||||
pbage = (TextView) view.findViewById(R.id.careportal_pbage);
|
pbage = (TextView) view.findViewById(R.id.careportal_pbage);
|
||||||
|
|
||||||
statsLayout = (View) view.findViewById(R.id.careportal_stats);
|
statsLayout = view.findViewById(R.id.careportal_stats);
|
||||||
|
|
||||||
noProfileView = (View) view.findViewById(R.id.profileview_noprofile);
|
noProfileView = view.findViewById(R.id.profileview_noprofile);
|
||||||
butonsLayout = (LinearLayout) view.findViewById(R.id.careportal_buttons);
|
butonsLayout = (LinearLayout) view.findViewById(R.id.careportal_buttons);
|
||||||
|
|
||||||
ProfileStore profileStore = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
|
ProfileStore profileStore = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
|
||||||
if (profileStore == null) {
|
if (profileStore == null) {
|
||||||
noProfileView.setVisibility(View.VISIBLE);
|
noProfileView.setVisibility(View.VISIBLE);
|
||||||
butonsLayout.setVisibility(View.GONE);
|
butonsLayout.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
noProfileView.setVisibility(View.GONE);
|
noProfileView.setVisibility(View.GONE);
|
||||||
butonsLayout.setVisibility(View.VISIBLE);
|
butonsLayout.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BuildConfig.NSCLIENTOLNY)
|
||||||
|
statsLayout.setVisibility(View.GONE); // visible on overview
|
||||||
|
|
||||||
|
updateGUI();
|
||||||
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BuildConfig.NSCLIENTOLNY)
|
return null;
|
||||||
statsLayout.setVisibility(View.GONE); // visible on overview
|
|
||||||
|
|
||||||
updateGUI();
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.widget.ListAdapter;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
|
|
||||||
|
@ -79,47 +80,53 @@ public class ConfigBuilderFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.configbuilder_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.configbuilder_fragment, container, false);
|
||||||
|
|
||||||
insulinListView = (ListView) view.findViewById(R.id.configbuilder_insulinlistview);
|
insulinListView = (ListView) view.findViewById(R.id.configbuilder_insulinlistview);
|
||||||
sensitivityListView = (ListView) view.findViewById(R.id.configbuilder_sensitivitylistview);
|
sensitivityListView = (ListView) view.findViewById(R.id.configbuilder_sensitivitylistview);
|
||||||
bgsourceListView = (ListView) view.findViewById(R.id.configbuilder_bgsourcelistview);
|
bgsourceListView = (ListView) view.findViewById(R.id.configbuilder_bgsourcelistview);
|
||||||
bgsourceLabel = (TextView) view.findViewById(R.id.configbuilder_bgsourcelabel);
|
bgsourceLabel = (TextView) view.findViewById(R.id.configbuilder_bgsourcelabel);
|
||||||
pumpListView = (ListView) view.findViewById(R.id.configbuilder_pumplistview);
|
pumpListView = (ListView) view.findViewById(R.id.configbuilder_pumplistview);
|
||||||
pumpLabel = (TextView) view.findViewById(R.id.configbuilder_pumplabel);
|
pumpLabel = (TextView) view.findViewById(R.id.configbuilder_pumplabel);
|
||||||
loopListView = (ListView) view.findViewById(R.id.configbuilder_looplistview);
|
loopListView = (ListView) view.findViewById(R.id.configbuilder_looplistview);
|
||||||
loopLabel = (TextView) view.findViewById(R.id.configbuilder_looplabel);
|
loopLabel = (TextView) view.findViewById(R.id.configbuilder_looplabel);
|
||||||
profileListView = (ListView) view.findViewById(R.id.configbuilder_profilelistview);
|
profileListView = (ListView) view.findViewById(R.id.configbuilder_profilelistview);
|
||||||
profileLabel = (TextView) view.findViewById(R.id.configbuilder_profilelabel);
|
profileLabel = (TextView) view.findViewById(R.id.configbuilder_profilelabel);
|
||||||
apsListView = (ListView) view.findViewById(R.id.configbuilder_apslistview);
|
apsListView = (ListView) view.findViewById(R.id.configbuilder_apslistview);
|
||||||
apsLabel = (TextView) view.findViewById(R.id.configbuilder_apslabel);
|
apsLabel = (TextView) view.findViewById(R.id.configbuilder_apslabel);
|
||||||
constraintsListView = (ListView) view.findViewById(R.id.configbuilder_constraintslistview);
|
constraintsListView = (ListView) view.findViewById(R.id.configbuilder_constraintslistview);
|
||||||
constraintsLabel = (TextView) view.findViewById(R.id.configbuilder_constraintslabel);
|
constraintsLabel = (TextView) view.findViewById(R.id.configbuilder_constraintslabel);
|
||||||
generalListView = (ListView) view.findViewById(R.id.configbuilder_generallistview);
|
generalListView = (ListView) view.findViewById(R.id.configbuilder_generallistview);
|
||||||
|
|
||||||
mainLayout = (LinearLayout) view.findViewById(R.id.configbuilder_mainlayout);
|
mainLayout = (LinearLayout) view.findViewById(R.id.configbuilder_mainlayout);
|
||||||
unlock = (Button) view.findViewById(R.id.configbuilder_unlock);
|
unlock = (Button) view.findViewById(R.id.configbuilder_unlock);
|
||||||
|
|
||||||
setViews();
|
setViews();
|
||||||
|
|
||||||
if (PasswordProtection.isLocked("settings_password")) {
|
if (PasswordProtection.isLocked("settings_password")) {
|
||||||
mainLayout.setVisibility(View.GONE);
|
mainLayout.setVisibility(View.GONE);
|
||||||
unlock.setOnClickListener(new View.OnClickListener() {
|
unlock.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
PasswordProtection.QueryPassword(getContext(), R.string.settings_password, "settings_password", new Runnable() {
|
PasswordProtection.QueryPassword(getContext(), R.string.settings_password, "settings_password", new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mainLayout.setVisibility(View.VISIBLE);
|
mainLayout.setVisibility(View.VISIBLE);
|
||||||
unlock.setVisibility(View.GONE);
|
unlock.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
unlock.setVisibility(View.GONE);
|
unlock.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
}
|
}
|
||||||
return view;
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setViews() {
|
void setViews() {
|
||||||
|
|
|
@ -15,6 +15,8 @@ import android.widget.CheckBox;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -27,15 +29,6 @@ import info.nightscout.androidaps.R;
|
||||||
public class ObjectivesFragment extends Fragment {
|
public class ObjectivesFragment extends Fragment {
|
||||||
private static Logger log = LoggerFactory.getLogger(ObjectivesFragment.class);
|
private static Logger log = LoggerFactory.getLogger(ObjectivesFragment.class);
|
||||||
|
|
||||||
private static ObjectivesPlugin objectivesPlugin;
|
|
||||||
|
|
||||||
public static ObjectivesPlugin getPlugin() {
|
|
||||||
if (objectivesPlugin == null) {
|
|
||||||
objectivesPlugin = new ObjectivesPlugin();
|
|
||||||
}
|
|
||||||
return objectivesPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
LinearLayoutManager llm;
|
LinearLayoutManager llm;
|
||||||
CheckBox enableFake;
|
CheckBox enableFake;
|
||||||
|
@ -59,7 +52,7 @@ public class ObjectivesFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(ObjectiveViewHolder holder, int position) {
|
public void onBindViewHolder(ObjectiveViewHolder holder, int position) {
|
||||||
ObjectivesPlugin.Objective o = objectives.get(position);
|
ObjectivesPlugin.Objective o = objectives.get(position);
|
||||||
ObjectivesPlugin.RequirementResult requirementsMet = getPlugin().requirementsMet(position);
|
ObjectivesPlugin.RequirementResult requirementsMet = ObjectivesPlugin.getPlugin().requirementsMet(position);
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
holder.position.setText(String.valueOf(position + 1));
|
holder.position.setText(String.valueOf(position + 1));
|
||||||
holder.objective.setText(o.objective);
|
holder.objective.setText(o.objective);
|
||||||
|
@ -83,7 +76,7 @@ public class ObjectivesFragment extends Fragment {
|
||||||
holder.verifyButton.setOnClickListener(new View.OnClickListener() {
|
holder.verifyButton.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
ObjectivesPlugin.Objective o = (ObjectivesPlugin.Objective) v.getTag();
|
ObjectivesPlugin.Objective o = (ObjectivesPlugin.Objective) v.getTag();
|
||||||
if (getPlugin().requirementsMet(o.num).done || enableFake.isChecked()) {
|
if (ObjectivesPlugin.getPlugin().requirementsMet(o.num).done || enableFake.isChecked()) {
|
||||||
o.accomplished = new Date();
|
o.accomplished = new Date();
|
||||||
updateGUI();
|
updateGUI();
|
||||||
ObjectivesPlugin.saveProgress();
|
ObjectivesPlugin.saveProgress();
|
||||||
|
@ -173,45 +166,51 @@ public class ObjectivesFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.objectives_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.objectives_fragment, container, false);
|
||||||
|
|
||||||
recyclerView = (RecyclerView) view.findViewById(R.id.objectives_recyclerview);
|
recyclerView = (RecyclerView) view.findViewById(R.id.objectives_recyclerview);
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
llm = new LinearLayoutManager(view.getContext());
|
llm = new LinearLayoutManager(view.getContext());
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
enableFake = (CheckBox) view.findViewById(R.id.objectives_fake);
|
enableFake = (CheckBox) view.findViewById(R.id.objectives_fake);
|
||||||
fake_layout = (LinearLayout) view.findViewById(R.id.objectives_fake_layout);
|
fake_layout = (LinearLayout) view.findViewById(R.id.objectives_fake_layout);
|
||||||
reset = (TextView) view.findViewById(R.id.objectives_reset);
|
reset = (TextView) view.findViewById(R.id.objectives_reset);
|
||||||
enableFake.setOnClickListener(new View.OnClickListener() {
|
enableFake.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
updateGUI();
|
updateGUI();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
reset.setOnClickListener(new View.OnClickListener() {
|
reset.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
getPlugin().initializeData();
|
ObjectivesPlugin.getPlugin().initializeData();
|
||||||
getPlugin().saveProgress();
|
ObjectivesPlugin.saveProgress();
|
||||||
updateGUI();
|
updateGUI();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add correct translations to array after app is initialized
|
// Add correct translations to array after app is initialized
|
||||||
getPlugin().objectives.get(0).objective = MainApp.sResources.getString(R.string.objectives_0_objective);
|
ObjectivesPlugin.objectives.get(0).objective = MainApp.sResources.getString(R.string.objectives_0_objective);
|
||||||
getPlugin().objectives.get(1).objective = MainApp.sResources.getString(R.string.objectives_1_objective);
|
ObjectivesPlugin.objectives.get(1).objective = MainApp.sResources.getString(R.string.objectives_1_objective);
|
||||||
getPlugin().objectives.get(2).objective = MainApp.sResources.getString(R.string.objectives_2_objective);
|
ObjectivesPlugin.objectives.get(2).objective = MainApp.sResources.getString(R.string.objectives_2_objective);
|
||||||
getPlugin().objectives.get(3).objective = MainApp.sResources.getString(R.string.objectives_3_objective);
|
ObjectivesPlugin.objectives.get(3).objective = MainApp.sResources.getString(R.string.objectives_3_objective);
|
||||||
getPlugin().objectives.get(4).objective = MainApp.sResources.getString(R.string.objectives_4_objective);
|
ObjectivesPlugin.objectives.get(4).objective = MainApp.sResources.getString(R.string.objectives_4_objective);
|
||||||
getPlugin().objectives.get(5).objective = MainApp.sResources.getString(R.string.objectives_5_objective);
|
ObjectivesPlugin.objectives.get(5).objective = MainApp.sResources.getString(R.string.objectives_5_objective);
|
||||||
getPlugin().objectives.get(6).objective = MainApp.sResources.getString(R.string.objectives_6_objective);
|
ObjectivesPlugin.objectives.get(6).objective = MainApp.sResources.getString(R.string.objectives_6_objective);
|
||||||
getPlugin().objectives.get(0).gate = MainApp.sResources.getString(R.string.objectives_0_gate);
|
ObjectivesPlugin.objectives.get(0).gate = MainApp.sResources.getString(R.string.objectives_0_gate);
|
||||||
getPlugin().objectives.get(1).gate = MainApp.sResources.getString(R.string.objectives_1_gate);
|
ObjectivesPlugin.objectives.get(1).gate = MainApp.sResources.getString(R.string.objectives_1_gate);
|
||||||
getPlugin().objectives.get(2).gate = MainApp.sResources.getString(R.string.objectives_2_gate);
|
ObjectivesPlugin.objectives.get(2).gate = MainApp.sResources.getString(R.string.objectives_2_gate);
|
||||||
getPlugin().objectives.get(3).gate = MainApp.sResources.getString(R.string.objectives_3_gate);
|
ObjectivesPlugin.objectives.get(3).gate = MainApp.sResources.getString(R.string.objectives_3_gate);
|
||||||
getPlugin().objectives.get(4).gate = MainApp.sResources.getString(R.string.objectives_4_gate);
|
ObjectivesPlugin.objectives.get(4).gate = MainApp.sResources.getString(R.string.objectives_4_gate);
|
||||||
getPlugin().objectives.get(5).gate = MainApp.sResources.getString(R.string.objectives_5_gate);
|
ObjectivesPlugin.objectives.get(5).gate = MainApp.sResources.getString(R.string.objectives_5_gate);
|
||||||
updateGUI();
|
updateGUI();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateGUI() {
|
void updateGUI() {
|
||||||
|
|
|
@ -25,11 +25,20 @@ import info.nightscout.utils.SP;
|
||||||
public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(ObjectivesPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(ObjectivesPlugin.class);
|
||||||
|
|
||||||
|
private static ObjectivesPlugin objectivesPlugin;
|
||||||
|
|
||||||
|
public static ObjectivesPlugin getPlugin() {
|
||||||
|
if (objectivesPlugin == null) {
|
||||||
|
objectivesPlugin = new ObjectivesPlugin();
|
||||||
|
}
|
||||||
|
return objectivesPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
public static List<Objective> objectives;
|
public static List<Objective> objectives;
|
||||||
|
|
||||||
boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
public ObjectivesPlugin() {
|
private ObjectivesPlugin() {
|
||||||
initializeData();
|
initializeData();
|
||||||
loadProgress();
|
loadProgress();
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
|
@ -95,7 +104,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
if (type == CONSTRAINTS) this.fragmentVisible = fragmentVisible;
|
if (type == CONSTRAINTS) this.fragmentVisible = fragmentVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Objective {
|
class Objective {
|
||||||
Integer num;
|
Integer num;
|
||||||
String objective;
|
String objective;
|
||||||
String gate;
|
String gate;
|
||||||
|
@ -118,13 +127,13 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
public static boolean pumpStatusIsAvailableInNS = false;
|
public static boolean pumpStatusIsAvailableInNS = false;
|
||||||
// Objective 1
|
// Objective 1
|
||||||
public static Integer manualEnacts = 0;
|
public static Integer manualEnacts = 0;
|
||||||
public static final Integer manualEnactsNeeded = 20;
|
private static final Integer manualEnactsNeeded = 20;
|
||||||
|
|
||||||
public class RequirementResult {
|
class RequirementResult {
|
||||||
boolean done = false;
|
boolean done = false;
|
||||||
String comment = "";
|
String comment = "";
|
||||||
|
|
||||||
public RequirementResult(boolean done, String comment) {
|
RequirementResult(boolean done, String comment) {
|
||||||
this.done = done;
|
this.done = done;
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +144,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
else return "---";
|
else return "---";
|
||||||
}
|
}
|
||||||
|
|
||||||
public RequirementResult requirementsMet(Integer objNum) {
|
RequirementResult requirementsMet(Integer objNum) {
|
||||||
switch (objNum) {
|
switch (objNum) {
|
||||||
case 0:
|
case 0:
|
||||||
return new RequirementResult(bgIsAvailableInNS && pumpStatusIsAvailableInNS,
|
return new RequirementResult(bgIsAvailableInNS && pumpStatusIsAvailableInNS,
|
||||||
|
@ -152,7 +161,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void initializeData() {
|
void initializeData() {
|
||||||
bgIsAvailableInNS = false;
|
bgIsAvailableInNS = false;
|
||||||
pumpStatusIsAvailableInNS = false;
|
pumpStatusIsAvailableInNS = false;
|
||||||
manualEnacts = 0;
|
manualEnacts = 0;
|
||||||
|
@ -220,7 +229,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadProgress() {
|
private void loadProgress() {
|
||||||
for (int num = 0; num < objectives.size(); num++) {
|
for (int num = 0; num < objectives.size(); num++) {
|
||||||
Objective o = objectives.get(num);
|
Objective o = objectives.get(num);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -7,8 +7,11 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 17.04.2017.
|
* Created by mike on 17.04.2017.
|
||||||
|
@ -22,16 +25,22 @@ public class InsulinFragment extends Fragment {
|
||||||
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.insulin_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.insulin_fragment, container, false);
|
||||||
|
|
||||||
insulinName = (TextView) view.findViewById(R.id.insulin_name);
|
insulinName = (TextView) view.findViewById(R.id.insulin_name);
|
||||||
insulinComment = (TextView) view.findViewById(R.id.insulin_comment);
|
insulinComment = (TextView) view.findViewById(R.id.insulin_comment);
|
||||||
insulinDia = (TextView) view.findViewById(R.id.insulin_dia);
|
insulinDia = (TextView) view.findViewById(R.id.insulin_dia);
|
||||||
insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph);
|
insulinGraph = (ActivityGraph) view.findViewById(R.id.insuling_graph);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,10 +50,10 @@ public class InsulinFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateGUI() {
|
private void updateGUI() {
|
||||||
insulinName.setText(MainApp.getConfigBuilder().getActiveInsulin().getFriendlyName());
|
insulinName.setText(ConfigBuilderPlugin.getActiveInsulin().getFriendlyName());
|
||||||
insulinComment.setText(MainApp.getConfigBuilder().getActiveInsulin().getComment());
|
insulinComment.setText(ConfigBuilderPlugin.getActiveInsulin().getComment());
|
||||||
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + Double.toString(MainApp.getConfigBuilder().getActiveInsulin().getDia()) + "h");
|
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + Double.toString(ConfigBuilderPlugin.getActiveInsulin().getDia()) + "h");
|
||||||
insulinGraph.show(MainApp.getConfigBuilder().getActiveInsulin());
|
insulinGraph.show(ConfigBuilderPlugin.getActiveInsulin());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
@ -25,15 +26,6 @@ import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui;
|
||||||
public class LoopFragment extends SubscriberFragment implements View.OnClickListener {
|
public class LoopFragment extends SubscriberFragment implements View.OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(LoopFragment.class);
|
private static Logger log = LoggerFactory.getLogger(LoopFragment.class);
|
||||||
|
|
||||||
private static LoopPlugin loopPlugin;
|
|
||||||
|
|
||||||
public static LoopPlugin getPlugin() {
|
|
||||||
if (loopPlugin == null){
|
|
||||||
loopPlugin = new LoopPlugin();
|
|
||||||
}
|
|
||||||
return loopPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
Button runNowButton;
|
Button runNowButton;
|
||||||
TextView lastRunView;
|
TextView lastRunView;
|
||||||
TextView lastEnactView;
|
TextView lastEnactView;
|
||||||
|
@ -46,19 +38,25 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.loop_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.loop_fragment, container, false);
|
||||||
|
|
||||||
lastRunView = (TextView) view.findViewById(R.id.loop_lastrun);
|
lastRunView = (TextView) view.findViewById(R.id.loop_lastrun);
|
||||||
lastEnactView = (TextView) view.findViewById(R.id.loop_lastenact);
|
lastEnactView = (TextView) view.findViewById(R.id.loop_lastenact);
|
||||||
sourceView = (TextView) view.findViewById(R.id.loop_source);
|
sourceView = (TextView) view.findViewById(R.id.loop_source);
|
||||||
requestView = (TextView) view.findViewById(R.id.loop_request);
|
requestView = (TextView) view.findViewById(R.id.loop_request);
|
||||||
constraintsProcessedView = (TextView) view.findViewById(R.id.loop_constraintsprocessed);
|
constraintsProcessedView = (TextView) view.findViewById(R.id.loop_constraintsprocessed);
|
||||||
setByPumpView = (TextView) view.findViewById(R.id.loop_setbypump);
|
setByPumpView = (TextView) view.findViewById(R.id.loop_setbypump);
|
||||||
runNowButton = (Button) view.findViewById(R.id.loop_run);
|
runNowButton = (Button) view.findViewById(R.id.loop_run);
|
||||||
runNowButton.setOnClickListener(this);
|
runNowButton.setOnClickListener(this);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,7 +67,7 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
getPlugin().invoke("Loop button", true);
|
LoopPlugin.getPlugin().invoke("Loop button", true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
|
@ -105,13 +103,13 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (getPlugin().lastRun != null) {
|
if (LoopPlugin.lastRun != null) {
|
||||||
requestView.setText(getPlugin().lastRun.request != null ? getPlugin().lastRun.request.toSpanned() : "");
|
requestView.setText(LoopPlugin.lastRun.request != null ? LoopPlugin.lastRun.request.toSpanned() : "");
|
||||||
constraintsProcessedView.setText(getPlugin().lastRun.constraintsProcessed != null ? getPlugin().lastRun.constraintsProcessed.toSpanned() : "");
|
constraintsProcessedView.setText(LoopPlugin.lastRun.constraintsProcessed != null ? LoopPlugin.lastRun.constraintsProcessed.toSpanned() : "");
|
||||||
setByPumpView.setText(getPlugin().lastRun.setByPump != null ? getPlugin().lastRun.setByPump.toSpanned() : "");
|
setByPumpView.setText(LoopPlugin.lastRun.setByPump != null ? LoopPlugin.lastRun.setByPump.toSpanned() : "");
|
||||||
sourceView.setText(getPlugin().lastRun.source != null ? getPlugin().lastRun.source : "");
|
sourceView.setText(LoopPlugin.lastRun.source != null ? LoopPlugin.lastRun.source : "");
|
||||||
lastRunView.setText(getPlugin().lastRun.lastAPSRun != null && getPlugin().lastRun.lastAPSRun.getTime() != 0 ? getPlugin().lastRun.lastAPSRun.toLocaleString() : "");
|
lastRunView.setText(LoopPlugin.lastRun.lastAPSRun != null && LoopPlugin.lastRun.lastAPSRun.getTime() != 0 ? LoopPlugin.lastRun.lastAPSRun.toLocaleString() : "");
|
||||||
lastEnactView.setText(getPlugin().lastRun.lastEnact != null && getPlugin().lastRun.lastEnact.getTime() != 0 ? getPlugin().lastRun.lastEnact.toLocaleString() : "");
|
lastEnactView.setText(LoopPlugin.lastRun.lastEnact != null && LoopPlugin.lastRun.lastEnact.getTime() != 0 ? LoopPlugin.lastRun.lastEnact.toLocaleString() : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -46,6 +46,15 @@ import info.nightscout.utils.SafeParse;
|
||||||
public class LoopPlugin implements PluginBase {
|
public class LoopPlugin implements PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(LoopPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(LoopPlugin.class);
|
||||||
|
|
||||||
|
private static LoopPlugin loopPlugin;
|
||||||
|
|
||||||
|
public static LoopPlugin getPlugin() {
|
||||||
|
if (loopPlugin == null) {
|
||||||
|
loopPlugin = new LoopPlugin();
|
||||||
|
}
|
||||||
|
return loopPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
private static Handler sHandler;
|
private static Handler sHandler;
|
||||||
private static HandlerThread sHandlerThread;
|
private static HandlerThread sHandlerThread;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import android.widget.CompoundButton;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
@ -37,15 +38,6 @@ import info.nightscout.utils.SP;
|
||||||
public class NSClientInternalFragment extends SubscriberFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
public class NSClientInternalFragment extends SubscriberFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(NSClientInternalFragment.class);
|
private static Logger log = LoggerFactory.getLogger(NSClientInternalFragment.class);
|
||||||
|
|
||||||
static NSClientInternalPlugin nsClientInternalPlugin;
|
|
||||||
|
|
||||||
static public NSClientInternalPlugin getPlugin() {
|
|
||||||
if (nsClientInternalPlugin == null) {
|
|
||||||
nsClientInternalPlugin = new NSClientInternalPlugin();
|
|
||||||
}
|
|
||||||
return nsClientInternalPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TextView logTextView;
|
private TextView logTextView;
|
||||||
private TextView queueTextView;
|
private TextView queueTextView;
|
||||||
private TextView urlTextView;
|
private TextView urlTextView;
|
||||||
|
@ -62,38 +54,44 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.nsclientinternal_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.nsclientinternal_fragment, container, false);
|
||||||
|
|
||||||
logScrollview = (ScrollView) view.findViewById(R.id.nsclientinternal_logscrollview);
|
logScrollview = (ScrollView) view.findViewById(R.id.nsclientinternal_logscrollview);
|
||||||
autoscrollCheckbox = (CheckBox) view.findViewById(R.id.nsclientinternal_autoscroll);
|
autoscrollCheckbox = (CheckBox) view.findViewById(R.id.nsclientinternal_autoscroll);
|
||||||
autoscrollCheckbox.setChecked(getPlugin().autoscroll);
|
autoscrollCheckbox.setChecked(NSClientInternalPlugin.getPlugin().autoscroll);
|
||||||
autoscrollCheckbox.setOnCheckedChangeListener(this);
|
autoscrollCheckbox.setOnCheckedChangeListener(this);
|
||||||
pausedCheckbox = (CheckBox) view.findViewById(R.id.nsclientinternal_paused);
|
pausedCheckbox = (CheckBox) view.findViewById(R.id.nsclientinternal_paused);
|
||||||
pausedCheckbox.setChecked(getPlugin().paused);
|
pausedCheckbox.setChecked(NSClientInternalPlugin.getPlugin().paused);
|
||||||
pausedCheckbox.setOnCheckedChangeListener(this);
|
pausedCheckbox.setOnCheckedChangeListener(this);
|
||||||
logTextView = (TextView) view.findViewById(R.id.nsclientinternal_log);
|
logTextView = (TextView) view.findViewById(R.id.nsclientinternal_log);
|
||||||
queueTextView = (TextView) view.findViewById(R.id.nsclientinternal_queue);
|
queueTextView = (TextView) view.findViewById(R.id.nsclientinternal_queue);
|
||||||
urlTextView = (TextView) view.findViewById(R.id.nsclientinternal_url);
|
urlTextView = (TextView) view.findViewById(R.id.nsclientinternal_url);
|
||||||
statusTextView = (TextView) view.findViewById(R.id.nsclientinternal_status);
|
statusTextView = (TextView) view.findViewById(R.id.nsclientinternal_status);
|
||||||
|
|
||||||
clearlog = (TextView) view.findViewById(R.id.nsclientinternal_clearlog);
|
clearlog = (TextView) view.findViewById(R.id.nsclientinternal_clearlog);
|
||||||
clearlog.setOnClickListener(this);
|
clearlog.setOnClickListener(this);
|
||||||
clearlog.setPaintFlags(clearlog.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
clearlog.setPaintFlags(clearlog.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
restart = (TextView) view.findViewById(R.id.nsclientinternal_restart);
|
restart = (TextView) view.findViewById(R.id.nsclientinternal_restart);
|
||||||
restart.setOnClickListener(this);
|
restart.setOnClickListener(this);
|
||||||
restart.setPaintFlags(restart.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
restart.setPaintFlags(restart.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
delivernow = (TextView) view.findViewById(R.id.nsclientinternal_delivernow);
|
delivernow = (TextView) view.findViewById(R.id.nsclientinternal_delivernow);
|
||||||
delivernow.setOnClickListener(this);
|
delivernow.setOnClickListener(this);
|
||||||
delivernow.setPaintFlags(delivernow.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
delivernow.setPaintFlags(delivernow.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
clearqueue = (TextView) view.findViewById(R.id.nsclientinternal_clearqueue);
|
clearqueue = (TextView) view.findViewById(R.id.nsclientinternal_clearqueue);
|
||||||
clearqueue.setOnClickListener(this);
|
clearqueue.setOnClickListener(this);
|
||||||
clearqueue.setPaintFlags(clearqueue.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
clearqueue.setPaintFlags(clearqueue.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
showqueue = (TextView) view.findViewById(R.id.nsclientinternal_showqueue);
|
showqueue = (TextView) view.findViewById(R.id.nsclientinternal_showqueue);
|
||||||
showqueue.setOnClickListener(this);
|
showqueue.setOnClickListener(this);
|
||||||
showqueue.setPaintFlags(showqueue.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
showqueue.setPaintFlags(showqueue.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -104,11 +102,11 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
|
||||||
Answers.getInstance().logCustom(new CustomEvent("NSClientRestart"));
|
Answers.getInstance().logCustom(new CustomEvent("NSClientRestart"));
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_delivernow:
|
case R.id.nsclientinternal_delivernow:
|
||||||
getPlugin().resend("GUI");
|
NSClientInternalPlugin.getPlugin().resend("GUI");
|
||||||
Answers.getInstance().logCustom(new CustomEvent("NSClientDeliverNow"));
|
Answers.getInstance().logCustom(new CustomEvent("NSClientDeliverNow"));
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_clearlog:
|
case R.id.nsclientinternal_clearlog:
|
||||||
getPlugin().clearLog();
|
NSClientInternalPlugin.getPlugin().clearLog();
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_clearqueue:
|
case R.id.nsclientinternal_clearqueue:
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
|
@ -127,7 +125,7 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
|
||||||
builder.show();
|
builder.show();
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_showqueue:
|
case R.id.nsclientinternal_showqueue:
|
||||||
MainApp.bus().post(new EventNSClientNewLog("QUEUE", getPlugin().queue().textList()));
|
MainApp.bus().post(new EventNSClientNewLog("QUEUE", NSClientInternalPlugin.getPlugin().queue().textList()));
|
||||||
Answers.getInstance().logCustom(new CustomEvent("NSClientShowQueue"));
|
Answers.getInstance().logCustom(new CustomEvent("NSClientShowQueue"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -138,14 +136,14 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
|
||||||
switch (buttonView.getId()) {
|
switch (buttonView.getId()) {
|
||||||
case R.id.nsclientinternal_paused:
|
case R.id.nsclientinternal_paused:
|
||||||
SP.putBoolean(R.string.key_nsclientinternal_paused, isChecked);
|
SP.putBoolean(R.string.key_nsclientinternal_paused, isChecked);
|
||||||
getPlugin().paused = isChecked;
|
NSClientInternalPlugin.getPlugin().paused = isChecked;
|
||||||
MainApp.bus().post(new EventPreferenceChange(R.string.key_nsclientinternal_paused));
|
MainApp.bus().post(new EventPreferenceChange(R.string.key_nsclientinternal_paused));
|
||||||
updateGUI();
|
updateGUI();
|
||||||
Answers.getInstance().logCustom(new CustomEvent("NSClientPause"));
|
Answers.getInstance().logCustom(new CustomEvent("NSClientPause"));
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_autoscroll:
|
case R.id.nsclientinternal_autoscroll:
|
||||||
SP.putBoolean(R.string.key_nsclientinternal_autoscroll, isChecked);
|
SP.putBoolean(R.string.key_nsclientinternal_autoscroll, isChecked);
|
||||||
getPlugin().autoscroll = isChecked;
|
NSClientInternalPlugin.getPlugin().autoscroll = isChecked;
|
||||||
updateGUI();
|
updateGUI();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -165,13 +163,13 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
|
||||||
public void run() {
|
public void run() {
|
||||||
NSClientInternalPlugin.updateLog();
|
NSClientInternalPlugin.updateLog();
|
||||||
logTextView.setText(NSClientInternalPlugin.textLog);
|
logTextView.setText(NSClientInternalPlugin.textLog);
|
||||||
if (getPlugin().autoscroll) {
|
if (NSClientInternalPlugin.getPlugin().autoscroll) {
|
||||||
logScrollview.fullScroll(ScrollView.FOCUS_DOWN);
|
logScrollview.fullScroll(ScrollView.FOCUS_DOWN);
|
||||||
}
|
}
|
||||||
urlTextView.setText(getPlugin().url());
|
urlTextView.setText(NSClientInternalPlugin.getPlugin().url());
|
||||||
Spanned queuetext = Html.fromHtml(MainApp.sResources.getString(R.string.queue) + " <b>" + UploadQueue.size() + "</b>");
|
Spanned queuetext = Html.fromHtml(MainApp.sResources.getString(R.string.queue) + " <b>" + UploadQueue.size() + "</b>");
|
||||||
queueTextView.setText(queuetext);
|
queueTextView.setText(queuetext);
|
||||||
statusTextView.setText(getPlugin().status);
|
statusTextView.setText(NSClientInternalPlugin.getPlugin().status);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,15 @@ import info.nightscout.utils.ToastUtils;
|
||||||
public class NSClientInternalPlugin implements PluginBase {
|
public class NSClientInternalPlugin implements PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(NSClientInternalPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(NSClientInternalPlugin.class);
|
||||||
|
|
||||||
|
static NSClientInternalPlugin nsClientInternalPlugin;
|
||||||
|
|
||||||
|
static public NSClientInternalPlugin getPlugin() {
|
||||||
|
if (nsClientInternalPlugin == null) {
|
||||||
|
nsClientInternalPlugin = new NSClientInternalPlugin();
|
||||||
|
}
|
||||||
|
return nsClientInternalPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
private boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
@ -28,15 +29,6 @@ import info.nightscout.utils.JSONFormatter;
|
||||||
public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnClickListener {
|
public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(OpenAPSAMAFragment.class);
|
private static Logger log = LoggerFactory.getLogger(OpenAPSAMAFragment.class);
|
||||||
|
|
||||||
private static OpenAPSAMAPlugin openAPSAMAPlugin;
|
|
||||||
|
|
||||||
public static OpenAPSAMAPlugin getPlugin() {
|
|
||||||
if(openAPSAMAPlugin ==null){
|
|
||||||
openAPSAMAPlugin = new OpenAPSAMAPlugin();
|
|
||||||
}
|
|
||||||
return openAPSAMAPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
Button run;
|
Button run;
|
||||||
TextView lastRunView;
|
TextView lastRunView;
|
||||||
TextView glucoseStatusView;
|
TextView glucoseStatusView;
|
||||||
|
@ -52,30 +44,36 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.openapsama_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.openapsama_fragment, container, false);
|
||||||
|
|
||||||
run = (Button) view.findViewById(R.id.openapsma_run);
|
run = (Button) view.findViewById(R.id.openapsma_run);
|
||||||
run.setOnClickListener(this);
|
run.setOnClickListener(this);
|
||||||
lastRunView = (TextView) view.findViewById(R.id.openapsma_lastrun);
|
lastRunView = (TextView) view.findViewById(R.id.openapsma_lastrun);
|
||||||
glucoseStatusView = (TextView) view.findViewById(R.id.openapsma_glucosestatus);
|
glucoseStatusView = (TextView) view.findViewById(R.id.openapsma_glucosestatus);
|
||||||
currentTempView = (TextView) view.findViewById(R.id.openapsma_currenttemp);
|
currentTempView = (TextView) view.findViewById(R.id.openapsma_currenttemp);
|
||||||
iobDataView = (TextView) view.findViewById(R.id.openapsma_iobdata);
|
iobDataView = (TextView) view.findViewById(R.id.openapsma_iobdata);
|
||||||
profileView = (TextView) view.findViewById(R.id.openapsma_profile);
|
profileView = (TextView) view.findViewById(R.id.openapsma_profile);
|
||||||
mealDataView = (TextView) view.findViewById(R.id.openapsma_mealdata);
|
mealDataView = (TextView) view.findViewById(R.id.openapsma_mealdata);
|
||||||
autosensDataView = (TextView) view.findViewById(R.id.openapsma_autosensdata);
|
autosensDataView = (TextView) view.findViewById(R.id.openapsma_autosensdata);
|
||||||
scriptdebugView = (TextView) view.findViewById(R.id.openapsma_scriptdebugdata);
|
scriptdebugView = (TextView) view.findViewById(R.id.openapsma_scriptdebugdata);
|
||||||
resultView = (TextView) view.findViewById(R.id.openapsma_result);
|
resultView = (TextView) view.findViewById(R.id.openapsma_result);
|
||||||
requestView = (TextView) view.findViewById(R.id.openapsma_request);
|
requestView = (TextView) view.findViewById(R.id.openapsma_request);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.openapsma_run:
|
case R.id.openapsma_run:
|
||||||
getPlugin().invoke("OpenAPSAMA button");
|
OpenAPSAMAPlugin.getPlugin().invoke("OpenAPSAMA button");
|
||||||
Answers.getInstance().logCustom(new CustomEvent("OpenAPS_AMA_Run"));
|
Answers.getInstance().logCustom(new CustomEvent("OpenAPS_AMA_Run"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -99,12 +97,12 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
DetermineBasalResultAMA lastAPSResult = getPlugin().lastAPSResult;
|
DetermineBasalResultAMA lastAPSResult = OpenAPSAMAPlugin.getPlugin().lastAPSResult;
|
||||||
if (lastAPSResult != null) {
|
if (lastAPSResult != null) {
|
||||||
resultView.setText(JSONFormatter.format(lastAPSResult.json));
|
resultView.setText(JSONFormatter.format(lastAPSResult.json));
|
||||||
requestView.setText(lastAPSResult.toSpanned());
|
requestView.setText(lastAPSResult.toSpanned());
|
||||||
}
|
}
|
||||||
DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS = getPlugin().lastDetermineBasalAdapterAMAJS;
|
DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS = OpenAPSAMAPlugin.getPlugin().lastDetermineBasalAdapterAMAJS;
|
||||||
if (determineBasalAdapterAMAJS != null) {
|
if (determineBasalAdapterAMAJS != null) {
|
||||||
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getGlucoseStatusParam()));
|
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getGlucoseStatusParam()));
|
||||||
currentTempView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getCurrentTempParam()));
|
currentTempView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getCurrentTempParam()));
|
||||||
|
@ -119,11 +117,11 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
|
||||||
mealDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getMealDataParam()));
|
mealDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getMealDataParam()));
|
||||||
scriptdebugView.setText(determineBasalAdapterAMAJS.getScriptDebug());
|
scriptdebugView.setText(determineBasalAdapterAMAJS.getScriptDebug());
|
||||||
}
|
}
|
||||||
if (getPlugin().lastAPSRun != null) {
|
if (OpenAPSAMAPlugin.getPlugin().lastAPSRun != null) {
|
||||||
lastRunView.setText(getPlugin().lastAPSRun.toLocaleString());
|
lastRunView.setText(OpenAPSAMAPlugin.getPlugin().lastAPSRun.toLocaleString());
|
||||||
}
|
}
|
||||||
if (getPlugin().lastAutosensResult != null) {
|
if (OpenAPSAMAPlugin.getPlugin().lastAutosensResult != null) {
|
||||||
autosensDataView.setText(JSONFormatter.format(getPlugin().lastAutosensResult.json()));
|
autosensDataView.setText(JSONFormatter.format(OpenAPSAMAPlugin.getPlugin().lastAutosensResult.json()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,14 +39,23 @@ import info.nightscout.utils.ToastUtils;
|
||||||
public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(OpenAPSAMAPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(OpenAPSAMAPlugin.class);
|
||||||
|
|
||||||
|
private static OpenAPSAMAPlugin openAPSAMAPlugin;
|
||||||
|
|
||||||
|
public static OpenAPSAMAPlugin getPlugin() {
|
||||||
|
if (openAPSAMAPlugin == null) {
|
||||||
|
openAPSAMAPlugin = new OpenAPSAMAPlugin();
|
||||||
|
}
|
||||||
|
return openAPSAMAPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
// last values
|
// last values
|
||||||
DetermineBasalAdapterAMAJS lastDetermineBasalAdapterAMAJS = null;
|
DetermineBasalAdapterAMAJS lastDetermineBasalAdapterAMAJS = null;
|
||||||
Date lastAPSRun = null;
|
Date lastAPSRun = null;
|
||||||
DetermineBasalResultAMA lastAPSResult = null;
|
DetermineBasalResultAMA lastAPSResult = null;
|
||||||
AutosensResult lastAutosensResult = null;
|
AutosensResult lastAutosensResult = null;
|
||||||
|
|
||||||
boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -196,9 +205,9 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
||||||
maxBasal = verifyHardLimits(maxBasal, "max_basal", 0.1, 10);
|
maxBasal = verifyHardLimits(maxBasal, "max_basal", 0.1, 10);
|
||||||
|
|
||||||
if (!checkOnlyHardLimits(profile.getDia(), "dia", 2, 7)) return;
|
if (!checkOnlyHardLimits(profile.getDia(), "dia", 2, 7)) return;
|
||||||
if (!checkOnlyHardLimits(profile.getIc(profile.secondsFromMidnight()), "carbratio", 2, 100))
|
if (!checkOnlyHardLimits(profile.getIc(Profile.secondsFromMidnight()), "carbratio", 2, 100))
|
||||||
return;
|
return;
|
||||||
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf().doubleValue(), units), "sens", 2, 900))
|
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf(), units), "sens", 2, 900))
|
||||||
return;
|
return;
|
||||||
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
|
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
|
||||||
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
@ -26,15 +27,6 @@ import info.nightscout.utils.JSONFormatter;
|
||||||
public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClickListener {
|
public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(OpenAPSMAFragment.class);
|
private static Logger log = LoggerFactory.getLogger(OpenAPSMAFragment.class);
|
||||||
|
|
||||||
private static OpenAPSMAPlugin openAPSMAPlugin;
|
|
||||||
|
|
||||||
public static OpenAPSMAPlugin getPlugin() {
|
|
||||||
if (openAPSMAPlugin == null) {
|
|
||||||
openAPSMAPlugin = new OpenAPSMAPlugin();
|
|
||||||
}
|
|
||||||
return openAPSMAPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
Button run;
|
Button run;
|
||||||
TextView lastRunView;
|
TextView lastRunView;
|
||||||
TextView glucoseStatusView;
|
TextView glucoseStatusView;
|
||||||
|
@ -48,28 +40,34 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.openapsma_fragment, container, false);
|
try {
|
||||||
|
View view = inflater.inflate(R.layout.openapsma_fragment, container, false);
|
||||||
|
|
||||||
run = (Button) view.findViewById(R.id.openapsma_run);
|
run = (Button) view.findViewById(R.id.openapsma_run);
|
||||||
run.setOnClickListener(this);
|
run.setOnClickListener(this);
|
||||||
lastRunView = (TextView) view.findViewById(R.id.openapsma_lastrun);
|
lastRunView = (TextView) view.findViewById(R.id.openapsma_lastrun);
|
||||||
glucoseStatusView = (TextView) view.findViewById(R.id.openapsma_glucosestatus);
|
glucoseStatusView = (TextView) view.findViewById(R.id.openapsma_glucosestatus);
|
||||||
currentTempView = (TextView) view.findViewById(R.id.openapsma_currenttemp);
|
currentTempView = (TextView) view.findViewById(R.id.openapsma_currenttemp);
|
||||||
iobDataView = (TextView) view.findViewById(R.id.openapsma_iobdata);
|
iobDataView = (TextView) view.findViewById(R.id.openapsma_iobdata);
|
||||||
profileView = (TextView) view.findViewById(R.id.openapsma_profile);
|
profileView = (TextView) view.findViewById(R.id.openapsma_profile);
|
||||||
mealDataView = (TextView) view.findViewById(R.id.openapsma_mealdata);
|
mealDataView = (TextView) view.findViewById(R.id.openapsma_mealdata);
|
||||||
resultView = (TextView) view.findViewById(R.id.openapsma_result);
|
resultView = (TextView) view.findViewById(R.id.openapsma_result);
|
||||||
requestView = (TextView) view.findViewById(R.id.openapsma_request);
|
requestView = (TextView) view.findViewById(R.id.openapsma_request);
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.openapsma_run:
|
case R.id.openapsma_run:
|
||||||
getPlugin().invoke("OpenAPSMA button");
|
OpenAPSMAPlugin.getPlugin().invoke("OpenAPSMA button");
|
||||||
Answers.getInstance().logCustom(new CustomEvent("OpenAPS_MA_Run"));
|
Answers.getInstance().logCustom(new CustomEvent("OpenAPS_MA_Run"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -93,12 +91,12 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
DetermineBasalResultMA lastAPSResult = getPlugin().lastAPSResult;
|
DetermineBasalResultMA lastAPSResult = OpenAPSMAPlugin.getPlugin().lastAPSResult;
|
||||||
if (lastAPSResult != null) {
|
if (lastAPSResult != null) {
|
||||||
resultView.setText(JSONFormatter.format(lastAPSResult.json));
|
resultView.setText(JSONFormatter.format(lastAPSResult.json));
|
||||||
requestView.setText(lastAPSResult.toSpanned());
|
requestView.setText(lastAPSResult.toSpanned());
|
||||||
}
|
}
|
||||||
DetermineBasalAdapterMAJS determineBasalAdapterMAJS = getPlugin().lastDetermineBasalAdapterMAJS;
|
DetermineBasalAdapterMAJS determineBasalAdapterMAJS = OpenAPSMAPlugin.getPlugin().lastDetermineBasalAdapterMAJS;
|
||||||
if (determineBasalAdapterMAJS != null) {
|
if (determineBasalAdapterMAJS != null) {
|
||||||
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getGlucoseStatusParam()));
|
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getGlucoseStatusParam()));
|
||||||
currentTempView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getCurrentTempParam()));
|
currentTempView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getCurrentTempParam()));
|
||||||
|
@ -106,8 +104,8 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic
|
||||||
profileView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getProfileParam()));
|
profileView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getProfileParam()));
|
||||||
mealDataView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getMealDataParam()));
|
mealDataView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getMealDataParam()));
|
||||||
}
|
}
|
||||||
if (getPlugin().lastAPSRun != null) {
|
if (OpenAPSMAPlugin.getPlugin().lastAPSRun != null) {
|
||||||
lastRunView.setText(getPlugin().lastAPSRun.toLocaleString());
|
lastRunView.setText(OpenAPSMAPlugin.getPlugin().lastAPSRun.toLocaleString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,13 +38,22 @@ import static info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin.ver
|
||||||
public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
private static Logger log = LoggerFactory.getLogger(OpenAPSMAPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(OpenAPSMAPlugin.class);
|
||||||
|
|
||||||
|
private static OpenAPSMAPlugin openAPSMAPlugin;
|
||||||
|
|
||||||
|
public static OpenAPSMAPlugin getPlugin() {
|
||||||
|
if (openAPSMAPlugin == null) {
|
||||||
|
openAPSMAPlugin = new OpenAPSMAPlugin();
|
||||||
|
}
|
||||||
|
return openAPSMAPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
// last values
|
// last values
|
||||||
DetermineBasalAdapterMAJS lastDetermineBasalAdapterMAJS = null;
|
DetermineBasalAdapterMAJS lastDetermineBasalAdapterMAJS = null;
|
||||||
Date lastAPSRun = null;
|
Date lastAPSRun = null;
|
||||||
DetermineBasalResultMA lastAPSResult = null;
|
DetermineBasalResultMA lastAPSResult = null;
|
||||||
|
|
||||||
boolean fragmentEnabled = false;
|
private boolean fragmentEnabled = false;
|
||||||
boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -196,7 +205,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
|
|
||||||
if (!checkOnlyHardLimits(profile.getDia(), "dia", 2, 7)) return;
|
if (!checkOnlyHardLimits(profile.getDia(), "dia", 2, 7)) return;
|
||||||
if (!checkOnlyHardLimits(profile.getIc(), "carbratio", 2, 100)) return;
|
if (!checkOnlyHardLimits(profile.getIc(), "carbratio", 2, 100)) return;
|
||||||
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf().doubleValue(), units), "sens", 2, 900))
|
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf(), units), "sens", 2, 900))
|
||||||
return;
|
return;
|
||||||
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
|
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
|
||||||
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
||||||
|
|
|
@ -33,6 +33,7 @@ import android.widget.CompoundButton;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.crashlytics.android.Crashlytics;
|
||||||
import com.crashlytics.android.answers.Answers;
|
import com.crashlytics.android.answers.Answers;
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
import com.jjoe64.graphview.GraphView;
|
import com.jjoe64.graphview.GraphView;
|
||||||
|
@ -133,12 +134,6 @@ import info.nightscout.utils.ToastUtils;
|
||||||
public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
|
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
|
||||||
|
|
||||||
private static OverviewPlugin overviewPlugin = new OverviewPlugin();
|
|
||||||
|
|
||||||
public static OverviewPlugin getPlugin() {
|
|
||||||
return overviewPlugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
TextView timeView;
|
TextView timeView;
|
||||||
TextView bgView;
|
TextView bgView;
|
||||||
TextView arrowView;
|
TextView arrowView;
|
||||||
|
@ -214,136 +209,142 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
|
||||||
//check screen width
|
try {
|
||||||
final DisplayMetrics dm = new DisplayMetrics();
|
//check screen width
|
||||||
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
|
final DisplayMetrics dm = new DisplayMetrics();
|
||||||
int screen_width = dm.widthPixels;
|
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
|
||||||
int screen_height = dm.heightPixels;
|
int screen_width = dm.widthPixels;
|
||||||
smallWidth = screen_width < Constants.SMALL_WIDTH;
|
int screen_height = dm.heightPixels;
|
||||||
smallHeight = screen_height < Constants.SMALL_HEIGHT;
|
smallWidth = screen_width < Constants.SMALL_WIDTH;
|
||||||
boolean landscape = screen_height < screen_width;
|
smallHeight = screen_height < Constants.SMALL_HEIGHT;
|
||||||
|
boolean landscape = screen_height < screen_width;
|
||||||
|
|
||||||
View view;
|
View view;
|
||||||
|
|
||||||
if (MainApp.sResources.getBoolean(R.bool.isTablet) && BuildConfig.NSCLIENTOLNY) {
|
if (MainApp.sResources.getBoolean(R.bool.isTablet) && BuildConfig.NSCLIENTOLNY) {
|
||||||
view = inflater.inflate(R.layout.overview_fragment_nsclient_tablet, container, false);
|
view = inflater.inflate(R.layout.overview_fragment_nsclient_tablet, container, false);
|
||||||
} else if (BuildConfig.NSCLIENTOLNY) {
|
} else if (BuildConfig.NSCLIENTOLNY) {
|
||||||
view = inflater.inflate(R.layout.overview_fragment_nsclient, container, false);
|
view = inflater.inflate(R.layout.overview_fragment_nsclient, container, false);
|
||||||
shorttextmode = true;
|
shorttextmode = true;
|
||||||
} else if (smallHeight || landscape) {
|
} else if (smallHeight || landscape) {
|
||||||
view = inflater.inflate(R.layout.overview_fragment_smallheight, container, false);
|
view = inflater.inflate(R.layout.overview_fragment_smallheight, container, false);
|
||||||
} else {
|
} else {
|
||||||
view = inflater.inflate(R.layout.overview_fragment, container, false);
|
view = inflater.inflate(R.layout.overview_fragment, container, false);
|
||||||
}
|
|
||||||
|
|
||||||
timeView = (TextView) view.findViewById(R.id.overview_time);
|
|
||||||
bgView = (TextView) view.findViewById(R.id.overview_bg);
|
|
||||||
arrowView = (TextView) view.findViewById(R.id.overview_arrow);
|
|
||||||
if (smallWidth) {
|
|
||||||
arrowView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 35);
|
|
||||||
}
|
|
||||||
timeAgoView = (TextView) view.findViewById(R.id.overview_timeago);
|
|
||||||
deltaView = (TextView) view.findViewById(R.id.overview_delta);
|
|
||||||
avgdeltaView = (TextView) view.findViewById(R.id.overview_avgdelta);
|
|
||||||
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
|
|
||||||
extendedBolusView = (TextView) view.findViewById(R.id.overview_extendedbolus);
|
|
||||||
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
|
|
||||||
pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus);
|
|
||||||
pumpDeviceStatusView = (TextView) view.findViewById(R.id.overview_pump);
|
|
||||||
openapsDeviceStatusView = (TextView) view.findViewById(R.id.overview_openaps);
|
|
||||||
uploaderDeviceStatusView = (TextView) view.findViewById(R.id.overview_uploader);
|
|
||||||
loopStatusLayout = (LinearLayout) view.findViewById(R.id.overview_looplayout);
|
|
||||||
pumpStatusLayout = (LinearLayout) view.findViewById(R.id.overview_pumpstatuslayout);
|
|
||||||
|
|
||||||
pumpStatusView.setBackgroundColor(MainApp.sResources.getColor(R.color.colorInitializingBorder));
|
|
||||||
|
|
||||||
iobView = (TextView) view.findViewById(R.id.overview_iob);
|
|
||||||
cobView = (TextView) view.findViewById(R.id.overview_cob);
|
|
||||||
apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
|
|
||||||
tempTargetView = (TextView) view.findViewById(R.id.overview_temptarget);
|
|
||||||
|
|
||||||
iage = (TextView) view.findViewById(R.id.careportal_insulinage);
|
|
||||||
cage = (TextView) view.findViewById(R.id.careportal_canulaage);
|
|
||||||
sage = (TextView) view.findViewById(R.id.careportal_sensorage);
|
|
||||||
pbage = (TextView) view.findViewById(R.id.careportal_pbage);
|
|
||||||
|
|
||||||
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
|
|
||||||
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
|
|
||||||
|
|
||||||
treatmentButton = (Button) view.findViewById(R.id.overview_treatmentbutton);
|
|
||||||
treatmentButton.setOnClickListener(this);
|
|
||||||
wizardButton = (Button) view.findViewById(R.id.overview_wizardbutton);
|
|
||||||
wizardButton.setOnClickListener(this);
|
|
||||||
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
|
|
||||||
if (acceptTempButton != null)
|
|
||||||
acceptTempButton.setOnClickListener(this);
|
|
||||||
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizardbutton);
|
|
||||||
quickWizardButton.setOnClickListener(this);
|
|
||||||
calibrationButton = (Button) view.findViewById(R.id.overview_calibrationbutton);
|
|
||||||
if (calibrationButton != null)
|
|
||||||
calibrationButton.setOnClickListener(this);
|
|
||||||
|
|
||||||
acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
|
|
||||||
|
|
||||||
showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction);
|
|
||||||
showBasalsView = (CheckBox) view.findViewById(R.id.overview_showbasals);
|
|
||||||
showIobView = (CheckBox) view.findViewById(R.id.overview_showiob);
|
|
||||||
showCobView = (CheckBox) view.findViewById(R.id.overview_showcob);
|
|
||||||
showDeviationsView = (CheckBox) view.findViewById(R.id.overview_showdeviations);
|
|
||||||
showRatiosView = (CheckBox) view.findViewById(R.id.overview_showratios);
|
|
||||||
showPredictionView.setChecked(SP.getBoolean("showprediction", false));
|
|
||||||
showBasalsView.setChecked(SP.getBoolean("showbasals", true));
|
|
||||||
showIobView.setChecked(SP.getBoolean("showiob", false));
|
|
||||||
showCobView.setChecked(SP.getBoolean("showcob", false));
|
|
||||||
showDeviationsView.setChecked(SP.getBoolean("showdeviations", false));
|
|
||||||
showRatiosView.setChecked(SP.getBoolean("showratios", false));
|
|
||||||
showPredictionView.setOnCheckedChangeListener(this);
|
|
||||||
showBasalsView.setOnCheckedChangeListener(this);
|
|
||||||
showIobView.setOnCheckedChangeListener(this);
|
|
||||||
showCobView.setOnCheckedChangeListener(this);
|
|
||||||
showDeviationsView.setOnCheckedChangeListener(this);
|
|
||||||
showRatiosView.setOnCheckedChangeListener(this);
|
|
||||||
|
|
||||||
notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
|
|
||||||
notificationsView.setHasFixedSize(true);
|
|
||||||
llm = new LinearLayoutManager(view.getContext());
|
|
||||||
notificationsView.setLayoutManager(llm);
|
|
||||||
|
|
||||||
bgGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
|
|
||||||
bgGraph.getGridLabelRenderer().reloadStyles();
|
|
||||||
iobGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
|
|
||||||
iobGraph.getGridLabelRenderer().reloadStyles();
|
|
||||||
iobGraph.getGridLabelRenderer().setHorizontalLabelsVisible(false);
|
|
||||||
bgGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
|
|
||||||
iobGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
|
|
||||||
iobGraph.getGridLabelRenderer().setNumVerticalLabels(5);
|
|
||||||
|
|
||||||
rangeToDisplay = SP.getInt(R.string.key_rangetodisplay, 6);
|
|
||||||
|
|
||||||
bgGraph.setOnLongClickListener(new View.OnLongClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onLongClick(View v) {
|
|
||||||
rangeToDisplay += 6;
|
|
||||||
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
|
||||||
SP.putInt(R.string.key_rangetodisplay, rangeToDisplay);
|
|
||||||
updateGUI("rangeChange");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
lockScreen = (CheckBox) view.findViewById(R.id.overview_lockscreen);
|
timeView = (TextView) view.findViewById(R.id.overview_time);
|
||||||
if (lockScreen != null) {
|
bgView = (TextView) view.findViewById(R.id.overview_bg);
|
||||||
lockScreen.setChecked(SP.getBoolean("lockscreen", false));
|
arrowView = (TextView) view.findViewById(R.id.overview_arrow);
|
||||||
lockScreen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
if (smallWidth) {
|
||||||
|
arrowView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 35);
|
||||||
|
}
|
||||||
|
timeAgoView = (TextView) view.findViewById(R.id.overview_timeago);
|
||||||
|
deltaView = (TextView) view.findViewById(R.id.overview_delta);
|
||||||
|
avgdeltaView = (TextView) view.findViewById(R.id.overview_avgdelta);
|
||||||
|
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
|
||||||
|
extendedBolusView = (TextView) view.findViewById(R.id.overview_extendedbolus);
|
||||||
|
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
|
||||||
|
pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus);
|
||||||
|
pumpDeviceStatusView = (TextView) view.findViewById(R.id.overview_pump);
|
||||||
|
openapsDeviceStatusView = (TextView) view.findViewById(R.id.overview_openaps);
|
||||||
|
uploaderDeviceStatusView = (TextView) view.findViewById(R.id.overview_uploader);
|
||||||
|
loopStatusLayout = (LinearLayout) view.findViewById(R.id.overview_looplayout);
|
||||||
|
pumpStatusLayout = (LinearLayout) view.findViewById(R.id.overview_pumpstatuslayout);
|
||||||
|
|
||||||
|
pumpStatusView.setBackgroundColor(MainApp.sResources.getColor(R.color.colorInitializingBorder));
|
||||||
|
|
||||||
|
iobView = (TextView) view.findViewById(R.id.overview_iob);
|
||||||
|
cobView = (TextView) view.findViewById(R.id.overview_cob);
|
||||||
|
apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
|
||||||
|
tempTargetView = (TextView) view.findViewById(R.id.overview_temptarget);
|
||||||
|
|
||||||
|
iage = (TextView) view.findViewById(R.id.careportal_insulinage);
|
||||||
|
cage = (TextView) view.findViewById(R.id.careportal_canulaage);
|
||||||
|
sage = (TextView) view.findViewById(R.id.careportal_sensorage);
|
||||||
|
pbage = (TextView) view.findViewById(R.id.careportal_pbage);
|
||||||
|
|
||||||
|
bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
|
||||||
|
iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
|
||||||
|
|
||||||
|
treatmentButton = (Button) view.findViewById(R.id.overview_treatmentbutton);
|
||||||
|
treatmentButton.setOnClickListener(this);
|
||||||
|
wizardButton = (Button) view.findViewById(R.id.overview_wizardbutton);
|
||||||
|
wizardButton.setOnClickListener(this);
|
||||||
|
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
|
||||||
|
if (acceptTempButton != null)
|
||||||
|
acceptTempButton.setOnClickListener(this);
|
||||||
|
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizardbutton);
|
||||||
|
quickWizardButton.setOnClickListener(this);
|
||||||
|
calibrationButton = (Button) view.findViewById(R.id.overview_calibrationbutton);
|
||||||
|
if (calibrationButton != null)
|
||||||
|
calibrationButton.setOnClickListener(this);
|
||||||
|
|
||||||
|
acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
|
||||||
|
|
||||||
|
showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction);
|
||||||
|
showBasalsView = (CheckBox) view.findViewById(R.id.overview_showbasals);
|
||||||
|
showIobView = (CheckBox) view.findViewById(R.id.overview_showiob);
|
||||||
|
showCobView = (CheckBox) view.findViewById(R.id.overview_showcob);
|
||||||
|
showDeviationsView = (CheckBox) view.findViewById(R.id.overview_showdeviations);
|
||||||
|
showRatiosView = (CheckBox) view.findViewById(R.id.overview_showratios);
|
||||||
|
showPredictionView.setChecked(SP.getBoolean("showprediction", false));
|
||||||
|
showBasalsView.setChecked(SP.getBoolean("showbasals", true));
|
||||||
|
showIobView.setChecked(SP.getBoolean("showiob", false));
|
||||||
|
showCobView.setChecked(SP.getBoolean("showcob", false));
|
||||||
|
showDeviationsView.setChecked(SP.getBoolean("showdeviations", false));
|
||||||
|
showRatiosView.setChecked(SP.getBoolean("showratios", false));
|
||||||
|
showPredictionView.setOnCheckedChangeListener(this);
|
||||||
|
showBasalsView.setOnCheckedChangeListener(this);
|
||||||
|
showIobView.setOnCheckedChangeListener(this);
|
||||||
|
showCobView.setOnCheckedChangeListener(this);
|
||||||
|
showDeviationsView.setOnCheckedChangeListener(this);
|
||||||
|
showRatiosView.setOnCheckedChangeListener(this);
|
||||||
|
|
||||||
|
notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
|
||||||
|
notificationsView.setHasFixedSize(true);
|
||||||
|
llm = new LinearLayoutManager(view.getContext());
|
||||||
|
notificationsView.setLayoutManager(llm);
|
||||||
|
|
||||||
|
bgGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
|
||||||
|
bgGraph.getGridLabelRenderer().reloadStyles();
|
||||||
|
iobGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
|
||||||
|
iobGraph.getGridLabelRenderer().reloadStyles();
|
||||||
|
iobGraph.getGridLabelRenderer().setHorizontalLabelsVisible(false);
|
||||||
|
bgGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
|
||||||
|
iobGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
|
||||||
|
iobGraph.getGridLabelRenderer().setNumVerticalLabels(5);
|
||||||
|
|
||||||
|
rangeToDisplay = SP.getInt(R.string.key_rangetodisplay, 6);
|
||||||
|
|
||||||
|
bgGraph.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public boolean onLongClick(View v) {
|
||||||
SP.putBoolean("lockscreen", isChecked);
|
rangeToDisplay += 6;
|
||||||
MainApp.bus().post(new EventSetWakeLock(isChecked));
|
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
||||||
|
SP.putInt(R.string.key_rangetodisplay, rangeToDisplay);
|
||||||
|
updateGUI("rangeChange");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
lockScreen = (CheckBox) view.findViewById(R.id.overview_lockscreen);
|
||||||
|
if (lockScreen != null) {
|
||||||
|
lockScreen.setChecked(SP.getBoolean("lockscreen", false));
|
||||||
|
lockScreen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
SP.putBoolean("lockscreen", isChecked);
|
||||||
|
MainApp.bus().post(new EventSetWakeLock(isChecked));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return view;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Crashlytics.logException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return view;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -638,7 +639,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
final TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory();
|
final TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory();
|
||||||
|
|
||||||
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
|
QuickWizard.QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
||||||
if (quickWizardEntry != null && actualBg != null) {
|
if (quickWizardEntry != null && actualBg != null) {
|
||||||
quickWizardButton.setVisibility(View.VISIBLE);
|
quickWizardButton.setVisibility(View.VISIBLE);
|
||||||
BolusWizard wizard = new BolusWizard();
|
BolusWizard wizard = new BolusWizard();
|
||||||
|
@ -1118,7 +1119,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
tempTargetView.setLongClickable(true);
|
tempTargetView.setLongClickable(true);
|
||||||
|
|
||||||
// QuickWizard button
|
// QuickWizard button
|
||||||
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
|
QuickWizard.QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
||||||
if (quickWizardEntry != null && lastBG != null && pump.isInitialized() && !pump.isSuspended()) {
|
if (quickWizardEntry != null && lastBG != null && pump.isInitialized() && !pump.isSuspended()) {
|
||||||
quickWizardButton.setVisibility(View.VISIBLE);
|
quickWizardButton.setVisibility(View.VISIBLE);
|
||||||
String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
||||||
|
@ -1805,7 +1806,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
// Adding current time to snooze if we got staleData
|
// Adding current time to snooze if we got staleData
|
||||||
log.debug("Notification text is: " + notification.text);
|
log.debug("Notification text is: " + notification.text);
|
||||||
if (notification.text.equals(MainApp.sResources.getString(R.string.nsalarm_staledata))) {
|
if (notification.text.equals(MainApp.sResources.getString(R.string.nsalarm_staledata))) {
|
||||||
NotificationStore nstore = getPlugin().notificationStore;
|
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
|
||||||
long msToSnooze = SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L;
|
long msToSnooze = SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L;
|
||||||
log.debug("snooze nsalarm_staledatavalue in minutes is " + SP.getInt("nsalarm_staledatavalue", 15) + "\n in ms is: " + msToSnooze + " currentTimeMillis is: " + System.currentTimeMillis());
|
log.debug("snooze nsalarm_staledatavalue in minutes is " + SP.getInt("nsalarm_staledatavalue", 15) + "\n in ms is: " + msToSnooze + " currentTimeMillis is: " + System.currentTimeMillis());
|
||||||
nstore.snoozeTo(System.currentTimeMillis() + (SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L));
|
nstore.snoozeTo(System.currentTimeMillis() + (SP.getInt("nsalarm_staledatavalue", 15) * 60 * 1000L));
|
||||||
|
@ -1822,7 +1823,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
NotificationStore nstore = getPlugin().notificationStore;
|
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
|
||||||
nstore.removeExpired();
|
nstore.removeExpired();
|
||||||
nstore.unSnooze();
|
nstore.unSnooze();
|
||||||
if (nstore.store.size() > 0) {
|
if (nstore.store.size() > 0) {
|
||||||
|
|
|
@ -21,6 +21,15 @@ import info.nightscout.utils.SP;
|
||||||
public class OverviewPlugin implements PluginBase {
|
public class OverviewPlugin implements PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(OverviewPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(OverviewPlugin.class);
|
||||||
|
|
||||||
|
private static OverviewPlugin overviewPlugin = new OverviewPlugin();
|
||||||
|
|
||||||
|
public static OverviewPlugin getPlugin() {
|
||||||
|
|
||||||
|
if (overviewPlugin == null)
|
||||||
|
overviewPlugin = new OverviewPlugin();
|
||||||
|
return overviewPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
public static double bgTargetLow = 80d;
|
public static double bgTargetLow = 80d;
|
||||||
public static double bgTargetHigh = 180d;
|
public static double bgTargetHigh = 180d;
|
||||||
|
|
||||||
|
@ -51,7 +60,7 @@ public class OverviewPlugin implements PluginBase {
|
||||||
@Override
|
@Override
|
||||||
public String getNameShort() {
|
public String getNameShort() {
|
||||||
String name = MainApp.sResources.getString(R.string.overview_shortname);
|
String name = MainApp.sResources.getString(R.string.overview_shortname);
|
||||||
if (!name.trim().isEmpty()){
|
if (!name.trim().isEmpty()) {
|
||||||
//only if translation exists
|
//only if translation exists
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue