Merge pull request #1939 from MilosKozak/loopkotlin
Remove butterknife dependency
This commit is contained in:
commit
7eafb76f3e
118 changed files with 2547 additions and 3164 deletions
|
@ -16,7 +16,6 @@ apply plugin: 'kotlin-android-extensions'
|
|||
apply plugin: 'com.google.gms.google-services'
|
||||
apply plugin: 'io.fabric'
|
||||
apply plugin: 'jacoco-android'
|
||||
apply plugin: 'com.jakewharton.butterknife'
|
||||
apply plugin: 'de.undercouch.download'
|
||||
|
||||
|
||||
|
@ -29,7 +28,6 @@ ext {
|
|||
ormLiteVersion = "4.46"
|
||||
powermockVersion = "1.7.3"
|
||||
dexmakerVersion = "1.2"
|
||||
butterknifeVersion = "10.1.0"
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,7 +109,7 @@ android {
|
|||
targetSdkVersion 28
|
||||
multiDexEnabled true
|
||||
versionCode 1500
|
||||
version "2.4-dev"
|
||||
version "2.4-dev-a"
|
||||
buildConfigField "String", "VERSION", '"' + version + '"'
|
||||
buildConfigField "String", "BUILDVERSION", '"' + generateGitBuild() + '-' + generateDate() + '"'
|
||||
buildConfigField "String", "REMOTE", '"' + generateGitRemote() + '"'
|
||||
|
@ -272,9 +270,6 @@ dependencies {
|
|||
|
||||
implementation 'org.mozilla:rhino:1.7.7.2'
|
||||
|
||||
implementation "com.jakewharton:butterknife:${butterknifeVersion}"
|
||||
annotationProcessor "com.jakewharton:butterknife-compiler:${butterknifeVersion}"
|
||||
|
||||
implementation 'com.github.DavidProdinger:weekdays-selector:1.1.0'
|
||||
|
||||
testImplementation "junit:junit:4.12"
|
||||
|
|
|
@ -7,16 +7,6 @@ import android.graphics.Rect;
|
|||
import android.os.Bundle;
|
||||
import android.os.PersistableBundle;
|
||||
import android.os.PowerManager;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.text.SpannableString;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.util.Linkify;
|
||||
|
@ -31,6 +21,16 @@ import android.widget.EditText;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.drawerlayout.widget.DrawerLayout;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.material.navigation.NavigationView;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.joanzapata.iconify.Iconify;
|
||||
import com.joanzapata.iconify.fonts.FontAwesomeModule;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import info.nightscout.androidaps.activities.AgreementActivity;
|
||||
import info.nightscout.androidaps.activities.HistoryBrowseActivity;
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
import info.nightscout.androidaps.activities.PreferencesActivity;
|
||||
import info.nightscout.androidaps.activities.SingleFragmentActivity;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
|
@ -63,7 +64,7 @@ import info.nightscout.androidaps.utils.OKDialog;
|
|||
import info.nightscout.androidaps.utils.PasswordProtection;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
public class MainActivity extends NoSplashAppCompatActivity {
|
||||
private static Logger log = LoggerFactory.getLogger(L.CORE);
|
||||
|
||||
protected PowerManager.WakeLock mWakeLock;
|
||||
|
@ -73,8 +74,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
private MenuItem pluginPreferencesMenuItem;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(R.style.AppTheme_NoActionBar);
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
if (L.isEnabled(L.CORE))
|
||||
|
|
|
@ -2,9 +2,6 @@ package info.nightscout.androidaps.activities;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.os.SystemClock;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import android.text.SpannableString;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.Menu;
|
||||
|
@ -15,6 +12,9 @@ import android.widget.ImageButton;
|
|||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.core.content.res.ResourcesCompat;
|
||||
|
||||
import com.jjoe64.graphview.GraphView;
|
||||
import com.squareup.otto.Subscribe;
|
||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
|
||||
|
@ -25,10 +25,6 @@ import org.slf4j.LoggerFactory;
|
|||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.OnLongClick;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
|
@ -36,12 +32,12 @@ import info.nightscout.androidaps.events.EventCustomCalculationFinished;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress;
|
||||
import info.nightscout.androidaps.plugins.general.overview.OverviewFragment;
|
||||
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCalculationProgress;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.T;
|
||||
|
||||
|
@ -55,19 +51,12 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
boolean showIob, showCob, showDev, showRat, showActPrim, showActSec, showDevslope;
|
||||
|
||||
|
||||
@BindView(R.id.historybrowse_date)
|
||||
Button buttonDate;
|
||||
@BindView(R.id.historybrowse_zoom)
|
||||
Button buttonZoom;
|
||||
@BindView(R.id.historyybrowse_bggraph)
|
||||
GraphView bgGraph;
|
||||
@BindView(R.id.historybrowse_iobgraph)
|
||||
GraphView iobGraph;
|
||||
@BindView(R.id.historybrowse_seekBar)
|
||||
SeekBar seekBar;
|
||||
@BindView(R.id.historybrowse_noprofile)
|
||||
TextView noProfile;
|
||||
@BindView(R.id.overview_iobcalculationprogess)
|
||||
TextView iobCalculationProgressView;
|
||||
|
||||
private int rangeToDisplay = 24; // for graph
|
||||
|
@ -86,7 +75,79 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_historybrowse);
|
||||
|
||||
ButterKnife.bind(this);
|
||||
buttonDate = findViewById(R.id.historybrowse_date);
|
||||
buttonZoom = findViewById(R.id.historybrowse_zoom);
|
||||
bgGraph = findViewById(R.id.historyybrowse_bggraph);
|
||||
iobGraph = findViewById(R.id.historybrowse_iobgraph);
|
||||
seekBar = findViewById(R.id.historybrowse_seekBar);
|
||||
noProfile = findViewById(R.id.historybrowse_noprofile);
|
||||
iobCalculationProgressView = findViewById(R.id.overview_iobcalculationprogess);
|
||||
|
||||
findViewById(R.id.historybrowse_left).setOnClickListener(v -> {
|
||||
start -= T.hours(rangeToDisplay).msecs();
|
||||
updateGUI("onClickLeft");
|
||||
runCalculation("onClickLeft");
|
||||
});
|
||||
|
||||
findViewById(R.id.historybrowse_right).setOnClickListener(v -> {
|
||||
start += T.hours(rangeToDisplay).msecs();
|
||||
updateGUI("onClickRight");
|
||||
runCalculation("onClickRight");
|
||||
});
|
||||
|
||||
findViewById(R.id.historybrowse_end).setOnClickListener(v -> {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
start = calendar.getTimeInMillis();
|
||||
updateGUI("onClickEnd");
|
||||
runCalculation("onClickEnd");
|
||||
});
|
||||
|
||||
findViewById(R.id.historybrowse_zoom).setOnClickListener(v -> {
|
||||
rangeToDisplay += 6;
|
||||
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
||||
updateGUI("rangeChange");
|
||||
});
|
||||
|
||||
findViewById(R.id.historybrowse_zoom).setOnLongClickListener(v -> {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(start);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
start = calendar.getTimeInMillis();
|
||||
updateGUI("resetToMidnight");
|
||||
runCalculation("onLongClickZoom");
|
||||
return true;
|
||||
});
|
||||
|
||||
findViewById(R.id.historybrowse_date).setOnClickListener(v -> {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date(start));
|
||||
DatePickerDialog dpd = DatePickerDialog.newInstance(
|
||||
(view, year, monthOfYear, dayOfMonth) -> {
|
||||
Date date = new Date(0);
|
||||
date.setYear(year - 1900);
|
||||
date.setMonth(monthOfYear);
|
||||
date.setDate(dayOfMonth);
|
||||
date.setHours(0);
|
||||
start = date.getTime();
|
||||
updateGUI("onClickDate");
|
||||
runCalculation("onClickDate");
|
||||
},
|
||||
calendar.get(Calendar.YEAR),
|
||||
calendar.get(Calendar.MONTH),
|
||||
calendar.get(Calendar.DAY_OF_MONTH)
|
||||
);
|
||||
dpd.setThemeDark(true);
|
||||
dpd.dismissOnPause(true);
|
||||
dpd.show(getFragmentManager(), "Datepickerdialog");
|
||||
});
|
||||
|
||||
bgGraph.getGridLabelRenderer().setGridColor(MainApp.gc(R.color.graphgrid));
|
||||
bgGraph.getGridLabelRenderer().reloadStyles();
|
||||
|
@ -124,78 +185,6 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
updateGUI("onResume");
|
||||
}
|
||||
|
||||
@OnClick(R.id.historybrowse_left)
|
||||
void onClickLeft() {
|
||||
start -= T.hours(rangeToDisplay).msecs();
|
||||
updateGUI("onClickLeft");
|
||||
runCalculation("onClickLeft");
|
||||
}
|
||||
|
||||
@OnClick(R.id.historybrowse_right)
|
||||
void onClickRight() {
|
||||
start += T.hours(rangeToDisplay).msecs();
|
||||
updateGUI("onClickRight");
|
||||
runCalculation("onClickRight");
|
||||
}
|
||||
|
||||
@OnClick(R.id.historybrowse_end)
|
||||
void onClickEnd() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
start = calendar.getTimeInMillis();
|
||||
updateGUI("onClickEnd");
|
||||
runCalculation("onClickEnd");
|
||||
}
|
||||
|
||||
@OnClick(R.id.historybrowse_zoom)
|
||||
void onClickZoom() {
|
||||
rangeToDisplay += 6;
|
||||
rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
|
||||
updateGUI("rangeChange");
|
||||
}
|
||||
|
||||
@OnLongClick(R.id.historybrowse_zoom)
|
||||
boolean onLongClickZoom() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(start);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
start = calendar.getTimeInMillis();
|
||||
updateGUI("resetToMidnight");
|
||||
runCalculation("onLongClickZoom");
|
||||
return true;
|
||||
}
|
||||
|
||||
@OnClick(R.id.historybrowse_date)
|
||||
void onClickDate() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(new Date(start));
|
||||
DatePickerDialog dpd = DatePickerDialog.newInstance(
|
||||
(view, year, monthOfYear, dayOfMonth) -> {
|
||||
Date date = new Date(0);
|
||||
date.setYear(year - 1900);
|
||||
date.setMonth(monthOfYear);
|
||||
date.setDate(dayOfMonth);
|
||||
date.setHours(0);
|
||||
start = date.getTime();
|
||||
updateGUI("onClickDate");
|
||||
runCalculation("onClickDate");
|
||||
},
|
||||
calendar.get(Calendar.YEAR),
|
||||
calendar.get(Calendar.MONTH),
|
||||
calendar.get(Calendar.DAY_OF_MONTH)
|
||||
);
|
||||
dpd.setThemeDark(true);
|
||||
dpd.dismissOnPause(true);
|
||||
dpd.show(getFragmentManager(), "Datepickerdialog");
|
||||
}
|
||||
|
||||
private void runCalculation(String from) {
|
||||
long end = start + T.hours(rangeToDisplay).msecs();
|
||||
iobCobCalculatorPlugin.stopCalculation(from);
|
||||
|
@ -285,8 +274,8 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
// set manual x bounds to have nice steps
|
||||
graphData.formatAxis(fromTime, toTime);
|
||||
|
||||
if(showActPrim) {
|
||||
graphData.addActivity(fromTime, toTime, false,1d);
|
||||
if (showActPrim) {
|
||||
graphData.addActivity(fromTime, toTime, false, 1d);
|
||||
}
|
||||
|
||||
// Treatments
|
||||
|
@ -335,7 +324,7 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
if (showRat)
|
||||
secondGraphData.addRatio(fromTime, toTime, useRatioForScale, 1d);
|
||||
if (showActSec)
|
||||
secondGraphData.addActivity(fromTime, toTime, useIAForScale, useIAForScale? 2d: 1d);
|
||||
secondGraphData.addActivity(fromTime, toTime, useIAForScale, useIAForScale ? 2d : 1d);
|
||||
if (showDevslope)
|
||||
secondGraphData.addDeviationSlope(fromTime, toTime, useDSForScale, 1d);
|
||||
|
||||
|
@ -362,7 +351,7 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
private void setupChartMenu() {
|
||||
chartButton = (ImageButton) findViewById(R.id.overview_chartMenuButton);
|
||||
chartButton.setOnClickListener(v -> {
|
||||
MenuItem item,dividerItem;
|
||||
MenuItem item, dividerItem;
|
||||
CharSequence title;
|
||||
int titleMaxChars = 0;
|
||||
SpannableString s;
|
||||
|
@ -371,7 +360,7 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
|
||||
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.BAS.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_basals));
|
||||
title = item.getTitle();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.basal, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
|
@ -380,7 +369,7 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
|
||||
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.ACTPRIM.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_activity));
|
||||
title = item.getTitle();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.activity, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
|
@ -392,7 +381,7 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
|
||||
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.IOB.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_iob));
|
||||
title = item.getTitle();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.iob, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
|
@ -401,7 +390,7 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
|
||||
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.COB.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_cob));
|
||||
title = item.getTitle();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.cob, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
|
@ -410,7 +399,7 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
|
||||
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.DEV.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_deviations));
|
||||
title = item.getTitle();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.deviations, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
|
@ -419,7 +408,7 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
|
||||
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.SEN.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_sensitivity));
|
||||
title = item.getTitle();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.ratio, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
|
@ -428,7 +417,7 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
|
||||
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.ACTSEC.ordinal(), Menu.NONE, MainApp.gs(R.string.overview_show_activity));
|
||||
title = item.getTitle();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.activity, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
|
@ -439,7 +428,7 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
if (MainApp.devBranch) {
|
||||
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.DEVSLOPE.ordinal(), Menu.NONE, "Deviation slope");
|
||||
title = item.getTitle();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
if (titleMaxChars < title.length()) titleMaxChars = title.length();
|
||||
s = new SpannableString(title);
|
||||
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.devslopepos, null)), 0, s.length(), 0);
|
||||
item.setTitle(s);
|
||||
|
@ -448,7 +437,7 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
|||
}
|
||||
|
||||
// Fairly good guestimate for required divider text size...
|
||||
title = new String(new char[titleMaxChars+10]).replace("\0", "_");
|
||||
title = new String(new char[titleMaxChars + 10]).replace("\0", "_");
|
||||
dividerItem.setTitle(title);
|
||||
|
||||
popup.setOnMenuItemClickListener(item1 -> {
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package info.nightscout.androidaps.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import info.nightscout.androidaps.R
|
||||
|
||||
open class NoSplashAppCompatActivity : AppCompatActivity() {
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
setTheme(R.style.AppTheme_NoActionBar)
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
}
|
|
@ -1,11 +1,9 @@
|
|||
package info.nightscout.androidaps.activities
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin
|
||||
|
||||
class RequestDexcomPermissionActivity : AppCompatActivity() {
|
||||
class RequestDexcomPermissionActivity : NoSplashAppCompatActivity() {
|
||||
|
||||
private val requestCode = "AndroidAPS <3".map { it.toInt() }.sum()
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.utils.PasswordProtection;
|
||||
|
||||
public class SingleFragmentActivity extends AppCompatActivity {
|
||||
public class SingleFragmentActivity extends NoSplashAppCompatActivity {
|
||||
|
||||
private PluginBase plugin;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_single_fragment);
|
||||
|
||||
|
|
|
@ -464,7 +464,7 @@ public class Profile {
|
|||
public String getBasalList() {
|
||||
if (basal_v == null)
|
||||
basal_v = convertToSparseArray(basal);
|
||||
return getValuesList(basal_v, null, new DecimalFormat("0.00"), MainApp.gs(R.string.profile_ins_units_per_hout));
|
||||
return getValuesList(basal_v, null, new DecimalFormat("0.00"), MainApp.gs(R.string.profile_ins_units_per_hour));
|
||||
}
|
||||
|
||||
public class ProfileValue {
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
package info.nightscout.androidaps.interfaces;
|
||||
|
||||
import android.os.SystemClock;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.EventConfigBuilderUpdateGui;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -41,39 +46,46 @@ public abstract class PluginBase {
|
|||
|
||||
// Default always calls invoke
|
||||
// Plugins that have special constraints if they get switched to may override this method
|
||||
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity activity) {
|
||||
pluginSwitcher.invoke();
|
||||
public void switchAllowed(boolean newState, FragmentActivity activity, PluginType type) {
|
||||
performPluginSwitch(newState, type);
|
||||
}
|
||||
|
||||
protected void confirmPumpPluginActivation(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity activity) {
|
||||
boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false);
|
||||
if (allowHardwarePump || activity == null) {
|
||||
pluginSwitcher.invoke();
|
||||
protected void confirmPumpPluginActivation(boolean newState, FragmentActivity activity, PluginType type) {
|
||||
if (type == PluginType.PUMP) {
|
||||
boolean allowHardwarePump = SP.getBoolean("allow_hardware_pump", false);
|
||||
if (allowHardwarePump || activity == null) {
|
||||
performPluginSwitch(newState, type);
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setMessage(R.string.allow_hardware_pump_text)
|
||||
.setPositiveButton(R.string.yes, (dialog, id) -> {
|
||||
performPluginSwitch(newState, type);
|
||||
SP.putBoolean("allow_hardware_pump", true);
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("First time HW pump allowed!");
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, (dialog, id) -> {
|
||||
RxBus.INSTANCE.send(new EventConfigBuilderUpdateGui());
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("User does not allow switching to HW pump!");
|
||||
});
|
||||
builder.create().show();
|
||||
}
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
builder.setMessage(R.string.allow_hardware_pump_text)
|
||||
.setPositiveButton(R.string.yes, (dialog, id) -> {
|
||||
pluginSwitcher.invoke();
|
||||
SP.putBoolean("allow_hardware_pump", true);
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("First time HW pump allowed!");
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, (dialog, id) -> {
|
||||
pluginSwitcher.cancel();
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("User does not allow switching to HW pump!");
|
||||
});
|
||||
builder.create().show();
|
||||
performPluginSwitch(newState, type);
|
||||
}
|
||||
}
|
||||
|
||||
// public PluginType getType() {
|
||||
// return mainType;
|
||||
// }
|
||||
|
||||
// public String getFragmentClass() {
|
||||
// return fragmentClass;
|
||||
// }
|
||||
private void performPluginSwitch(boolean enabled, PluginType type) {
|
||||
setPluginEnabled(type, enabled);
|
||||
setFragmentVisible(type, enabled);
|
||||
ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(this, getType());
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxEnabled");
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
MainApp.bus().post(new EventConfigBuilderChange());
|
||||
RxBus.INSTANCE.send(new EventConfigBuilderUpdateGui());
|
||||
ConfigBuilderPlugin.getPlugin().logPluginStatus();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if (pluginDescription.pluginName == -1)
|
||||
|
@ -105,10 +117,6 @@ public abstract class PluginBase {
|
|||
return pluginDescription.preferencesId;
|
||||
}
|
||||
|
||||
public int getAdvancedPreferencesId() {
|
||||
return pluginDescription.advancedPreferencesId;
|
||||
}
|
||||
|
||||
public boolean isEnabled(PluginType type) {
|
||||
if (pluginDescription.alwaysEnabled && type == pluginDescription.mainType)
|
||||
return true;
|
||||
|
@ -168,7 +176,7 @@ public abstract class PluginBase {
|
|||
}
|
||||
|
||||
public boolean isFragmentVisible() {
|
||||
if (pluginDescription.alwayVisible)
|
||||
if (pluginDescription.alwaysVisible)
|
||||
return true;
|
||||
if (pluginDescription.neverVisible)
|
||||
return false;
|
||||
|
|
|
@ -3,7 +3,7 @@ package info.nightscout.androidaps.interfaces;
|
|||
public class PluginDescription {
|
||||
PluginType mainType = PluginType.GENERAL;
|
||||
String fragmentClass = null;
|
||||
public boolean alwayVisible = false;
|
||||
public boolean alwaysVisible = false;
|
||||
public boolean neverVisible = false;
|
||||
public boolean alwaysEnabled = false;
|
||||
boolean showInList = true;
|
||||
|
@ -11,7 +11,6 @@ public class PluginDescription {
|
|||
int shortName = -1;
|
||||
int description = -1;
|
||||
int preferencesId = -1;
|
||||
int advancedPreferencesId = -1;
|
||||
public boolean enableByDefault = false;
|
||||
public boolean visibleByDefault = false;
|
||||
|
||||
|
@ -30,8 +29,8 @@ public class PluginDescription {
|
|||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription alwayVisible(boolean alwayVisible) {
|
||||
this.alwayVisible = alwayVisible;
|
||||
public PluginDescription alwaysVisible(boolean alwayVisible) {
|
||||
this.alwaysVisible = alwayVisible;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -60,11 +59,6 @@ public class PluginDescription {
|
|||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription advancedPreferencesId(int advancedPreferencesId) {
|
||||
this.advancedPreferencesId = advancedPreferencesId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PluginDescription enableByDefault(boolean enableByDefault) {
|
||||
this.enableByDefault = enableByDefault;
|
||||
return this;
|
||||
|
|
|
@ -1,145 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.aps.loop;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.Constraint;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopSetLastRunGui;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
|
||||
public class LoopFragment extends SubscriberFragment {
|
||||
@BindView(R.id.loop_run)
|
||||
Button runNowButton;
|
||||
@BindView(R.id.loop_lastrun)
|
||||
TextView lastRunView;
|
||||
@BindView(R.id.loop_lastenact)
|
||||
TextView lastEnactView;
|
||||
@BindView(R.id.loop_source)
|
||||
TextView sourceView;
|
||||
@BindView(R.id.loop_request)
|
||||
TextView requestView;
|
||||
@BindView(R.id.loop_constraintsprocessed)
|
||||
TextView constraintsProcessedView;
|
||||
@BindView(R.id.loop_constraints)
|
||||
TextView constraintsView;
|
||||
@BindView(R.id.loop_tbrsetbypump)
|
||||
TextView tbrSetByPumpView;
|
||||
@BindView(R.id.loop_smbsetbypump)
|
||||
TextView smbSetByPumpView;
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
try {
|
||||
View view = inflater.inflate(R.layout.loop_fragment, container, false);
|
||||
unbinder = ButterKnife.bind(this, view);
|
||||
return view;
|
||||
} catch (Exception e) {
|
||||
FabricPrivacy.logException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@OnClick(R.id.loop_run)
|
||||
void onRunClick() {
|
||||
lastRunView.setText(MainApp.gs(R.string.executing));
|
||||
new Thread(() -> LoopPlugin.getPlugin().invoke("Loop button", true)).start();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventLoopUpdateGui ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventLoopSetLastRunGui ev) {
|
||||
clearGUI();
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
synchronized (LoopFragment.this) {
|
||||
if (lastRunView != null) lastRunView.setText(ev.text);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
synchronized (LoopFragment.this) {
|
||||
if (!isBound()) return;
|
||||
LoopPlugin.LastRun lastRun = LoopPlugin.lastRun;
|
||||
if (lastRun != null) {
|
||||
requestView.setText(lastRun.request != null ? lastRun.request.toSpanned() : "");
|
||||
constraintsProcessedView.setText(lastRun.constraintsProcessed != null ? lastRun.constraintsProcessed.toSpanned() : "");
|
||||
sourceView.setText(lastRun.source != null ? lastRun.source : "");
|
||||
lastRunView.setText(lastRun.lastAPSRun != null && lastRun.lastAPSRun.getTime() != 0 ? lastRun.lastAPSRun.toLocaleString() : "");
|
||||
lastEnactView.setText(lastRun.lastEnact != null && lastRun.lastEnact.getTime() != 0 ? lastRun.lastEnact.toLocaleString() : "");
|
||||
tbrSetByPumpView.setText(lastRun.tbrSetByPump != null ? Html.fromHtml(lastRun.tbrSetByPump.toHtml()) : "");
|
||||
smbSetByPumpView.setText(lastRun.smbSetByPump != null ? Html.fromHtml(lastRun.smbSetByPump.toHtml()) : "");
|
||||
|
||||
String constraints = "";
|
||||
if (lastRun.constraintsProcessed != null) {
|
||||
Constraint<Double> allConstraints = new Constraint<>(0d);
|
||||
if (lastRun.constraintsProcessed.rateConstraint != null)
|
||||
allConstraints.copyReasons(lastRun.constraintsProcessed.rateConstraint);
|
||||
if (lastRun.constraintsProcessed.smbConstraint != null)
|
||||
allConstraints.copyReasons(lastRun.constraintsProcessed.smbConstraint);
|
||||
constraints = allConstraints.getMostLimitedReasons();
|
||||
}
|
||||
constraintsView.setText(constraints);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void clearGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
synchronized (LoopFragment.this) {
|
||||
if (isBound()) {
|
||||
requestView.setText("");
|
||||
constraintsProcessedView.setText("");
|
||||
sourceView.setText("");
|
||||
lastRunView.setText("");
|
||||
lastEnactView.setText("");
|
||||
tbrSetByPumpView.setText("");
|
||||
smbSetByPumpView.setText("");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
boolean isBound() {
|
||||
return requestView != null
|
||||
&& constraintsProcessedView != null
|
||||
&& sourceView != null
|
||||
&& lastRunView != null
|
||||
&& lastEnactView != null
|
||||
&& tbrSetByPumpView != null
|
||||
&& smbSetByPumpView != null
|
||||
&& constraintsView != null
|
||||
&& runNowButton != null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package info.nightscout.androidaps.plugins.aps.loop
|
||||
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.Constraint
|
||||
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopSetLastRunGui
|
||||
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.HtmlHelper
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotlinx.android.synthetic.main.loop_fragment.*
|
||||
|
||||
class LoopFragment : Fragment() {
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
operator fun CompositeDisposable.plusAssign(disposable: Disposable) {
|
||||
add(disposable)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.loop_fragment, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
loop_run.setOnClickListener {
|
||||
loop_lastrun.text = MainApp.gs(R.string.executing)
|
||||
Thread { LoopPlugin.getPlugin().invoke("Loop button", true) }.start()
|
||||
}
|
||||
|
||||
updateGUI()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
disposable += RxBus
|
||||
.toObservable(EventLoopUpdateGui::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
updateGUI()
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
|
||||
disposable += RxBus
|
||||
.toObservable(EventLoopSetLastRunGui::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
clearGUI()
|
||||
loop_lastrun.text = it.text
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
}
|
||||
|
||||
fun updateGUI() {
|
||||
LoopPlugin.lastRun?.let {
|
||||
loop_request.text = it.request?.toSpanned() ?: ""
|
||||
loop_constraintsprocessed.text = it.constraintsProcessed?.toSpanned() ?: ""
|
||||
loop_source.text = it.source ?: ""
|
||||
loop_lastrun.text = it.lastAPSRun?.let { lastRun -> DateUtil.dateAndTimeString(lastRun.time) }
|
||||
?: ""
|
||||
loop_lastenact.text = it.lastAPSRun?.let { lastEnact -> DateUtil.dateAndTimeString(lastEnact.time) }
|
||||
?: ""
|
||||
loop_tbrsetbypump.text = it.tbrSetByPump?.let { tbrSetByPump -> HtmlHelper.fromHtml(tbrSetByPump.toHtml()) }
|
||||
?: ""
|
||||
loop_smbsetbypump.text = it.smbSetByPump?.let { smbSetByPump -> HtmlHelper.fromHtml(smbSetByPump.toHtml()) }
|
||||
?: ""
|
||||
|
||||
val constraints =
|
||||
it.constraintsProcessed?.let { constraintsProcessed ->
|
||||
val allConstraints = Constraint(0.0)
|
||||
constraintsProcessed.rateConstraint?.let { rateConstraint -> allConstraints.copyReasons(rateConstraint) }
|
||||
constraintsProcessed.smbConstraint?.let { smbConstraint -> allConstraints.copyReasons(smbConstraint) }
|
||||
allConstraints.mostLimitedReasons
|
||||
} ?: ""
|
||||
loop_constraints.text = constraints
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearGUI() {
|
||||
loop_request.text = ""
|
||||
loop_constraints.text = ""
|
||||
loop_constraintsprocessed.text = ""
|
||||
loop_source.text = ""
|
||||
loop_lastrun.text = ""
|
||||
loop_lastenact.text = ""
|
||||
loop_tbrsetbypump.text = ""
|
||||
loop_smbsetbypump.text = ""
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
|
@ -47,6 +48,7 @@ import info.nightscout.androidaps.logging.L;
|
|||
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopSetLastRunGui;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.events.EventLoopUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.events.EventNewOpenLoopNotification;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.constraints.objectives.ObjectivesPlugin;
|
||||
|
@ -278,7 +280,7 @@ public class LoopPlugin extends PluginBase {
|
|||
String message = MainApp.gs(R.string.loopdisabled) + "\n" + loopEnabled.getReasons();
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(message);
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(message));
|
||||
RxBus.INSTANCE.send(new EventLoopSetLastRunGui(message));
|
||||
return;
|
||||
}
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
|
@ -292,7 +294,7 @@ public class LoopPlugin extends PluginBase {
|
|||
if (!ProfileFunctions.getInstance().isProfileValid("Loop")) {
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(MainApp.gs(R.string.noprofileselected));
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.noprofileselected)));
|
||||
RxBus.INSTANCE.send(new EventLoopSetLastRunGui(MainApp.gs(R.string.noprofileselected)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -307,7 +309,7 @@ public class LoopPlugin extends PluginBase {
|
|||
|
||||
// Check if we have any result
|
||||
if (result == null) {
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.noapsselected)));
|
||||
RxBus.INSTANCE.send(new EventLoopSetLastRunGui(MainApp.gs(R.string.noapsselected)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -349,14 +351,14 @@ public class LoopPlugin extends PluginBase {
|
|||
if (isSuspended()) {
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(MainApp.gs(R.string.loopsuspended));
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.loopsuspended)));
|
||||
RxBus.INSTANCE.send(new EventLoopSetLastRunGui(MainApp.gs(R.string.loopsuspended)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (pump.isSuspended()) {
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(MainApp.gs(R.string.pumpsuspended));
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.gs(R.string.pumpsuspended)));
|
||||
RxBus.INSTANCE.send(new EventLoopSetLastRunGui(MainApp.gs(R.string.pumpsuspended)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -372,7 +374,7 @@ public class LoopPlugin extends PluginBase {
|
|||
lastRun.tbrSetByPump = waiting;
|
||||
if (resultAfterConstraints.bolusRequested)
|
||||
lastRun.smbSetByPump = waiting;
|
||||
MainApp.bus().post(new EventLoopUpdateGui());
|
||||
RxBus.INSTANCE.send(new EventLoopUpdateGui());
|
||||
FabricPrivacy.getInstance().logCustom("APSRequest");
|
||||
applyTBRRequest(resultAfterConstraints, profile, new Callback() {
|
||||
@Override
|
||||
|
@ -393,11 +395,11 @@ public class LoopPlugin extends PluginBase {
|
|||
LoopPlugin.getPlugin().invoke("tempBasalFallback", allowNotification, true);
|
||||
}).start();
|
||||
}
|
||||
MainApp.bus().post(new EventLoopUpdateGui());
|
||||
RxBus.INSTANCE.send(new EventLoopUpdateGui());
|
||||
}
|
||||
});
|
||||
}
|
||||
MainApp.bus().post(new EventLoopUpdateGui());
|
||||
RxBus.INSTANCE.send(new EventLoopUpdateGui());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
@ -451,7 +453,7 @@ public class LoopPlugin extends PluginBase {
|
|||
}
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventLoopUpdateGui());
|
||||
RxBus.INSTANCE.send(new EventLoopUpdateGui());
|
||||
} finally {
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug("invoke end");
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.aps.loop.events;
|
||||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class EventLoopSetLastRunGui extends EventUpdateGui {
|
||||
public String text = null;
|
||||
|
||||
public EventLoopSetLastRunGui(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package info.nightscout.androidaps.plugins.aps.loop.events
|
||||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
class EventLoopSetLastRunGui(val text: String) : EventUpdateGui()
|
|
@ -1,9 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.aps.loop.events;
|
||||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class EventLoopUpdateGui extends EventUpdateGui {
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
package info.nightscout.androidaps.plugins.aps.loop.events
|
||||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
class EventLoopUpdateGui : EventUpdateGui()
|
|
@ -1,135 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.aps.openAPSAMA;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.JSONFormatter;
|
||||
|
||||
public class OpenAPSAMAFragment extends SubscriberFragment implements View.OnClickListener {
|
||||
private static Logger log = LoggerFactory.getLogger(L.APS);
|
||||
|
||||
Button run;
|
||||
TextView lastRunView;
|
||||
TextView glucoseStatusView;
|
||||
TextView currentTempView;
|
||||
TextView iobDataView;
|
||||
TextView profileView;
|
||||
TextView mealDataView;
|
||||
TextView autosensDataView;
|
||||
TextView resultView;
|
||||
TextView scriptdebugView;
|
||||
TextView requestView;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.openapsama_fragment, container, false);
|
||||
|
||||
run = (Button) view.findViewById(R.id.openapsma_run);
|
||||
run.setOnClickListener(this);
|
||||
lastRunView = (TextView) view.findViewById(R.id.openapsma_lastrun);
|
||||
glucoseStatusView = (TextView) view.findViewById(R.id.openapsma_glucosestatus);
|
||||
currentTempView = (TextView) view.findViewById(R.id.openapsma_currenttemp);
|
||||
iobDataView = (TextView) view.findViewById(R.id.openapsma_iobdata);
|
||||
profileView = (TextView) view.findViewById(R.id.openapsma_profile);
|
||||
mealDataView = (TextView) view.findViewById(R.id.openapsma_mealdata);
|
||||
autosensDataView = (TextView) view.findViewById(R.id.openapsma_autosensdata);
|
||||
scriptdebugView = (TextView) view.findViewById(R.id.openapsma_scriptdebugdata);
|
||||
resultView = (TextView) view.findViewById(R.id.openapsma_result);
|
||||
requestView = (TextView) view.findViewById(R.id.openapsma_request);
|
||||
|
||||
updateGUI();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.openapsma_run:
|
||||
OpenAPSAMAPlugin.getPlugin().invoke("OpenAPSAMA button", false);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventOpenAPSUpdateGui ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventOpenAPSUpdateResultGui ev) {
|
||||
updateResultGUI(ev.text);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
DetermineBasalResultAMA lastAPSResult = OpenAPSAMAPlugin.getPlugin().lastAPSResult;
|
||||
if (lastAPSResult != null) {
|
||||
resultView.setText(JSONFormatter.format(lastAPSResult.json));
|
||||
requestView.setText(lastAPSResult.toSpanned());
|
||||
}
|
||||
DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS = OpenAPSAMAPlugin.getPlugin().lastDetermineBasalAdapterAMAJS;
|
||||
if (determineBasalAdapterAMAJS != null) {
|
||||
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getGlucoseStatusParam()));
|
||||
currentTempView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getCurrentTempParam()));
|
||||
try {
|
||||
JSONArray iobArray = new JSONArray(determineBasalAdapterAMAJS.getIobDataParam());
|
||||
iobDataView.setText(TextUtils.concat(String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n", JSONFormatter.format(iobArray.getString(0))));
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
iobDataView.setText("JSONException");
|
||||
}
|
||||
profileView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getProfileParam()));
|
||||
mealDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getMealDataParam()));
|
||||
scriptdebugView.setText(determineBasalAdapterAMAJS.getScriptDebug());
|
||||
}
|
||||
if (OpenAPSAMAPlugin.getPlugin().lastAPSRun != 0) {
|
||||
lastRunView.setText(DateUtil.dateAndTimeFullString(OpenAPSAMAPlugin.getPlugin().lastAPSRun));
|
||||
}
|
||||
if (OpenAPSAMAPlugin.getPlugin().lastAutosensResult != null) {
|
||||
autosensDataView.setText(JSONFormatter.format(OpenAPSAMAPlugin.getPlugin().lastAutosensResult.json()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void updateResultGUI(final String text) {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
resultView.setText(text);
|
||||
glucoseStatusView.setText("");
|
||||
currentTempView.setText("");
|
||||
iobDataView.setText("");
|
||||
profileView.setText("");
|
||||
mealDataView.setText("");
|
||||
autosensDataView.setText("");
|
||||
scriptdebugView.setText("");
|
||||
requestView.setText("");
|
||||
lastRunView.setText("");
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,115 @@
|
|||
package info.nightscout.androidaps.plugins.aps.openAPSAMA
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.logging.L
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.JSONFormatter
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotlinx.android.synthetic.main.openapsama_fragment.*
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
class OpenAPSAMAFragment : Fragment() {
|
||||
private val log = LoggerFactory.getLogger(L.APS)
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
operator fun CompositeDisposable.plusAssign(disposable: Disposable) {
|
||||
add(disposable)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.openapsama_fragment, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
openapsma_run.setOnClickListener {
|
||||
OpenAPSAMAPlugin.getPlugin().invoke("OpenAPSAMA button", false)
|
||||
}
|
||||
|
||||
updateGUI()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
disposable += RxBus
|
||||
.toObservable(EventOpenAPSUpdateGui::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
updateGUI()
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
disposable += RxBus
|
||||
.toObservable(EventOpenAPSUpdateResultGui::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
updateResultGUI(it.text)
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
}
|
||||
|
||||
private fun updateGUI() {
|
||||
OpenAPSAMAPlugin.getPlugin().lastAPSResult?.let { lastAPSResult ->
|
||||
openapsma_result.text = JSONFormatter.format(lastAPSResult.json)
|
||||
openapsma_request.text = lastAPSResult.toSpanned()
|
||||
}
|
||||
OpenAPSAMAPlugin.getPlugin().lastDetermineBasalAdapterAMAJS?.let { determineBasalAdapterAMAJS ->
|
||||
openapsma_glucosestatus.text = JSONFormatter.format(determineBasalAdapterAMAJS.glucoseStatusParam)
|
||||
openapsma_currenttemp.text = JSONFormatter.format(determineBasalAdapterAMAJS.currentTempParam)
|
||||
try {
|
||||
val iobArray = JSONArray(determineBasalAdapterAMAJS.iobDataParam)
|
||||
openapsma_iobdata.text = TextUtils.concat(String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n", JSONFormatter.format(iobArray.getString(0)))
|
||||
} catch (e: JSONException) {
|
||||
log.error("Unhandled exception", e)
|
||||
openapsma_iobdata.text = "JSONException see log for details"
|
||||
}
|
||||
|
||||
openapsma_profile.text = JSONFormatter.format(determineBasalAdapterAMAJS.profileParam)
|
||||
openapsma_mealdata.text = JSONFormatter.format(determineBasalAdapterAMAJS.mealDataParam)
|
||||
openapsma_scriptdebugdata.text = determineBasalAdapterAMAJS.scriptDebug
|
||||
}
|
||||
if (OpenAPSAMAPlugin.getPlugin().lastAPSRun != 0L) {
|
||||
openapsma_lastrun.text = DateUtil.dateAndTimeFullString(OpenAPSAMAPlugin.getPlugin().lastAPSRun)
|
||||
}
|
||||
OpenAPSAMAPlugin.getPlugin().lastAutosensResult?.let {
|
||||
openapsma_autosensdata.text = JSONFormatter.format(it.json())
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateResultGUI(text: String) {
|
||||
openapsma_result.text = text
|
||||
openapsma_glucosestatus.text = ""
|
||||
openapsma_currenttemp.text = ""
|
||||
openapsma_iobdata.text = ""
|
||||
openapsma_profile.text = ""
|
||||
openapsma_mealdata.text = ""
|
||||
openapsma_autosensdata.text = ""
|
||||
openapsma_scriptdebugdata.text = ""
|
||||
openapsma_request.text = ""
|
||||
openapsma_lastrun.text = ""
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.MealData;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
|
@ -17,15 +16,17 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
|||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.ScriptReader;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.HardLimits;
|
||||
|
@ -99,21 +100,21 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
|||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
|
||||
if (profile == null) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
|
||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(MainApp.gs(R.string.noprofileselected));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isEnabled(PluginType.APS)) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
|
||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(MainApp.gs(R.string.openapsma_disabled));
|
||||
return;
|
||||
}
|
||||
|
||||
if (glucoseStatus == null) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
|
||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(MainApp.gs(R.string.openapsma_noglucosedata));
|
||||
return;
|
||||
|
@ -171,7 +172,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
|||
if (MainApp.getConstraintChecker().isAutosensModeEnabled().value()) {
|
||||
AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensDataSynchronized("OpenAPSPlugin");
|
||||
if (autosensData == null) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openaps_noasdata)));
|
||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openaps_noasdata)));
|
||||
return;
|
||||
}
|
||||
lastAutosensResult = autosensData.autosensResult;
|
||||
|
@ -216,7 +217,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
|||
lastDetermineBasalAdapterAMAJS = determineBasalAdapterAMAJS;
|
||||
lastAPSResult = determineBasalResultAMA;
|
||||
lastAPSRun = now;
|
||||
MainApp.bus().post(new EventOpenAPSUpdateGui());
|
||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateGui());
|
||||
|
||||
//deviceStatus.suggested = determineBasalResultAMA.json;
|
||||
}
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.aps.openAPSMA;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.JSONFormatter;
|
||||
|
||||
public class OpenAPSMAFragment extends SubscriberFragment implements View.OnClickListener {
|
||||
Button run;
|
||||
TextView lastRunView;
|
||||
TextView glucoseStatusView;
|
||||
TextView currentTempView;
|
||||
TextView iobDataView;
|
||||
TextView profileView;
|
||||
TextView mealDataView;
|
||||
TextView resultView;
|
||||
TextView requestView;
|
||||
|
||||
@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);
|
||||
run.setOnClickListener(this);
|
||||
lastRunView = (TextView) view.findViewById(R.id.openapsma_lastrun);
|
||||
glucoseStatusView = (TextView) view.findViewById(R.id.openapsma_glucosestatus);
|
||||
currentTempView = (TextView) view.findViewById(R.id.openapsma_currenttemp);
|
||||
iobDataView = (TextView) view.findViewById(R.id.openapsma_iobdata);
|
||||
profileView = (TextView) view.findViewById(R.id.openapsma_profile);
|
||||
mealDataView = (TextView) view.findViewById(R.id.openapsma_mealdata);
|
||||
resultView = (TextView) view.findViewById(R.id.openapsma_result);
|
||||
requestView = (TextView) view.findViewById(R.id.openapsma_request);
|
||||
|
||||
updateGUI();
|
||||
return view;
|
||||
} catch (Exception e) {
|
||||
FabricPrivacy.logException(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.openapsma_run:
|
||||
OpenAPSMAPlugin.getPlugin().invoke("OpenAPSMA button", false);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventOpenAPSUpdateGui ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventOpenAPSUpdateResultGui ev) {
|
||||
updateResultGUI(ev.text);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
DetermineBasalResultMA lastAPSResult = OpenAPSMAPlugin.getPlugin().lastAPSResult;
|
||||
if (lastAPSResult != null) {
|
||||
resultView.setText(JSONFormatter.format(lastAPSResult.json));
|
||||
requestView.setText(lastAPSResult.toSpanned());
|
||||
}
|
||||
DetermineBasalAdapterMAJS determineBasalAdapterMAJS = OpenAPSMAPlugin.getPlugin().lastDetermineBasalAdapterMAJS;
|
||||
if (determineBasalAdapterMAJS != null) {
|
||||
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getGlucoseStatusParam()));
|
||||
currentTempView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getCurrentTempParam()));
|
||||
iobDataView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getIobDataParam()));
|
||||
profileView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getProfileParam()));
|
||||
mealDataView.setText(JSONFormatter.format(determineBasalAdapterMAJS.getMealDataParam()));
|
||||
}
|
||||
if (OpenAPSMAPlugin.getPlugin().lastAPSRun != 0) {
|
||||
lastRunView.setText(DateUtil.dateAndTimeFullString(OpenAPSMAPlugin.getPlugin().lastAPSRun));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateResultGUI(final String text) {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
resultView.setText(text);
|
||||
glucoseStatusView.setText("");
|
||||
currentTempView.setText("");
|
||||
iobDataView.setText("");
|
||||
profileView.setText("");
|
||||
mealDataView.setText("");
|
||||
requestView.setText("");
|
||||
lastRunView.setText("");
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
package info.nightscout.androidaps.plugins.aps.openAPSMA
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.logging.L
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.JSONFormatter
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotlinx.android.synthetic.main.openapsama_fragment.*
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
class OpenAPSMAFragment : Fragment() {
|
||||
private val log = LoggerFactory.getLogger(L.APS)
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
operator fun CompositeDisposable.plusAssign(disposable: Disposable) {
|
||||
add(disposable)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.openapsma_fragment, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
openapsma_run.setOnClickListener {
|
||||
OpenAPSMAPlugin.getPlugin().invoke("OpenAPSMA button", false)
|
||||
}
|
||||
|
||||
updateGUI()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
disposable += RxBus
|
||||
.toObservable(EventOpenAPSUpdateGui::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
updateGUI()
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
disposable += RxBus
|
||||
.toObservable(EventOpenAPSUpdateResultGui::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
updateResultGUI(it.text)
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
}
|
||||
|
||||
fun updateGUI() {
|
||||
OpenAPSMAPlugin.getPlugin().lastAPSResult?.let { lastAPSResult ->
|
||||
openapsma_result.text = JSONFormatter.format(lastAPSResult.json)
|
||||
openapsma_request.text = lastAPSResult.toSpanned()
|
||||
}
|
||||
OpenAPSMAPlugin.getPlugin().lastDetermineBasalAdapterMAJS?.let { determineBasalAdapterMAJS ->
|
||||
openapsma_glucosestatus.text = JSONFormatter.format(determineBasalAdapterMAJS.glucoseStatusParam)
|
||||
openapsma_currenttemp.text = JSONFormatter.format(determineBasalAdapterMAJS.currentTempParam)
|
||||
openapsma_iobdata.text = JSONFormatter.format(determineBasalAdapterMAJS.iobDataParam)
|
||||
openapsma_profile.text = JSONFormatter.format(determineBasalAdapterMAJS.profileParam)
|
||||
openapsma_mealdata.text = JSONFormatter.format(determineBasalAdapterMAJS.mealDataParam)
|
||||
}
|
||||
if (OpenAPSMAPlugin.getPlugin().lastAPSRun != 0L) {
|
||||
openapsma_lastrun.text = DateUtil.dateAndTimeString(OpenAPSMAPlugin.getPlugin().lastAPSRun)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateResultGUI(text: String) {
|
||||
openapsma_result.text = text
|
||||
openapsma_glucosestatus.text = ""
|
||||
openapsma_currenttemp.text = ""
|
||||
openapsma_iobdata.text = ""
|
||||
openapsma_profile.text = ""
|
||||
openapsma_mealdata.text = ""
|
||||
openapsma_request.text = ""
|
||||
openapsma_lastrun.text = ""
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.MealData;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
|
@ -17,12 +16,14 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
|||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.ScriptReader;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.HardLimits;
|
||||
|
@ -98,21 +99,21 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
|||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
|
||||
if (profile == null) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
|
||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(MainApp.gs(R.string.noprofileselected));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isEnabled(PluginType.APS)) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
|
||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(MainApp.gs(R.string.openapsma_disabled));
|
||||
return;
|
||||
}
|
||||
|
||||
if (glucoseStatus == null) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
|
||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(MainApp.gs(R.string.openapsma_noglucosedata));
|
||||
return;
|
||||
|
@ -193,7 +194,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
|||
lastDetermineBasalAdapterMAJS = determineBasalAdapterMAJS;
|
||||
lastAPSResult = determineBasalResultMA;
|
||||
lastAPSRun = now;
|
||||
MainApp.bus().post(new EventOpenAPSUpdateGui());
|
||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateGui());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.aps.openAPSMA.events;
|
||||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class EventOpenAPSUpdateGui extends EventUpdateGui {
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.aps.openAPSMA.events
|
||||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui
|
||||
|
||||
class EventOpenAPSUpdateGui : EventUpdateGui()
|
|
@ -1,14 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.aps.openAPSMA.events;
|
||||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class EventOpenAPSUpdateResultGui extends EventUpdateGui {
|
||||
public String text;
|
||||
|
||||
public EventOpenAPSUpdateResultGui(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.aps.openAPSMA.events
|
||||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui
|
||||
|
||||
class EventOpenAPSUpdateResultGui(val text: String) : EventUpdateGui()
|
|
@ -1,159 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.aps.openAPSSMB;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.JSONFormatter;
|
||||
|
||||
public class OpenAPSSMBFragment extends SubscriberFragment {
|
||||
private static Logger log = LoggerFactory.getLogger(L.APS);
|
||||
|
||||
@BindView(R.id.openapsma_run)
|
||||
Button run;
|
||||
@BindView(R.id.openapsma_lastrun)
|
||||
TextView lastRunView;
|
||||
@BindView(R.id.openapsma_constraints)
|
||||
TextView constraintsView;
|
||||
@BindView(R.id.openapsma_glucosestatus)
|
||||
TextView glucoseStatusView;
|
||||
@BindView(R.id.openapsma_currenttemp)
|
||||
TextView currentTempView;
|
||||
@BindView(R.id.openapsma_iobdata)
|
||||
TextView iobDataView;
|
||||
@BindView(R.id.openapsma_profile)
|
||||
TextView profileView;
|
||||
@BindView(R.id.openapsma_mealdata)
|
||||
TextView mealDataView;
|
||||
@BindView(R.id.openapsma_autosensdata)
|
||||
TextView autosensDataView;
|
||||
@BindView(R.id.openapsma_result)
|
||||
TextView resultView;
|
||||
@BindView(R.id.openapsma_scriptdebugdata)
|
||||
TextView scriptdebugView;
|
||||
@BindView(R.id.openapsma_request)
|
||||
TextView requestView;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.openapsama_fragment, container, false);
|
||||
|
||||
unbinder = ButterKnife.bind(this, view);
|
||||
return view;
|
||||
}
|
||||
|
||||
@OnClick(R.id.openapsma_run)
|
||||
public void onRunClick() {
|
||||
OpenAPSSMBPlugin.getPlugin().invoke("OpenAPSSMB button", false);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventOpenAPSUpdateGui ev) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventOpenAPSUpdateResultGui ev) {
|
||||
updateResultGUI(ev.text);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
synchronized (OpenAPSSMBFragment.this) {
|
||||
if (!isBound()) return;
|
||||
OpenAPSSMBPlugin plugin = OpenAPSSMBPlugin.getPlugin();
|
||||
DetermineBasalResultSMB lastAPSResult = plugin.lastAPSResult;
|
||||
if (lastAPSResult != null) {
|
||||
resultView.setText(JSONFormatter.format(lastAPSResult.json));
|
||||
requestView.setText(lastAPSResult.toSpanned());
|
||||
}
|
||||
DetermineBasalAdapterSMBJS determineBasalAdapterSMBJS = plugin.lastDetermineBasalAdapterSMBJS;
|
||||
if (determineBasalAdapterSMBJS != null) {
|
||||
glucoseStatusView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getGlucoseStatusParam()));
|
||||
currentTempView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getCurrentTempParam()));
|
||||
try {
|
||||
JSONArray iobArray = new JSONArray(determineBasalAdapterSMBJS.getIobDataParam());
|
||||
iobDataView.setText(TextUtils.concat(String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n", JSONFormatter.format(iobArray.getString(0))));
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
iobDataView.setText("JSONException see log for details");
|
||||
}
|
||||
profileView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getProfileParam()));
|
||||
mealDataView.setText(JSONFormatter.format(determineBasalAdapterSMBJS.getMealDataParam()));
|
||||
scriptdebugView.setText(determineBasalAdapterSMBJS.getScriptDebug());
|
||||
if (lastAPSResult != null && lastAPSResult.inputConstraints != null)
|
||||
constraintsView.setText(lastAPSResult.inputConstraints.getReasons());
|
||||
}
|
||||
if (plugin.lastAPSRun != 0) {
|
||||
lastRunView.setText(DateUtil.dateAndTimeFullString(plugin.lastAPSRun));
|
||||
}
|
||||
if (plugin.lastAutosensResult != null) {
|
||||
autosensDataView.setText(JSONFormatter.format(plugin.lastAutosensResult.json()));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void updateResultGUI(final String text) {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
synchronized (OpenAPSSMBFragment.this) {
|
||||
if (isBound()) {
|
||||
resultView.setText(text);
|
||||
glucoseStatusView.setText("");
|
||||
currentTempView.setText("");
|
||||
iobDataView.setText("");
|
||||
profileView.setText("");
|
||||
mealDataView.setText("");
|
||||
autosensDataView.setText("");
|
||||
scriptdebugView.setText("");
|
||||
requestView.setText("");
|
||||
lastRunView.setText("");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isBound() {
|
||||
return run != null
|
||||
&& lastRunView != null
|
||||
&& constraintsView != null
|
||||
&& glucoseStatusView != null
|
||||
&& currentTempView != null
|
||||
&& iobDataView != null
|
||||
&& profileView != null
|
||||
&& mealDataView != null
|
||||
&& autosensDataView != null
|
||||
&& resultView != null
|
||||
&& scriptdebugView != null
|
||||
&& requestView != null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package info.nightscout.androidaps.plugins.aps.openAPSSMB
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.logging.L
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.JSONFormatter
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotlinx.android.synthetic.main.openapsama_fragment.*
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
class OpenAPSSMBFragment : Fragment() {
|
||||
private val log = LoggerFactory.getLogger(L.APS)
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
operator fun CompositeDisposable.plusAssign(disposable: Disposable) {
|
||||
add(disposable)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.openapsama_fragment, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
openapsma_run.setOnClickListener {
|
||||
OpenAPSSMBPlugin.getPlugin().invoke("OpenAPSSMB button", false)
|
||||
}
|
||||
|
||||
updateGUI()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
disposable += RxBus
|
||||
.toObservable(EventOpenAPSUpdateGui::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
updateGUI()
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
disposable += RxBus
|
||||
.toObservable(EventOpenAPSUpdateResultGui::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
updateResultGUI(it.text)
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
}
|
||||
|
||||
fun updateGUI() {
|
||||
val plugin = OpenAPSSMBPlugin.getPlugin()
|
||||
plugin.lastAPSResult?.let { lastAPSResult ->
|
||||
openapsma_result.text = JSONFormatter.format(lastAPSResult.json)
|
||||
openapsma_request.text = lastAPSResult.toSpanned()
|
||||
}
|
||||
plugin.lastDetermineBasalAdapterSMBJS?.let { determineBasalAdapterSMBJS ->
|
||||
openapsma_glucosestatus.text = JSONFormatter.format(determineBasalAdapterSMBJS.glucoseStatusParam)
|
||||
openapsma_currenttemp.text = JSONFormatter.format(determineBasalAdapterSMBJS.currentTempParam)
|
||||
try {
|
||||
val iobArray = JSONArray(determineBasalAdapterSMBJS.iobDataParam)
|
||||
openapsma_iobdata.text = TextUtils.concat(String.format(MainApp.gs(R.string.array_of_elements), iobArray.length()) + "\n", JSONFormatter.format(iobArray.getString(0)))
|
||||
} catch (e: JSONException) {
|
||||
log.error("Unhandled exception", e)
|
||||
openapsma_iobdata.text = "JSONException see log for details"
|
||||
}
|
||||
|
||||
openapsma_profile.text = JSONFormatter.format(determineBasalAdapterSMBJS.profileParam)
|
||||
openapsma_mealdata.text = JSONFormatter.format(determineBasalAdapterSMBJS.mealDataParam)
|
||||
openapsma_scriptdebugdata.text = determineBasalAdapterSMBJS.scriptDebug
|
||||
plugin.lastAPSResult?.inputConstraints?.let {
|
||||
openapsma_constraints.text = it.reasons
|
||||
}
|
||||
}
|
||||
if (plugin.lastAPSRun != 0L) {
|
||||
openapsma_lastrun.text = DateUtil.dateAndTimeFullString(plugin.lastAPSRun)
|
||||
}
|
||||
plugin.lastAutosensResult?.let {
|
||||
openapsma_autosensdata.text = JSONFormatter.format(it.json())
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateResultGUI(text: String) {
|
||||
openapsma_result.text = text
|
||||
openapsma_glucosestatus.text = ""
|
||||
openapsma_currenttemp.text = ""
|
||||
openapsma_iobdata.text = ""
|
||||
openapsma_profile.text = ""
|
||||
openapsma_mealdata.text = ""
|
||||
openapsma_autosensdata.text = ""
|
||||
openapsma_scriptdebugdata.text = ""
|
||||
openapsma_request.text = ""
|
||||
openapsma_lastrun.text = ""
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.MealData;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
|
@ -19,16 +18,18 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
|||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.ScriptReader;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.HardLimits;
|
||||
|
@ -103,21 +104,21 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
|||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||
|
||||
if (profile == null) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
|
||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected)));
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(MainApp.gs(R.string.noprofileselected));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isEnabled(PluginType.APS)) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
|
||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(MainApp.gs(R.string.openapsma_disabled));
|
||||
return;
|
||||
}
|
||||
|
||||
if (glucoseStatus == null) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
|
||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_noglucosedata)));
|
||||
if (L.isEnabled(L.APS))
|
||||
log.debug(MainApp.gs(R.string.openapsma_noglucosedata));
|
||||
return;
|
||||
|
@ -177,7 +178,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
|||
if (MainApp.getConstraintChecker().isAutosensModeEnabled().value()) {
|
||||
AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensDataSynchronized("OpenAPSPlugin");
|
||||
if (autosensData == null) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openaps_noasdata)));
|
||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openaps_noasdata)));
|
||||
return;
|
||||
}
|
||||
lastAutosensResult = autosensData.autosensResult;
|
||||
|
@ -245,7 +246,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
|||
lastDetermineBasalAdapterSMBJS = determineBasalAdapterSMBJS;
|
||||
lastAPSResult = determineBasalResultSMB;
|
||||
lastAPSRun = now;
|
||||
MainApp.bus().post(new EventOpenAPSUpdateGui());
|
||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateGui());
|
||||
|
||||
//deviceStatus.suggested = determineBasalResultAMA.json;
|
||||
}
|
||||
|
|
|
@ -2,12 +2,9 @@ package info.nightscout.androidaps.plugins.common;
|
|||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import butterknife.Unbinder;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
|
||||
abstract public class SubscriberFragment extends Fragment {
|
||||
protected Unbinder unbinder;
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
@ -21,12 +18,5 @@ abstract public class SubscriberFragment extends Fragment {
|
|||
updateGUI();
|
||||
}
|
||||
|
||||
@Override public synchronized void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if (unbinder != null)
|
||||
unbinder.unbind();
|
||||
}
|
||||
|
||||
|
||||
protected abstract void updateGUI();
|
||||
}
|
||||
|
|
|
@ -1,283 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.configBuilder;
|
||||
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.StringRes;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.Unbinder;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.PreferencesActivity;
|
||||
import info.nightscout.androidaps.events.EventConfigBuilderChange;
|
||||
import info.nightscout.androidaps.events.EventRefreshGui;
|
||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||
import info.nightscout.androidaps.interfaces.BgSourceInterface;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefRapidActingPlugin;
|
||||
import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.PasswordProtection;
|
||||
|
||||
|
||||
public class ConfigBuilderFragment extends SubscriberFragment {
|
||||
|
||||
private List<PluginViewHolder> pluginViewHolders = new ArrayList<>();
|
||||
|
||||
@BindView(R.id.categories)
|
||||
LinearLayout categories;
|
||||
|
||||
@BindView(R.id.main_layout)
|
||||
ScrollView mainLayout;
|
||||
@BindView(R.id.unlock)
|
||||
Button unlock;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
try {
|
||||
View view = inflater.inflate(R.layout.configbuilder_fragment, container, false);
|
||||
unbinder = ButterKnife.bind(this, view);
|
||||
|
||||
if (PasswordProtection.isLocked("settings_password"))
|
||||
mainLayout.setVisibility(View.GONE);
|
||||
else unlock.setVisibility(View.GONE);
|
||||
|
||||
createViews();
|
||||
|
||||
return view;
|
||||
} catch (Exception e) {
|
||||
FabricPrivacy.logException(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@OnClick(R.id.unlock)
|
||||
void onClickUnlock() {
|
||||
PasswordProtection.QueryPassword(getContext(), R.string.settings_password, "settings_password", () -> {
|
||||
mainLayout.setVisibility(View.VISIBLE);
|
||||
unlock.setVisibility(View.GONE);
|
||||
}, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
for (PluginViewHolder pluginViewHolder : pluginViewHolders) pluginViewHolder.unbind();
|
||||
pluginViewHolders.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
for (PluginViewHolder pluginViewHolder : pluginViewHolders) pluginViewHolder.update();
|
||||
}
|
||||
|
||||
private void createViews() {
|
||||
createViewsForPlugins(R.string.configbuilder_profile, R.string.configbuilder_profile_description, PluginType.PROFILE, MainApp.getSpecificPluginsVisibleInListByInterface(ProfileInterface.class, PluginType.PROFILE));
|
||||
createViewsForPlugins(R.string.configbuilder_insulin, R.string.configbuilder_insulin_description, PluginType.INSULIN, MainApp.getSpecificPluginsVisibleInListByInterface(InsulinInterface.class, PluginType.INSULIN));
|
||||
createViewsForPlugins(R.string.configbuilder_bgsource, R.string.configbuilder_bgsource_description, PluginType.BGSOURCE, MainApp.getSpecificPluginsVisibleInListByInterface(BgSourceInterface.class, PluginType.BGSOURCE));
|
||||
createViewsForPlugins(R.string.configbuilder_pump, R.string.configbuilder_pump_description, PluginType.PUMP, MainApp.getSpecificPluginsVisibleInList(PluginType.PUMP));
|
||||
createViewsForPlugins(R.string.configbuilder_sensitivity, R.string.configbuilder_sensitivity_description, PluginType.SENSITIVITY, MainApp.getSpecificPluginsVisibleInListByInterface(SensitivityInterface.class, PluginType.SENSITIVITY));
|
||||
createViewsForPlugins(R.string.configbuilder_aps, R.string.configbuilder_aps_description, PluginType.APS, MainApp.getSpecificPluginsVisibleInList(PluginType.APS));
|
||||
createViewsForPlugins(R.string.configbuilder_loop, R.string.configbuilder_loop_description, PluginType.LOOP, MainApp.getSpecificPluginsVisibleInList(PluginType.LOOP));
|
||||
createViewsForPlugins(R.string.constraints, R.string.configbuilder_constraints_description, PluginType.CONSTRAINTS, MainApp.getSpecificPluginsVisibleInListByInterface(ConstraintsInterface.class, PluginType.CONSTRAINTS));
|
||||
createViewsForPlugins(R.string.configbuilder_treatments, R.string.configbuilder_treatments_description, PluginType.TREATMENT, MainApp.getSpecificPluginsVisibleInList(PluginType.TREATMENT));
|
||||
createViewsForPlugins(R.string.configbuilder_general, R.string.configbuilder_general_description, PluginType.GENERAL, MainApp.getSpecificPluginsVisibleInList(PluginType.GENERAL));
|
||||
}
|
||||
|
||||
private void createViewsForPlugins(@StringRes int title, @StringRes int description, PluginType pluginType, List<PluginBase> plugins) {
|
||||
if (plugins.size() == 0) return;
|
||||
LinearLayout parent = (LinearLayout) getLayoutInflater().inflate(R.layout.configbuilder_single_category, null);
|
||||
((TextView) parent.findViewById(R.id.category_title)).setText(MainApp.gs(title));
|
||||
((TextView) parent.findViewById(R.id.category_description)).setText(MainApp.gs(description));
|
||||
LinearLayout pluginContainer = parent.findViewById(R.id.category_plugins);
|
||||
for (PluginBase plugin: plugins) {
|
||||
PluginViewHolder pluginViewHolder = new PluginViewHolder(pluginType, plugin);
|
||||
pluginContainer.addView(pluginViewHolder.getBaseView());
|
||||
pluginViewHolders.add(pluginViewHolder);
|
||||
}
|
||||
categories.addView(parent);
|
||||
}
|
||||
|
||||
private boolean areMultipleSelectionsAllowed(PluginType type) {
|
||||
return type == PluginType.GENERAL || type == PluginType.CONSTRAINTS ||type == PluginType.LOOP;
|
||||
}
|
||||
|
||||
public static void processOnEnabledCategoryChanged(PluginBase changedPlugin, PluginType type) {
|
||||
ArrayList<PluginBase> pluginsInCategory = null;
|
||||
switch (type) {
|
||||
// Multiple selection allowed
|
||||
case GENERAL:
|
||||
case CONSTRAINTS:
|
||||
case LOOP:
|
||||
break;
|
||||
// Single selection allowed
|
||||
case INSULIN:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(InsulinInterface.class);
|
||||
break;
|
||||
case SENSITIVITY:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(SensitivityInterface.class);
|
||||
break;
|
||||
case APS:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(APSInterface.class);
|
||||
break;
|
||||
case PROFILE:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(ProfileInterface.class);
|
||||
break;
|
||||
case BGSOURCE:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(BgSourceInterface.class);
|
||||
break;
|
||||
case TREATMENT:
|
||||
case PUMP:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(PumpInterface.class);
|
||||
break;
|
||||
}
|
||||
if (pluginsInCategory != null) {
|
||||
boolean newSelection = changedPlugin.isEnabled(type);
|
||||
if (newSelection) { // new plugin selected -> disable others
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
if (p.getName().equals(changedPlugin.getName())) {
|
||||
// this is new selected
|
||||
} else {
|
||||
p.setPluginEnabled(type, false);
|
||||
p.setFragmentVisible(type, false);
|
||||
}
|
||||
}
|
||||
} else { // enable first plugin in list
|
||||
if (type == PluginType.PUMP)
|
||||
VirtualPumpPlugin.getPlugin().setPluginEnabled(type, true);
|
||||
else if (type == PluginType.INSULIN)
|
||||
InsulinOrefRapidActingPlugin.getPlugin().setPluginEnabled(type, true);
|
||||
else if (type == PluginType.SENSITIVITY)
|
||||
SensitivityOref0Plugin.getPlugin().setPluginEnabled(type, true);
|
||||
else if (type == PluginType.PROFILE)
|
||||
NSProfilePlugin.getPlugin().setPluginEnabled(type, true);
|
||||
else
|
||||
pluginsInCategory.get(0).setPluginEnabled(type, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class PluginViewHolder {
|
||||
|
||||
private Unbinder unbinder;
|
||||
private PluginType pluginType;
|
||||
private PluginBase plugin;
|
||||
|
||||
LinearLayout baseView;
|
||||
@BindView(R.id.plugin_enabled_exclusive)
|
||||
RadioButton enabledExclusive;
|
||||
@BindView(R.id.plugin_enabled_inclusive)
|
||||
CheckBox enabledInclusive;
|
||||
@BindView(R.id.plugin_name)
|
||||
TextView pluginName;
|
||||
@BindView(R.id.plugin_description)
|
||||
TextView pluginDescription;
|
||||
@BindView(R.id.plugin_preferences)
|
||||
ImageButton pluginPreferences;
|
||||
@BindView(R.id.plugin_visibility)
|
||||
CheckBox pluginVisibility;
|
||||
|
||||
public PluginViewHolder(PluginType pluginType, PluginBase plugin) {
|
||||
this.pluginType = pluginType;
|
||||
this.plugin = plugin;
|
||||
baseView = (LinearLayout) getLayoutInflater().inflate(R.layout.configbuilder_single_plugin, null);
|
||||
unbinder = ButterKnife.bind(this, baseView);
|
||||
update();
|
||||
}
|
||||
|
||||
public LinearLayout getBaseView() {
|
||||
return baseView;
|
||||
}
|
||||
|
||||
public void update() {
|
||||
enabledExclusive.setVisibility(areMultipleSelectionsAllowed(pluginType) ? View.GONE : View.VISIBLE);
|
||||
enabledInclusive.setVisibility(areMultipleSelectionsAllowed(pluginType) ? View.VISIBLE : View.GONE);
|
||||
enabledExclusive.setChecked(plugin.isEnabled(pluginType));
|
||||
enabledInclusive.setChecked(plugin.isEnabled(pluginType));
|
||||
enabledInclusive.setEnabled(!plugin.pluginDescription.alwaysEnabled);
|
||||
enabledExclusive.setEnabled(!plugin.pluginDescription.alwaysEnabled);
|
||||
pluginName.setText(plugin.getName());
|
||||
if (plugin.getDescription() == null) pluginDescription.setVisibility(View.GONE);
|
||||
else {
|
||||
pluginDescription.setVisibility(View.VISIBLE);
|
||||
pluginDescription.setText(plugin.getDescription());
|
||||
}
|
||||
pluginPreferences.setVisibility(plugin.getPreferencesId() == -1 || !plugin.isEnabled(pluginType) ? View.INVISIBLE : View.VISIBLE);
|
||||
pluginVisibility.setVisibility(plugin.hasFragment() ? View.VISIBLE : View.INVISIBLE);
|
||||
pluginVisibility.setEnabled(!(plugin.pluginDescription.neverVisible || plugin.pluginDescription.alwayVisible) && plugin.isEnabled(pluginType));
|
||||
pluginVisibility.setChecked(plugin.isFragmentVisible());
|
||||
}
|
||||
|
||||
@OnClick(R.id.plugin_visibility)
|
||||
void onVisibilityChanged() {
|
||||
plugin.setFragmentVisible(pluginType, pluginVisibility.isChecked());
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxVisible");
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
ConfigBuilderPlugin.getPlugin().logPluginStatus();
|
||||
}
|
||||
|
||||
@OnClick({R.id.plugin_enabled_exclusive, R.id.plugin_enabled_inclusive})
|
||||
void onEnabledChanged() {
|
||||
plugin.switchAllowed(new PluginSwitcher(), getActivity());
|
||||
}
|
||||
|
||||
@OnClick(R.id.plugin_preferences)
|
||||
void onPluginPreferencesClicked() {
|
||||
PasswordProtection.QueryPassword(getContext(), R.string.settings_password, "settings_password", () -> {
|
||||
Intent i = new Intent(getContext(), PreferencesActivity.class);
|
||||
i.putExtra("id", plugin.getPreferencesId());
|
||||
startActivity(i);
|
||||
}, null);
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
unbinder.unbind();
|
||||
}
|
||||
|
||||
public class PluginSwitcher {
|
||||
public void invoke() {
|
||||
boolean enabled = enabledExclusive.getVisibility() == View.VISIBLE ? enabledExclusive.isChecked() : enabledInclusive.isChecked();
|
||||
plugin.setPluginEnabled(pluginType, enabled);
|
||||
plugin.setFragmentVisible(pluginType, enabled);
|
||||
processOnEnabledCategoryChanged(plugin, pluginType);
|
||||
updateGUI();
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxEnabled");
|
||||
MainApp.bus().post(new EventRefreshGui());
|
||||
MainApp.bus().post(new EventConfigBuilderChange());
|
||||
ConfigBuilderPlugin.getPlugin().logPluginStatus();
|
||||
}
|
||||
|
||||
public void cancel(){
|
||||
updateGUI();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package info.nightscout.androidaps.plugins.configBuilder
|
||||
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.fragment.app.Fragment
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.interfaces.*
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.PasswordProtection
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.android.synthetic.main.configbuilder_fragment.*
|
||||
import java.util.*
|
||||
|
||||
class ConfigBuilderFragment : Fragment() {
|
||||
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
private val pluginViewHolders = ArrayList<PluginViewHolder>()
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.configbuilder_fragment, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
if (PasswordProtection.isLocked("settings_password"))
|
||||
configbuilder_main_layout.visibility = View.GONE
|
||||
else
|
||||
unlock.visibility = View.GONE
|
||||
|
||||
unlock.setOnClickListener {
|
||||
PasswordProtection.QueryPassword(context, R.string.settings_password, "settings_password", {
|
||||
configbuilder_main_layout.visibility = View.VISIBLE
|
||||
unlock.visibility = View.GONE
|
||||
}, null)
|
||||
}
|
||||
|
||||
updateGUI()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
disposable.add(RxBus
|
||||
.toObservable(EventConfigBuilderUpdateGui::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
for (pluginViewHolder in pluginViewHolders) pluginViewHolder.update()
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
}))
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
}
|
||||
|
||||
private fun updateGUI() {
|
||||
createViewsForPlugins(R.string.configbuilder_profile, R.string.configbuilder_profile_description, PluginType.PROFILE, MainApp.getSpecificPluginsVisibleInListByInterface(ProfileInterface::class.java, PluginType.PROFILE))
|
||||
createViewsForPlugins(R.string.configbuilder_insulin, R.string.configbuilder_insulin_description, PluginType.INSULIN, MainApp.getSpecificPluginsVisibleInListByInterface(InsulinInterface::class.java, PluginType.INSULIN))
|
||||
createViewsForPlugins(R.string.configbuilder_bgsource, R.string.configbuilder_bgsource_description, PluginType.BGSOURCE, MainApp.getSpecificPluginsVisibleInListByInterface(BgSourceInterface::class.java, PluginType.BGSOURCE))
|
||||
createViewsForPlugins(R.string.configbuilder_pump, R.string.configbuilder_pump_description, PluginType.PUMP, MainApp.getSpecificPluginsVisibleInList(PluginType.PUMP))
|
||||
createViewsForPlugins(R.string.configbuilder_sensitivity, R.string.configbuilder_sensitivity_description, PluginType.SENSITIVITY, MainApp.getSpecificPluginsVisibleInListByInterface(SensitivityInterface::class.java, PluginType.SENSITIVITY))
|
||||
createViewsForPlugins(R.string.configbuilder_aps, R.string.configbuilder_aps_description, PluginType.APS, MainApp.getSpecificPluginsVisibleInList(PluginType.APS))
|
||||
createViewsForPlugins(R.string.configbuilder_loop, R.string.configbuilder_loop_description, PluginType.LOOP, MainApp.getSpecificPluginsVisibleInList(PluginType.LOOP))
|
||||
createViewsForPlugins(R.string.constraints, R.string.configbuilder_constraints_description, PluginType.CONSTRAINTS, MainApp.getSpecificPluginsVisibleInListByInterface(ConstraintsInterface::class.java, PluginType.CONSTRAINTS))
|
||||
createViewsForPlugins(R.string.configbuilder_treatments, R.string.configbuilder_treatments_description, PluginType.TREATMENT, MainApp.getSpecificPluginsVisibleInList(PluginType.TREATMENT))
|
||||
createViewsForPlugins(R.string.configbuilder_general, R.string.configbuilder_general_description, PluginType.GENERAL, MainApp.getSpecificPluginsVisibleInList(PluginType.GENERAL))
|
||||
}
|
||||
|
||||
private fun createViewsForPlugins(@StringRes title: Int, @StringRes description: Int, pluginType: PluginType, plugins: List<PluginBase>) {
|
||||
if (plugins.size == 0) return
|
||||
val parent = layoutInflater.inflate(R.layout.configbuilder_single_category, null) as LinearLayout
|
||||
(parent.findViewById<View>(R.id.category_title) as TextView).text = MainApp.gs(title)
|
||||
(parent.findViewById<View>(R.id.category_description) as TextView).text = MainApp.gs(description)
|
||||
val pluginContainer = parent.findViewById<LinearLayout>(R.id.category_plugins)
|
||||
for (plugin in plugins) {
|
||||
val pluginViewHolder = PluginViewHolder(this, pluginType, plugin)
|
||||
pluginContainer.addView(pluginViewHolder.baseView)
|
||||
pluginViewHolders.add(pluginViewHolder)
|
||||
}
|
||||
configbuilder_categories.addView(parent)
|
||||
}
|
||||
|
||||
}
|
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.interfaces.PumpInterface;
|
|||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefRapidActingPlugin;
|
||||
import info.nightscout.androidaps.plugins.profile.ns.NSProfilePlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref0Plugin;
|
||||
import info.nightscout.androidaps.queue.CommandQueue;
|
||||
|
@ -57,7 +58,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
|||
.fragmentClass(ConfigBuilderFragment.class.getName())
|
||||
.showInList(true)
|
||||
.alwaysEnabled(true)
|
||||
.alwayVisible(false)
|
||||
.alwaysVisible(false)
|
||||
.pluginName(R.string.configbuilder)
|
||||
.shortName(R.string.configbuilder_shortname)
|
||||
.description(R.string.description_config_builder)
|
||||
|
@ -102,7 +103,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
|||
|
||||
for (PluginBase p : pluginList) {
|
||||
PluginType type = p.getType();
|
||||
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.alwayVisible)
|
||||
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.alwaysVisible)
|
||||
continue;
|
||||
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.neverVisible)
|
||||
continue;
|
||||
|
@ -262,7 +263,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
|||
return activeSensitivity;
|
||||
}
|
||||
|
||||
void logPluginStatus() {
|
||||
public void logPluginStatus() {
|
||||
if (L.isEnabled(L.CONFIGBUILDER))
|
||||
for (PluginBase p : pluginList) {
|
||||
log.debug(p.getName() + ":" +
|
||||
|
@ -405,4 +406,58 @@ public class ConfigBuilderPlugin extends PluginBase {
|
|||
return found;
|
||||
}
|
||||
|
||||
public void processOnEnabledCategoryChanged(PluginBase changedPlugin, PluginType type) {
|
||||
ArrayList<PluginBase> pluginsInCategory = null;
|
||||
switch (type) {
|
||||
// Multiple selection allowed
|
||||
case GENERAL:
|
||||
case CONSTRAINTS:
|
||||
case LOOP:
|
||||
break;
|
||||
// Single selection allowed
|
||||
case INSULIN:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(InsulinInterface.class);
|
||||
break;
|
||||
case SENSITIVITY:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(SensitivityInterface.class);
|
||||
break;
|
||||
case APS:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(APSInterface.class);
|
||||
break;
|
||||
case PROFILE:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(ProfileInterface.class);
|
||||
break;
|
||||
case BGSOURCE:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(BgSourceInterface.class);
|
||||
break;
|
||||
case TREATMENT:
|
||||
case PUMP:
|
||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(PumpInterface.class);
|
||||
break;
|
||||
}
|
||||
if (pluginsInCategory != null) {
|
||||
boolean newSelection = changedPlugin.isEnabled(type);
|
||||
if (newSelection) { // new plugin selected -> disable others
|
||||
for (PluginBase p : pluginsInCategory) {
|
||||
if (p.getName().equals(changedPlugin.getName())) {
|
||||
// this is new selected
|
||||
} else {
|
||||
p.setPluginEnabled(type, false);
|
||||
p.setFragmentVisible(type, false);
|
||||
}
|
||||
}
|
||||
} else { // enable first plugin in list
|
||||
if (type == PluginType.PUMP)
|
||||
VirtualPumpPlugin.getPlugin().setPluginEnabled(type, true);
|
||||
else if (type == PluginType.INSULIN)
|
||||
InsulinOrefRapidActingPlugin.getPlugin().setPluginEnabled(type, true);
|
||||
else if (type == PluginType.SENSITIVITY)
|
||||
SensitivityOref0Plugin.getPlugin().setPluginEnabled(type, true);
|
||||
else if (type == PluginType.PROFILE)
|
||||
NSProfilePlugin.getPlugin().setPluginEnabled(type, true);
|
||||
else
|
||||
pluginsInCategory.get(0).setPluginEnabled(type, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package info.nightscout.androidaps.plugins.configBuilder
|
||||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui
|
||||
|
||||
class EventConfigBuilderUpdateGui : EventUpdateGui() {
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package info.nightscout.androidaps.plugins.configBuilder
|
||||
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.PreferencesActivity
|
||||
import info.nightscout.androidaps.events.EventRefreshGui
|
||||
import info.nightscout.androidaps.interfaces.PluginBase
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.utils.PasswordProtection
|
||||
|
||||
class PluginViewHolder internal constructor(private val fragment: ConfigBuilderFragment,
|
||||
private val pluginType: PluginType,
|
||||
private val plugin: PluginBase) {
|
||||
|
||||
val baseView: LinearLayout = fragment.layoutInflater.inflate(R.layout.configbuilder_single_plugin, null) as LinearLayout
|
||||
private val enabledExclusive: RadioButton
|
||||
private val enabledInclusive: CheckBox
|
||||
private val pluginName: TextView
|
||||
private val pluginDescription: TextView
|
||||
private val pluginPreferences: ImageButton
|
||||
private val pluginVisibility: CheckBox
|
||||
|
||||
init {
|
||||
enabledExclusive = baseView.findViewById(R.id.plugin_enabled_exclusive)
|
||||
enabledInclusive = baseView.findViewById(R.id.plugin_enabled_inclusive)
|
||||
pluginName = baseView.findViewById(R.id.plugin_name)
|
||||
pluginDescription = baseView.findViewById(R.id.plugin_description)
|
||||
pluginPreferences = baseView.findViewById(R.id.plugin_preferences)
|
||||
pluginVisibility = baseView.findViewById(R.id.plugin_visibility)
|
||||
|
||||
pluginVisibility.setOnClickListener {
|
||||
plugin.setFragmentVisible(pluginType, pluginVisibility.isChecked)
|
||||
ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxVisible")
|
||||
MainApp.bus().post(EventRefreshGui())
|
||||
ConfigBuilderPlugin.getPlugin().logPluginStatus()
|
||||
}
|
||||
|
||||
enabledExclusive.setOnClickListener {
|
||||
plugin.switchAllowed(if (enabledExclusive.visibility == View.VISIBLE) enabledExclusive.isChecked else enabledInclusive.isChecked, fragment.activity, pluginType)
|
||||
}
|
||||
enabledInclusive.setOnClickListener {
|
||||
plugin.switchAllowed(if (enabledExclusive.visibility == View.VISIBLE) enabledExclusive.isChecked else enabledInclusive.isChecked, fragment.activity, pluginType)
|
||||
}
|
||||
|
||||
pluginPreferences.setOnClickListener {
|
||||
PasswordProtection.QueryPassword(fragment.context, R.string.settings_password, "settings_password", {
|
||||
val i = Intent(fragment.context, PreferencesActivity::class.java)
|
||||
i.putExtra("id", plugin.preferencesId)
|
||||
fragment.startActivity(i)
|
||||
}, null)
|
||||
}
|
||||
update()
|
||||
}
|
||||
|
||||
fun update() {
|
||||
enabledExclusive.visibility = if (areMultipleSelectionsAllowed(pluginType)) View.GONE else View.VISIBLE
|
||||
enabledInclusive.visibility = if (areMultipleSelectionsAllowed(pluginType)) View.VISIBLE else View.GONE
|
||||
enabledExclusive.isChecked = plugin.isEnabled(pluginType)
|
||||
enabledInclusive.isChecked = plugin.isEnabled(pluginType)
|
||||
enabledInclusive.isEnabled = !plugin.pluginDescription.alwaysEnabled
|
||||
enabledExclusive.isEnabled = !plugin.pluginDescription.alwaysEnabled
|
||||
pluginName.text = plugin.name
|
||||
if (plugin.description == null)
|
||||
pluginDescription.visibility = View.GONE
|
||||
else {
|
||||
pluginDescription.visibility = View.VISIBLE
|
||||
pluginDescription.text = plugin.description
|
||||
}
|
||||
pluginPreferences.visibility = if (plugin.preferencesId == -1 || !plugin.isEnabled(pluginType)) View.INVISIBLE else View.VISIBLE
|
||||
pluginVisibility.visibility = if (plugin.hasFragment()) View.VISIBLE else View.INVISIBLE
|
||||
pluginVisibility.isEnabled = !(plugin.pluginDescription.neverVisible || plugin.pluginDescription.alwaysVisible) && plugin.isEnabled(pluginType)
|
||||
pluginVisibility.isChecked = plugin.isFragmentVisible
|
||||
}
|
||||
|
||||
private fun areMultipleSelectionsAllowed(type: PluginType): Boolean {
|
||||
return type == PluginType.GENERAL || type == PluginType.CONSTRAINTS || type == PluginType.LOOP
|
||||
}
|
||||
|
||||
}
|
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.plugins.bus.RxBus
|
|||
import info.nightscout.androidaps.plugins.general.automation.dialogs.EditEventDialog
|
||||
import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationDataChanged
|
||||
import info.nightscout.androidaps.plugins.general.automation.events.EventAutomationUpdateGui
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
|
@ -45,6 +46,10 @@ class AutomationFragment : Fragment() {
|
|||
fragmentManager?.let { dialog.show(it, "EditEventDialog") }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
disposable += RxBus
|
||||
.toObservable(EventAutomationUpdateGui::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
@ -56,17 +61,21 @@ class AutomationFragment : Fragment() {
|
|||
sb.append("\n")
|
||||
}
|
||||
automation_logView.text = sb.toString()
|
||||
}, {})
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
disposable += RxBus
|
||||
.toObservable(EventAutomationDataChanged::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
eventListAdapter?.notifyDataSetChanged()
|
||||
}, {})
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutos
|
|||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.services.LocationService
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
@ -79,11 +80,15 @@ object AutomationPlugin : PluginBase(PluginDescription()
|
|||
ctx.stopService(Intent(ctx, LocationService::class.java))
|
||||
ctx.startService(Intent(ctx, LocationService::class.java))
|
||||
}
|
||||
}, {})
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
disposable += RxBus
|
||||
.toObservable(EventAutomationDataChanged::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ storeToSP() }, {})
|
||||
.subscribe({ storeToSP() }, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
disposable += RxBus
|
||||
.toObservable(EventLocationChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
|
@ -92,19 +97,27 @@ object AutomationPlugin : PluginBase(PluginDescription()
|
|||
log.debug("Grabbed location: $it.location.latitude $it.location.longitude Provider: $it.location.provider")
|
||||
processActions()
|
||||
}
|
||||
}, {})
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
disposable += RxBus
|
||||
.toObservable(EventChargingState::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ processActions() }, {})
|
||||
.subscribe({ processActions() }, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
disposable += RxBus
|
||||
.toObservable(EventNetworkChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ processActions() }, {})
|
||||
.subscribe({ processActions() }, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
disposable += RxBus
|
||||
.toObservable(EventAutosensCalculationFinished::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ processActions() }, {})
|
||||
.subscribe({ processActions() }, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
|
|
|
@ -12,6 +12,7 @@ import info.nightscout.androidaps.plugins.general.automation.AutomationEvent
|
|||
import info.nightscout.androidaps.plugins.general.automation.AutomationPlugin
|
||||
import info.nightscout.androidaps.plugins.general.automation.events.*
|
||||
import info.nightscout.androidaps.plugins.general.automation.triggers.TriggerConnector
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
@ -100,7 +101,9 @@ class EditEventDialog : DialogFragment() {
|
|||
.subscribe({
|
||||
actionListAdapter?.notifyDataSetChanged()
|
||||
showPreconditions()
|
||||
}, {})
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
)
|
||||
disposable.add(RxBus
|
||||
.toObservable(EventAutomationAddAction::class.java)
|
||||
|
@ -108,7 +111,9 @@ class EditEventDialog : DialogFragment() {
|
|||
.subscribe({
|
||||
event.addAction(it.action)
|
||||
actionListAdapter?.notifyDataSetChanged()
|
||||
}, {})
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
)
|
||||
disposable.add(RxBus
|
||||
.toObservable(EventAutomationUpdateTrigger::class.java)
|
||||
|
@ -116,7 +121,9 @@ class EditEventDialog : DialogFragment() {
|
|||
.subscribe({
|
||||
event.trigger = it.trigger
|
||||
automation_triggerDescription.text = event.trigger.friendlyDescription()
|
||||
}, {})
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
)
|
||||
disposable.add(RxBus
|
||||
.toObservable(EventAutomationUpdateAction::class.java)
|
||||
|
@ -124,7 +131,9 @@ class EditEventDialog : DialogFragment() {
|
|||
.subscribe({
|
||||
event.actions[it.position] = it.action
|
||||
actionListAdapter?.notifyDataSetChanged()
|
||||
}, {})
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class MaintenancePlugin extends PluginBase {
|
|||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.fragmentClass(MaintenanceFragment.class.getName())
|
||||
.alwayVisible(false)
|
||||
.alwaysVisible(false)
|
||||
.alwaysEnabled(true)
|
||||
.pluginName(R.string.maintenance)
|
||||
.shortName(R.string.maintenance_shortname)
|
||||
|
|
|
@ -1,80 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.maintenance.activities;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.Unbinder;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
||||
public class LogSettingActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_logsetting);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
createViewsForSettings(L.getLogElements());
|
||||
}
|
||||
|
||||
private void createViewsForSettings(List<L.LogElement> elements) {
|
||||
if (elements.size() == 0) return;
|
||||
LinearLayout container = (LinearLayout) findViewById(R.id.logsettings_placeholder);
|
||||
container.removeAllViews();
|
||||
for (L.LogElement element : elements) {
|
||||
PluginViewHolder pluginViewHolder = new PluginViewHolder(element);
|
||||
container.addView(pluginViewHolder.getBaseView());
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.logsettings_reset)
|
||||
public void onResetClick() {
|
||||
L.resetToDefaults();
|
||||
createViewsForSettings(L.getLogElements());
|
||||
}
|
||||
|
||||
public class PluginViewHolder {
|
||||
|
||||
private Unbinder unbinder;
|
||||
private L.LogElement element;
|
||||
|
||||
LinearLayout baseView;
|
||||
@BindView(R.id.logsettings_description)
|
||||
TextView description;
|
||||
@BindView(R.id.logsettings_visibility)
|
||||
CheckBox enabled;
|
||||
|
||||
public PluginViewHolder(L.LogElement element) {
|
||||
this.element = element;
|
||||
baseView = (LinearLayout) getLayoutInflater().inflate(R.layout.logsettings_item, null);
|
||||
unbinder = ButterKnife.bind(this, baseView);
|
||||
|
||||
description.setText(element.name);
|
||||
enabled.setChecked(element.enabled);
|
||||
}
|
||||
|
||||
public View getBaseView() {
|
||||
return baseView;
|
||||
}
|
||||
|
||||
@OnClick(R.id.logsettings_visibility)
|
||||
void onEnagledChanged() {
|
||||
element.setEnabled(enabled.isChecked());
|
||||
}
|
||||
|
||||
public void unbind() {
|
||||
unbinder.unbind();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package info.nightscout.androidaps.plugins.general.maintenance.activities
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.CheckBox
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.NoSplashActivity
|
||||
import info.nightscout.androidaps.logging.L
|
||||
import kotlinx.android.synthetic.main.activity_logsetting.*
|
||||
|
||||
class LogSettingActivity : NoSplashActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_logsetting)
|
||||
|
||||
createViewsForSettings()
|
||||
|
||||
logsettings_reset.setOnClickListener {
|
||||
L.resetToDefaults()
|
||||
createViewsForSettings()
|
||||
}
|
||||
}
|
||||
|
||||
private fun createViewsForSettings() {
|
||||
logsettings_placeholder.removeAllViews()
|
||||
for (element in L.getLogElements()) {
|
||||
val logViewHolder = LogViewHolder(element)
|
||||
logsettings_placeholder.addView(logViewHolder.baseView)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal inner class LogViewHolder(element: L.LogElement) {
|
||||
var baseView: LinearLayout = layoutInflater.inflate(R.layout.logsettings_item, null) as LinearLayout
|
||||
|
||||
init {
|
||||
(baseView.findViewById<View>(R.id.logsettings_description) as TextView).text = element.name
|
||||
val enabled = baseView.findViewById<CheckBox>(R.id.logsettings_visibility)
|
||||
enabled.isChecked = element.enabled
|
||||
enabled.setOnClickListener { element.setEnabled(enabled.isChecked) }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -633,9 +633,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
|
||||
newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.danar_viewprofile))) {
|
||||
ProfileViewerDialog pvd = ProfileViewerDialog.newInstance(System.currentTimeMillis());
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("time", DateUtil.now());
|
||||
args.putInt("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal());
|
||||
ProfileViewerDialog pvd = new ProfileViewerDialog();
|
||||
pvd.setArguments(args);
|
||||
FragmentManager manager = getFragmentManager();
|
||||
pvd.show(manager, "ProfileViewDialog");
|
||||
if (manager != null)
|
||||
pvd.show(manager, "ProfileViewDialog");
|
||||
} else if (item.getTitle().equals(MainApp.gs(R.string.eatingsoon))) {
|
||||
DefaultValueHelper defHelper = new DefaultValueHelper();
|
||||
double target = defHelper.determineEatingSoonTT(profile.getUnits());
|
||||
|
|
|
@ -47,7 +47,7 @@ public class OverviewPlugin extends PluginBase {
|
|||
super(new PluginDescription()
|
||||
.mainType(PluginType.GENERAL)
|
||||
.fragmentClass(OverviewFragment.class.getName())
|
||||
.alwayVisible(true)
|
||||
.alwaysVisible(true)
|
||||
.alwaysEnabled(true)
|
||||
.pluginName(R.string.overview)
|
||||
.shortName(R.string.overview_shortname)
|
||||
|
|
|
@ -2,29 +2,30 @@ package info.nightscout.androidaps.plugins.general.overview.activities;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.cardview.widget.CardView;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
import info.nightscout.androidaps.data.QuickWizard;
|
||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog;
|
||||
import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.EditQuickWizardDialog;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventQuickWizardChange;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
|
||||
public class QuickWizardListActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
public class QuickWizardListActivity extends NoSplashAppCompatActivity implements View.OnClickListener {
|
||||
|
||||
RecyclerView recyclerView;
|
||||
LinearLayoutManager llm;
|
||||
|
@ -113,7 +114,7 @@ public class QuickWizardListActivity extends AppCompatActivity implements View.O
|
|||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.overview_quickwizardlist_activity);
|
||||
|
||||
|
|
|
@ -1,23 +1,20 @@
|
|||
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
/**
|
||||
* Created by adrian on 09/02/17.
|
||||
*/
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
|
||||
public class BolusProgressHelperActivity extends AppCompatActivity {
|
||||
public class BolusProgressHelperActivity extends NoSplashAppCompatActivity {
|
||||
public BolusProgressHelperActivity() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
BolusProgressDialog bolusProgressDialog = new BolusProgressDialog();
|
||||
bolusProgressDialog.setHelperActivity(this);
|
||||
bolusProgressDialog.setInsulin(getIntent().getDoubleExtra("insulin", 0d));
|
||||
bolusProgressDialog.show(getSupportFragmentManager(), "BolusProgress");
|
||||
super.onCreate(savedInstanceState);
|
||||
BolusProgressDialog bolusProgressDialog = new BolusProgressDialog();
|
||||
bolusProgressDialog.setHelperActivity(this);
|
||||
bolusProgressDialog.setInsulin(getIntent().getDoubleExtra("insulin", 0d));
|
||||
bolusProgressDialog.show(getSupportFragmentManager(), "BolusProgress");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package info.nightscout.androidaps.plugins.general.overview.dialogs
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
|
||||
class ErrorHelperActivity : AppCompatActivity() {
|
||||
class ErrorHelperActivity : NoSplashAppCompatActivity() {
|
||||
|
||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@Override
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val errorDialog = ErrorDialog()
|
||||
errorDialog.helperActivity = this
|
||||
|
|
|
@ -12,6 +12,7 @@ import info.nightscout.androidaps.plugins.general.tidepool.comm.TidepoolUploader
|
|||
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolDoUpload
|
||||
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolResetData
|
||||
import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolUpdateGUI
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
@ -36,7 +37,10 @@ class TidepoolFragment : Fragment() {
|
|||
tidepool_uploadnow.setOnClickListener { RxBus.send(EventTidepoolDoUpload()) }
|
||||
tidepool_removeall.setOnClickListener { RxBus.send(EventTidepoolResetData()) }
|
||||
tidepool_resertstart.setOnClickListener { SP.putLong(R.string.key_tidepool_last_end, 0) }
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
disposable.add(RxBus
|
||||
.toObservable(EventTidepoolUpdateGUI::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
@ -46,12 +50,14 @@ class TidepoolFragment : Fragment() {
|
|||
tidepool_status.text = TidepoolUploader.connectionStatus.name
|
||||
tidepool_log.text = TidepoolPlugin.textLog
|
||||
tidepool_logscrollview.fullScroll(ScrollView.FOCUS_DOWN)
|
||||
}, {})
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
override fun onStop() {
|
||||
super.onStop()
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,7 @@ import info.nightscout.androidaps.plugins.general.tidepool.events.EventTidepoolU
|
|||
import info.nightscout.androidaps.plugins.general.tidepool.utils.RateLimit
|
||||
import info.nightscout.androidaps.receivers.ChargingStateReceiver
|
||||
import info.nightscout.androidaps.receivers.NetworkChangeReceiver
|
||||
import info.nightscout.androidaps.utils.SP
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import info.nightscout.androidaps.utils.ToastUtils
|
||||
import info.nightscout.androidaps.utils.*
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
@ -43,8 +41,7 @@ object TidepoolPlugin : PluginBase(PluginDescription()
|
|||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
private val listLog = ArrayList<EventTidepoolStatus>()
|
||||
@Suppress("DEPRECATION") // API level 24 to replace call
|
||||
var textLog: Spanned = Html.fromHtml("")
|
||||
var textLog: Spanned = HtmlHelper.fromHtml("")
|
||||
|
||||
operator fun CompositeDisposable.plusAssign(disposable: Disposable) {
|
||||
add(disposable)
|
||||
|
@ -56,7 +53,7 @@ object TidepoolPlugin : PluginBase(PluginDescription()
|
|||
.toObservable(EventTidepoolDoUpload::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ doUpload() }, {
|
||||
log.error(it.message)
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
disposable += RxBus
|
||||
.toObservable(EventTidepoolResetData::class.java)
|
||||
|
@ -70,12 +67,14 @@ object TidepoolPlugin : PluginBase(PluginDescription()
|
|||
TidepoolUploader.doLogin()
|
||||
}
|
||||
}, {
|
||||
log.error(it.message)
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
disposable += RxBus
|
||||
.toObservable(EventTidepoolStatus::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({ event -> addToLog(event) }, {})
|
||||
.subscribe({ event -> addToLog(event) }, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
disposable += RxBus
|
||||
.toObservable(EventNewBG::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
|
@ -90,7 +89,7 @@ object TidepoolPlugin : PluginBase(PluginDescription()
|
|||
&& RateLimit.rateLimit("tidepool-new-data-upload", T.mins(4).secs().toInt()))
|
||||
doUpload()
|
||||
}, {
|
||||
log.error(it.message)
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
disposable += RxBus
|
||||
.toObservable(EventPreferenceChange::class.java)
|
||||
|
@ -102,13 +101,13 @@ object TidepoolPlugin : PluginBase(PluginDescription()
|
|||
)
|
||||
TidepoolUploader.resetInstance()
|
||||
}, {
|
||||
log.error(it.message)
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
disposable += RxBus
|
||||
.toObservable(EventNetworkChange::class.java)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe({}, {
|
||||
log.error(it.message)
|
||||
FabricPrivacy.logException(it)
|
||||
}) // TODO start upload on wifi connect
|
||||
|
||||
}
|
||||
|
@ -147,8 +146,7 @@ object TidepoolPlugin : PluginBase(PluginDescription()
|
|||
newTextLog.append(log.toPreparedHtml())
|
||||
}
|
||||
}
|
||||
@Suppress("DEPRECATION") // API level 24 to replace call
|
||||
textLog = Html.fromHtml(newTextLog.toString())
|
||||
textLog = HtmlHelper.fromHtml(newTextLog.toString())
|
||||
} catch (e: OutOfMemoryError) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().applicationContext, "Out of memory!\nStop using this phone !!!", R.raw.error)
|
||||
}
|
||||
|
|
|
@ -20,11 +20,16 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
|||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissBolusprogressIfRunning;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
||||
import info.nightscout.androidaps.plugins.general.wear.wearintegration.WatchUpdaterService;
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Created by adrian on 17/11/16.
|
||||
|
@ -38,6 +43,7 @@ public class WearPlugin extends PluginBase {
|
|||
private static WearPlugin wearPlugin;
|
||||
private static String TAG = "WearPlugin";
|
||||
|
||||
private CompositeDisposable disposable = new CompositeDisposable();
|
||||
|
||||
public static WearPlugin getPlugin() {
|
||||
return wearPlugin;
|
||||
|
@ -71,11 +77,20 @@ public class WearPlugin extends PluginBase {
|
|||
watchUS.setSettings();
|
||||
}
|
||||
super.onStart();
|
||||
|
||||
disposable.add(RxBus.INSTANCE
|
||||
.toObservable(EventOpenAPSUpdateGui.class)
|
||||
.observeOn(Schedulers.io())
|
||||
.subscribe(eventOpenAPSUpdateGui -> sendDataToWatch(true, true, false),
|
||||
error -> FabricPrivacy.logException(error)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
MainApp.bus().unregister(this);
|
||||
disposable.clear();
|
||||
}
|
||||
|
||||
private void sendDataToWatch(boolean status, boolean basals, boolean bgValue) {
|
||||
|
@ -112,7 +127,7 @@ public class WearPlugin extends PluginBase {
|
|||
//Log.d(TAG, "WR: WearPlugin:requestNotificationCancel");
|
||||
|
||||
Intent intent = new Intent(ctx, WatchUpdaterService.class)
|
||||
.setAction(WatchUpdaterService.ACTION_CANCEL_NOTIFICATION);
|
||||
.setAction(WatchUpdaterService.ACTION_CANCEL_NOTIFICATION);
|
||||
intent.putExtra("actionstring", actionstring);
|
||||
ctx.startService(intent);
|
||||
}
|
||||
|
@ -136,11 +151,6 @@ public class WearPlugin extends PluginBase {
|
|||
sendDataToWatch(true, true, false);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventOpenAPSUpdateGui ev) {
|
||||
sendDataToWatch(true, true, false);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventExtendedBolusChange ev) {
|
||||
sendDataToWatch(true, true, false);
|
||||
|
|
|
@ -1,164 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.profile.ns;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import butterknife.OnItemSelected;
|
||||
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.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.profile.ns.events.EventNSProfileUpdateGUI;
|
||||
import info.nightscout.androidaps.plugins.treatments.fragments.ProfileGraph;
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
import info.nightscout.androidaps.utils.OKDialog;
|
||||
|
||||
import static butterknife.OnItemSelected.Callback.NOTHING_SELECTED;
|
||||
|
||||
|
||||
public class NSProfileFragment extends SubscriberFragment {
|
||||
@BindView(R.id.nsprofile_spinner)
|
||||
Spinner profileSpinner;
|
||||
@BindView(R.id.profileview_noprofile)
|
||||
TextView noProfile;
|
||||
@BindView(R.id.profileview_invalidprofile)
|
||||
TextView invalidProfile;
|
||||
@BindView(R.id.profileview_units)
|
||||
TextView units;
|
||||
@BindView(R.id.profileview_dia)
|
||||
TextView dia;
|
||||
@BindView(R.id.profileview_activeprofile)
|
||||
TextView activeProfile;
|
||||
@BindView(R.id.profileview_ic)
|
||||
TextView ic;
|
||||
@BindView(R.id.profileview_isf)
|
||||
TextView isf;
|
||||
@BindView(R.id.profileview_basal)
|
||||
TextView basal;
|
||||
@BindView(R.id.profileview_basaltotal)
|
||||
TextView basaltotal;
|
||||
@BindView(R.id.profileview_target)
|
||||
TextView target;
|
||||
@BindView(R.id.basal_graph)
|
||||
ProfileGraph basalGraph;
|
||||
@BindView(R.id.nsprofile_profileswitch)
|
||||
Button activateButton;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.nsprofile_fragment, container, false);
|
||||
|
||||
unbinder = ButterKnife.bind(this, view);
|
||||
updateGUI();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventNSProfileUpdateGUI ev) {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
synchronized (NSProfileFragment.this) {
|
||||
updateGUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
if (noProfile == null || profileSpinner == null)
|
||||
return;
|
||||
|
||||
ProfileStore profileStore = NSProfilePlugin.getPlugin().getProfile();
|
||||
if (profileStore != null) {
|
||||
ArrayList<CharSequence> profileList = profileStore.getProfileList();
|
||||
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(getContext(),
|
||||
R.layout.spinner_centered, profileList);
|
||||
profileSpinner.setAdapter(adapter);
|
||||
// set selected to actual profile
|
||||
for (int p = 0; p < profileList.size(); p++) {
|
||||
if (profileList.get(p).equals(ProfileFunctions.getInstance().getProfileName()))
|
||||
profileSpinner.setSelection(p);
|
||||
}
|
||||
noProfile.setVisibility(View.GONE);
|
||||
} else {
|
||||
noProfile.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@OnItemSelected(R.id.nsprofile_spinner)
|
||||
public void onItemSelected(Spinner spinner, int position) {
|
||||
String name = spinner.getItemAtPosition(position).toString();
|
||||
|
||||
ProfileStore store = NSProfilePlugin.getPlugin().getProfile();
|
||||
if (store != null) {
|
||||
Profile profile = store.getSpecificProfile(name);
|
||||
if (profile != null) {
|
||||
units.setText(profile.getUnits());
|
||||
dia.setText(DecimalFormatter.to2Decimal(profile.getDia()) + " h");
|
||||
activeProfile.setText(name);
|
||||
ic.setText(profile.getIcList());
|
||||
isf.setText(profile.getIsfList());
|
||||
basal.setText(profile.getBasalList());
|
||||
basaltotal.setText(String.format(MainApp.gs(R.string.profile_total), DecimalFormatter.to2Decimal(profile.baseBasalSum())));
|
||||
target.setText(profile.getTargetList());
|
||||
basalGraph.show(profile);
|
||||
}
|
||||
if (profile.isValid("NSProfileFragment")) {
|
||||
invalidProfile.setVisibility(View.GONE);
|
||||
activateButton.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
invalidProfile.setVisibility(View.VISIBLE);
|
||||
activateButton.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
activateButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@OnItemSelected(value = R.id.nsprofile_spinner, callback = NOTHING_SELECTED)
|
||||
public void onNothingSelected() {
|
||||
invalidProfile.setVisibility(View.VISIBLE);
|
||||
noProfile.setVisibility(View.VISIBLE);
|
||||
units.setText("");
|
||||
dia.setText("");
|
||||
activeProfile.setText("");
|
||||
ic.setText("");
|
||||
isf.setText("");
|
||||
basal.setText("");
|
||||
basaltotal.setText("");
|
||||
target.setText("");
|
||||
activateButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@OnClick(R.id.nsprofile_profileswitch)
|
||||
public void onClickProfileSwitch() {
|
||||
String name = profileSpinner.getSelectedItem() != null ? profileSpinner.getSelectedItem().toString() : "";
|
||||
ProfileStore store = NSProfilePlugin.getPlugin().getProfile();
|
||||
if (store != null) {
|
||||
Profile profile = store.getSpecificProfile(name);
|
||||
if (profile != null) {
|
||||
OKDialog.showConfirmation(getActivity(), MainApp.gs(R.string.activate_profile) + ": " + name + " ?", () ->
|
||||
ProfileFunctions.doProfileSwitch(store, name, 0, 100, 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,129 @@
|
|||
package info.nightscout.androidaps.plugins.profile.ns
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.AdapterView
|
||||
import android.widget.ArrayAdapter
|
||||
import androidx.fragment.app.Fragment
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||
import info.nightscout.androidaps.plugins.profile.ns.events.EventNSProfileUpdateGUI
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.OKDialog
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import kotlinx.android.synthetic.main.close.*
|
||||
import kotlinx.android.synthetic.main.nsprofile_fragment.*
|
||||
import kotlinx.android.synthetic.main.profileviewer_fragment.*
|
||||
|
||||
|
||||
class NSProfileFragment : Fragment() {
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.nsprofile_fragment, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
close.visibility = View.GONE // not needed for fragment
|
||||
|
||||
nsprofile_profileswitch.setOnClickListener {
|
||||
val name = nsprofile_spinner.selectedItem?.toString() ?: ""
|
||||
NSProfilePlugin.getPlugin().profile?.let { store ->
|
||||
store.getSpecificProfile(name)?.let {
|
||||
OKDialog.showConfirmation(activity,
|
||||
MainApp.gs(R.string.activate_profile) + ": " + name + " ?"
|
||||
) {
|
||||
ProfileFunctions.doProfileSwitch(store, name, 0, 100, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsprofile_spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||
profileview_invalidprofile.visibility = View.VISIBLE
|
||||
profileview_noprofile.visibility = View.VISIBLE
|
||||
profileview_units.text = ""
|
||||
profileview_dia.text = ""
|
||||
profileview_activeprofile.text = ""
|
||||
profileview_ic.text = ""
|
||||
profileview_isf.text = ""
|
||||
profileview_basal.text = ""
|
||||
profileview_basaltotal.text = ""
|
||||
profileview_target.text = ""
|
||||
nsprofile_profileswitch.visibility = View.GONE
|
||||
}
|
||||
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
val name = nsprofile_spinner.getItemAtPosition(position).toString()
|
||||
|
||||
nsprofile_profileswitch.visibility = View.GONE
|
||||
|
||||
NSProfilePlugin.getPlugin().profile?.let { store ->
|
||||
store.getSpecificProfile(name)?.let { profile ->
|
||||
profileview_units.text = profile.units
|
||||
profileview_dia.text = MainApp.gs(R.string.format_hours, profile.dia)
|
||||
profileview_activeprofile.text = name
|
||||
profileview_ic.text = profile.icList
|
||||
profileview_isf.text = profile.isfList
|
||||
profileview_basal.text = profile.basalList
|
||||
profileview_basaltotal.text = String.format(MainApp.gs(R.string.profile_total), DecimalFormatter.to2Decimal(profile.baseBasalSum()))
|
||||
profileview_target.text = profile.targetList
|
||||
basal_graph.show(profile)
|
||||
if (profile.isValid("NSProfileFragment")) {
|
||||
profileview_invalidprofile.visibility = View.GONE
|
||||
nsprofile_profileswitch.visibility = View.VISIBLE
|
||||
} else {
|
||||
profileview_invalidprofile.visibility = View.VISIBLE
|
||||
nsprofile_profileswitch.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
updateGUI()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
disposable.add(RxBus
|
||||
.toObservable(EventNSProfileUpdateGUI::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
updateGUI()
|
||||
}, {
|
||||
FabricPrivacy.logException(it)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
}
|
||||
|
||||
fun updateGUI() {
|
||||
profileview_noprofile.visibility = View.VISIBLE
|
||||
|
||||
NSProfilePlugin.getPlugin().profile?.let { profileStore ->
|
||||
val profileList = profileStore.profileList
|
||||
val adapter = ArrayAdapter(context!!, R.layout.spinner_centered, profileList)
|
||||
nsprofile_spinner.adapter = adapter
|
||||
// set selected to actual profile
|
||||
for (p in profileList.indices) {
|
||||
if (profileList[p] == ProfileFunctions.getInstance().profileName)
|
||||
nsprofile_spinner.setSelection(p)
|
||||
}
|
||||
profileview_noprofile.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ import info.nightscout.androidaps.Constants;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.services.Intents;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.events.EventProfileStoreChanged;
|
||||
|
@ -47,7 +48,7 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
|
|||
.pluginName(R.string.nsprofile)
|
||||
.shortName(R.string.profileviewer_shortname)
|
||||
.alwaysEnabled(Config.NSCLIENT)
|
||||
.alwayVisible(Config.NSCLIENT)
|
||||
.alwaysVisible(Config.NSCLIENT)
|
||||
.showInList(!Config.NSCLIENT)
|
||||
.description(R.string.description_profile_nightscout)
|
||||
);
|
||||
|
@ -76,7 +77,7 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
|
|||
storeNSProfile();
|
||||
if (isEnabled(PluginType.PROFILE)) {
|
||||
MainApp.bus().post(new EventProfileStoreChanged());
|
||||
MainApp.bus().post(new EventNSProfileUpdateGUI());
|
||||
RxBus.INSTANCE.send(new EventNSProfileUpdateGUI());
|
||||
}
|
||||
if (L.isEnabled(L.PROFILE))
|
||||
log.debug("Received profileStore: " + activeProfile + " " + profile);
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.profile.ns.events;
|
||||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class EventNSProfileUpdateGUI extends EventUpdateGui {
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.profile.ns.events
|
||||
|
||||
import info.nightscout.androidaps.events.EventUpdateGui
|
||||
|
||||
class EventNSProfileUpdateGUI : EventUpdateGui()
|
|
@ -1,11 +1,10 @@
|
|||
package info.nightscout.androidaps.plugins.pump.combo;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -40,7 +39,6 @@ import info.nightscout.androidaps.interfaces.PumpDescription;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||
|
@ -164,8 +162,8 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
|||
}
|
||||
|
||||
@Override
|
||||
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity activity) {
|
||||
confirmPumpPluginActivation(pluginSwitcher, activity);
|
||||
public void switchAllowed(boolean newState, FragmentActivity activity, PluginType type) {
|
||||
confirmPumpPluginActivation(newState, activity, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
|
@ -27,6 +27,7 @@ import info.nightscout.androidaps.events.EventAppExit;
|
|||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
@ -108,8 +109,8 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
|
|||
public abstract void onStartCustomActions();
|
||||
|
||||
@Override
|
||||
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity activity) {
|
||||
confirmPumpPluginActivation(pluginSwitcher, activity);
|
||||
public void switchAllowed(boolean newState, FragmentActivity activity, PluginType type) {
|
||||
confirmPumpPluginActivation(newState, activity, type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ public abstract class PumpStatus {
|
|||
// other pump settings
|
||||
public String activeProfileName = "0";
|
||||
public double reservoirRemainingUnits = 0d;
|
||||
public String reservoirFullUnits = "???";
|
||||
public int reservoirFullUnits = 0;
|
||||
public int batteryRemaining = 0; // percent, so 0-100
|
||||
public Double batteryVoltage = null;
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@ import java.util.Map;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkConst;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.GattAttributes;
|
||||
|
@ -52,7 +54,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
|||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
// IMPORTANT: This activity needs to be called from RileyLinkSelectPreference (see pref_medtronic.xml as example)
|
||||
public class RileyLinkBLEScanActivity extends AppCompatActivity {
|
||||
public class RileyLinkBLEScanActivity extends NoSplashAppCompatActivity {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RileyLinkBLEScanActivity.class);
|
||||
|
||||
|
@ -79,7 +81,7 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
|
|||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.rileylink_scan_activity);
|
||||
|
||||
|
@ -108,7 +110,7 @@ public class RileyLinkBLEScanActivity extends AppCompatActivity {
|
|||
MedtronicPumpStatus pumpStatus = MedtronicUtil.getPumpStatus();
|
||||
pumpStatus.verifyConfiguration(); // force reloading of address
|
||||
|
||||
MainApp.bus().post(new EventMedtronicPumpConfigurationChanged());
|
||||
RxBus.INSTANCE.send(new EventMedtronicPumpConfigurationChanged());
|
||||
|
||||
finish();
|
||||
});
|
||||
|
|
|
@ -15,8 +15,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkBLE;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.encoding.Encoding4b6b;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.encoding.Encoding4b6bGeoff;
|
||||
|
@ -124,7 +124,7 @@ public class RileyLinkUtil {
|
|||
|
||||
RileyLinkUtil.historyRileyLink.add(new RLHistoryItem(RileyLinkUtil.rileyLinkServiceData.serviceState,
|
||||
RileyLinkUtil.rileyLinkServiceData.errorCode, targetDevice));
|
||||
MainApp.bus().post(new EventMedtronicDeviceStatusChange(newState, errorCode));
|
||||
RxBus.INSTANCE.send(new EventMedtronicDeviceStatusChange(newState, errorCode));
|
||||
return null;
|
||||
|
||||
} else {
|
||||
|
|
|
@ -1,39 +1,31 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
import butterknife.BindView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
import info.nightscout.androidaps.plugins.pump.common.dialog.RefreshableInterface;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkServiceData;
|
||||
|
||||
public class RileyLinkStatusActivity extends AppCompatActivity {
|
||||
public class RileyLinkStatusActivity extends NoSplashAppCompatActivity {
|
||||
|
||||
@BindView(R.id.rls_t1_connection_status)
|
||||
TextView connectionStatus;
|
||||
|
||||
@BindView(R.id.rls_t1_configured_address)
|
||||
TextView configuredAddress;
|
||||
|
||||
@BindView(R.id.rls_t1_connected_device)
|
||||
TextView connectedDevice;
|
||||
|
||||
@BindView(R.id.rls_t1_connection_error)
|
||||
TextView connectionError;
|
||||
RileyLinkServiceData rileyLinkServiceData;
|
||||
|
||||
|
@ -47,7 +39,7 @@ public class RileyLinkStatusActivity extends AppCompatActivity {
|
|||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.rileylink_status);
|
||||
|
||||
|
@ -55,34 +47,30 @@ public class RileyLinkStatusActivity extends AppCompatActivity {
|
|||
// primary sections of the activity.
|
||||
|
||||
// Set up the ViewPager with the sections adapter.
|
||||
mViewPager = (ViewPager)findViewById(R.id.rileylink_settings_container);
|
||||
mViewPager = (ViewPager) findViewById(R.id.rileylink_settings_container);
|
||||
// mViewPager.setAdapter(mSectionsPagerAdapter);
|
||||
setupViewPager(mViewPager);
|
||||
|
||||
tabLayout = (TabLayout)findViewById(R.id.rileylink_settings_tabs);
|
||||
tabLayout = (TabLayout) findViewById(R.id.rileylink_settings_tabs);
|
||||
tabLayout.setupWithViewPager(mViewPager);
|
||||
|
||||
floatingActionButton = (FloatingActionButton)findViewById(R.id.rileylink_settings_fab);
|
||||
floatingActionButton.setOnClickListener(new View.OnClickListener() {
|
||||
floatingActionButton = (FloatingActionButton) findViewById(R.id.rileylink_settings_fab);
|
||||
floatingActionButton.setOnClickListener(v -> {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
RefreshableInterface selectableInterface = (RefreshableInterface)mSectionsPagerAdapter
|
||||
RefreshableInterface selectableInterface = (RefreshableInterface) mSectionsPagerAdapter
|
||||
.getItem(tabLayout.getSelectedTabPosition());
|
||||
selectableInterface.refreshData();
|
||||
selectableInterface.refreshData();
|
||||
|
||||
// refreshData(tabLayout.getSelectedTabPosition());
|
||||
// refreshData(tabLayout.getSelectedTabPosition());
|
||||
|
||||
// Toast.makeText(getApplicationContext(), "Test pos: " + tabLayout.getSelectedTabPosition(),
|
||||
// Toast.LENGTH_LONG);
|
||||
}
|
||||
// Toast.makeText(getApplicationContext(), "Test pos: " + tabLayout.getSelectedTabPosition(),
|
||||
// Toast.LENGTH_LONG);
|
||||
});
|
||||
|
||||
this.connectionStatus = (TextView)findViewById(R.id.rls_t1_connection_status);
|
||||
this.configuredAddress = (TextView)findViewById(R.id.rls_t1_configured_address);
|
||||
this.connectedDevice = (TextView)findViewById(R.id.rls_t1_connected_device);
|
||||
this.connectionError = (TextView)findViewById(R.id.rls_t1_connection_error);
|
||||
this.connectionStatus = findViewById(R.id.rls_t1_connection_status);
|
||||
this.configuredAddress = findViewById(R.id.rls_t1_configured_address);
|
||||
this.connectedDevice = findViewById(R.id.rls_t1_connected_device);
|
||||
this.connectionError = findViewById(R.id.rls_t1_connection_error);
|
||||
|
||||
rileyLinkServiceData = RileyLinkUtil.getRileyLinkServiceData();
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
|
||||
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventRefreshButtonState;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService;
|
||||
|
||||
/**
|
||||
|
@ -24,11 +25,11 @@ public class ResetRileyLinkConfigurationTask extends PumpTask {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
MedtronicFragment.refreshButtonEnabled(false);
|
||||
RxBus.INSTANCE.send(new EventRefreshButtonState(false));
|
||||
MedtronicPumpPlugin.isBusy = true;
|
||||
RileyLinkMedtronicService.getInstance().resetRileyLinkConfiguration();
|
||||
MedtronicPumpPlugin.isBusy = false;
|
||||
MedtronicFragment.refreshButtonEnabled(true);
|
||||
RxBus.INSTANCE.send(new EventRefreshButtonState(true));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks;
|
||||
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicFragment;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.MedtronicPumpPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventRefreshButtonState;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService;
|
||||
|
||||
/**
|
||||
|
@ -24,11 +25,10 @@ public class WakeAndTuneTask extends PumpTask {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
MedtronicFragment.refreshButtonEnabled(false);
|
||||
RxBus.INSTANCE.send(new EventRefreshButtonState(false));
|
||||
MedtronicPumpPlugin.isBusy = true;
|
||||
RileyLinkMedtronicService.getInstance().doTuneUpDevice();
|
||||
MedtronicPumpPlugin.isBusy = false;
|
||||
MedtronicFragment.refreshButtonEnabled(true);
|
||||
RxBus.INSTANCE.send(new EventRefreshButtonState(true));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -80,8 +79,8 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
|||
}
|
||||
|
||||
@Override
|
||||
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity activity) {
|
||||
confirmPumpPluginActivation(pluginSwitcher, activity);
|
||||
public void switchAllowed(boolean newState, FragmentActivity activity, PluginType type) {
|
||||
confirmPumpPluginActivation(newState, activity, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,304 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import android.text.Spanned;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.TDDStatsActivity;
|
||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.dialogs.ProfileViewDialog;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRHistoryActivity;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRUserOptionsActivity;
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRNewStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
import info.nightscout.androidaps.utils.SetWarnColor;
|
||||
|
||||
public class DanaRFragment extends SubscriberFragment {
|
||||
private static Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
private Handler loopHandler = new Handler();
|
||||
private Runnable refreshLoop = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateGUI();
|
||||
loopHandler.postDelayed(refreshLoop, 60 * 1000L);
|
||||
}
|
||||
};
|
||||
|
||||
@BindView(R.id.danar_lastconnection)
|
||||
TextView lastConnectionView;
|
||||
@BindView(R.id.danar_btconnection)
|
||||
TextView btConnectionView;
|
||||
@BindView(R.id.danar_lastbolus)
|
||||
TextView lastBolusView;
|
||||
@BindView(R.id.danar_dailyunits)
|
||||
TextView dailyUnitsView;
|
||||
@BindView(R.id.danar_basabasalrate)
|
||||
TextView basaBasalRateView;
|
||||
@BindView(R.id.danar_tempbasal)
|
||||
TextView tempBasalView;
|
||||
@BindView(R.id.danar_extendedbolus)
|
||||
TextView extendedBolusView;
|
||||
@BindView(R.id.danar_battery)
|
||||
TextView batteryView;
|
||||
@BindView(R.id.danar_reservoir)
|
||||
TextView reservoirView;
|
||||
@BindView(R.id.danar_iob)
|
||||
TextView iobView;
|
||||
@BindView(R.id.danar_firmware)
|
||||
TextView firmwareView;
|
||||
@BindView(R.id.danar_basalstep)
|
||||
TextView basalStepView;
|
||||
@BindView(R.id.danar_bolusstep)
|
||||
TextView bolusStepView;
|
||||
@BindView(R.id.danar_serialnumber)
|
||||
TextView serialNumberView;
|
||||
@BindView(R.id.danar_queue)
|
||||
TextView queueView;
|
||||
|
||||
@BindView(R.id.overview_pumpstatuslayout)
|
||||
LinearLayout pumpStatusLayout;
|
||||
@BindView(R.id.overview_pumpstatus)
|
||||
TextView pumpStatusView;
|
||||
@BindView(R.id.danar_user_options)
|
||||
Button danar_user_options;
|
||||
|
||||
public DanaRFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
loopHandler.postDelayed(refreshLoop, 60 * 1000L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
loopHandler.removeCallbacks(refreshLoop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.danar_fragment, container, false);
|
||||
unbinder = ButterKnife.bind(this, view);
|
||||
|
||||
pumpStatusView.setBackgroundColor(MainApp.gc(R.color.colorInitializingBorder));
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@OnClick(R.id.danar_history)
|
||||
void onHistoryClick() {
|
||||
startActivity(new Intent(getContext(), DanaRHistoryActivity.class));
|
||||
}
|
||||
|
||||
@OnClick(R.id.danar_viewprofile)
|
||||
void onViewProfileClick() {
|
||||
FragmentManager manager = getFragmentManager();
|
||||
ProfileViewDialog profileViewDialog = new ProfileViewDialog();
|
||||
profileViewDialog.show(manager, "ProfileViewDialog");
|
||||
}
|
||||
|
||||
@OnClick(R.id.danar_stats)
|
||||
void onStatsClick() {
|
||||
startActivity(new Intent(getContext(), TDDStatsActivity.class));
|
||||
}
|
||||
|
||||
@OnClick(R.id.danar_user_options)
|
||||
void onUserOptionsClick() {
|
||||
startActivity(new Intent(getContext(), DanaRUserOptionsActivity.class));
|
||||
}
|
||||
|
||||
@OnClick(R.id.danar_btconnection)
|
||||
void onBtConnectionClick() {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Clicked connect to pump");
|
||||
DanaRPump.getInstance().lastConnection = 0;
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Clicked connect to pump", null);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||
Activity activity = getActivity();
|
||||
final String status = c.textStatus();
|
||||
if (activity != null) {
|
||||
activity.runOnUiThread(
|
||||
() -> {
|
||||
synchronized (DanaRFragment.this) {
|
||||
|
||||
if (btConnectionView == null || pumpStatusView == null || pumpStatusLayout == null)
|
||||
return;
|
||||
|
||||
if (c.sStatus == EventPumpStatusChanged.CONNECTING)
|
||||
btConnectionView.setText("{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s");
|
||||
else if (c.sStatus == EventPumpStatusChanged.CONNECTED)
|
||||
btConnectionView.setText("{fa-bluetooth}");
|
||||
else if (c.sStatus == EventPumpStatusChanged.DISCONNECTED)
|
||||
btConnectionView.setText("{fa-bluetooth-b}");
|
||||
|
||||
if (!status.equals("")) {
|
||||
pumpStatusView.setText(status);
|
||||
pumpStatusLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
pumpStatusLayout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventDanaRNewStatus s) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventTempBasalChange s) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventExtendedBolusChange s) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventQueueChanged s) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
// GUI functions
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null && basaBasalRateView != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
synchronized (DanaRFragment.this) {
|
||||
if (!isBound()) return;
|
||||
|
||||
DanaRPump pump = DanaRPump.getInstance();
|
||||
if (pump.lastConnection != 0) {
|
||||
Long agoMsec = System.currentTimeMillis() - pump.lastConnection;
|
||||
int agoMin = (int) (agoMsec / 60d / 1000d);
|
||||
lastConnectionView.setText(DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.gs(R.string.minago), agoMin) + ")");
|
||||
SetWarnColor.setColor(lastConnectionView, agoMin, 16d, 31d);
|
||||
}
|
||||
if (pump.lastBolusTime != 0) {
|
||||
Long agoMsec = System.currentTimeMillis() - pump.lastBolusTime;
|
||||
double agoHours = agoMsec / 60d / 60d / 1000d;
|
||||
if (agoHours < 6) // max 6h back
|
||||
lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " " + DateUtil.sinceString(pump.lastBolusTime) + " " + DecimalFormatter.to2Decimal(DanaRPump.getInstance().lastBolusAmount) + " U");
|
||||
else lastBolusView.setText("");
|
||||
}
|
||||
|
||||
dailyUnitsView.setText(DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U");
|
||||
SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d);
|
||||
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate()) + " U/h");
|
||||
// DanaRPlugin, DanaRKoreanPlugin
|
||||
if (ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress()) {
|
||||
tempBasalView.setText(TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||
} else {
|
||||
tempBasalView.setText("");
|
||||
}
|
||||
} else {
|
||||
// v2 plugin
|
||||
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||
if (tb != null) {
|
||||
tempBasalView.setText(tb.toStringFull());
|
||||
} else {
|
||||
tempBasalView.setText("");
|
||||
}
|
||||
}
|
||||
ExtendedBolus activeExtendedBolus = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
if (activeExtendedBolus != null) {
|
||||
extendedBolusView.setText(activeExtendedBolus.toString());
|
||||
} else {
|
||||
extendedBolusView.setText("");
|
||||
}
|
||||
reservoirView.setText(DecimalFormatter.to0Decimal(pump.reservoirRemainingUnits) + " / 300 U");
|
||||
SetWarnColor.setColorInverse(reservoirView, pump.reservoirRemainingUnits, 50d, 20d);
|
||||
batteryView.setText("{fa-battery-" + (pump.batteryRemaining / 25) + "}");
|
||||
SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d);
|
||||
iobView.setText(pump.iob + " U");
|
||||
if (pump.model != 0 || pump.protocol != 0 || pump.productCode != 0) {
|
||||
firmwareView.setText(String.format(MainApp.gs(R.string.danar_model), pump.model, pump.protocol, pump.productCode));
|
||||
} else {
|
||||
firmwareView.setText("OLD");
|
||||
}
|
||||
basalStepView.setText("" + pump.basalStep);
|
||||
bolusStepView.setText("" + pump.bolusStep);
|
||||
serialNumberView.setText("" + pump.serialNumber);
|
||||
if (queueView != null) {
|
||||
Spanned status = ConfigBuilderPlugin.getPlugin().getCommandQueue().spannedStatus();
|
||||
if (status.toString().equals("")) {
|
||||
queueView.setVisibility(View.GONE);
|
||||
} else {
|
||||
queueView.setVisibility(View.VISIBLE);
|
||||
queueView.setText(status);
|
||||
}
|
||||
}
|
||||
//hide user options button if not an RS pump or old firmware
|
||||
// also excludes pump with model 03 because of untested error
|
||||
boolean isKorean = DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PUMP);
|
||||
if (isKorean || firmwareView.getText() == "OLD" || pump.model == 3) {
|
||||
danar_user_options.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isBound() {
|
||||
return lastConnectionView != null
|
||||
&& lastBolusView != null
|
||||
&& dailyUnitsView != null
|
||||
&& basaBasalRateView != null
|
||||
&& tempBasalView != null
|
||||
&& extendedBolusView != null
|
||||
&& reservoirView != null
|
||||
&& batteryView != null
|
||||
&& iobView != null
|
||||
&& firmwareView != null
|
||||
&& basalStepView != null
|
||||
&& bolusStepView != null
|
||||
&& serialNumberView != null
|
||||
&& danar_user_options != null
|
||||
&& queueView != null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR
|
||||
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.squareup.otto.Subscribe
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.activities.TDDStatsActivity
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange
|
||||
import info.nightscout.androidaps.interfaces.PluginType
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface
|
||||
import info.nightscout.androidaps.logging.L
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRHistoryActivity
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.activities.DanaRUserOptionsActivity
|
||||
import info.nightscout.androidaps.plugins.pump.danaR.events.EventDanaRNewStatus
|
||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.plugins.treatments.fragments.ProfileViewerDialog
|
||||
import info.nightscout.androidaps.queue.events.EventQueueChanged
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.SetWarnColor
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotlinx.android.synthetic.main.danar_fragment.*
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
class DanaRFragment : Fragment() {
|
||||
private val log = LoggerFactory.getLogger(L.PUMP)
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
operator fun CompositeDisposable.plusAssign(disposable: Disposable) {
|
||||
add(disposable)
|
||||
}
|
||||
|
||||
private val loopHandler = Handler()
|
||||
private lateinit var refreshLoop: Runnable
|
||||
|
||||
init {
|
||||
refreshLoop = Runnable {
|
||||
activity?.runOnUiThread { updateGUI() }
|
||||
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.danar_fragment, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
dana_pumpstatus.setBackgroundColor(MainApp.gc(R.color.colorInitializingBorder))
|
||||
|
||||
danar_history.setOnClickListener { startActivity(Intent(context, DanaRHistoryActivity::class.java)) }
|
||||
danar_viewprofile.setOnClickListener {
|
||||
fragmentManager?.let { fragmentManager ->
|
||||
val args = Bundle()
|
||||
args.putLong("time", DateUtil.now())
|
||||
args.putInt("mode", ProfileViewerDialog.Mode.PUMP_PROFILE.ordinal)
|
||||
val pvd = ProfileViewerDialog()
|
||||
pvd.arguments = args
|
||||
pvd.show(fragmentManager, "ProfileViewDialog")
|
||||
}
|
||||
}
|
||||
danar_stats.setOnClickListener { startActivity(Intent(context, TDDStatsActivity::class.java)) }
|
||||
danar_user_options.setOnClickListener { startActivity(Intent(context, DanaRUserOptionsActivity::class.java)) }
|
||||
danar_btconnection.setOnClickListener {
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("Clicked connect to pump")
|
||||
DanaRPump.getInstance().lastConnection = 0
|
||||
ConfigBuilderPlugin.getPlugin().commandQueue.readStatus("Clicked connect to pump", null)
|
||||
}
|
||||
updateGUI()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
MainApp.bus().register(this)
|
||||
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
|
||||
disposable += RxBus
|
||||
.toObservable(EventDanaRNewStatus::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ updateGUI() }, { FabricPrivacy.logException(it) })
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
MainApp.bus().unregister(this)
|
||||
loopHandler.removeCallbacks(refreshLoop)
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public fun onStatusEvent(c: EventPumpStatusChanged) {
|
||||
activity?.runOnUiThread {
|
||||
when {
|
||||
c.sStatus == EventPumpStatusChanged.CONNECTING -> danar_btconnection.text = "{fa-bluetooth-b spin} " + c.sSecondsElapsed + "s"
|
||||
c.sStatus == EventPumpStatusChanged.CONNECTED -> danar_btconnection.text = "{fa-bluetooth}"
|
||||
c.sStatus == EventPumpStatusChanged.DISCONNECTED -> danar_btconnection.text = "{fa-bluetooth-b}"
|
||||
}
|
||||
if (c.textStatus() != "") {
|
||||
dana_pumpstatus.text = c.textStatus()
|
||||
dana_pumpstatuslayout.visibility = View.VISIBLE
|
||||
} else {
|
||||
dana_pumpstatuslayout.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public fun onStatusEvent(s: EventTempBasalChange) =
|
||||
activity?.runOnUiThread { updateGUI() }
|
||||
|
||||
|
||||
@Subscribe
|
||||
public fun onStatusEvent(s: EventExtendedBolusChange) =
|
||||
activity?.runOnUiThread { updateGUI() }
|
||||
|
||||
@Subscribe
|
||||
public fun onStatusEvent(s: EventQueueChanged) =
|
||||
activity?.runOnUiThread { updateGUI() }
|
||||
|
||||
// GUI functions
|
||||
internal fun updateGUI() {
|
||||
val pump = DanaRPump.getInstance()
|
||||
val plugin: PumpInterface = ConfigBuilderPlugin.getPlugin().activePump ?: return
|
||||
if (pump.lastConnection != 0L) {
|
||||
val agoMsec = System.currentTimeMillis() - pump.lastConnection
|
||||
val agoMin = (agoMsec.toDouble() / 60.0 / 1000.0).toInt()
|
||||
danar_lastconnection.text = DateUtil.timeString(pump.lastConnection) + " (" + String.format(MainApp.gs(R.string.minago), agoMin) + ")"
|
||||
SetWarnColor.setColor(danar_lastconnection, agoMin.toDouble(), 16.0, 31.0)
|
||||
}
|
||||
if (pump.lastBolusTime != 0L) {
|
||||
val agoMsec = System.currentTimeMillis() - pump.lastBolusTime
|
||||
val agoHours = agoMsec.toDouble() / 60.0 / 60.0 / 1000.0
|
||||
if (agoHours < 6)
|
||||
// max 6h back
|
||||
danar_lastbolus.text = DateUtil.timeString(pump.lastBolusTime) + " " + DateUtil.sinceString(pump.lastBolusTime) + " " + MainApp.gs(R.string.formatinsulinunits, pump.lastBolusAmount)
|
||||
else
|
||||
danar_lastbolus.text = ""
|
||||
}
|
||||
|
||||
danar_dailyunits.text = MainApp.gs(R.string.reservoirvalue, pump.dailyTotalUnits, pump.maxDailyTotalUnits)
|
||||
SetWarnColor.setColor(danar_dailyunits, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75, pump.maxDailyTotalUnits * 0.9)
|
||||
danar_basabasalrate.text = "( " + (pump.activeProfile + 1) + " ) " + MainApp.gs(R.string.pump_basebasalrate, plugin.baseBasalRate)
|
||||
// DanaRPlugin, DanaRKoreanPlugin
|
||||
if (ConfigBuilderPlugin.getPlugin().activePump!!.isFakingTempsByExtendedBoluses) {
|
||||
danar_tempbasal.text = TreatmentsPlugin.getPlugin()
|
||||
.getRealTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() ?: ""
|
||||
} else {
|
||||
// v2 plugin
|
||||
danar_tempbasal.text = TreatmentsPlugin.getPlugin()
|
||||
.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() ?: ""
|
||||
}
|
||||
danar_extendedbolus.text = TreatmentsPlugin.getPlugin()
|
||||
.getExtendedBolusFromHistory(System.currentTimeMillis())?.toString() ?: ""
|
||||
danar_reservoir.text = MainApp.gs(R.string.reservoirvalue, pump.reservoirRemainingUnits, 300)
|
||||
SetWarnColor.setColorInverse(danar_reservoir, pump.reservoirRemainingUnits, 50.0, 20.0)
|
||||
danar_battery.text = "{fa-battery-" + pump.batteryRemaining / 25 + "}"
|
||||
SetWarnColor.setColorInverse(danar_battery, pump.batteryRemaining.toDouble(), 51.0, 26.0)
|
||||
danar_iob.text = MainApp.gs(R.string.formatinsulinunits, pump.iob)
|
||||
if (pump.model != 0 || pump.protocol != 0 || pump.productCode != 0) {
|
||||
danar_firmware.text = String.format(MainApp.gs(R.string.danar_model), pump.model, pump.protocol, pump.productCode)
|
||||
} else {
|
||||
danar_firmware.text = "OLD"
|
||||
}
|
||||
danar_basalstep.text = pump.basalStep.toString()
|
||||
danar_bolusstep.text = pump.bolusStep.toString()
|
||||
danar_serialnumber.text = pump.serialNumber
|
||||
val status = ConfigBuilderPlugin.getPlugin().commandQueue.spannedStatus()
|
||||
if (status.toString() == "") {
|
||||
danar_queue.visibility = View.GONE
|
||||
} else {
|
||||
danar_queue.visibility = View.VISIBLE
|
||||
danar_queue.text = status
|
||||
}
|
||||
//hide user options button if not an RS pump or old firmware
|
||||
// also excludes pump with model 03 because of untested error
|
||||
val isKorean = DanaRKoreanPlugin.getPlugin().isEnabled(PluginType.PUMP)
|
||||
if (isKorean || danar_firmware.text === "OLD" || pump.model == 3) {
|
||||
danar_user_options.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.dialogs;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.treatments.fragments.ProfileGraph;
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
|
||||
/**
|
||||
* Created by mike on 10.07.2016.
|
||||
*/
|
||||
public class ProfileViewDialog extends DialogFragment {
|
||||
private TextView noProfile;
|
||||
private TextView units;
|
||||
private TextView dia;
|
||||
private TextView activeProfile;
|
||||
private TextView ic;
|
||||
private TextView isf;
|
||||
private TextView basal;
|
||||
private TextView target;
|
||||
private ProfileGraph basalGraph;
|
||||
|
||||
|
||||
private Button refreshButton;
|
||||
|
||||
public ProfileViewDialog() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.profileviewer_fragment, container, false);
|
||||
|
||||
noProfile = (TextView) layout.findViewById(R.id.profileview_noprofile);
|
||||
units = (TextView) layout.findViewById(R.id.profileview_units);
|
||||
dia = (TextView) layout.findViewById(R.id.profileview_dia);
|
||||
activeProfile = (TextView) layout.findViewById(R.id.profileview_activeprofile);
|
||||
ic = (TextView) layout.findViewById(R.id.profileview_ic);
|
||||
isf = (TextView) layout.findViewById(R.id.profileview_isf);
|
||||
basal = (TextView) layout.findViewById(R.id.profileview_basal);
|
||||
target = (TextView) layout.findViewById(R.id.profileview_target);
|
||||
refreshButton = (Button) layout.findViewById(R.id.profileview_reload);
|
||||
refreshButton.setVisibility(View.VISIBLE);
|
||||
refreshButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("ProfileViewDialog", null);
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
basalGraph = (ProfileGraph) layout.findViewById(R.id.basal_graph);
|
||||
setContent();
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
}
|
||||
|
||||
private void setContent() {
|
||||
ProfileStore store = ((ProfileInterface)ConfigBuilderPlugin.getPlugin().getActivePump()).getProfile();
|
||||
if (store != null) {
|
||||
noProfile.setVisibility(View.GONE);
|
||||
Profile profile = store.getDefaultProfile();
|
||||
units.setText(profile.getUnits());
|
||||
dia.setText(DecimalFormatter.to2Decimal(profile.getDia()) + " h");
|
||||
activeProfile.setText(((ProfileInterface) ConfigBuilderPlugin.getPlugin().getActivePump()).getProfileName());
|
||||
ic.setText(profile.getIcList());
|
||||
isf.setText(profile.getIsfList());
|
||||
basal.setText(profile.getBasalList());
|
||||
target.setText(profile.getTargetList());
|
||||
basalGraph.show(store.getDefaultProfile());
|
||||
} else {
|
||||
noProfile.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -27,6 +27,7 @@ import java.util.List;
|
|||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.NoSplashActivity;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
|
@ -43,7 +44,7 @@ import info.nightscout.androidaps.utils.DateUtil;
|
|||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
import info.nightscout.androidaps.utils.ToastUtils;
|
||||
|
||||
public class DanaRHistoryActivity extends Activity {
|
||||
public class DanaRHistoryActivity extends NoSplashActivity {
|
||||
private static Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
private Handler mHandler;
|
||||
|
@ -96,7 +97,7 @@ public class DanaRHistoryActivity extends Activity {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.danar_historyactivity);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.text.DecimalFormat;
|
|||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.NoSplashActivity;
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
|
@ -31,7 +32,7 @@ import info.nightscout.androidaps.utils.NumberPicker;
|
|||
* Created by Rumen Georgiev on 5/31/2018.
|
||||
*/
|
||||
|
||||
public class DanaRUserOptionsActivity extends Activity {
|
||||
public class DanaRUserOptionsActivity extends NoSplashActivity {
|
||||
private static Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
Switch timeFormat;
|
||||
|
@ -65,7 +66,7 @@ public class DanaRUserOptionsActivity extends Activity {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.danar_user_options);
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.events;
|
||||
|
||||
import info.nightscout.androidaps.events.Event;
|
||||
|
||||
/**
|
||||
* Created by mike on 08.07.2016.
|
||||
*/
|
||||
public class EventDanaRNewStatus extends Event {
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaR.events
|
||||
|
||||
import info.nightscout.androidaps.events.Event
|
||||
|
||||
class EventDanaRNewStatus : Event()
|
|
@ -22,6 +22,7 @@ import info.nightscout.androidaps.events.EventProfileNeedsUpdate;
|
|||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
|
@ -198,7 +199,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService {
|
|||
danaRPump.lastSettingsRead = now;
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventDanaRNewStatus());
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
NSUpload.uploadDeviceStatus();
|
||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
|
|
|
@ -22,6 +22,7 @@ import info.nightscout.androidaps.events.EventProfileNeedsUpdate;
|
|||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
|
@ -201,7 +202,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
|
|||
danaRPump.lastSettingsRead = now;
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventDanaRNewStatus());
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
NSUpload.uploadDeviceStatus();
|
||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
|
|
|
@ -5,9 +5,9 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
|
@ -39,7 +39,6 @@ import info.nightscout.androidaps.interfaces.PumpDescription;
|
|||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.DetailedBolusInfoStorage;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||
|
@ -127,8 +126,8 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
|||
}
|
||||
|
||||
@Override
|
||||
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity activity) {
|
||||
confirmPumpPluginActivation(pluginSwitcher, activity);
|
||||
public void switchAllowed(boolean newState, FragmentActivity activity, PluginType type) {
|
||||
confirmPumpPluginActivation(newState, activity, type);
|
||||
}
|
||||
|
||||
private ServiceConnection mConnection = new ServiceConnection() {
|
||||
|
|
|
@ -7,7 +7,6 @@ import android.bluetooth.le.ScanCallback;
|
|||
import android.bluetooth.le.ScanResult;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
|
@ -20,10 +19,11 @@ import java.util.regex.Pattern;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSDeviceChange;
|
||||
import info.nightscout.androidaps.utils.SP;
|
||||
|
||||
public class BLEScanActivity extends AppCompatActivity {
|
||||
public class BLEScanActivity extends NoSplashAppCompatActivity {
|
||||
private ListView listView = null;
|
||||
private ListAdapter mListAdapter = null;
|
||||
private ArrayList<BluetoothDeviceItem> mDevices = new ArrayList<>();
|
||||
|
@ -33,7 +33,7 @@ public class BLEScanActivity extends AppCompatActivity {
|
|||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.danars_blescanner_activity);
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package info.nightscout.androidaps.plugins.pump.danaRS.activities;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class PairingHelperActivity extends AppCompatActivity {
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
|
||||
public class PairingHelperActivity extends NoSplashAppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
PairingProgressDialog bolusProgressDialog = new PairingProgressDialog();
|
||||
bolusProgressDialog.setHelperActivity(this);
|
||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.events.EventProfileNeedsUpdate;
|
|||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.BolusProgressDialog;
|
||||
|
@ -173,7 +174,7 @@ public class DanaRSService extends Service {
|
|||
|
||||
//deinitialize pump
|
||||
danaRPump.lastConnection = 0;
|
||||
MainApp.bus().post(new EventDanaRNewStatus());
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -23,6 +23,7 @@ import info.nightscout.androidaps.events.EventProfileNeedsUpdate;
|
|||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
|
@ -211,7 +212,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
//deinitialize pump
|
||||
danaRPump.lastConnection = 0;
|
||||
MainApp.bus().post(new EventDanaRNewStatus());
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
return;
|
||||
} else {
|
||||
|
@ -244,7 +245,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
|||
|
||||
loadEvents();
|
||||
|
||||
MainApp.bus().post(new EventDanaRNewStatus());
|
||||
RxBus.INSTANCE.send(new EventDanaRNewStatus());
|
||||
MainApp.bus().post(new EventInitializationChanged());
|
||||
NSUpload.uploadDeviceStatus();
|
||||
if (danaRPump.dailyTotalUnits > danaRPump.maxDailyTotalUnits * Constants.dailyLimitWarning) {
|
||||
|
|
|
@ -9,12 +9,7 @@ import android.os.IBinder;
|
|||
import android.os.Looper;
|
||||
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderFragment;
|
||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.*;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.*;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -48,8 +43,11 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
|||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||
import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
|
||||
|
@ -76,6 +74,13 @@ import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history
|
|||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history_events.StartOfTBREvent;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history_events.TotalDailyDoseEvent;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.history.history_events.TubeFilledEvent;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.ActiveBRProfileBlock;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.BRProfile1Block;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.BRProfileBlock;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.FactoryMinBolusAmountBlock;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.MaxBasalAmountBlock;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.MaxBolusAmountBlock;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.parameter_blocks.TBROverNotificationBlock;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.remote_control.CancelBolusMessage;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.remote_control.CancelTBRMessage;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.app_layer.remote_control.ChangeTBRMessage;
|
||||
|
@ -99,6 +104,19 @@ import info.nightscout.androidaps.plugins.pump.insight.connection_service.Insigh
|
|||
import info.nightscout.androidaps.plugins.pump.insight.database.InsightBolusID;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.database.InsightHistoryOffset;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.database.InsightPumpID;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.ActiveBasalRate;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.ActiveBolus;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.ActiveTBR;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.AlertType;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.BasalProfile;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.BasalProfileBlock;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.BatteryStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.BolusType;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.CartridgeStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.InsightState;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.OperatingMode;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.PumpTime;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.TotalDailyDose;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.exceptions.InsightException;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.AppLayerErrorException;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.exceptions.app_layer_errors.NoActiveTBRToCanceLException;
|
||||
|
@ -232,8 +250,8 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
|||
}
|
||||
|
||||
@Override
|
||||
public void switchAllowed(ConfigBuilderFragment.PluginViewHolder.PluginSwitcher pluginSwitcher, FragmentActivity activity) {
|
||||
confirmPumpPluginActivation(pluginSwitcher, activity);
|
||||
public void switchAllowed(boolean newState, FragmentActivity activity, PluginType type) {
|
||||
confirmPumpPluginActivation(newState, activity, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,8 +5,6 @@ import android.content.Intent;
|
|||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
@ -14,14 +12,17 @@ import android.widget.Button;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.InsightAlertService;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.Alert;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.AlertStatus;
|
||||
|
||||
public class InsightAlertActivity extends AppCompatActivity {
|
||||
public class InsightAlertActivity extends NoSplashAppCompatActivity {
|
||||
|
||||
private Alert alert;
|
||||
private InsightAlertService alertService;
|
||||
|
@ -50,7 +51,7 @@ public class InsightAlertActivity extends AppCompatActivity {
|
|||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_insight_alert);
|
||||
|
||||
|
|
|
@ -10,11 +10,6 @@ import android.content.IntentFilter;
|
|||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -22,15 +17,21 @@ import android.widget.Button;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.connection_service.InsightConnectionService;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.descriptors.InsightState;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.utils.ExceptionTranslator;
|
||||
|
||||
public class InsightPairingActivity extends AppCompatActivity implements InsightConnectionService.StateCallback, View.OnClickListener, InsightConnectionService.ExceptionCallback {
|
||||
public class InsightPairingActivity extends NoSplashAppCompatActivity implements InsightConnectionService.StateCallback, View.OnClickListener, InsightConnectionService.ExceptionCallback {
|
||||
|
||||
private boolean scanning;
|
||||
private LinearLayout deviceSearchSection;
|
||||
|
@ -66,7 +67,7 @@ public class InsightPairingActivity extends AppCompatActivity implements Insight
|
|||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_insight_pairing);
|
||||
|
||||
|
|
|
@ -5,15 +5,16 @@ import android.content.Intent;
|
|||
import android.content.ServiceConnection;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||
import info.nightscout.androidaps.plugins.pump.insight.connection_service.InsightConnectionService;
|
||||
|
||||
public class InsightPairingInformationActivity extends AppCompatActivity {
|
||||
public class InsightPairingInformationActivity extends NoSplashAppCompatActivity {
|
||||
|
||||
private InsightConnectionService connectionService;
|
||||
|
||||
|
@ -57,7 +58,7 @@ public class InsightPairingInformationActivity extends AppCompatActivity {
|
|||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_insight_pairing_information);
|
||||
serialNumber = findViewById(R.id.serial_number);
|
||||
|
|
|
@ -1,521 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Spanned;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.crashlytics.android.Crashlytics;
|
||||
import com.joanzapata.iconify.widget.IconTextView;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.OnClick;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.MedtronicHistoryActivity;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicDeviceStatusChange;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpConfigurationChanged;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpValuesChanged;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
import info.nightscout.androidaps.utils.SetWarnColor;
|
||||
|
||||
public class MedtronicFragment extends SubscriberFragment {
|
||||
|
||||
private static Logger LOG = LoggerFactory.getLogger(L.PUMP);
|
||||
|
||||
@BindView(R.id.medtronic_lastconnection)
|
||||
TextView lastConnectionView;
|
||||
@BindView(R.id.medtronic_lastbolus)
|
||||
TextView lastBolusView;
|
||||
@BindView(R.id.medtronic_basabasalrate)
|
||||
TextView basaBasalRateView;
|
||||
|
||||
// @BindView(R.id.medtronic_btconnection)
|
||||
// TextView btConnectionView;
|
||||
@BindView(R.id.medtronic_tempbasal)
|
||||
TextView tempBasalView;
|
||||
@BindView(R.id.medtronic_pumpstate_battery)
|
||||
TextView batteryView;
|
||||
@BindView(R.id.medtronic_rl_status)
|
||||
IconTextView rileyLinkStatus;
|
||||
@BindView(R.id.medtronic_reservoir)
|
||||
TextView reservoirView;
|
||||
@BindView(R.id.medtronic_errors)
|
||||
TextView errorsView;
|
||||
@BindView(R.id.medtronic_queue)
|
||||
TextView queueView;
|
||||
@BindView(R.id.overview_pumpstatuslayout)
|
||||
LinearLayout pumpStatusLayout;
|
||||
@BindView(R.id.overview_pump_medtronic)
|
||||
TextView overviewPumpMedtronicView;
|
||||
@BindView(R.id.medtronic_pump_status)
|
||||
IconTextView pumpStatusIconView;
|
||||
@BindView(R.id.medtronic_refresh)
|
||||
Button refreshButton;
|
||||
private Handler loopHandler = new Handler();
|
||||
private static Activity localActivity;
|
||||
|
||||
static Button refreshButtonStatic;
|
||||
|
||||
private Runnable refreshLoop = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
updateGUI();
|
||||
loopHandler.postDelayed(refreshLoop, 60 * 1000L);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public MedtronicFragment() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
loopHandler.postDelayed(refreshLoop, 60 * 1000L);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
loopHandler.removeCallbacks(refreshLoop);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
try {
|
||||
View view = inflater.inflate(R.layout.medtronic_fragment, container, false);
|
||||
unbinder = ButterKnife.bind(this, view);
|
||||
|
||||
overviewPumpMedtronicView.setBackgroundColor(MainApp.sResources.getColor(R.color.colorInitializingBorder));
|
||||
|
||||
rileyLinkStatus.setText(getTranslation(RileyLinkServiceState.NotStarted.getResourceId(getTargetDevice())));
|
||||
rileyLinkStatus.setTextSize(14);
|
||||
|
||||
pumpStatusIconView.setTextColor(Color.WHITE);
|
||||
pumpStatusIconView.setTextSize(14);
|
||||
pumpStatusIconView.setText("{fa-bed}");
|
||||
|
||||
refreshButtonStatic = refreshButton;
|
||||
|
||||
return view;
|
||||
} catch (Exception e) {
|
||||
Crashlytics.logException(e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@OnClick(R.id.medtronic_history)
|
||||
void onHistoryClick() {
|
||||
if (MedtronicUtil.getPumpStatus().verifyConfiguration()) {
|
||||
startActivity(new Intent(getContext(), MedtronicHistoryActivity.class));
|
||||
} else {
|
||||
MedtronicUtil.displayNotConfiguredDialog(getContext());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@OnClick(R.id.medtronic_refresh)
|
||||
void onRefreshClick() {
|
||||
|
||||
if (!MedtronicUtil.getPumpStatus().verifyConfiguration()) {
|
||||
MedtronicUtil.displayNotConfiguredDialog(getContext());
|
||||
return;
|
||||
}
|
||||
|
||||
if (refreshButtonStatic != null)
|
||||
refreshButtonStatic.setEnabled(false);
|
||||
|
||||
MedtronicPumpPlugin.getPlugin().resetStatusState();
|
||||
|
||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().readStatus("Clicked refresh", new Callback() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Activity activity = getActivity();
|
||||
|
||||
if (activity != null) {
|
||||
activity.runOnUiThread(() -> {
|
||||
if (refreshButtonStatic != null)
|
||||
refreshButtonStatic.setEnabled(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@OnClick(R.id.medtronic_stats)
|
||||
void onStatsClick() {
|
||||
if (MedtronicUtil.getPumpStatus().verifyConfiguration()) {
|
||||
startActivity(new Intent(getContext(), RileyLinkStatusActivity.class));
|
||||
} else {
|
||||
MedtronicUtil.displayNotConfiguredDialog(getContext());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventPumpStatusChanged c) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
|
||||
public static void refreshButtonEnabled(boolean enable) {
|
||||
if (localActivity != null) {
|
||||
localActivity.runOnUiThread(() -> {
|
||||
if (refreshButtonStatic != null) {
|
||||
refreshButtonStatic.setEnabled(enable);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static Activity getCustomActivity() {
|
||||
return localActivity;
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventMedtronicDeviceStatusChange eventStatusChange) {
|
||||
if (isLogEnabled())
|
||||
LOG.info("onStatusEvent(EventMedtronicDeviceStatusChange): {}", eventStatusChange);
|
||||
Activity activity = getActivity();
|
||||
|
||||
if (activity != null) {
|
||||
localActivity = activity;
|
||||
activity.runOnUiThread(() -> {
|
||||
MedtronicPumpStatus pumpStatus = MedtronicUtil.getPumpStatus();
|
||||
setDeviceStatus(pumpStatus);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private synchronized void setDeviceStatus(MedtronicPumpStatus pumpStatus) {
|
||||
|
||||
pumpStatus.rileyLinkServiceState = (RileyLinkServiceState) checkStatusSet(pumpStatus.rileyLinkServiceState,
|
||||
RileyLinkUtil.getServiceState());
|
||||
|
||||
if (pumpStatus.rileyLinkServiceState != null && rileyLinkStatus != null) {
|
||||
|
||||
int resourceId = pumpStatus.rileyLinkServiceState.getResourceId(getTargetDevice());
|
||||
rileyLinkStatus.setTextColor(Color.WHITE);
|
||||
rileyLinkStatus.setTextSize(14);
|
||||
|
||||
if (pumpStatus.rileyLinkServiceState == RileyLinkServiceState.NotStarted) {
|
||||
rileyLinkStatus.setText(getTranslation(resourceId));
|
||||
rileyLinkStatus.setTextSize(14);
|
||||
} else if (pumpStatus.rileyLinkServiceState.isConnecting()) {
|
||||
rileyLinkStatus.setText("{fa-bluetooth-b spin} " + getTranslation(resourceId));
|
||||
} else if (pumpStatus.rileyLinkServiceState.isError()) {
|
||||
|
||||
RileyLinkError rileyLinkError = RileyLinkUtil.getError();
|
||||
|
||||
if (rileyLinkError == null)
|
||||
rileyLinkStatus.setText("{fa-bluetooth-b} " + getTranslation(resourceId));
|
||||
else
|
||||
rileyLinkStatus.setText("{fa-bluetooth-b} "
|
||||
+ getTranslation(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump)));
|
||||
|
||||
rileyLinkStatus.setTextColor(Color.RED);
|
||||
} else {
|
||||
rileyLinkStatus.setText("{fa-bluetooth-b} " + getTranslation(resourceId));
|
||||
}
|
||||
}
|
||||
|
||||
pumpStatus.rileyLinkError = (RileyLinkError) checkStatusSet(pumpStatus.rileyLinkError, RileyLinkUtil.getError());
|
||||
|
||||
if (errorsView != null) {
|
||||
if (pumpStatus.rileyLinkError != null) {
|
||||
int resourceId = pumpStatus.rileyLinkError.getResourceId(getTargetDevice());
|
||||
errorsView.setText(getTranslation(resourceId));
|
||||
} else
|
||||
errorsView.setText("-");
|
||||
}
|
||||
|
||||
pumpStatus.pumpDeviceState = (PumpDeviceState) checkStatusSet(pumpStatus.pumpDeviceState,
|
||||
MedtronicUtil.getPumpDeviceState());
|
||||
|
||||
if (pumpStatusIconView != null) {
|
||||
|
||||
if (pumpStatus.pumpDeviceState != null) {
|
||||
|
||||
switch (pumpStatus.pumpDeviceState) {
|
||||
case Sleeping:
|
||||
pumpStatusIconView.setText("{fa-bed} "); // + pumpStatus.pumpDeviceState.name());
|
||||
break;
|
||||
|
||||
case NeverContacted:
|
||||
case WakingUp:
|
||||
case PumpUnreachable:
|
||||
case ErrorWhenCommunicating:
|
||||
case TimeoutWhenCommunicating:
|
||||
case InvalidConfiguration:
|
||||
pumpStatusIconView.setText(" " + getTranslation(pumpStatus.pumpDeviceState.getResourceId()));
|
||||
break;
|
||||
|
||||
case Active: {
|
||||
MedtronicCommandType cmd = MedtronicUtil.getCurrentCommand();
|
||||
|
||||
LOG.debug("Command: " + cmd);
|
||||
|
||||
if (cmd == null)
|
||||
pumpStatusIconView.setText(" " + MainApp.gs(pumpStatus.pumpDeviceState.getResourceId()));
|
||||
else {
|
||||
Integer resourceId = cmd.getResourceId();
|
||||
|
||||
if (cmd == MedtronicCommandType.GetHistoryData) {
|
||||
|
||||
if (MedtronicUtil.frameNumber == null) {
|
||||
pumpStatusIconView.setText(MainApp.gs(
|
||||
R.string.medtronic_cmd_desc_get_history_request, MedtronicUtil.pageNumber));
|
||||
} else {
|
||||
pumpStatusIconView.setText(MainApp.gs(resourceId, MedtronicUtil.pageNumber,
|
||||
MedtronicUtil.frameNumber));
|
||||
}
|
||||
|
||||
} else {
|
||||
if (resourceId == null) {
|
||||
pumpStatusIconView.setText(" " + cmd.getCommandDescription());
|
||||
} else {
|
||||
pumpStatusIconView.setText(" " + getTranslation(resourceId));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG.warn("Unknown pump state: " + pumpStatus.pumpDeviceState);
|
||||
}
|
||||
} else {
|
||||
pumpStatusIconView.setText("{fa-bed} ");
|
||||
}
|
||||
}
|
||||
|
||||
if (queueView != null) {
|
||||
Spanned status = ConfigBuilderPlugin.getPlugin().getCommandQueue().spannedStatus();
|
||||
if (status.toString().equals("")) {
|
||||
queueView.setVisibility(View.GONE);
|
||||
} else {
|
||||
queueView.setVisibility(View.VISIBLE);
|
||||
queueView.setText(status);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Object checkStatusSet(Object object1, Object object2) {
|
||||
if (object1 == null) {
|
||||
return object2;
|
||||
} else {
|
||||
if (!object1.equals(object2)) {
|
||||
return object2;
|
||||
} else
|
||||
return object1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public RileyLinkTargetDevice getTargetDevice() {
|
||||
return RileyLinkTargetDevice.MedtronicPump;
|
||||
}
|
||||
|
||||
|
||||
public String getTranslation(int resourceId) {
|
||||
return MainApp.gs(resourceId);
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventMedtronicPumpValuesChanged s) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventMedtronicPumpConfigurationChanged s) {
|
||||
if (isLogEnabled())
|
||||
LOG.debug("EventMedtronicPumpConfigurationChanged triggered");
|
||||
MedtronicPumpStatus pumpStatus = MedtronicUtil.getPumpStatus();
|
||||
pumpStatus.verifyConfiguration();
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventTempBasalChange s) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventExtendedBolusChange s) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventQueueChanged s) {
|
||||
updateGUI();
|
||||
}
|
||||
|
||||
|
||||
// GUI functions
|
||||
@Override
|
||||
protected void updateGUI() {
|
||||
Activity activity = getActivity();
|
||||
if (activity != null && basaBasalRateView != null)
|
||||
activity.runOnUiThread(() -> {
|
||||
|
||||
if (lastConnectionView == null) // ui not yet initialized
|
||||
return;
|
||||
|
||||
localActivity = activity;
|
||||
MedtronicPumpPlugin plugin = (MedtronicPumpPlugin) MedtronicPumpPlugin.getPlugin();
|
||||
MedtronicPumpStatus pumpStatus = MedtronicUtil.getPumpStatus();
|
||||
|
||||
setDeviceStatus(pumpStatus);
|
||||
|
||||
// last connection
|
||||
String minAgo = DateUtil.minAgo(pumpStatus.lastConnection);
|
||||
long min = (System.currentTimeMillis() - pumpStatus.lastConnection) / 1000 / 60;
|
||||
if (pumpStatus.lastConnection + 60 * 1000 > System.currentTimeMillis()) {
|
||||
lastConnectionView.setText(R.string.combo_pump_connected_now);
|
||||
lastConnectionView.setTextColor(Color.WHITE);
|
||||
} else if (pumpStatus.lastConnection + 30 * 60 * 1000 < System.currentTimeMillis()) {
|
||||
|
||||
if (min < 60) {
|
||||
lastConnectionView.setText(MainApp.gs(R.string.minago, min));
|
||||
} else if (min < 1440) {
|
||||
int h = (int) (min / 60);
|
||||
|
||||
lastConnectionView.setText(MainApp.gq(R.plurals.objective_hours, h, h) + " "
|
||||
+ MainApp.gs(R.string.ago));
|
||||
} else {
|
||||
|
||||
int h = (int) (min / 60);
|
||||
int d = h / 24;
|
||||
// h = h - (d * 24);
|
||||
|
||||
lastConnectionView.setText(MainApp.gq(R.plurals.objective_days, d, d) + " "
|
||||
+ MainApp.gs(R.string.ago));
|
||||
}
|
||||
lastConnectionView.setTextColor(Color.RED);
|
||||
} else {
|
||||
lastConnectionView.setText(minAgo);
|
||||
lastConnectionView.setTextColor(Color.WHITE);
|
||||
}
|
||||
|
||||
// last bolus
|
||||
Double bolus = pumpStatus.lastBolusAmount;
|
||||
Date bolusTime = pumpStatus.lastBolusTime;
|
||||
if (bolus != null && bolusTime != null) {
|
||||
long agoMsc = System.currentTimeMillis() - pumpStatus.lastBolusTime.getTime();
|
||||
double bolusMinAgo = agoMsc / 60d / 1000d;
|
||||
String unit = MainApp.gs(R.string.insulin_unit_shortname);
|
||||
String ago;
|
||||
if ((agoMsc < 60 * 1000)) {
|
||||
ago = MainApp.gs(R.string.combo_pump_connected_now);
|
||||
} else if (bolusMinAgo < 60) {
|
||||
ago = DateUtil.minAgo(pumpStatus.lastBolusTime.getTime());
|
||||
} else {
|
||||
ago = DateUtil.hourAgo(pumpStatus.lastBolusTime.getTime());
|
||||
}
|
||||
lastBolusView.setText(MainApp.gs(R.string.combo_last_bolus, bolus, unit, ago));
|
||||
} else {
|
||||
lastBolusView.setText("");
|
||||
}
|
||||
|
||||
// base basal rate
|
||||
basaBasalRateView.setText("(" + (pumpStatus.activeProfileName) + ") "
|
||||
+ MainApp.gs(R.string.pump_basebasalrate, plugin.getBaseBasalRate()));
|
||||
|
||||
if (ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress()) {
|
||||
tempBasalView.setText(TreatmentsPlugin.getPlugin()
|
||||
.getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||
} else {
|
||||
tempBasalView.setText("");
|
||||
}
|
||||
} else {
|
||||
// v2 plugin
|
||||
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||
tempBasalView.setText(TreatmentsPlugin.getPlugin()
|
||||
.getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||
} else {
|
||||
tempBasalView.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
// battery
|
||||
if (MedtronicUtil.getBatteryType() == BatteryType.None || pumpStatus.batteryVoltage == null) {
|
||||
batteryView.setText("{fa-battery-" + (pumpStatus.batteryRemaining / 25) + "} ");
|
||||
} else {
|
||||
batteryView.setText("{fa-battery-" + (pumpStatus.batteryRemaining / 25) + "} " + pumpStatus.batteryRemaining + "%" + String.format(" (%.2f V)", pumpStatus.batteryVoltage));
|
||||
}
|
||||
SetWarnColor.setColorInverse(batteryView, pumpStatus.batteryRemaining, 25d, 10d);
|
||||
|
||||
// reservoir
|
||||
reservoirView.setText(DecimalFormatter.to0Decimal(pumpStatus.reservoirRemainingUnits) + " / "
|
||||
+ pumpStatus.reservoirFullUnits + " " + MainApp.gs(R.string.insulin_unit_shortname));
|
||||
SetWarnColor.setColorInverse(reservoirView, pumpStatus.reservoirRemainingUnits, 50d, 20d);
|
||||
|
||||
errorsView.setText(pumpStatus.getErrorInfo());
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private boolean isLogEnabled() {
|
||||
return L.isEnabled(L.PUMP);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,328 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.squareup.otto.Subscribe
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.events.EventExtendedBolusChange
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged
|
||||
import info.nightscout.androidaps.events.EventTempBasalChange
|
||||
import info.nightscout.androidaps.logging.L
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.dialog.RileyLinkStatusActivity
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicCommandType
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.dialog.MedtronicHistoryActivity
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicDeviceStatusChange
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpConfigurationChanged
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpValuesChanged
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventRefreshButtonState
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.queue.Callback
|
||||
import info.nightscout.androidaps.queue.events.EventQueueChanged
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import info.nightscout.androidaps.utils.SetWarnColor
|
||||
import info.nightscout.androidaps.utils.T
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotlinx.android.synthetic.main.medtronic_fragment.*
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
|
||||
class MedtronicFragment : Fragment() {
|
||||
private val log = LoggerFactory.getLogger(L.PUMP)
|
||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||
|
||||
operator fun CompositeDisposable.plusAssign(disposable: Disposable) {
|
||||
add(disposable)
|
||||
}
|
||||
|
||||
private val loopHandler = Handler()
|
||||
private lateinit var refreshLoop: Runnable
|
||||
|
||||
init {
|
||||
refreshLoop = Runnable {
|
||||
activity?.runOnUiThread { updateGUI() }
|
||||
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
return inflater.inflate(R.layout.medtronic_fragment, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
medtronic_pumpstatus.setBackgroundColor(MainApp.gc(R.color.colorInitializingBorder))
|
||||
|
||||
medtronic_rl_status.text = MainApp.gs(RileyLinkServiceState.NotStarted.getResourceId(RileyLinkTargetDevice.MedtronicPump))
|
||||
|
||||
medtronic_pump_status.setTextColor(Color.WHITE)
|
||||
medtronic_pump_status.text = "{fa-bed}"
|
||||
|
||||
medtronic_history.setOnClickListener {
|
||||
if (MedtronicUtil.getPumpStatus().verifyConfiguration()) {
|
||||
startActivity(Intent(context, MedtronicHistoryActivity::class.java))
|
||||
} else {
|
||||
MedtronicUtil.displayNotConfiguredDialog(context)
|
||||
}
|
||||
}
|
||||
|
||||
medtronic_refresh.setOnClickListener {
|
||||
if (!MedtronicUtil.getPumpStatus().verifyConfiguration()) {
|
||||
MedtronicUtil.displayNotConfiguredDialog(context)
|
||||
} else {
|
||||
medtronic_refresh.isEnabled = false
|
||||
MedtronicPumpPlugin.getPlugin().resetStatusState()
|
||||
ConfigBuilderPlugin.getPlugin().commandQueue.readStatus("Clicked refresh", object : Callback() {
|
||||
override fun run() {
|
||||
activity?.runOnUiThread { medtronic_refresh.isEnabled = true }
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
medtronic_stats.setOnClickListener {
|
||||
if (MedtronicUtil.getPumpStatus().verifyConfiguration()) {
|
||||
startActivity(Intent(context, RileyLinkStatusActivity::class.java))
|
||||
} else {
|
||||
MedtronicUtil.displayNotConfiguredDialog(context)
|
||||
}
|
||||
}
|
||||
|
||||
updateGUI()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
MainApp.bus().register(this)
|
||||
loopHandler.postDelayed(refreshLoop, T.mins(1).msecs())
|
||||
disposable += RxBus
|
||||
.toObservable(EventRefreshButtonState::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ medtronic_refresh.isEnabled = it.newState }, { FabricPrivacy.logException(it) })
|
||||
disposable += RxBus
|
||||
.toObservable(EventMedtronicDeviceStatusChange::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.info("onStatusEvent(EventMedtronicDeviceStatusChange): {}", it)
|
||||
setDeviceStatus()
|
||||
}, { FabricPrivacy.logException(it) })
|
||||
disposable += RxBus
|
||||
.toObservable(EventMedtronicPumpValuesChanged::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({ updateGUI() }, { FabricPrivacy.logException(it) })
|
||||
disposable += RxBus
|
||||
.toObservable(EventMedtronicPumpConfigurationChanged::class.java)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
if (L.isEnabled(L.PUMP))
|
||||
log.debug("EventMedtronicPumpConfigurationChanged triggered")
|
||||
MedtronicUtil.getPumpStatus().verifyConfiguration()
|
||||
updateGUI()
|
||||
}, { FabricPrivacy.logException(it) })
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
disposable.clear()
|
||||
MainApp.bus().unregister(this)
|
||||
loopHandler.removeCallbacks(refreshLoop)
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onStatusEvent(c: EventPumpStatusChanged) {
|
||||
activity?.runOnUiThread { updateGUI() }
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onStatusEvent(s: EventTempBasalChange) {
|
||||
activity?.runOnUiThread { updateGUI() }
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onStatusEvent(s: EventExtendedBolusChange) {
|
||||
activity?.runOnUiThread { updateGUI() }
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
fun onStatusEvent(s: EventQueueChanged) {
|
||||
activity?.runOnUiThread { updateGUI() }
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun setDeviceStatus() {
|
||||
val pumpStatus: MedtronicPumpStatus = MedtronicUtil.getPumpStatus()
|
||||
pumpStatus.rileyLinkServiceState = checkStatusSet(pumpStatus.rileyLinkServiceState,
|
||||
RileyLinkUtil.getServiceState()) as RileyLinkServiceState?
|
||||
|
||||
val resourceId = pumpStatus.rileyLinkServiceState.getResourceId(RileyLinkTargetDevice.MedtronicPump)
|
||||
val rileyLinkError = RileyLinkUtil.getError()
|
||||
medtronic_rl_status.text =
|
||||
when {
|
||||
pumpStatus.rileyLinkServiceState == RileyLinkServiceState.NotStarted -> MainApp.gs(resourceId)
|
||||
pumpStatus.rileyLinkServiceState.isConnecting -> "{fa-bluetooth-b spin} " + MainApp.gs(resourceId)
|
||||
pumpStatus.rileyLinkServiceState.isError && rileyLinkError == null -> "{fa-bluetooth-b} " + MainApp.gs(resourceId)
|
||||
pumpStatus.rileyLinkServiceState.isError && rileyLinkError != null -> "{fa-bluetooth-b} " + MainApp.gs(rileyLinkError.getResourceId(RileyLinkTargetDevice.MedtronicPump))
|
||||
else -> "{fa-bluetooth-b} " + MainApp.gs(resourceId)
|
||||
}
|
||||
medtronic_rl_status.setTextColor(if (rileyLinkError != null) Color.RED else Color.WHITE)
|
||||
|
||||
pumpStatus.rileyLinkError = checkStatusSet(pumpStatus.rileyLinkError, RileyLinkUtil.getError()) as RileyLinkError?
|
||||
|
||||
medtronic_errors.text =
|
||||
pumpStatus.rileyLinkError?.let {
|
||||
MainApp.gs(it.getResourceId(RileyLinkTargetDevice.MedtronicPump))
|
||||
} ?: "-"
|
||||
|
||||
pumpStatus.pumpDeviceState = checkStatusSet(pumpStatus.pumpDeviceState,
|
||||
MedtronicUtil.getPumpDeviceState()) as PumpDeviceState?
|
||||
|
||||
when (pumpStatus.pumpDeviceState) {
|
||||
null,
|
||||
PumpDeviceState.Sleeping -> medtronic_pump_status.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name());
|
||||
PumpDeviceState.NeverContacted,
|
||||
PumpDeviceState.WakingUp,
|
||||
PumpDeviceState.PumpUnreachable,
|
||||
PumpDeviceState.ErrorWhenCommunicating,
|
||||
PumpDeviceState.TimeoutWhenCommunicating,
|
||||
PumpDeviceState.InvalidConfiguration -> medtronic_pump_status.text = " " + MainApp.gs(pumpStatus.pumpDeviceState.resourceId)
|
||||
PumpDeviceState.Active -> {
|
||||
val cmd = MedtronicUtil.getCurrentCommand()
|
||||
if (cmd == null)
|
||||
medtronic_pump_status.text = " " + MainApp.gs(pumpStatus.pumpDeviceState.resourceId)
|
||||
else {
|
||||
log.debug("Command: " + cmd)
|
||||
val cmdResourceId = cmd.resourceId
|
||||
if (cmd == MedtronicCommandType.GetHistoryData) {
|
||||
medtronic_pump_status.text = MedtronicUtil.frameNumber?.let {
|
||||
MainApp.gs(cmdResourceId, MedtronicUtil.pageNumber, MedtronicUtil.frameNumber)
|
||||
}
|
||||
?: MainApp.gs(R.string.medtronic_cmd_desc_get_history_request, MedtronicUtil.pageNumber)
|
||||
} else {
|
||||
medtronic_pump_status.text = " " + (cmdResourceId?.let { MainApp.gs(it) }
|
||||
?: cmd.getCommandDescription())
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> log.warn("Unknown pump state: " + pumpStatus.pumpDeviceState)
|
||||
}
|
||||
|
||||
val status = ConfigBuilderPlugin.getPlugin().commandQueue.spannedStatus()
|
||||
if (status.toString() == "") {
|
||||
medtronic_queue.visibility = View.GONE
|
||||
} else {
|
||||
medtronic_queue.visibility = View.VISIBLE
|
||||
medtronic_queue.text = status
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun checkStatusSet(object1: Any?, object2: Any?): Any? {
|
||||
return if (object1 == null) {
|
||||
object2
|
||||
} else {
|
||||
if (object1 != object2) {
|
||||
object2
|
||||
} else
|
||||
object1
|
||||
}
|
||||
}
|
||||
|
||||
// GUI functions
|
||||
fun updateGUI() {
|
||||
val plugin = MedtronicPumpPlugin.getPlugin()
|
||||
val pumpStatus = MedtronicUtil.getPumpStatus()
|
||||
|
||||
setDeviceStatus()
|
||||
|
||||
// last connection
|
||||
if (pumpStatus.lastConnection != 0L) {
|
||||
val minAgo = DateUtil.minAgo(pumpStatus.lastConnection)
|
||||
val min = (System.currentTimeMillis() - pumpStatus.lastConnection) / 1000 / 60
|
||||
if (pumpStatus.lastConnection + 60 * 1000 > System.currentTimeMillis()) {
|
||||
medtronic_lastconnection.setText(R.string.combo_pump_connected_now)
|
||||
medtronic_lastconnection.setTextColor(Color.WHITE)
|
||||
} else if (pumpStatus.lastConnection + 30 * 60 * 1000 < System.currentTimeMillis()) {
|
||||
|
||||
if (min < 60) {
|
||||
medtronic_lastconnection.text = MainApp.gs(R.string.minago, min)
|
||||
} else if (min < 1440) {
|
||||
val h = (min / 60).toInt()
|
||||
medtronic_lastconnection.text = (MainApp.gq(R.plurals.objective_hours, h, h) + " "
|
||||
+ MainApp.gs(R.string.ago))
|
||||
} else {
|
||||
val h = (min / 60).toInt()
|
||||
val d = h / 24
|
||||
// h = h - (d * 24);
|
||||
medtronic_lastconnection.text = (MainApp.gq(R.plurals.objective_days, d, d) + " "
|
||||
+ MainApp.gs(R.string.ago))
|
||||
}
|
||||
medtronic_lastconnection.setTextColor(Color.RED)
|
||||
} else {
|
||||
medtronic_lastconnection.text = minAgo
|
||||
medtronic_lastconnection.setTextColor(Color.WHITE)
|
||||
}
|
||||
}
|
||||
|
||||
// last bolus
|
||||
val bolus = pumpStatus.lastBolusAmount
|
||||
val bolusTime = pumpStatus.lastBolusTime
|
||||
if (bolus != null && bolusTime != null) {
|
||||
val agoMsc = System.currentTimeMillis() - pumpStatus.lastBolusTime.time
|
||||
val bolusMinAgo = agoMsc.toDouble() / 60.0 / 1000.0
|
||||
val unit = MainApp.gs(R.string.insulin_unit_shortname)
|
||||
val ago: String
|
||||
if (agoMsc < 60 * 1000) {
|
||||
ago = MainApp.gs(R.string.combo_pump_connected_now)
|
||||
} else if (bolusMinAgo < 60) {
|
||||
ago = DateUtil.minAgo(pumpStatus.lastBolusTime.time)
|
||||
} else {
|
||||
ago = DateUtil.hourAgo(pumpStatus.lastBolusTime.time)
|
||||
}
|
||||
medtronic_lastbolus.text = MainApp.gs(R.string.combo_last_bolus, bolus, unit, ago)
|
||||
} else {
|
||||
medtronic_lastbolus.text = ""
|
||||
}
|
||||
|
||||
// base basal rate
|
||||
medtronic_basabasalrate.text = ("(" + pumpStatus.activeProfileName + ") "
|
||||
+ MainApp.gs(R.string.pump_basebasalrate, plugin.baseBasalRate))
|
||||
|
||||
medtronic_tempbasal.text = TreatmentsPlugin.getPlugin()
|
||||
.getTempBasalFromHistory(System.currentTimeMillis())?.toStringFull() ?: ""
|
||||
|
||||
// battery
|
||||
if (MedtronicUtil.getBatteryType() == BatteryType.None || pumpStatus.batteryVoltage == null) {
|
||||
medtronic_pumpstate_battery.text = "{fa-battery-" + pumpStatus.batteryRemaining / 25 + "} "
|
||||
} else {
|
||||
medtronic_pumpstate_battery.text = "{fa-battery-" + pumpStatus.batteryRemaining / 25 + "} " + pumpStatus.batteryRemaining + "%" + String.format(" (%.2f V)", pumpStatus.batteryVoltage)
|
||||
}
|
||||
SetWarnColor.setColorInverse(medtronic_pumpstate_battery, pumpStatus.batteryRemaining.toDouble(), 25.0, 10.0)
|
||||
|
||||
// reservoir
|
||||
medtronic_reservoir.text = MainApp.gs(R.string.reservoirvalue, pumpStatus.reservoirRemainingUnits, pumpStatus.reservoirFullUnits)
|
||||
SetWarnColor.setColorInverse(medtronic_reservoir, pumpStatus.reservoirRemainingUnits, 50.0, 20.0)
|
||||
|
||||
medtronic_errors.text = pumpStatus.errorInfo
|
||||
}
|
||||
}
|
|
@ -39,6 +39,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
|||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||
|
@ -73,6 +74,7 @@ import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicStatusRef
|
|||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicUIResponseType;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.driver.MedtronicPumpStatus;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventMedtronicPumpValuesChanged;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.events.EventRefreshButtonState;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.service.RileyLinkMedtronicService;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicUtil;
|
||||
|
@ -370,7 +372,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
refreshAnyStatusThatNeedsToBeRefreshed();
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventMedtronicPumpValuesChanged());
|
||||
RxBus.INSTANCE.send(new EventMedtronicPumpValuesChanged());
|
||||
}
|
||||
|
||||
|
||||
|
@ -494,7 +496,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
|
||||
|
||||
private void setRefreshButtonEnabled(boolean enabled) {
|
||||
MedtronicFragment.refreshButtonEnabled(enabled);
|
||||
RxBus.INSTANCE.send(new EventRefreshButtonState(enabled));
|
||||
}
|
||||
|
||||
|
||||
|
@ -710,7 +712,7 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
|||
|
||||
|
||||
protected void triggerUIChange() {
|
||||
MainApp.bus().post(new EventMedtronicPumpValuesChanged());
|
||||
RxBus.INSTANCE.send(new EventMedtronicPumpValuesChanged());
|
||||
}
|
||||
|
||||
private BolusDeliveryType bolusDeliveryType = BolusDeliveryType.Idle;
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.MedtronicCommunicationManager;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.comm.history.pump.PumpHistoryEntry;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.data.dto.BasalProfile;
|
||||
|
@ -181,9 +182,8 @@ public class MedtronicUITask {
|
|||
}
|
||||
|
||||
|
||||
public void postProcess(MedtronicUIPostprocessor postprocessor) {
|
||||
void postProcess(MedtronicUIPostprocessor postprocessor) {
|
||||
|
||||
EventMedtronicDeviceStatusChange statusChange;
|
||||
if (isLogEnabled())
|
||||
LOG.debug("MedtronicUITask: @@@ In execute. {}", commandType);
|
||||
|
||||
|
@ -192,15 +192,13 @@ public class MedtronicUITask {
|
|||
}
|
||||
|
||||
if (responseType == MedtronicUIResponseType.Invalid) {
|
||||
statusChange = new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
|
||||
"Unsupported command in MedtronicUITask");
|
||||
MainApp.bus().post(statusChange);
|
||||
RxBus.INSTANCE.send(new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
|
||||
"Unsupported command in MedtronicUITask"));
|
||||
} else if (responseType == MedtronicUIResponseType.Error) {
|
||||
statusChange = new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
|
||||
errorDescription);
|
||||
MainApp.bus().post(statusChange);
|
||||
RxBus.INSTANCE.send(new EventMedtronicDeviceStatusChange(PumpDeviceState.ErrorWhenCommunicating,
|
||||
errorDescription));
|
||||
} else {
|
||||
MainApp.bus().post(new EventMedtronicPumpValuesChanged());
|
||||
RxBus.INSTANCE.send(new EventMedtronicPumpValuesChanged());
|
||||
MedtronicUtil.getPumpStatus().setLastCommunicationToNow();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,19 +18,12 @@ public enum PumpDeviceState {
|
|||
PumpUnreachable(R.string.medtronic_pump_status_pump_unreachable), //
|
||||
InvalidConfiguration(R.string.medtronic_pump_status_invalid_config);
|
||||
|
||||
Integer resourceId = null;
|
||||
|
||||
|
||||
PumpDeviceState() {
|
||||
|
||||
}
|
||||
|
||||
Integer resourceId;
|
||||
|
||||
PumpDeviceState(int resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
|
||||
public Integer getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
|
|
@ -184,9 +184,9 @@ public class MedtronicPumpStatus extends PumpStatus {
|
|||
this.medtronicDeviceType = medtronicDeviceTypeMap.get(pumpTypePart);
|
||||
|
||||
if (pumpTypePart.startsWith("7"))
|
||||
this.reservoirFullUnits = "300";
|
||||
this.reservoirFullUnits = 300;
|
||||
else
|
||||
this.reservoirFullUnits = "176";
|
||||
this.reservoirFullUnits = 176;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.events;
|
||||
|
||||
import info.nightscout.androidaps.events.Event;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError;
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState;
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState;
|
||||
|
||||
/**
|
||||
* Created by andy on 04.06.2018.
|
||||
*/
|
||||
public class EventMedtronicDeviceStatusChange extends Event {
|
||||
|
||||
public RileyLinkServiceState rileyLinkServiceState;
|
||||
public RileyLinkError rileyLinkError;
|
||||
|
||||
public PumpDeviceState pumpDeviceState;
|
||||
public String errorDescription;
|
||||
|
||||
|
||||
// public EventMedtronicDeviceStatusChange(RileyLinkServiceState rileyLinkServiceState, PumpDeviceState
|
||||
// pumpDeviceState) {
|
||||
// this.rileyLinkServiceState = rileyLinkServiceState;
|
||||
// this.pumpDeviceState = pumpDeviceState;
|
||||
// }
|
||||
|
||||
public EventMedtronicDeviceStatusChange(RileyLinkServiceState rileyLinkServiceState) {
|
||||
this(rileyLinkServiceState, null);
|
||||
}
|
||||
|
||||
|
||||
public EventMedtronicDeviceStatusChange(RileyLinkServiceState rileyLinkServiceState, RileyLinkError rileyLinkError) {
|
||||
this.rileyLinkServiceState = rileyLinkServiceState;
|
||||
this.rileyLinkError = rileyLinkError;
|
||||
}
|
||||
|
||||
|
||||
public EventMedtronicDeviceStatusChange(PumpDeviceState pumpDeviceState) {
|
||||
this.pumpDeviceState = pumpDeviceState;
|
||||
}
|
||||
|
||||
|
||||
public EventMedtronicDeviceStatusChange(PumpDeviceState pumpDeviceState, String errorDescription) {
|
||||
this.pumpDeviceState = pumpDeviceState;
|
||||
this.errorDescription = errorDescription;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EventMedtronicDeviceStatusChange [" + "rileyLinkServiceState=" + rileyLinkServiceState
|
||||
+ ", rileyLinkError=" + rileyLinkError + ", pumpDeviceState=" + pumpDeviceState + ']';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.events
|
||||
|
||||
import info.nightscout.androidaps.events.Event
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkError
|
||||
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkServiceState
|
||||
import info.nightscout.androidaps.plugins.pump.medtronic.defs.PumpDeviceState
|
||||
|
||||
class EventMedtronicDeviceStatusChange : Event {
|
||||
|
||||
private var rileyLinkServiceState: RileyLinkServiceState? = null
|
||||
private var rileyLinkError: RileyLinkError? = null
|
||||
|
||||
private var pumpDeviceState: PumpDeviceState? = null
|
||||
private var errorDescription: String? = null
|
||||
|
||||
|
||||
constructor(rileyLinkServiceState: RileyLinkServiceState?, rileyLinkError: RileyLinkError?) {
|
||||
this.rileyLinkServiceState = rileyLinkServiceState
|
||||
this.rileyLinkError = rileyLinkError
|
||||
}
|
||||
|
||||
constructor(pumpDeviceState: PumpDeviceState?) {
|
||||
this.pumpDeviceState = pumpDeviceState
|
||||
}
|
||||
|
||||
constructor(pumpDeviceState: PumpDeviceState?, errorDescription: String?) {
|
||||
this.pumpDeviceState = pumpDeviceState
|
||||
this.errorDescription = errorDescription
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.events;
|
||||
|
||||
import info.nightscout.androidaps.events.Event;
|
||||
|
||||
/**
|
||||
* Created by andy on 04.06.2018.
|
||||
*/
|
||||
public class EventMedtronicPumpConfigurationChanged extends Event {
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.events
|
||||
|
||||
import info.nightscout.androidaps.events.Event
|
||||
|
||||
class EventMedtronicPumpConfigurationChanged : Event()
|
|
@ -1,9 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.events;
|
||||
|
||||
import info.nightscout.androidaps.events.Event;
|
||||
|
||||
/**
|
||||
* Created by andy on 04.06.2018.
|
||||
*/
|
||||
public class EventMedtronicPumpValuesChanged extends Event {
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.events
|
||||
|
||||
import info.nightscout.androidaps.events.Event
|
||||
|
||||
class EventMedtronicPumpValuesChanged : Event()
|
|
@ -0,0 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.pump.medtronic.events
|
||||
|
||||
import info.nightscout.androidaps.events.Event
|
||||
|
||||
class EventRefreshButtonState (val newState : Boolean): Event()
|
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.PluginType;
|
||||
import info.nightscout.androidaps.logging.L;
|
||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||
|
@ -419,7 +420,7 @@ public class MedtronicUtil extends RileyLinkUtil {
|
|||
|
||||
historyRileyLink.add(new RLHistoryItem(pumpDeviceState, RileyLinkTargetDevice.MedtronicPump));
|
||||
|
||||
MainApp.bus().post(new EventMedtronicDeviceStatusChange(pumpDeviceState));
|
||||
RxBus.INSTANCE.send(new EventMedtronicDeviceStatusChange(pumpDeviceState));
|
||||
}
|
||||
|
||||
|
||||
|
@ -488,7 +489,7 @@ public class MedtronicUtil extends RileyLinkUtil {
|
|||
setCurrentCommand(currentCommand);
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventMedtronicDeviceStatusChange(pumpDeviceState));
|
||||
RxBus.INSTANCE.send(new EventMedtronicDeviceStatusChange(pumpDeviceState));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,135 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.treatments.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import butterknife.Unbinder;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||
import info.nightscout.androidaps.utils.DateUtil;
|
||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||
|
||||
/**
|
||||
* Created by adrian on 17/08/17.
|
||||
*/
|
||||
|
||||
public class ProfileViewerDialog extends DialogFragment {
|
||||
|
||||
private long time;
|
||||
|
||||
@BindView(R.id.profileview_noprofile)
|
||||
TextView noProfile;
|
||||
@BindView(R.id.profileview_invalidprofile)
|
||||
TextView invalidProfile;
|
||||
@BindView(R.id.profileview_units)
|
||||
TextView units;
|
||||
@BindView(R.id.profileview_dia)
|
||||
TextView dia;
|
||||
@BindView(R.id.profileview_activeprofile)
|
||||
TextView activeProfile;
|
||||
@BindView(R.id.profileview_ic)
|
||||
TextView ic;
|
||||
@BindView(R.id.profileview_isf)
|
||||
TextView isf;
|
||||
@BindView(R.id.profileview_basal)
|
||||
TextView basal;
|
||||
@BindView(R.id.profileview_target)
|
||||
TextView target;
|
||||
@BindView(R.id.profileview_datedelimiter)
|
||||
View dateDelimiter;
|
||||
@BindView(R.id.profileview_datelayout)
|
||||
LinearLayout dateLayout;
|
||||
@BindView(R.id.profileview_date)
|
||||
TextView dateTextView;
|
||||
@BindView(R.id.profileview_reload)
|
||||
Button refreshButton;
|
||||
@BindView(R.id.basal_graph)
|
||||
ProfileGraph basalGraph;
|
||||
|
||||
private Unbinder unbinder;
|
||||
|
||||
public static ProfileViewerDialog newInstance(long time) {
|
||||
ProfileViewerDialog dialog = new ProfileViewerDialog();
|
||||
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("time", time);
|
||||
dialog.setArguments(args);
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
time = getArguments().getLong("time");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if (unbinder != null)
|
||||
unbinder.unbind();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.profileviewer_fragment, container, false);
|
||||
|
||||
unbinder = ButterKnife.bind(this, view);
|
||||
|
||||
refreshButton.setVisibility(View.GONE);
|
||||
dateDelimiter.setVisibility(View.VISIBLE);
|
||||
dateLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
setContent();
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
ViewGroup.LayoutParams params = getDialog().getWindow().getAttributes();
|
||||
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
params.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
getDialog().getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
private void setContent() {
|
||||
Profile profile = null;
|
||||
ProfileSwitch profileSwitch = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(time);
|
||||
if (profileSwitch != null && profileSwitch.profileJson != null) {
|
||||
profile = profileSwitch.getProfileObject();
|
||||
}
|
||||
if (profile != null) {
|
||||
noProfile.setVisibility(View.GONE);
|
||||
units.setText(profile.getUnits());
|
||||
dia.setText(DecimalFormatter.to2Decimal(profile.getDia()) + " h");
|
||||
activeProfile.setText(profileSwitch.getCustomizedName());
|
||||
dateTextView.setText(DateUtil.dateAndTimeString(profileSwitch.date));
|
||||
ic.setText(profile.getIcList());
|
||||
isf.setText(profile.getIsfList());
|
||||
basal.setText(profile.getBasalList());
|
||||
target.setText(profile.getTargetList());
|
||||
basalGraph.show(profile);
|
||||
|
||||
if (profile.isValid("ProfileViewDialog"))
|
||||
invalidProfile.setVisibility(View.GONE);
|
||||
else
|
||||
invalidProfile.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
noProfile.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package info.nightscout.androidaps.plugins.treatments.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import info.nightscout.androidaps.MainApp
|
||||
import info.nightscout.androidaps.R
|
||||
import info.nightscout.androidaps.data.Profile
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface
|
||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||
import info.nightscout.androidaps.utils.DateUtil
|
||||
import kotlinx.android.synthetic.main.close.*
|
||||
import kotlinx.android.synthetic.main.profileviewer_fragment.*
|
||||
|
||||
class ProfileViewerDialog : DialogFragment() {
|
||||
private var time: Long = 0
|
||||
|
||||
enum class Mode(val i: Int) {
|
||||
RUNNING_PROFILE(1),
|
||||
PUMP_PROFILE(2)
|
||||
}
|
||||
|
||||
private var mode: Mode = Mode.RUNNING_PROFILE;
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
// load data from bundle
|
||||
(savedInstanceState ?: arguments)?.let { bundle ->
|
||||
time = bundle.getLong("time", 0)
|
||||
mode = Mode.values()[bundle.getInt("mode", Mode.RUNNING_PROFILE.ordinal)]
|
||||
}
|
||||
|
||||
return inflater.inflate(R.layout.profileviewer_fragment, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
close.setOnClickListener { dismiss() }
|
||||
profileview_reload.setOnClickListener {
|
||||
ConfigBuilderPlugin.getPlugin().commandQueue.readStatus("ProfileViewDialog", null)
|
||||
dismiss()
|
||||
}
|
||||
|
||||
val profile: Profile?
|
||||
val profileName: String?
|
||||
val date: String?
|
||||
when (mode) {
|
||||
Mode.RUNNING_PROFILE -> {
|
||||
profile = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(time)?.profileObject
|
||||
profileName = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(time)?.customizedName
|
||||
date = DateUtil.dateAndTimeString(TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(time)?.date
|
||||
?: 0)
|
||||
profileview_reload.visibility = View.GONE
|
||||
profileview_datelayout.visibility = View.VISIBLE
|
||||
}
|
||||
Mode.PUMP_PROFILE -> {
|
||||
profile = (ConfigBuilderPlugin.getPlugin().activePump as ProfileInterface?)?.profile?.defaultProfile
|
||||
profileName = (ConfigBuilderPlugin.getPlugin().activePump as ProfileInterface?)?.profileName
|
||||
date = ""
|
||||
profileview_reload.visibility = View.VISIBLE
|
||||
profileview_datelayout.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
profileview_noprofile.visibility = View.VISIBLE
|
||||
|
||||
profile?.let {
|
||||
profileview_units.text = it.units
|
||||
profileview_dia.text = MainApp.gs(R.string.format_hours, it.dia)
|
||||
profileview_activeprofile.text = profileName
|
||||
profileview_date.text = date
|
||||
profileview_ic.text = it.icList
|
||||
profileview_isf.text = it.isfList
|
||||
profileview_basal.text = it.basalList
|
||||
profileview_target.text = it.targetList
|
||||
basal_graph.show(it)
|
||||
|
||||
profileview_noprofile.visibility = View.GONE
|
||||
profileview_invalidprofile.visibility = if (it.isValid("ProfileViewDialog")) View.GONE else View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
dialog.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
|
||||
super.onResume()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(bundle: Bundle) {
|
||||
super.onSaveInstanceState(bundle)
|
||||
bundle.putLong("time", time)
|
||||
bundle.putInt("mode", mode.ordinal)
|
||||
}
|
||||
|
||||
}
|
|
@ -159,10 +159,14 @@ public class TreatmentsProfileSwitchFragment extends SubscriberFragment implemen
|
|||
break;
|
||||
case R.id.profileswitch_date:
|
||||
case R.id.profileswitch_name:
|
||||
long time = ((ProfileSwitch) v.getTag()).date;
|
||||
ProfileViewerDialog pvd = ProfileViewerDialog.newInstance(time);
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("time", ((ProfileSwitch) v.getTag()).date);
|
||||
args.putLong("mode", ProfileViewerDialog.Mode.RUNNING_PROFILE.ordinal());
|
||||
ProfileViewerDialog pvd = new ProfileViewerDialog();
|
||||
pvd.setArguments(args);
|
||||
FragmentManager manager = getFragmentManager();
|
||||
pvd.show(manager, "ProfileViewDialog");
|
||||
if (manager != null)
|
||||
pvd.show(manager, "ProfileViewDialog");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package info.nightscout.androidaps.queue.events;
|
||||
|
||||
/**
|
||||
* Created by mike on 11.11.2017.
|
||||
*/
|
||||
|
||||
public class EventQueueChanged {
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue