fix merge conflict

This commit is contained in:
Milos Kozak 2017-10-07 18:27:20 +02:00
commit ef645ca600
82 changed files with 1576 additions and 850 deletions

View file

@ -44,7 +44,7 @@ android {
minSdkVersion 21
targetSdkVersion 23
versionCode 1500
version "1.53"
version "1.54-dev"
buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", generateGitBuild()
}

View file

@ -29,7 +29,7 @@ import info.nightscout.androidaps.plugins.Actions.ActionsFragment;
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderFragment;
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.Insulin.InsulinFastactingPlugin;
import info.nightscout.androidaps.plugins.Insulin.InsulinFastactingProlongedPlugin;
@ -37,17 +37,17 @@ import info.nightscout.androidaps.plugins.Insulin.InsulinOrefFreePeakPlugin;
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin;
import info.nightscout.androidaps.plugins.Insulin.InsulinOrefUltraRapidActingPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Loop.LoopFragment;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalFragment;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientInternalPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.receivers.AckAlarmReceiver;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAFragment;
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAFragment;
import info.nightscout.androidaps.plugins.Overview.OverviewFragment;
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
import info.nightscout.androidaps.plugins.OpenAPSMA.OpenAPSMAPlugin;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
import info.nightscout.androidaps.plugins.Persistentnotification.PersistentNotificationPlugin;
import info.nightscout.androidaps.plugins.ProfileCircadianPercentage.CircadianPercentageProfileFragment;
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfileFragment;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfileFragment;
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfileFragment;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
import info.nightscout.androidaps.plugins.ProfileSimple.SimpleProfilePlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
@ -59,12 +59,12 @@ import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorFragment;
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
import info.nightscout.androidaps.plugins.SourceGlimp.SourceGlimpPlugin;
import info.nightscout.androidaps.plugins.SourceMM640g.SourceMM640gPlugin;
import info.nightscout.androidaps.plugins.SourceNSClient.SourceNSClientPlugin;
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsFragment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.androidaps.plugins.Wear.WearFragment;
import info.nightscout.androidaps.plugins.XDripStatusline.StatuslinePlugin;
import info.nightscout.androidaps.receivers.DataReceiver;
@ -110,7 +110,7 @@ public class MainApp extends Application {
if (pluginsList == null) {
pluginsList = new ArrayList<>();
// Register all tabs in app here
pluginsList.add(OverviewFragment.getPlugin());
pluginsList.add(OverviewPlugin.getPlugin());
pluginsList.add(IobCobCalculatorPlugin.getPlugin());
if (Config.ACTION) pluginsList.add(ActionsFragment.getPlugin());
pluginsList.add(InsulinFastactingPlugin.getPlugin());
@ -127,17 +127,17 @@ public class MainApp extends Application {
pluginsList.add(CareportalFragment.getPlugin());
if (Config.MDI) pluginsList.add(MDIPlugin.getPlugin());
if (Config.VIRTUALPUMP) pluginsList.add(VirtualPumpPlugin.getInstance());
if (Config.LOOPENABLED) pluginsList.add(LoopFragment.getPlugin());
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSMAFragment.getPlugin());
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSAMAFragment.getPlugin());
pluginsList.add(NSProfileFragment.getPlugin());
if (Config.OTHERPROFILES) pluginsList.add(SimpleProfileFragment.getPlugin());
if (Config.LOOPENABLED) pluginsList.add(LoopPlugin.getPlugin());
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSMAPlugin.getPlugin());
if (Config.OPENAPSENABLED) pluginsList.add(OpenAPSAMAPlugin.getPlugin());
pluginsList.add(NSProfilePlugin.getPlugin());
if (Config.OTHERPROFILES) pluginsList.add(SimpleProfilePlugin.getPlugin());
if (Config.OTHERPROFILES) pluginsList.add(LocalProfileFragment.getPlugin());
if (Config.OTHERPROFILES)
pluginsList.add(CircadianPercentageProfileFragment.getPlugin());
pluginsList.add(TreatmentsFragment.getPlugin());
pluginsList.add(TreatmentsPlugin.getPlugin());
if (Config.SAFETY) pluginsList.add(SafetyPlugin.getPlugin());
if (Config.APS) pluginsList.add(ObjectivesFragment.getPlugin());
if (Config.APS) pluginsList.add(ObjectivesPlugin.getPlugin());
if (!Config.NSCLIENT)
pluginsList.add(SourceXdripPlugin.getPlugin());
pluginsList.add(SourceNSClientPlugin.getPlugin());
@ -145,12 +145,12 @@ public class MainApp extends Application {
pluginsList.add(SourceMM640gPlugin.getPlugin());
if (!Config.NSCLIENT)
pluginsList.add(SourceGlimpPlugin.getPlugin());
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorFragment.getPlugin());
if (Config.SMSCOMMUNICATORENABLED) pluginsList.add(SmsCommunicatorPlugin.getPlugin());
if (Config.WEAR) pluginsList.add(WearFragment.getPlugin(this));
pluginsList.add(StatuslinePlugin.getPlugin(this));
pluginsList.add(new PersistentNotificationPlugin(this));
pluginsList.add(NSClientInternalFragment.getPlugin());
pluginsList.add(NSClientInternalPlugin.getPlugin());
pluginsList.add(sConfigBuilder = ConfigBuilderFragment.getPlugin());

View file

@ -316,28 +316,8 @@ public class DataService extends IntentService {
log.error("Unhandled exception", e);
}
}
if (intent.getAction().equals(Intents.ACTION_NEW_TREATMENT)) {
try {
if (bundles.containsKey("treatment")) {
String trstring = bundles.getString("treatment");
handleAddChangeDataFromNS(trstring);
}
if (bundles.containsKey("treatments")) {
String trstring = bundles.getString("treatments");
JSONArray jsonArray = new JSONArray(trstring);
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject trJson = jsonArray.getJSONObject(i);
String trstr = trJson.toString();
handleAddChangeDataFromNS(trstr);
}
}
} catch (Exception e) {
log.error("Unhandled exception", e);
}
}
if (intent.getAction().equals(Intents.ACTION_CHANGED_TREATMENT)) {
if (intent.getAction().equals(Intents.ACTION_NEW_TREATMENT) || intent.getAction().equals(Intents.ACTION_CHANGED_TREATMENT)) {
try {
if (bundles.containsKey("treatment")) {
String trstring = bundles.getString("treatment");

View file

@ -8,6 +8,9 @@ public interface Intents {
String ACTION_NEW_PROFILE = "info.nightscout.client.NEW_PROFILE";
String ACTION_NEW_SGV = "info.nightscout.client.NEW_SGV";
String ACTION_NEW_DEVICESTATUS = "info.nightscout.client.NEW_DEVICESTATUS";
String ACTION_NEW_FOOD = "info.nightscout.client.NEW_FOOD";
String ACTION_CHANGED_FOOD = "info.nightscout.client.CHANGED_FOOD";
String ACTION_REMOVED_FOOD = "info.nightscout.client.REMOVED_FOOD";
String ACTION_NEW_MBG = "info.nightscout.client.NEW_MBG";
String ACTION_NEW_CAL = "info.nightscout.client.NEW_CAL";
String ACTION_NEW_STATUS = "info.nightscout.client.NEW_STATUS";

View file

@ -33,6 +33,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.events.EventCareportalEventChange;
import info.nightscout.androidaps.events.EventExtendedBolusChange;
import info.nightscout.androidaps.events.EventFoodDatabaseChanged;
import info.nightscout.androidaps.events.EventNewBG;
import info.nightscout.androidaps.events.EventProfileSwitchChange;
import info.nightscout.androidaps.events.EventRefreshOverview;
@ -59,6 +60,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
public static final String DATABASE_DBREQUESTS = "DBRequests";
public static final String DATABASE_CAREPORTALEVENTS = "CareportalEvents";
public static final String DATABASE_PROFILESWITCHES = "ProfileSwitches";
public static final String DATABASE_FOODS = "Foods";
private static final int DATABASE_VERSION = 8;
@ -85,6 +87,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
private static final ScheduledExecutorService profileSwitchEventWorker = Executors.newSingleThreadScheduledExecutor();
private static ScheduledFuture<?> scheduledProfileSwitchEventPost = null;
public FoodHelper foodHelper = new FoodHelper(this);
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
onCreate(getWritableDatabase(), getConnectionSource());
@ -104,6 +108,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
TableUtils.createTableIfNotExists(connectionSource, ExtendedBolus.class);
TableUtils.createTableIfNotExists(connectionSource, CareportalEvent.class);
TableUtils.createTableIfNotExists(connectionSource, ProfileSwitch.class);
TableUtils.createTableIfNotExists(connectionSource, Food.class);
} catch (SQLException e) {
log.error("Can't create database", e);
throw new RuntimeException(e);
@ -128,6 +133,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
TableUtils.dropTable(connectionSource, ExtendedBolus.class, true);
TableUtils.dropTable(connectionSource, CareportalEvent.class, true);
TableUtils.dropTable(connectionSource, ProfileSwitch.class, true);
TableUtils.dropTable(connectionSource, Food.class, true);
onCreate(database, connectionSource);
}
} catch (SQLException e) {
@ -205,6 +211,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
TableUtils.createTableIfNotExists(connectionSource, ExtendedBolus.class);
TableUtils.createTableIfNotExists(connectionSource, CareportalEvent.class);
TableUtils.createTableIfNotExists(connectionSource, ProfileSwitch.class);
foodHelper.resetFood();
updateEarliestDataChange(0);
} catch (SQLException e) {
log.error("Unhandled exception", e);
@ -217,6 +224,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
scheduleTemporaryTargetChange();
scheduleCareportalEventChange();
scheduleProfileSwitchChange();
foodHelper.scheduleFoodChange();
new java.util.Timer().schedule(
new java.util.TimerTask() {
@Override
@ -655,8 +663,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
class PostRunnable implements Runnable {
public void run() {
log.debug("Firing EventTreatmentChange");
MainApp.bus().post(new EventReloadTreatmentData());
MainApp.bus().post(new EventTreatmentChange());
MainApp.bus().post(new EventReloadTreatmentData(new EventTreatmentChange()));
if (earliestDataChange != null)
MainApp.bus().post(new EventNewHistoryData(earliestDataChange));
earliestDataChange = null;
@ -1357,8 +1364,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
class PostRunnable implements Runnable {
public void run() {
log.debug("Firing EventExtendedBolusChange");
MainApp.bus().post(new EventReloadTreatmentData());
MainApp.bus().post(new EventExtendedBolusChange());
MainApp.bus().post(new EventReloadTreatmentData(new EventExtendedBolusChange()));
if (earliestDataChange != null)
MainApp.bus().post(new EventNewHistoryData(earliestDataChange));
earliestDataChange = null;
@ -1672,4 +1678,5 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return null;
}
// ---------------- Food handling ---------------
}

View file

@ -0,0 +1,107 @@
package info.nightscout.androidaps.db;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Objects;
/**
* Created by mike on 20.09.2017.
*/
@DatabaseTable(tableName = DatabaseHelper.DATABASE_FOODS)
public class Food {
private static Logger log = LoggerFactory.getLogger(Food.class);
@DatabaseField(id = true)
public long key;
@DatabaseField
public boolean isValid = true;
@DatabaseField
public String _id; // NS _id
@DatabaseField
public String name;
@DatabaseField
public String category;
@DatabaseField
public String subcategory;
// Example:
// name="juice" portion=250 units="ml" carbs=12
// means 250ml of juice has 12g of carbs
@DatabaseField
public double portion; // common portion in "units"
@DatabaseField
public int carbs; // in grams
@DatabaseField
public int fat = 0; // in grams
@DatabaseField
public int protein = 0; // in grams
@DatabaseField
public int energy = 0; // in kJ
@DatabaseField
public String units = "g";
@DatabaseField
public int gi; // not used yet
public Food() {
key = System.currentTimeMillis();
}
public boolean isEqual(Food other) {
if (portion != other.portion)
return false;
if (carbs != other.carbs)
return false;
if (fat != other.fat)
return false;
if (protein != other.protein)
return false;
if (energy != other.energy)
return false;
if (gi != other.gi)
return false;
if (!Objects.equals(_id, other._id))
return false;
if (!Objects.equals(name, other.name))
return false;
if (!Objects.equals(category, other.category))
return false;
if (!Objects.equals(subcategory, other.subcategory))
return false;
if (!Objects.equals(units, other.units))
return false;
return true;
}
public void copyFrom(Food other) {
isValid = other.isValid;
_id = other._id;
name = other.name;
category = other.category;
subcategory = other.subcategory;
portion = other.portion;
carbs = other.carbs;
fat = other.fat;
protein = other.protein;
energy = other.energy;
units = other.units;
gi = other.gi;
}
}

View file

@ -0,0 +1,205 @@
package info.nightscout.androidaps.db;
import com.j256.ormlite.android.AndroidConnectionSource;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.stmt.PreparedQuery;
import com.j256.ormlite.stmt.QueryBuilder;
import com.j256.ormlite.stmt.Where;
import com.j256.ormlite.table.TableUtils;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.events.EventFoodDatabaseChanged;
/**
* Created by mike on 24.09.2017.
*/
public class FoodHelper {
private static Logger log = LoggerFactory.getLogger(FoodHelper.class);
DatabaseHelper databaseHelper;
private static final ScheduledExecutorService foodEventWorker = Executors.newSingleThreadScheduledExecutor();
private static ScheduledFuture<?> scheduledFoodEventPost = null;
public FoodHelper(DatabaseHelper databaseHelper) {
this.databaseHelper = databaseHelper;
}
private Dao<Food, Long> getDaoFood() throws SQLException {
return databaseHelper.getDao(Food.class);
}
public void resetFood() {
try {
TableUtils.dropTable(databaseHelper.getConnectionSource(), Food.class, true);
TableUtils.createTableIfNotExists(databaseHelper.getConnectionSource(), Food.class);
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
scheduleFoodChange();
}
public List<Food> getFoodData() {
try {
Dao<Food, Long> daoFood = getDaoFood();
List<Food> foods;
QueryBuilder<Food, Long> queryBuilder = daoFood.queryBuilder();
PreparedQuery<Food> preparedQuery = queryBuilder.prepare();
foods = daoFood.query(preparedQuery);
return foods;
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return new ArrayList<>();
}
public boolean createOrUpdate(Food food) {
try {
// find by NS _id
if (food._id != null) {
Food old;
QueryBuilder<Food, Long> queryBuilder = getDaoFood().queryBuilder();
Where where = queryBuilder.where();
where.eq("_id", food._id);
PreparedQuery<Food> preparedQuery = queryBuilder.prepare();
List<Food> found = getDaoFood().query(preparedQuery);
if (found.size() > 0) {
old = found.get(0);
if (!old.isEqual(food)) {
getDaoFood().delete(old); // need to delete/create because date may change too
old.copyFrom(food);
getDaoFood().create(old);
log.debug("FOOD: Updating record by _id: " + old.toString());
scheduleFoodChange();
return true;
}
}
}
getDaoFood().createOrUpdate(food);
log.debug("FOOD: New record: " + food.toString());
scheduleFoodChange();
return true;
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return false;
}
public void delete(Food food) {
try {
getDaoFood().delete(food);
scheduleFoodChange();
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
}
public static void scheduleFoodChange() {
class PostRunnable implements Runnable {
public void run() {
log.debug("Firing EventFoodChange");
MainApp.bus().post(new EventFoodDatabaseChanged());
scheduledFoodEventPost = null;
}
}
// prepare task for execution in 1 sec
// cancel waiting task to prevent sending multiple posts
if (scheduledFoodEventPost != null)
scheduledFoodEventPost.cancel(false);
Runnable task = new PostRunnable();
final int sec = 1;
scheduledFoodEventPost = foodEventWorker.schedule(task, sec, TimeUnit.SECONDS);
}
/*
{
"_id": "551ee3ad368e06e80856e6a9",
"type": "food",
"category": "Zakladni",
"subcategory": "Napoje",
"name": "Mleko",
"portion": 250,
"carbs": 12,
"gi": 1,
"created_at": "2015-04-14T06:59:16.500Z",
"unit": "ml"
}
*/
public void createFoodFromJsonIfNotExists(JSONObject trJson) {
try {
Food food = new Food();
if (trJson.has("type") && trJson.getString("type").equals("food")) {
if (trJson.has("_id"))
food._id = trJson.getString("_id");
if (trJson.has("category"))
food.category = trJson.getString("category");
if (trJson.has("subcategory"))
food.subcategory = trJson.getString("subcategory");
if (trJson.has("name"))
food.name = trJson.getString("name");
if (trJson.has("unit"))
food.units = trJson.getString("unit");
if (trJson.has("portion"))
food.portion = trJson.getDouble("portion");
if (trJson.has("carbs"))
food.carbs = trJson.getInt("carbs");
if (trJson.has("gi"))
food.gi = trJson.getInt("gi");
if (trJson.has("energy"))
food.energy = trJson.getInt("energy");
if (trJson.has("protein"))
food.protein = trJson.getInt("protein");
if (trJson.has("fat"))
food.fat = trJson.getInt("fat");
}
createOrUpdate(food);
} catch (JSONException e) {
log.error("Unhandled exception", e);
}
}
public void deleteFoodById(String _id) {
Food stored = findFoodById(_id);
if (stored != null) {
log.debug("FOOD: Removing Food record from database: " + stored.toString());
delete(stored);
scheduleFoodChange();
}
}
public Food findFoodById(String _id) {
try {
QueryBuilder<Food, Long> queryBuilder = getDaoFood().queryBuilder();
Where where = queryBuilder.where();
where.eq("_id", _id);
PreparedQuery<Food> preparedQuery = queryBuilder.prepare();
List<Food> list = getDaoFood().query(preparedQuery);
if (list.size() == 1) {
return list.get(0);
} else {
return null;
}
} catch (SQLException e) {
log.error("Unhandled exception", e);
}
return null;
}
}

View file

@ -0,0 +1,8 @@
package info.nightscout.androidaps.events;
/**
* Created by mike on 20.09.2017.
*/
public class EventFoodDatabaseChanged {
}

View file

@ -5,4 +5,9 @@ package info.nightscout.androidaps.events;
*/
public class EventReloadTreatmentData {
public Object next;
public EventReloadTreatmentData(Object next) {
this.next = next;
}
}

View file

@ -12,6 +12,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.squareup.otto.Subscribe;
@ -69,6 +70,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.actions_fragment, container, false);
profileSwitch = (Button) view.findViewById(R.id.actions_profileswitch);
@ -89,6 +91,11 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
updateGUI();
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@Subscribe

View file

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

View file

@ -10,6 +10,7 @@ import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import com.squareup.otto.Subscribe;
import info.nightscout.androidaps.BuildConfig;
@ -69,6 +70,7 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.careportal_fragment, container, false);
view.findViewById(R.id.careportal_bgcheck).setOnClickListener(this);
@ -97,9 +99,9 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
sage = (TextView) view.findViewById(R.id.careportal_sensorage);
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);
ProfileStore profileStore = ConfigBuilderPlugin.getActiveProfileInterface().getProfile();
@ -116,6 +118,11 @@ public class CareportalFragment extends SubscriberFragment implements View.OnCli
updateGUI();
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@Override

View file

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

View file

@ -14,6 +14,7 @@ import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.EditText;
@ -178,19 +179,57 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
profileSpinner.setSelection(p);
}
final Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile != null ? profile.getUnits() : Constants.MGDL);
// temp target
ArrayList<CharSequence> reasonList = new ArrayList<CharSequence>();
final ArrayList<CharSequence> reasonList = new ArrayList<CharSequence>();
reasonList.add(MainApp.sResources.getString(R.string.manual));
reasonList.add(MainApp.sResources.getString(R.string.eatingsoon));
reasonList.add(MainApp.sResources.getString(R.string.activity));
reasonList.add(MainApp.sResources.getString(R.string.manual));
ArrayAdapter<CharSequence> adapterReason = new ArrayAdapter<CharSequence>(getContext(),
R.layout.spinner_centered, reasonList);
reasonSpinner.setAdapter(adapterReason);
reasonSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
double defaultDuration = 0;
double defaultTarget = 0;
if(profile!=null){
defaultTarget = bg.doubleValue();
}
boolean erase = false;
if(MainApp.sResources.getString(R.string.eatingsoon).equals(reasonList.get(position))){
defaultDuration = SP.getDouble(R.string.key_eatingsoon_duration, 0d);
defaultTarget = SP.getDouble(R.string.key_eatingsoon_target, 0d);;
} else if (MainApp.sResources.getString(R.string.activity).equals(reasonList.get(position))){
defaultDuration = SP.getDouble(R.string.key_activity_duration, 0d);;
defaultTarget = SP.getDouble(R.string.key_activity_target, 0d);;
} else {
defaultDuration = 0;
erase = true;
}
if(defaultTarget != 0 || erase){
editTemptarget.setValue(defaultTarget);
}
if(defaultDuration != 0){
editDuration.setValue(defaultDuration);
} else if (erase){
editDuration.setValue(0d);
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
// bg
bgUnitsView.setText(units);
TextWatcher bgTextWatcher = new TextWatcher() {
public void afterTextChanged(Editable s) {
}
@ -202,7 +241,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
}
};
Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile != null ? profile.getUnits() : Constants.MGDL);
editBg = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_bginput);
editTemptarget = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_temptarget);
if (profile == null) {

View file

@ -15,6 +15,7 @@ import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
@ -79,6 +80,7 @@ public class ConfigBuilderFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.configbuilder_fragment, container, false);
insulinListView = (ListView) view.findViewById(R.id.configbuilder_insulinlistview);
@ -120,6 +122,11 @@ public class ConfigBuilderFragment extends Fragment {
unlock.setVisibility(View.GONE);
}
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
void setViews() {

View file

@ -15,6 +15,8 @@ import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -27,15 +29,6 @@ import info.nightscout.androidaps.R;
public class ObjectivesFragment extends Fragment {
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;
LinearLayoutManager llm;
CheckBox enableFake;
@ -59,7 +52,7 @@ public class ObjectivesFragment extends Fragment {
@Override
public void onBindViewHolder(ObjectiveViewHolder holder, int 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();
holder.position.setText(String.valueOf(position + 1));
holder.objective.setText(o.objective);
@ -83,7 +76,7 @@ public class ObjectivesFragment extends Fragment {
holder.verifyButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
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();
updateGUI();
ObjectivesPlugin.saveProgress();
@ -173,6 +166,7 @@ public class ObjectivesFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.objectives_fragment, container, false);
recyclerView = (RecyclerView) view.findViewById(R.id.objectives_recyclerview);
@ -189,29 +183,34 @@ public class ObjectivesFragment extends Fragment {
});
reset.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
getPlugin().initializeData();
getPlugin().saveProgress();
ObjectivesPlugin.getPlugin().initializeData();
ObjectivesPlugin.saveProgress();
updateGUI();
}
});
// Add correct translations to array after app is initialized
getPlugin().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);
getPlugin().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);
getPlugin().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);
getPlugin().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);
getPlugin().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);
getPlugin().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);
getPlugin().objectives.get(5).gate = MainApp.sResources.getString(R.string.objectives_5_gate);
ObjectivesPlugin.objectives.get(0).objective = MainApp.sResources.getString(R.string.objectives_0_objective);
ObjectivesPlugin.objectives.get(1).objective = MainApp.sResources.getString(R.string.objectives_1_objective);
ObjectivesPlugin.objectives.get(2).objective = MainApp.sResources.getString(R.string.objectives_2_objective);
ObjectivesPlugin.objectives.get(3).objective = MainApp.sResources.getString(R.string.objectives_3_objective);
ObjectivesPlugin.objectives.get(4).objective = MainApp.sResources.getString(R.string.objectives_4_objective);
ObjectivesPlugin.objectives.get(5).objective = MainApp.sResources.getString(R.string.objectives_5_objective);
ObjectivesPlugin.objectives.get(6).objective = MainApp.sResources.getString(R.string.objectives_6_objective);
ObjectivesPlugin.objectives.get(0).gate = MainApp.sResources.getString(R.string.objectives_0_gate);
ObjectivesPlugin.objectives.get(1).gate = MainApp.sResources.getString(R.string.objectives_1_gate);
ObjectivesPlugin.objectives.get(2).gate = MainApp.sResources.getString(R.string.objectives_2_gate);
ObjectivesPlugin.objectives.get(3).gate = MainApp.sResources.getString(R.string.objectives_3_gate);
ObjectivesPlugin.objectives.get(4).gate = MainApp.sResources.getString(R.string.objectives_4_gate);
ObjectivesPlugin.objectives.get(5).gate = MainApp.sResources.getString(R.string.objectives_5_gate);
updateGUI();
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
void updateGUI() {

View file

@ -25,11 +25,20 @@ import info.nightscout.utils.SP;
public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
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;
boolean fragmentVisible = true;
private boolean fragmentVisible = true;
public ObjectivesPlugin() {
private ObjectivesPlugin() {
initializeData();
loadProgress();
MainApp.bus().register(this);
@ -95,7 +104,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
if (type == CONSTRAINTS) this.fragmentVisible = fragmentVisible;
}
public class Objective {
class Objective {
Integer num;
String objective;
String gate;
@ -118,13 +127,13 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
public static boolean pumpStatusIsAvailableInNS = false;
// Objective 1
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;
String comment = "";
public RequirementResult(boolean done, String comment) {
RequirementResult(boolean done, String comment) {
this.done = done;
this.comment = comment;
}
@ -135,7 +144,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
else return "---";
}
public RequirementResult requirementsMet(Integer objNum) {
RequirementResult requirementsMet(Integer objNum) {
switch (objNum) {
case 0:
return new RequirementResult(bgIsAvailableInNS && pumpStatusIsAvailableInNS,
@ -152,7 +161,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
}
public void initializeData() {
void initializeData() {
bgIsAvailableInNS = false;
pumpStatusIsAvailableInNS = false;
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++) {
Objective o = objectives.get(num);
try {

View file

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

View file

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

View file

@ -7,8 +7,11 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
/**
* Created by mike on 17.04.2017.
@ -22,6 +25,7 @@ public class InsulinFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.insulin_fragment, container, false);
insulinName = (TextView) view.findViewById(R.id.insulin_name);
@ -32,6 +36,11 @@ public class InsulinFragment extends Fragment {
updateGUI();
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@Override
@ -41,10 +50,10 @@ public class InsulinFragment extends Fragment {
}
private void updateGUI() {
insulinName.setText(MainApp.getConfigBuilder().getActiveInsulin().getFriendlyName());
insulinComment.setText(MainApp.getConfigBuilder().getActiveInsulin().getComment());
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + Double.toString(MainApp.getConfigBuilder().getActiveInsulin().getDia()) + "h");
insulinGraph.show(MainApp.getConfigBuilder().getActiveInsulin());
insulinName.setText(ConfigBuilderPlugin.getActiveInsulin().getFriendlyName());
insulinComment.setText(ConfigBuilderPlugin.getActiveInsulin().getComment());
insulinDia.setText(MainApp.sResources.getText(R.string.dia) + " " + Double.toString(ConfigBuilderPlugin.getActiveInsulin().getDia()) + "h");
insulinGraph.show(ConfigBuilderPlugin.getActiveInsulin());
}
}

View file

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

View file

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

View file

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

View file

@ -9,6 +9,7 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
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 {
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;
TextView lastRunView;
TextView lastEnactView;
@ -46,6 +38,7 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.loop_fragment, container, false);
lastRunView = (TextView) view.findViewById(R.id.loop_lastrun);
@ -59,6 +52,11 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList
updateGUI();
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@Override
@ -69,7 +67,7 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
getPlugin().invoke("Loop button", true);
LoopPlugin.getPlugin().invoke("Loop button", true);
}
});
thread.start();
@ -105,13 +103,13 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (getPlugin().lastRun != null) {
requestView.setText(getPlugin().lastRun.request != null ? getPlugin().lastRun.request.toSpanned() : "");
constraintsProcessedView.setText(getPlugin().lastRun.constraintsProcessed != null ? getPlugin().lastRun.constraintsProcessed.toSpanned() : "");
setByPumpView.setText(getPlugin().lastRun.setByPump != null ? getPlugin().lastRun.setByPump.toSpanned() : "");
sourceView.setText(getPlugin().lastRun.source != null ? getPlugin().lastRun.source : "");
lastRunView.setText(getPlugin().lastRun.lastAPSRun != null && getPlugin().lastRun.lastAPSRun.getTime() != 0 ? getPlugin().lastRun.lastAPSRun.toLocaleString() : "");
lastEnactView.setText(getPlugin().lastRun.lastEnact != null && getPlugin().lastRun.lastEnact.getTime() != 0 ? getPlugin().lastRun.lastEnact.toLocaleString() : "");
if (LoopPlugin.lastRun != null) {
requestView.setText(LoopPlugin.lastRun.request != null ? LoopPlugin.lastRun.request.toSpanned() : "");
constraintsProcessedView.setText(LoopPlugin.lastRun.constraintsProcessed != null ? LoopPlugin.lastRun.constraintsProcessed.toSpanned() : "");
setByPumpView.setText(LoopPlugin.lastRun.setByPump != null ? LoopPlugin.lastRun.setByPump.toSpanned() : "");
sourceView.setText(LoopPlugin.lastRun.source != null ? LoopPlugin.lastRun.source : "");
lastRunView.setText(LoopPlugin.lastRun.lastAPSRun != null && LoopPlugin.lastRun.lastAPSRun.getTime() != 0 ? LoopPlugin.lastRun.lastAPSRun.toLocaleString() : "");
lastEnactView.setText(LoopPlugin.lastRun.lastEnact != null && LoopPlugin.lastRun.lastEnact.getTime() != 0 ? LoopPlugin.lastRun.lastEnact.toLocaleString() : "");
}
}
});

View file

@ -46,6 +46,15 @@ import info.nightscout.utils.SafeParse;
public class LoopPlugin implements PluginBase {
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 HandlerThread sHandlerThread;

View file

@ -18,6 +18,7 @@ import android.widget.CompoundButton;
import android.widget.ScrollView;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.squareup.otto.Subscribe;
@ -37,15 +38,6 @@ import info.nightscout.utils.SP;
public class NSClientInternalFragment extends SubscriberFragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
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 queueTextView;
private TextView urlTextView;
@ -62,14 +54,15 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.nsclientinternal_fragment, container, false);
logScrollview = (ScrollView) view.findViewById(R.id.nsclientinternal_logscrollview);
autoscrollCheckbox = (CheckBox) view.findViewById(R.id.nsclientinternal_autoscroll);
autoscrollCheckbox.setChecked(getPlugin().autoscroll);
autoscrollCheckbox.setChecked(NSClientInternalPlugin.getPlugin().autoscroll);
autoscrollCheckbox.setOnCheckedChangeListener(this);
pausedCheckbox = (CheckBox) view.findViewById(R.id.nsclientinternal_paused);
pausedCheckbox.setChecked(getPlugin().paused);
pausedCheckbox.setChecked(NSClientInternalPlugin.getPlugin().paused);
pausedCheckbox.setOnCheckedChangeListener(this);
logTextView = (TextView) view.findViewById(R.id.nsclientinternal_log);
queueTextView = (TextView) view.findViewById(R.id.nsclientinternal_queue);
@ -94,6 +87,11 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
updateGUI();
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@Override
@ -104,11 +102,11 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
Answers.getInstance().logCustom(new CustomEvent("NSClientRestart"));
break;
case R.id.nsclientinternal_delivernow:
getPlugin().resend("GUI");
NSClientInternalPlugin.getPlugin().resend("GUI");
Answers.getInstance().logCustom(new CustomEvent("NSClientDeliverNow"));
break;
case R.id.nsclientinternal_clearlog:
getPlugin().clearLog();
NSClientInternalPlugin.getPlugin().clearLog();
break;
case R.id.nsclientinternal_clearqueue:
final Context context = getContext();
@ -127,7 +125,7 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
builder.show();
break;
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"));
break;
}
@ -138,14 +136,14 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
switch (buttonView.getId()) {
case R.id.nsclientinternal_paused:
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));
updateGUI();
Answers.getInstance().logCustom(new CustomEvent("NSClientPause"));
break;
case R.id.nsclientinternal_autoscroll:
SP.putBoolean(R.string.key_nsclientinternal_autoscroll, isChecked);
getPlugin().autoscroll = isChecked;
NSClientInternalPlugin.getPlugin().autoscroll = isChecked;
updateGUI();
break;
}
@ -165,13 +163,13 @@ public class NSClientInternalFragment extends SubscriberFragment implements View
public void run() {
NSClientInternalPlugin.updateLog();
logTextView.setText(NSClientInternalPlugin.textLog);
if (getPlugin().autoscroll) {
if (NSClientInternalPlugin.getPlugin().autoscroll) {
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>");
queueTextView.setText(queuetext);
statusTextView.setText(getPlugin().status);
statusTextView.setText(NSClientInternalPlugin.getPlugin().status);
}
});
}

View file

@ -34,6 +34,15 @@ import info.nightscout.utils.ToastUtils;
public class NSClientInternalPlugin implements PluginBase {
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 fragmentVisible = true;

View file

@ -67,4 +67,31 @@ public class BroadcastDeviceStatus {
}
}
}
public static void handleNewFoods(JSONArray foods, Context context, boolean isDelta) {
List<JSONArray> splitted = BroadcastTreatment.splitArray(foods);
for (JSONArray part: splitted) {
Bundle bundle = new Bundle();
bundle.putString("foods", part.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_FOOD);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
}
if(SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
splitted = BroadcastTreatment.splitArray(foods);
for (JSONArray part : splitted) {
Bundle bundle = new Bundle();
bundle.putString("foods", part.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_FOOD);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
}
}
}

View file

@ -0,0 +1,104 @@
package info.nightscout.androidaps.plugins.NSClientInternal.broadcasts;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.Intents;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSTreatment;
import info.nightscout.utils.SP;
/**
* Created by mike on 20.02.2016.
*/
public class BroadcastFood {
private static Logger log = LoggerFactory.getLogger(BroadcastFood.class);
public static void handleNewFood(JSONArray foods, Context context, boolean isDelta) {
List<JSONArray> splitted = BroadcastTreatment.splitArray(foods);
for (JSONArray part : splitted) {
Bundle bundle = new Bundle();
bundle.putString("foods", part.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_FOOD);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
}
if (SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
for (JSONArray part : splitted) {
Bundle bundle = new Bundle();
bundle.putString("foods", part.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_NEW_FOOD);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
}
}
public static void handleChangedFood(JSONArray foods, Context context, boolean isDelta) {
List<JSONArray> splitted = BroadcastTreatment.splitArray(foods);
for (JSONArray part : splitted) {
Bundle bundle = new Bundle();
bundle.putString("foods", part.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_CHANGED_FOOD);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
}
if (SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
for (JSONArray part : splitted) {
Bundle bundle = new Bundle();
bundle.putString("foods", part.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_CHANGED_FOOD);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
}
}
public static void handleRemovedFood(JSONArray foods, Context context, boolean isDelta) {
Bundle bundle = new Bundle();
bundle.putString("foods", foods.toString());
bundle.putBoolean("delta", isDelta);
Intent intent = new Intent(Intents.ACTION_REMOVED_FOOD);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
LocalBroadcastManager.getInstance(MainApp.instance()).sendBroadcast(intent);
if (SP.getBoolean(R.string.key_nsclient_localbroadcasts, true)) {
bundle = new Bundle();
bundle.putString("foods", foods.toString());
bundle.putBoolean("delta", isDelta);
intent = new Intent(Intents.ACTION_REMOVED_FOOD);
intent.putExtras(bundle);
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
context.sendBroadcast(intent);
}
}
}

View file

@ -43,6 +43,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastA
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastCals;
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastClearAlarm;
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastDeviceStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastFood;
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastMbgs;
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastProfile;
import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastSgvs;
@ -519,6 +520,55 @@ public class NSClientService extends Service {
BroadcastDeviceStatus.handleNewDeviceStatus(devicestatuses, MainApp.instance().getApplicationContext(), isDelta);
}
}
if (data.has("food")) {
JSONArray foods = data.getJSONArray("food");
JSONArray removedFoods = new JSONArray();
JSONArray updatedFoods = new JSONArray();
JSONArray addedFoods = new JSONArray();
if (foods.length() > 0)
MainApp.bus().post(new EventNSClientNewLog("DATA", "received " + foods.length() + " foods"));
for (Integer index = 0; index < foods.length(); index++) {
JSONObject jsonFood = foods.getJSONObject(index);
NSTreatment treatment = new NSTreatment(jsonFood);
// remove from upload queue if Ack is failing
UploadQueue.removeID(jsonFood);
//Find latest date in treatment
if (treatment.getMills() != null && treatment.getMills() < System.currentTimeMillis())
if (treatment.getMills() > latestDateInReceivedData)
latestDateInReceivedData = treatment.getMills();
if (treatment.getAction() == null) {
addedFoods.put(jsonFood);
} else if (treatment.getAction().equals("update")) {
updatedFoods.put(jsonFood);
} else if (treatment.getAction().equals("remove")) {
if (treatment.getMills() != null && treatment.getMills() > System.currentTimeMillis() - 24 * 60 * 60 * 1000L) // handle 1 day old deletions only
removedFoods.put(jsonFood);
}
}
if (removedFoods.length() > 0) {
BroadcastFood.handleRemovedFood(removedFoods, MainApp.instance().getApplicationContext(), isDelta);
}
if (updatedFoods.length() > 0) {
BroadcastFood.handleChangedFood(updatedFoods, MainApp.instance().getApplicationContext(), isDelta);
}
if (addedFoods.length() > 0) {
BroadcastFood.handleNewFood(addedFoods, MainApp.instance().getApplicationContext(), isDelta);
}
}
if (data.has("")) {
JSONArray foods = data.getJSONArray("food");
if (foods.length() > 0) {
MainApp.bus().post(new EventNSClientNewLog("DATA", "received " + foods.length() + " foods"));
for (Integer index = 0; index < foods.length(); index++) {
JSONObject jsonFood = foods.getJSONObject(index);
// remove from upload queue if Ack is failing
UploadQueue.removeID(jsonFood);
}
BroadcastDeviceStatus.handleNewFoods(foods, MainApp.instance().getApplicationContext(), isDelta);
}
}
if (data.has("mbgs")) {
JSONArray mbgs = data.getJSONArray("mbgs");
if (mbgs.length() > 0)

View file

@ -9,6 +9,7 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.squareup.otto.Subscribe;
@ -28,15 +29,6 @@ import info.nightscout.utils.JSONFormatter;
public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnClickListener {
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;
TextView lastRunView;
TextView glucoseStatusView;
@ -52,6 +44,7 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.openapsama_fragment, container, false);
run = (Button) view.findViewById(R.id.openapsma_run);
@ -69,13 +62,18 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
updateGUI();
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.openapsma_run:
getPlugin().invoke("OpenAPSAMA button");
OpenAPSAMAPlugin.getPlugin().invoke("OpenAPSAMA button");
Answers.getInstance().logCustom(new CustomEvent("OpenAPS_AMA_Run"));
break;
}
@ -99,12 +97,12 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
DetermineBasalResultAMA lastAPSResult = getPlugin().lastAPSResult;
DetermineBasalResultAMA lastAPSResult = OpenAPSAMAPlugin.getPlugin().lastAPSResult;
if (lastAPSResult != null) {
resultView.setText(JSONFormatter.format(lastAPSResult.json));
requestView.setText(lastAPSResult.toSpanned());
}
DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS = getPlugin().lastDetermineBasalAdapterAMAJS;
DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS = OpenAPSAMAPlugin.getPlugin().lastDetermineBasalAdapterAMAJS;
if (determineBasalAdapterAMAJS != null) {
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getGlucoseStatusParam()));
currentTempView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getCurrentTempParam()));
@ -119,11 +117,11 @@ public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnCli
mealDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getMealDataParam()));
scriptdebugView.setText(determineBasalAdapterAMAJS.getScriptDebug());
}
if (getPlugin().lastAPSRun != null) {
lastRunView.setText(getPlugin().lastAPSRun.toLocaleString());
if (OpenAPSAMAPlugin.getPlugin().lastAPSRun != null) {
lastRunView.setText(OpenAPSAMAPlugin.getPlugin().lastAPSRun.toLocaleString());
}
if (getPlugin().lastAutosensResult != null) {
autosensDataView.setText(JSONFormatter.format(getPlugin().lastAutosensResult.json()));
if (OpenAPSAMAPlugin.getPlugin().lastAutosensResult != null) {
autosensDataView.setText(JSONFormatter.format(OpenAPSAMAPlugin.getPlugin().lastAutosensResult.json()));
}
}
});

View file

@ -39,14 +39,23 @@ import info.nightscout.utils.ToastUtils;
public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
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
DetermineBasalAdapterAMAJS lastDetermineBasalAdapterAMAJS = null;
Date lastAPSRun = null;
DetermineBasalResultAMA lastAPSResult = null;
AutosensResult lastAutosensResult = null;
boolean fragmentEnabled = false;
boolean fragmentVisible = true;
private boolean fragmentEnabled = false;
private boolean fragmentVisible = true;
@Override
public String getName() {
@ -196,9 +205,9 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
maxBasal = verifyHardLimits(maxBasal, "max_basal", 0.1, 10);
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;
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf().doubleValue(), units), "sens", 2, 900))
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf(), units), "sens", 2, 900))
return;
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;

View file

@ -9,6 +9,7 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.squareup.otto.Subscribe;
@ -26,15 +27,6 @@ import info.nightscout.utils.JSONFormatter;
public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClickListener {
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;
TextView lastRunView;
TextView glucoseStatusView;
@ -48,6 +40,7 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.openapsma_fragment, container, false);
run = (Button) view.findViewById(R.id.openapsma_run);
@ -63,13 +56,18 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic
updateGUI();
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.openapsma_run:
getPlugin().invoke("OpenAPSMA button");
OpenAPSMAPlugin.getPlugin().invoke("OpenAPSMA button");
Answers.getInstance().logCustom(new CustomEvent("OpenAPS_MA_Run"));
break;
}
@ -93,12 +91,12 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
DetermineBasalResultMA lastAPSResult = getPlugin().lastAPSResult;
DetermineBasalResultMA lastAPSResult = OpenAPSMAPlugin.getPlugin().lastAPSResult;
if (lastAPSResult != null) {
resultView.setText(JSONFormatter.format(lastAPSResult.json));
requestView.setText(lastAPSResult.toSpanned());
}
DetermineBasalAdapterMAJS determineBasalAdapterMAJS = getPlugin().lastDetermineBasalAdapterMAJS;
DetermineBasalAdapterMAJS determineBasalAdapterMAJS = OpenAPSMAPlugin.getPlugin().lastDetermineBasalAdapterMAJS;
if (determineBasalAdapterMAJS != null) {
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getGlucoseStatusParam()));
currentTempView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getCurrentTempParam()));
@ -106,8 +104,8 @@ public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClic
profileView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getProfileParam()));
mealDataView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getMealDataParam()));
}
if (getPlugin().lastAPSRun != null) {
lastRunView.setText(getPlugin().lastAPSRun.toLocaleString());
if (OpenAPSMAPlugin.getPlugin().lastAPSRun != null) {
lastRunView.setText(OpenAPSMAPlugin.getPlugin().lastAPSRun.toLocaleString());
}
}
});

View file

@ -38,13 +38,22 @@ import static info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin.ver
public class OpenAPSMAPlugin implements PluginBase, APSInterface {
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
DetermineBasalAdapterMAJS lastDetermineBasalAdapterMAJS = null;
Date lastAPSRun = null;
DetermineBasalResultMA lastAPSResult = null;
boolean fragmentEnabled = false;
boolean fragmentVisible = true;
private boolean fragmentEnabled = false;
private boolean fragmentVisible = true;
@Override
public String getName() {
@ -196,7 +205,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
if (!checkOnlyHardLimits(profile.getDia(), "dia", 2, 7)) 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;
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;

View file

@ -33,6 +33,7 @@ import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.answers.Answers;
import com.crashlytics.android.answers.CustomEvent;
import com.jjoe64.graphview.GraphView;
@ -134,12 +135,6 @@ import info.nightscout.utils.ToastUtils;
public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
private static OverviewPlugin overviewPlugin = new OverviewPlugin();
public static OverviewPlugin getPlugin() {
return overviewPlugin;
}
TextView timeView;
TextView bgView;
TextView arrowView;
@ -215,6 +210,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
//check screen width
final DisplayMetrics dm = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
@ -345,6 +341,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
}
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@ -655,7 +656,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
final Profile profile = MainApp.getConfigBuilder().getProfile();
final TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory();
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
QuickWizard.QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
if (quickWizardEntry != null && actualBg != null) {
quickWizardButton.setVisibility(View.VISIBLE);
BolusWizard wizard = new BolusWizard();
@ -1122,7 +1123,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
tempTargetView.setLongClickable(true);
// QuickWizard button
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
QuickWizard.QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
if (quickWizardEntry != null && lastBG != null && pump.isInitialized() && !pump.isSuspended()) {
quickWizardButton.setVisibility(View.VISIBLE);
String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
@ -1809,7 +1810,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// Adding current time to snooze if we got staleData
log.debug("Notification text is: " + notification.text);
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;
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));
@ -1826,7 +1827,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
NotificationStore nstore = getPlugin().notificationStore;
NotificationStore nstore = OverviewPlugin.getPlugin().notificationStore;
nstore.removeExpired();
nstore.unSnooze();
if (nstore.store.size() > 0) {

View file

@ -21,6 +21,15 @@ import info.nightscout.utils.SP;
public class OverviewPlugin implements PluginBase {
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 bgTargetHigh = 180d;

View file

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

View file

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

View file

@ -10,27 +10,21 @@ import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import com.squareup.otto.Subscribe;
import java.util.ArrayList;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
import info.nightscout.utils.DecimalFormatter;
public class NSProfileFragment extends SubscriberFragment implements AdapterView.OnItemSelectedListener {
private static NSProfilePlugin nsProfilePlugin = new NSProfilePlugin();
public static NSProfilePlugin getPlugin() {
return nsProfilePlugin;
}
private Spinner profileSpinner;
private TextView noProfile;
private TextView units;
@ -44,6 +38,7 @@ public class NSProfileFragment extends SubscriberFragment implements AdapterView
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View layout = inflater.inflate(R.layout.nsprofile_fragment, container, false);
profileSpinner = (Spinner) layout.findViewById(R.id.nsprofile_spinner);
@ -60,6 +55,11 @@ public class NSProfileFragment extends SubscriberFragment implements AdapterView
updateGUI();
return layout;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@Subscribe
@ -83,7 +83,7 @@ public class NSProfileFragment extends SubscriberFragment implements AdapterView
noProfile.setVisibility(View.GONE);
}
ProfileStore profileStore = getPlugin().getProfile();
ProfileStore profileStore = NSProfilePlugin.getPlugin().getProfile();
ArrayList<CharSequence> profileList = profileStore.getProfileList();
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(getContext(),
R.layout.spinner_centered, profileList);
@ -100,7 +100,7 @@ public class NSProfileFragment extends SubscriberFragment implements AdapterView
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String name = parent.getItemAtPosition(position).toString();
Profile profile = getPlugin().getProfile().getSpecificProfile(name);
Profile profile = NSProfilePlugin.getPlugin().getProfile().getSpecificProfile(name);
units.setText(profile.getUnits());
dia.setText(DecimalFormatter.to2Decimal(profile.getDia()) + " h");
activeProfile.setText(name);

View file

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

View file

@ -12,6 +12,7 @@ import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import com.crashlytics.android.Crashlytics;
import com.squareup.otto.Subscribe;
import org.slf4j.Logger;
@ -30,12 +31,6 @@ import info.nightscout.utils.SafeParse;
public class SimpleProfileFragment extends SubscriberFragment {
private static Logger log = LoggerFactory.getLogger(SimpleProfileFragment.class);
private static SimpleProfilePlugin simpleProfilePlugin = new SimpleProfilePlugin();
public static SimpleProfilePlugin getPlugin() {
return simpleProfilePlugin;
}
EditText diaView;
RadioButton mgdlView;
RadioButton mmolView;
@ -49,6 +44,7 @@ public class SimpleProfileFragment extends SubscriberFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View layout = inflater.inflate(R.layout.simpleprofile_fragment, container, false);
diaView = (EditText) layout.findViewById(R.id.simpleprofile_dia);
mgdlView = (RadioButton) layout.findViewById(R.id.simpleprofile_mgdl);
@ -68,31 +64,31 @@ public class SimpleProfileFragment extends SubscriberFragment {
updateGUI();
mgdlView.setChecked(simpleProfilePlugin.mgdl);
mmolView.setChecked(simpleProfilePlugin.mmol);
diaView.setText(simpleProfilePlugin.dia.toString());
icView.setText(simpleProfilePlugin.ic.toString());
isfView.setText(simpleProfilePlugin.isf.toString());
basalView.setText(simpleProfilePlugin.basal.toString());
targetlowView.setText(simpleProfilePlugin.targetLow.toString());
targethighView.setText(simpleProfilePlugin.targetHigh.toString());
mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
diaView.setText(SimpleProfilePlugin.getPlugin().dia.toString());
icView.setText(SimpleProfilePlugin.getPlugin().ic.toString());
isfView.setText(SimpleProfilePlugin.getPlugin().isf.toString());
basalView.setText(SimpleProfilePlugin.getPlugin().basal.toString());
targetlowView.setText(SimpleProfilePlugin.getPlugin().targetLow.toString());
targethighView.setText(SimpleProfilePlugin.getPlugin().targetHigh.toString());
mgdlView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
simpleProfilePlugin.mgdl = mgdlView.isChecked();
simpleProfilePlugin.mmol = !simpleProfilePlugin.mgdl;
mmolView.setChecked(simpleProfilePlugin.mmol);
simpleProfilePlugin.storeSettings();
SimpleProfilePlugin.getPlugin().mgdl = mgdlView.isChecked();
SimpleProfilePlugin.getPlugin().mmol = !SimpleProfilePlugin.getPlugin().mgdl;
mmolView.setChecked(SimpleProfilePlugin.getPlugin().mmol);
SimpleProfilePlugin.getPlugin().storeSettings();
}
});
mmolView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
simpleProfilePlugin.mmol = mmolView.isChecked();
simpleProfilePlugin.mgdl = !simpleProfilePlugin.mmol;
mgdlView.setChecked(simpleProfilePlugin.mgdl);
simpleProfilePlugin.storeSettings();
SimpleProfilePlugin.getPlugin().mmol = mmolView.isChecked();
SimpleProfilePlugin.getPlugin().mgdl = !SimpleProfilePlugin.getPlugin().mmol;
mgdlView.setChecked(SimpleProfilePlugin.getPlugin().mgdl);
SimpleProfilePlugin.getPlugin().storeSettings();
}
});
@ -100,7 +96,7 @@ public class SimpleProfileFragment extends SubscriberFragment {
@Override
public void onClick(View view) {
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCHDIRECT;
final OptionsToShow profileswitch = CareportalFragment.PROFILESWITCH;
profileswitch.executeProfileSwitch = true;
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
@ -121,13 +117,13 @@ public class SimpleProfileFragment extends SubscriberFragment {
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
simpleProfilePlugin.dia = SafeParse.stringToDouble(diaView.getText().toString());
simpleProfilePlugin.ic = SafeParse.stringToDouble(icView.getText().toString());
simpleProfilePlugin.isf = SafeParse.stringToDouble(isfView.getText().toString());
simpleProfilePlugin.basal = SafeParse.stringToDouble(basalView.getText().toString());
simpleProfilePlugin.targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
simpleProfilePlugin.targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
simpleProfilePlugin.storeSettings();
SimpleProfilePlugin.getPlugin().dia = SafeParse.stringToDouble(diaView.getText().toString());
SimpleProfilePlugin.getPlugin().ic = SafeParse.stringToDouble(icView.getText().toString());
SimpleProfilePlugin.getPlugin().isf = SafeParse.stringToDouble(isfView.getText().toString());
SimpleProfilePlugin.getPlugin().basal = SafeParse.stringToDouble(basalView.getText().toString());
SimpleProfilePlugin.getPlugin().targetLow = SafeParse.stringToDouble(targetlowView.getText().toString());
SimpleProfilePlugin.getPlugin().targetHigh = SafeParse.stringToDouble(targethighView.getText().toString());
SimpleProfilePlugin.getPlugin().storeSettings();
}
};
@ -141,6 +137,11 @@ public class SimpleProfileFragment extends SubscriberFragment {
updateGUI();
return layout;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@Subscribe

View file

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

View file

@ -7,7 +7,6 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
@ -15,13 +14,12 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import com.crashlytics.android.Crashlytics;
import com.squareup.otto.Subscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventExtendedBolusChange;
@ -89,6 +87,7 @@ public class DanaRFragment extends SubscriberFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
try {
View view = inflater.inflate(R.layout.danar_fragment, container, false);
btConnectionView = (TextView) view.findViewById(R.id.danar_btconnection);
lastConnectionView = (TextView) view.findViewById(R.id.danar_lastconnection);
@ -146,6 +145,11 @@ public class DanaRFragment extends SubscriberFragment {
updateGUI();
return view;
} catch (Exception e) {
Crashlytics.logException(e);
}
return null;
}
@Subscribe

View file

@ -59,11 +59,11 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
return DanaRFragment.class.getName();
}
static boolean fragmentPumpEnabled = false;
static boolean fragmentProfileEnabled = false;
static boolean fragmentPumpVisible = true;
private static boolean fragmentPumpEnabled = false;
private static boolean fragmentProfileEnabled = false;
private static boolean fragmentPumpVisible = true;
public static DanaRExecutionService sExecutionService;
private static DanaRExecutionService sExecutionService;
private static DanaRPump pump = DanaRPump.getInstance();
@ -199,22 +199,22 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
@Override
public void setFragmentEnabled(int type, boolean fragmentEnabled) {
if (type == PluginBase.PROFILE)
this.fragmentProfileEnabled = fragmentEnabled;
fragmentProfileEnabled = fragmentEnabled;
else if (type == PluginBase.PUMP)
this.fragmentPumpEnabled = fragmentEnabled;
fragmentPumpEnabled = fragmentEnabled;
// if pump profile was enabled need to switch to another too
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
if (type == PluginBase.PUMP && !fragmentEnabled && fragmentProfileEnabled) {
setFragmentEnabled(PluginBase.PROFILE, false);
setFragmentVisible(PluginBase.PROFILE, false);
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentEnabled(PluginBase.PROFILE, true);
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentVisible(PluginBase.PROFILE, true);
NSProfilePlugin.getPlugin().setFragmentEnabled(PluginBase.PROFILE, true);
NSProfilePlugin.getPlugin().setFragmentVisible(PluginBase.PROFILE, true);
}
}
@Override
public void setFragmentVisible(int type, boolean fragmentVisible) {
if (type == PluginBase.PUMP)
this.fragmentPumpVisible = fragmentVisible;
fragmentPumpVisible = fragmentVisible;
}
@Override
@ -506,7 +506,8 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
}
if (percent > getPumpDescription().maxTempPercent)
percent = getPumpDescription().maxTempPercent;
if (pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null && runningTB.percentRate == percent) {
result.enacted = false;
result.success = true;
result.isTempCancel = false;
@ -550,7 +551,8 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep * (1 + durationInHalfHours % 1));
PumpEnactResult result = new PumpEnactResult();
if (pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) {
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
result.enacted = false;
result.success = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
@ -601,7 +603,8 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
public PumpEnactResult cancelRealTempBasal() {
PumpEnactResult result = new PumpEnactResult();
if (pump.isTempBasalInProgress) {
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null) {
sExecutionService.tempBasalStop();
result.enacted = true;
result.isTempCancel = true;
@ -625,7 +628,8 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
@Override
public PumpEnactResult cancelExtendedBolus() {
PumpEnactResult result = new PumpEnactResult();
if (pump.isExtendedInProgress) {
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
if (runningEB != null) {
sExecutionService.extendedBolusStop();
result.enacted = true;
result.isTempCancel = true;

View file

@ -61,15 +61,15 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
return DanaRFragment.class.getName();
}
static boolean fragmentPumpEnabled = false;
static boolean fragmentProfileEnabled = false;
static boolean fragmentPumpVisible = true;
private boolean fragmentPumpEnabled = false;
private boolean fragmentProfileEnabled = false;
private boolean fragmentPumpVisible = true;
public static DanaRKoreanExecutionService sExecutionService;
private static DanaRKoreanExecutionService sExecutionService;
private static DanaRPump pump = DanaRPump.getInstance();
private static boolean useExtendedBoluses = false;
private DanaRPump pump = DanaRPump.getInstance();
private boolean useExtendedBoluses = false;
private static DanaRKoreanPlugin plugin = null;
@ -208,8 +208,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
setFragmentEnabled(PluginBase.PROFILE, false);
setFragmentVisible(PluginBase.PROFILE, false);
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentEnabled(PluginBase.PROFILE, true);
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentVisible(PluginBase.PROFILE, true);
NSProfilePlugin.getPlugin().setFragmentEnabled(PluginBase.PROFILE, true);
NSProfilePlugin.getPlugin().setFragmentVisible(PluginBase.PROFILE, true);
}
}
@ -503,7 +503,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
}
if (percent > getPumpDescription().maxTempPercent)
percent = getPumpDescription().maxTempPercent;
if (pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null && runningTB.percentRate == percent) {
result.enacted = false;
result.success = true;
result.isTempCancel = false;
@ -547,7 +548,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep * (1 + durationInHalfHours % 1));
PumpEnactResult result = new PumpEnactResult();
if (pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) {
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
result.enacted = false;
result.success = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
@ -598,7 +600,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
public PumpEnactResult cancelRealTempBasal() {
PumpEnactResult result = new PumpEnactResult();
if (pump.isTempBasalInProgress) {
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null) {
sExecutionService.tempBasalStop();
result.enacted = true;
result.isTempCancel = true;
@ -622,7 +625,8 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
@Override
public PumpEnactResult cancelExtendedBolus() {
PumpEnactResult result = new PumpEnactResult();
if (pump.isExtendedInProgress) {
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
if (runningEB != null) {
sExecutionService.extendedBolusStop();
result.enacted = true;
result.isTempCancel = true;

View file

@ -60,11 +60,11 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
return DanaRFragment.class.getName();
}
static boolean fragmentPumpEnabled = false;
static boolean fragmentProfileEnabled = false;
static boolean fragmentPumpVisible = false;
private boolean fragmentPumpEnabled = false;
private boolean fragmentProfileEnabled = false;
private boolean fragmentPumpVisible = false;
public static DanaRv2ExecutionService sExecutionService;
private static DanaRv2ExecutionService sExecutionService;
private static DanaRv2Plugin plugin = null;
@ -77,9 +77,9 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
private static DanaRPump pump = DanaRPump.getInstance();
public static PumpDescription pumpDescription = new PumpDescription();
private static PumpDescription pumpDescription = new PumpDescription();
public DanaRv2Plugin() {
private DanaRv2Plugin() {
Context context = MainApp.instance().getApplicationContext();
Intent intent = new Intent(context, DanaRv2ExecutionService.class);
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
@ -192,8 +192,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
if (type == PluginBase.PUMP && !fragmentEnabled && this.fragmentProfileEnabled) {
setFragmentEnabled(PluginBase.PROFILE, false);
setFragmentVisible(PluginBase.PROFILE, false);
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentEnabled(PluginBase.PROFILE, true);
MainApp.getSpecificPlugin(NSProfilePlugin.class).setFragmentVisible(PluginBase.PROFILE, true);
NSProfilePlugin.getPlugin().setFragmentEnabled(PluginBase.PROFILE, true);
NSProfilePlugin.getPlugin().setFragmentVisible(PluginBase.PROFILE, true);
}
}
@ -429,7 +429,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
}
if (percent > getPumpDescription().maxTempPercent)
percent = getPumpDescription().maxTempPercent;
if (pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null && runningTB.percentRate == percent) {
result.enacted = false;
result.success = true;
result.isTempCancel = false;
@ -494,7 +495,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep * (1 + durationInHalfHours % 1));
PumpEnactResult result = new PumpEnactResult();
if (pump.isExtendedInProgress && Math.abs(pump.extendedBolusAmount - insulin) < getPumpDescription().extendedBolusStep) {
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
result.enacted = false;
result.success = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
@ -530,7 +532,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
@Override
public PumpEnactResult cancelTempBasal(boolean force) {
PumpEnactResult result = new PumpEnactResult();
if (pump.isTempBasalInProgress) {
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
if (runningTB != null) {
sExecutionService.tempBasalStop();
result.enacted = true;
result.isTempCancel = true;
@ -554,7 +557,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
@Override
public PumpEnactResult cancelExtendedBolus() {
PumpEnactResult result = new PumpEnactResult();
if (pump.isExtendedInProgress) {
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
if (runningEB != null) {
sExecutionService.extendedBolusStop();
result.enacted = true;
result.isTempCancel = true;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -53,12 +53,22 @@ import info.nightscout.utils.XdripCalibrations;
public class SmsCommunicatorPlugin implements PluginBase {
private static Logger log = LoggerFactory.getLogger(SmsCommunicatorPlugin.class);
private static boolean fragmentEnabled = false;
private static boolean fragmentVisible = true;
private static SmsCommunicatorPlugin smsCommunicatorPlugin;
public static SmsCommunicatorPlugin getPlugin() {
if (smsCommunicatorPlugin == null) {
smsCommunicatorPlugin = new SmsCommunicatorPlugin();
}
return smsCommunicatorPlugin;
}
private boolean fragmentEnabled = false;
private boolean fragmentVisible = true;
private final long CONFIRM_TIMEOUT = 5 * 60 * 1000L;
private List<String> allowedNumbers = new ArrayList<String>();
private List<String> allowedNumbers = new ArrayList<>();
class Sms {
String phoneNumber;
@ -110,7 +120,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
ArrayList<Sms> messages = new ArrayList<>();
public SmsCommunicatorPlugin() {
private SmsCommunicatorPlugin() {
MainApp.bus().register(this);
processSettings(null);
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -3,6 +3,7 @@ package info.nightscout.utils;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.KeyEvent;
@ -123,6 +124,22 @@ public class NumberPicker extends LinearLayout implements View.OnKeyListener,
plusButton.setOnTouchListener(this);
plusButton.setOnKeyListener(this);
plusButton.setOnClickListener(this);
setTextWatcher(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
value = SafeParse.stringToDouble(editText.getText().toString());
}
});
}
public void setTextWatcher(TextWatcher textWatcher) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -610,27 +610,38 @@
<Button
android:id="@+id/danar_viewprofile"
style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="@drawable/icon_danarprofile"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/danar_viewprofile"/>
<Button
android:id="@+id/danar_history"
style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="@drawable/icon_danarhistory"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/danar_history" />
</LinearLayout>
<Button
android:id="@+id/danar_stats"
style="@style/ButtonSmallFontStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableTop="@drawable/icon_danarstats"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:text="@string/danar_stats" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</FrameLayout>

View file

@ -708,5 +708,14 @@
<string name="key_wizard_include_basal_iob">wizard_include_basal_iob</string>
<string name="careportal_newnstreatment_percentage_label">Percentage</string>
<string name="careportal_newnstreatment_timeshift_label">Time shift</string>
<string name="default_temptargets">Default Temp-Targets</string>
<string name="eatingsoon_duration">eatingsoon duration</string>
<string name="eatingsoon_target">eatingsoon target</string>
<string name="activity_duration">activity duration</string>
<string name="activity_target">activity target</string>
<string name="key_eatingsoon_duration">eatingsoon_duration</string>
<string name="key_eatingsoon_target">eatingsoon_target</string>
<string name="key_activity_duration">activity_duration</string>
<string name="key_activity_target">activity_target</string>
</resources>

View file

@ -3,6 +3,33 @@
<PreferenceCategory
android:key="others"
android:title="@string/othersettings_title">
<PreferenceScreen
android:title="@string/default_temptargets">
<EditTextPreference
android:title="@string/eatingsoon_duration"
android:key="@string/key_eatingsoon_duration"
android:defaultValue="0"
android:inputType="number">
</EditTextPreference>
<EditTextPreference
android:title="@string/eatingsoon_target"
android:key="@string/key_eatingsoon_target"
android:defaultValue="0"
android:inputType="numberDecimal">
</EditTextPreference>
<EditTextPreference
android:title="@string/activity_duration"
android:key="@string/key_activity_duration"
android:defaultValue="0"
android:inputType="number">
</EditTextPreference>
<EditTextPreference
android:title="@string/activity_target"
android:key="@string/key_activity_target"
android:defaultValue="0"
android:inputType="numberDecimal">
</EditTextPreference>
</PreferenceScreen>
<PreferenceScreen
android:title="@string/fillbolus_title">
<EditTextPreference