Confirmation dialogs cleanup
This commit is contained in:
parent
808dd92de1
commit
91000dc1bb
46 changed files with 867 additions and 1114 deletions
|
@ -42,7 +42,6 @@ import info.nightscout.androidaps.activities.NoSplashAppCompatActivity;
|
||||||
import info.nightscout.androidaps.activities.PreferencesActivity;
|
import info.nightscout.androidaps.activities.PreferencesActivity;
|
||||||
import info.nightscout.androidaps.activities.SingleFragmentActivity;
|
import info.nightscout.androidaps.activities.SingleFragmentActivity;
|
||||||
import info.nightscout.androidaps.activities.StatsActivity;
|
import info.nightscout.androidaps.activities.StatsActivity;
|
||||||
import info.nightscout.androidaps.activities.SurveyActivity;
|
|
||||||
import info.nightscout.androidaps.events.EventAppExit;
|
import info.nightscout.androidaps.events.EventAppExit;
|
||||||
import info.nightscout.androidaps.events.EventPreferenceChange;
|
import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
import info.nightscout.androidaps.events.EventRebuildTabs;
|
import info.nightscout.androidaps.events.EventRebuildTabs;
|
||||||
|
@ -58,6 +57,7 @@ import info.nightscout.androidaps.tabs.TabPageAdapter;
|
||||||
import info.nightscout.androidaps.utils.AndroidPermission;
|
import info.nightscout.androidaps.utils.AndroidPermission;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.LocaleHelper;
|
import info.nightscout.androidaps.utils.LocaleHelper;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
import info.nightscout.androidaps.utils.PasswordProtection;
|
import info.nightscout.androidaps.utils.PasswordProtection;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
@ -239,10 +239,7 @@ public class MainActivity extends NoSplashAppCompatActivity {
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case AndroidPermission.CASE_STORAGE:
|
case AndroidPermission.CASE_STORAGE:
|
||||||
//show dialog after permission is granted
|
//show dialog after permission is granted
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
OKDialog.show(this, "", MainApp.gs(R.string.alert_dialog_storage_permission_text));
|
||||||
alert.setMessage(R.string.alert_dialog_storage_permission_text);
|
|
||||||
alert.setPositiveButton(R.string.ok, null);
|
|
||||||
alert.show();
|
|
||||||
break;
|
break;
|
||||||
case AndroidPermission.CASE_LOCATION:
|
case AndroidPermission.CASE_LOCATION:
|
||||||
case AndroidPermission.CASE_SMS:
|
case AndroidPermission.CASE_SMS:
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (key.equals(MainApp.gs(R.string.key_openapsama_useautosens)) && SP.getBoolean(R.string.key_openapsama_useautosens, false)) {
|
if (key.equals(MainApp.gs(R.string.key_openapsama_useautosens)) && SP.getBoolean(R.string.key_openapsama_useautosens, false)) {
|
||||||
OKDialog.show(this, MainApp.gs(R.string.configbuilder_sensitivity), MainApp.gs(R.string.sensitivity_warning), null);
|
OKDialog.show(this, MainApp.gs(R.string.configbuilder_sensitivity), MainApp.gs(R.string.sensitivity_warning));
|
||||||
}
|
}
|
||||||
updatePrefSummary(myPreferenceFragment.findPreference(key));
|
updatePrefSummary(myPreferenceFragment.findPreference(key));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
package info.nightscout.androidaps.activities;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
|
||||||
import info.nightscout.androidaps.utils.PasswordProtection;
|
|
||||||
|
|
||||||
public class SingleFragmentActivity extends AppCompatActivity {
|
|
||||||
|
|
||||||
private PluginBase plugin;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_single_fragment);
|
|
||||||
|
|
||||||
this.plugin = MainApp.getPluginsList().get(getIntent().getIntExtra("plugin", -1));
|
|
||||||
setTitle(plugin.getName());
|
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
||||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout,
|
|
||||||
Fragment.instantiate(this, plugin.pluginDescription.getFragmentClass())).commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
|
||||||
if (item.getItemId() == android.R.id.home) {
|
|
||||||
finish();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (item.getItemId() == R.id.nav_plugin_preferences) {
|
|
||||||
PasswordProtection.QueryPassword(this, R.string.settings_password, "settings_password", () -> {
|
|
||||||
Intent i = new Intent(this, PreferencesActivity.class);
|
|
||||||
i.putExtra("id", plugin.getPreferencesId());
|
|
||||||
startActivity(i);
|
|
||||||
}, null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
if (plugin.getPreferencesId() != -1)
|
|
||||||
getMenuInflater().inflate(R.menu.menu_single_fragment, menu);
|
|
||||||
return super.onCreateOptionsMenu(menu);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
package info.nightscout.androidaps.activities
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.Menu
|
||||||
|
import android.view.MenuItem
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import info.nightscout.androidaps.MainApp
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
|
import info.nightscout.androidaps.utils.LocaleHelper
|
||||||
|
import info.nightscout.androidaps.utils.PasswordProtection
|
||||||
|
|
||||||
|
class SingleFragmentActivity : AppCompatActivity() {
|
||||||
|
private var plugin: PluginBase? = null
|
||||||
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
setContentView(R.layout.activity_single_fragment)
|
||||||
|
plugin = MainApp.getPluginsList()[intent.getIntExtra("plugin", -1)]
|
||||||
|
title = plugin?.name
|
||||||
|
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||||
|
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||||
|
if (savedInstanceState == null) {
|
||||||
|
supportFragmentManager.beginTransaction().replace(R.id.frame_layout,
|
||||||
|
supportFragmentManager.fragmentFactory.instantiate(ClassLoader.getSystemClassLoader(), plugin?.pluginDescription?.fragmentClass!!)).commit()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
if (item.itemId == android.R.id.home) {
|
||||||
|
finish()
|
||||||
|
return true
|
||||||
|
} else if (item.itemId == R.id.nav_plugin_preferences) {
|
||||||
|
PasswordProtection.QueryPassword(this, R.string.settings_password, "settings_password", Runnable {
|
||||||
|
val i = Intent(this, PreferencesActivity::class.java)
|
||||||
|
i.putExtra("id", plugin?.preferencesId)
|
||||||
|
startActivity(i)
|
||||||
|
}, null)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
|
if (plugin?.preferencesId != -1) menuInflater.inflate(R.menu.menu_single_fragment, menu)
|
||||||
|
return super.onCreateOptionsMenu(menu)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override fun attachBaseContext(newBase: Context) {
|
||||||
|
super.attachBaseContext(LocaleHelper.wrap(newBase))
|
||||||
|
}
|
||||||
|
}
|
|
@ -22,10 +22,10 @@ class StatsActivity : NoSplashAppCompatActivity() {
|
||||||
|
|
||||||
ok.setOnClickListener { finish() }
|
ok.setOnClickListener { finish() }
|
||||||
stats_reset.setOnClickListener {
|
stats_reset.setOnClickListener {
|
||||||
OKDialog.showConfirmation(this, MainApp.gs(R.string.doyouwantresetstats)) {
|
OKDialog.showConfirmation(this, MainApp.gs(R.string.doyouwantresetstats), Runnable {
|
||||||
ActivityMonitor.reset()
|
ActivityMonitor.reset()
|
||||||
recreate()
|
recreate()
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,16 +52,17 @@ class CalibrationDialog : DialogFragmentWithDate() {
|
||||||
val unitLabel = if (units == Constants.MMOL) MainApp.gs(R.string.mmol) else MainApp.gs(R.string.mgdl)
|
val unitLabel = if (units == Constants.MMOL) MainApp.gs(R.string.mmol) else MainApp.gs(R.string.mgdl)
|
||||||
val actions: LinkedList<String?> = LinkedList()
|
val actions: LinkedList<String?> = LinkedList()
|
||||||
val bg = overview_calibration_bg.value
|
val bg = overview_calibration_bg.value
|
||||||
actions.add("<b>" + MainApp.gs(R.string.overview_calibration) + "</b>")
|
|
||||||
actions.add(MainApp.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(bg) + " " + unitLabel)
|
actions.add(MainApp.gs(R.string.treatments_wizard_bg_label) + ": " + Profile.toCurrentUnitsString(bg) + " " + unitLabel)
|
||||||
if (bg > 0) {
|
if (bg > 0) {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions))) {
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.overview_calibration), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
XdripCalibrations.confirmAndSendCalibration(bg, context)
|
XdripCalibrations.confirmAndSendCalibration(bg, context)
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
OKDialog.show(activity, "", MainApp.gs(R.string.no_action_selected), null)
|
activity?.let { activity ->
|
||||||
|
OKDialog.show(activity, MainApp.gs(R.string.overview_calibration), MainApp.gs(R.string.no_action_selected))
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -172,7 +172,7 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
if (carbsAfterConstraints > 0 || activitySelected || eatingSoonSelected || hypoSelected) {
|
if (carbsAfterConstraints > 0 || activitySelected || eatingSoonSelected || hypoSelected) {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions))) {
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.carbs), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
if (activitySelected) {
|
if (activitySelected) {
|
||||||
val tempTarget = TempTarget()
|
val tempTarget = TempTarget()
|
||||||
.date(System.currentTimeMillis())
|
.date(System.currentTimeMillis())
|
||||||
|
@ -209,10 +209,12 @@ class CarbsDialog : DialogFragmentWithDate() {
|
||||||
NSUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, MainApp.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset))
|
NSUpload.uploadEvent(CareportalEvent.NOTE, DateUtil.now() - 2000, MainApp.gs(R.string.generated_ecarbs_note, carbsAfterConstraints, duration, timeOffset))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}, null)
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
OKDialog.show(activity, "", MainApp.gs(R.string.no_action_selected), null)
|
activity?.let { activity ->
|
||||||
|
OKDialog.show(activity, MainApp.gs(R.string.carbs), MainApp.gs(R.string.no_action_selected))
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -109,7 +109,6 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
val json = JSONObject()
|
val json = JSONObject()
|
||||||
val actions: LinkedList<String> = LinkedList()
|
val actions: LinkedList<String> = LinkedList()
|
||||||
actions.add("<b>" + MainApp.gs(event) + "</b>")
|
|
||||||
if (options == EventType.BGCHECK) {
|
if (options == EventType.BGCHECK) {
|
||||||
val type =
|
val type =
|
||||||
when {
|
when {
|
||||||
|
@ -141,10 +140,10 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
json.put("enteredBy", enteredBy)
|
json.put("enteredBy", enteredBy)
|
||||||
|
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions))) {
|
OKDialog.showConfirmation(activity, MainApp.gs(event), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
MainApp.getDbHelper().createCareportalEventFromJsonIfNotExists(json)
|
MainApp.getDbHelper().createCareportalEventFromJsonIfNotExists(json)
|
||||||
NSUpload.uploadCareportalEntryToNS(json)
|
NSUpload.uploadCareportalEntryToNS(json)
|
||||||
}
|
}, null)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
||||||
val insulin = SafeParse.stringToDouble(actions_extendedbolus_insulin.text)
|
val insulin = SafeParse.stringToDouble(actions_extendedbolus_insulin.text)
|
||||||
val durationInMinutes = SafeParse.stringToInt(actions_extendedbolus_duration.text)
|
val durationInMinutes = SafeParse.stringToInt(actions_extendedbolus_duration.text)
|
||||||
val actions: LinkedList<String> = LinkedList()
|
val actions: LinkedList<String> = LinkedList()
|
||||||
actions.add("<b>" + MainApp.gs(R.string.setextendedbolusquestion) + "</b>")
|
|
||||||
val insulinAfterConstraint = MainApp.getConstraintChecker().applyExtendedBolusConstraints(Constraint(insulin)).value()
|
val insulinAfterConstraint = MainApp.getConstraintChecker().applyExtendedBolusConstraints(Constraint(insulin)).value()
|
||||||
actions.add(MainApp.gs(R.string.formatinsulinunits, insulinAfterConstraint))
|
actions.add(MainApp.gs(R.string.formatinsulinunits, insulinAfterConstraint))
|
||||||
actions.add(MainApp.gs(R.string.duration) + ": " + MainApp.gs(R.string.format_mins, durationInMinutes))
|
actions.add(MainApp.gs(R.string.duration) + ": " + MainApp.gs(R.string.format_mins, durationInMinutes))
|
||||||
|
@ -63,7 +62,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
||||||
actions.add("<font color='" + MainApp.gc(R.color.warning) + "'>" + MainApp.gs(R.string.constraintapllied) + "</font>")
|
actions.add("<font color='" + MainApp.gc(R.color.warning) + "'>" + MainApp.gs(R.string.constraintapllied) + "</font>")
|
||||||
|
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions))) {
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.extended_bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
ConfigBuilderPlugin.getPlugin().commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() {
|
ConfigBuilderPlugin.getPlugin().commandQueue.extendedBolus(insulinAfterConstraint, durationInMinutes, object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -76,7 +75,7 @@ class ExtendedBolusDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}, null)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
if (insulinAfterConstraints > 0 || fill_catheter_change.isChecked || fill_cartridge_change.isChecked) {
|
if (insulinAfterConstraints > 0 || fill_catheter_change.isChecked || fill_cartridge_change.isChecked) {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions))) {
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.primefill), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
if (insulinAfterConstraints > 0) {
|
if (insulinAfterConstraints > 0) {
|
||||||
val detailedBolusInfo = DetailedBolusInfo()
|
val detailedBolusInfo = DetailedBolusInfo()
|
||||||
detailedBolusInfo.insulin = insulinAfterConstraints
|
detailedBolusInfo.insulin = insulinAfterConstraints
|
||||||
|
@ -119,10 +119,12 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
if (siteChange) NSUpload.uploadEvent(CareportalEvent.SITECHANGE, eventTime, notes)
|
if (siteChange) NSUpload.uploadEvent(CareportalEvent.SITECHANGE, eventTime, notes)
|
||||||
if (insulinChange) NSUpload.uploadEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes)
|
if (insulinChange) NSUpload.uploadEvent(CareportalEvent.INSULINCHANGE, eventTime + 1000, notes)
|
||||||
}
|
}, null)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
OKDialog.show(activity, "", MainApp.gs(R.string.no_action_selected), null)
|
activity?.let { activity ->
|
||||||
|
OKDialog.show(activity, MainApp.gs(R.string.primefill), MainApp.gs(R.string.no_action_selected))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dismiss()
|
dismiss()
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -145,7 +145,7 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
|
|
||||||
if (insulinAfterConstraints > 0 || eatingSoonChecked) {
|
if (insulinAfterConstraints > 0 || eatingSoonChecked) {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions))) {
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.bolus), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
if (eatingSoonChecked) {
|
if (eatingSoonChecked) {
|
||||||
val tempTarget = TempTarget()
|
val tempTarget = TempTarget()
|
||||||
.date(System.currentTimeMillis())
|
.date(System.currentTimeMillis())
|
||||||
|
@ -182,10 +182,12 @@ class InsulinDialog : DialogFragmentWithDate() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
OKDialog.show(activity, "", MainApp.gs(R.string.no_action_selected), null)
|
activity?.let { activity ->
|
||||||
|
OKDialog.show(activity, MainApp.gs(R.string.bolus), MainApp.gs(R.string.no_action_selected))
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -96,9 +96,9 @@ class ProfileSwitchDialog : DialogFragmentWithDate() {
|
||||||
actions.add(MainApp.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime))
|
actions.add(MainApp.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime))
|
||||||
|
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions))) {
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.careportal_profileswitch), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
ProfileFunctions.doProfileSwitch(profileStore, profile, duration.toInt(), percent, timeShift, eventTime)
|
ProfileFunctions.doProfileSwitch(profileStore, profile, duration.toInt(), percent, timeShift, eventTime)
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,23 +75,22 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
||||||
val durationInMinutes = SafeParse.stringToInt(actions_tempbasal_duration.text)
|
val durationInMinutes = SafeParse.stringToInt(actions_tempbasal_duration.text)
|
||||||
val profile = ProfileFunctions.getInstance().profile ?: return false
|
val profile = ProfileFunctions.getInstance().profile ?: return false
|
||||||
val actions: LinkedList<String> = LinkedList()
|
val actions: LinkedList<String> = LinkedList()
|
||||||
actions.add("<b>" + MainApp.gs(R.string.setbasalquestion) + "</b>")
|
|
||||||
if (isPercentPump) {
|
if (isPercentPump) {
|
||||||
val basalPercentInput = SafeParse.stringToInt(actions_tempbasal_basalpercentinput.text)
|
val basalPercentInput = SafeParse.stringToInt(actions_tempbasal_basalpercentinput.text)
|
||||||
percent = MainApp.getConstraintChecker().applyBasalPercentConstraints(Constraint(basalPercentInput), profile).value()
|
percent = MainApp.getConstraintChecker().applyBasalPercentConstraints(Constraint(basalPercentInput), profile).value()
|
||||||
actions.add("$percent%")
|
actions.add(MainApp.gs(R.string.pump_tempbasal_label)+ ": $percent%")
|
||||||
actions.add(MainApp.gs(R.string.duration) + ": " + MainApp.gs(R.string.format_mins, durationInMinutes))
|
actions.add(MainApp.gs(R.string.duration) + ": " + MainApp.gs(R.string.format_mins, durationInMinutes))
|
||||||
if (percent != basalPercentInput) actions.add(MainApp.gs(R.string.constraintapllied))
|
if (percent != basalPercentInput) actions.add(MainApp.gs(R.string.constraintapllied))
|
||||||
} else {
|
} else {
|
||||||
val basalAbsoluteInput = SafeParse.stringToDouble(actions_tempbasal_basalabsoluteinput.text)
|
val basalAbsoluteInput = SafeParse.stringToDouble(actions_tempbasal_basalabsoluteinput.text)
|
||||||
absolute = MainApp.getConstraintChecker().applyBasalConstraints(Constraint(basalAbsoluteInput), profile).value()
|
absolute = MainApp.getConstraintChecker().applyBasalConstraints(Constraint(basalAbsoluteInput), profile).value()
|
||||||
actions.add(MainApp.gs(R.string.pump_basebasalrate, absolute))
|
actions.add(MainApp.gs(R.string.pump_tempbasal_label)+ ": " + MainApp.gs(R.string.pump_basebasalrate, absolute))
|
||||||
actions.add(MainApp.gs(R.string.duration) + ": " + MainApp.gs(R.string.format_mins, durationInMinutes))
|
actions.add(MainApp.gs(R.string.duration) + ": " + MainApp.gs(R.string.format_mins, durationInMinutes))
|
||||||
if (abs(absolute - basalAbsoluteInput) > 0.01)
|
if (abs(absolute - basalAbsoluteInput) > 0.01)
|
||||||
actions.add("<font color='" + MainApp.gc(R.color.warning) + "'>" + MainApp.gs(R.string.constraintapllied) + "</font>")
|
actions.add("<font color='" + MainApp.gc(R.color.warning) + "'>" + MainApp.gs(R.string.constraintapllied) + "</font>")
|
||||||
}
|
}
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions))) {
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.pump_tempbasal_label), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
val callback: Callback = object : Callback() {
|
val callback: Callback = object : Callback() {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
|
@ -109,7 +108,7 @@ class TempBasalDialog : DialogFragmentWithDate() {
|
||||||
} else {
|
} else {
|
||||||
ConfigBuilderPlugin.getPlugin().commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, callback)
|
ConfigBuilderPlugin.getPlugin().commandQueue.tempBasalAbsolute(absolute, durationInMinutes, true, profile, callback)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,7 +126,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
actions.add(MainApp.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime))
|
actions.add(MainApp.gs(R.string.time) + ": " + DateUtil.dateAndTimeString(eventTime))
|
||||||
|
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions))) {
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.careportal_temporarytarget), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
if (target == 0.0 || duration == 0.0) {
|
if (target == 0.0 || duration == 0.0) {
|
||||||
val tempTarget = TempTarget()
|
val tempTarget = TempTarget()
|
||||||
.date(eventTime)
|
.date(eventTime)
|
||||||
|
@ -145,7 +145,7 @@ class TempTargetDialog : DialogFragmentWithDate() {
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget)
|
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget)
|
||||||
}
|
}
|
||||||
if (duration == 10.0) SP.putBoolean(R.string.key_objectiveusetemptarget, true)
|
if (duration == 10.0) SP.putBoolean(R.string.key_objectiveusetemptarget, true)
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,6 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
val insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(Constraint(insulin)).value()
|
val insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(Constraint(insulin)).value()
|
||||||
val carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(Constraint(carbs)).value()
|
val carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(Constraint(carbs)).value()
|
||||||
|
|
||||||
actions.add("<b>" + MainApp.gs(R.string.entertreatmentquestion) + "</b>")
|
|
||||||
if (insulinAfterConstraints > 0) {
|
if (insulinAfterConstraints > 0) {
|
||||||
actions.add(MainApp.gs(R.string.bolus) + ": " + "<font color='" + MainApp.gc(R.color.bolus) + "'>" + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints) + MainApp.gs(R.string.insulin_unit_shortname) + "</font>")
|
actions.add(MainApp.gs(R.string.bolus) + ": " + "<font color='" + MainApp.gc(R.color.bolus) + "'>" + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints) + MainApp.gs(R.string.insulin_unit_shortname) + "</font>")
|
||||||
if (recordOnlyChecked)
|
if (recordOnlyChecked)
|
||||||
|
@ -99,7 +98,7 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
}
|
}
|
||||||
if (insulinAfterConstraints > 0 || carbsAfterConstraints > 0) {
|
if (insulinAfterConstraints > 0 || carbsAfterConstraints > 0) {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions))) {
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.overview_treatment_label), HtmlHelper.fromHtml(Joiner.on("<br/>").join(actions)), Runnable {
|
||||||
val detailedBolusInfo = DetailedBolusInfo()
|
val detailedBolusInfo = DetailedBolusInfo()
|
||||||
if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = CareportalEvent.CARBCORRECTION
|
if (insulinAfterConstraints == 0.0) detailedBolusInfo.eventType = CareportalEvent.CARBCORRECTION
|
||||||
if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS
|
if (carbsAfterConstraints == 0) detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS
|
||||||
|
@ -122,10 +121,12 @@ class TreatmentDialog : DialogFragmentWithDate() {
|
||||||
})
|
})
|
||||||
} else
|
} else
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false)
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false)
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
OKDialog.show(activity, "", MainApp.gs(R.string.no_action_selected), null)
|
activity?.let { activity ->
|
||||||
|
OKDialog.show(activity, MainApp.gs(R.string.overview_treatment_label), MainApp.gs(R.string.no_action_selected))
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -4,7 +4,6 @@ import android.os.SystemClock;
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
import androidx.fragment.app.FragmentActivity;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -20,6 +19,7 @@ import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.EventConfigBuilderUpdateGui;
|
import info.nightscout.androidaps.plugins.configBuilder.EventConfigBuilderUpdateGui;
|
||||||
import info.nightscout.androidaps.queue.CommandQueue;
|
import info.nightscout.androidaps.queue.CommandQueue;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,20 +58,16 @@ public abstract class PluginBase {
|
||||||
if (allowHardwarePump || activity == null) {
|
if (allowHardwarePump || activity == null) {
|
||||||
performPluginSwitch(newState, type);
|
performPluginSwitch(newState, type);
|
||||||
} else {
|
} else {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.allow_hardware_pump_text), () -> {
|
||||||
builder.setMessage(R.string.allow_hardware_pump_text)
|
performPluginSwitch(newState, type);
|
||||||
.setPositiveButton(R.string.yes, (dialog, id) -> {
|
SP.putBoolean("allow_hardware_pump", true);
|
||||||
performPluginSwitch(newState, type);
|
if (L.isEnabled(L.PUMP))
|
||||||
SP.putBoolean("allow_hardware_pump", true);
|
log.debug("First time HW pump allowed!");
|
||||||
if (L.isEnabled(L.PUMP))
|
}, () -> {
|
||||||
log.debug("First time HW pump allowed!");
|
RxBus.INSTANCE.send(new EventConfigBuilderUpdateGui());
|
||||||
})
|
if (L.isEnabled(L.PUMP))
|
||||||
.setNegativeButton(R.string.cancel, (dialog, id) -> {
|
log.debug("User does not allow switching to HW pump!");
|
||||||
RxBus.INSTANCE.send(new EventConfigBuilderUpdateGui());
|
});
|
||||||
if (L.isEnabled(L.PUMP))
|
|
||||||
log.debug("User does not allow switching to HW pump!");
|
|
||||||
});
|
|
||||||
builder.create().show();
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
performPluginSwitch(newState, type);
|
performPluginSwitch(newState, type);
|
||||||
|
|
|
@ -72,13 +72,13 @@ class ObjectivesFragment : Fragment() {
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable.add(RxBus
|
disposable.add(RxBus
|
||||||
.toObservable(EventObjectivesUpdateGui::class.java)
|
.toObservable(EventObjectivesUpdateGui::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({
|
.subscribe({
|
||||||
objectives_recyclerview.adapter?.notifyDataSetChanged()
|
objectives_recyclerview.adapter?.notifyDataSetChanged()
|
||||||
}, {
|
}, {
|
||||||
FabricPrivacy.logException(it)
|
FabricPrivacy.logException(it)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,11 +285,13 @@ class ObjectivesFragment : Fragment() {
|
||||||
}.start()
|
}.start()
|
||||||
}
|
}
|
||||||
holder.unStart.setOnClickListener {
|
holder.unStart.setOnClickListener {
|
||||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.doyouwantresetstart)) {
|
activity?.let { activity ->
|
||||||
objective.startedOn = 0
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.objectives), MainApp.gs(R.string.doyouwantresetstart), Runnable {
|
||||||
scrollToCurrentObjective()
|
objective.startedOn = 0
|
||||||
RxBus.send(EventObjectivesUpdateGui())
|
scrollToCurrentObjective()
|
||||||
RxBus.send(EventSWUpdate(false))
|
RxBus.send(EventObjectivesUpdateGui())
|
||||||
|
RxBus.send(EventSWUpdate(false))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
holder.unFinish.setOnClickListener {
|
holder.unFinish.setOnClickListener {
|
||||||
|
@ -320,7 +322,6 @@ class ObjectivesFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
return ObjectivesPlugin.objectives.size
|
return ObjectivesPlugin.objectives.size
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,9 +122,9 @@ object ObjectivesPlugin : PluginBase(PluginDescription()
|
||||||
SP.putLong("Objectives_" + "smb" + "_started", DateUtil.now())
|
SP.putLong("Objectives_" + "smb" + "_started", DateUtil.now())
|
||||||
SP.putLong("Objectives_" + "smb" + "_accomplished", DateUtil.now())
|
SP.putLong("Objectives_" + "smb" + "_accomplished", DateUtil.now())
|
||||||
setupObjectives()
|
setupObjectives()
|
||||||
OKDialog.show(activity, "", MainApp.gs(R.string.codeaccepted), null)
|
OKDialog.show(activity, MainApp.gs(R.string.objectives), MainApp.gs(R.string.codeaccepted))
|
||||||
} else {
|
} else {
|
||||||
OKDialog.show(activity, "", MainApp.gs(R.string.codeinvalid), null)
|
OKDialog.show(activity, MainApp.gs(R.string.objectives), MainApp.gs(R.string.codeinvalid))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class TriggerTempTarget extends Trigger {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int friendlyName() {
|
public int friendlyName() {
|
||||||
return R.string.temptarget;
|
return R.string.careportal_temporarytarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -124,7 +124,7 @@ public class TriggerTempTarget extends Trigger {
|
||||||
@Override
|
@Override
|
||||||
public void generateDialog(LinearLayout root, FragmentManager fragmentManager) {
|
public void generateDialog(LinearLayout root, FragmentManager fragmentManager) {
|
||||||
new LayoutBuilder()
|
new LayoutBuilder()
|
||||||
.add(new StaticLabel(R.string.temptarget))
|
.add(new StaticLabel(R.string.careportal_temporarytarget))
|
||||||
.add(comparator)
|
.add(comparator)
|
||||||
.build(root);
|
.build(root);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.careportal.Dialogs;
|
package info.nightscout.androidaps.plugins.general.careportal.Dialogs;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
@ -20,7 +19,6 @@ import android.widget.RadioButton;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.appcompat.app.AppCompatDialogFragment;
|
import androidx.appcompat.app.AppCompatDialogFragment;
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
|
|
||||||
|
@ -58,6 +56,7 @@ import info.nightscout.androidaps.utils.DefaultValueHelper;
|
||||||
import info.nightscout.androidaps.utils.HardLimits;
|
import info.nightscout.androidaps.utils.HardLimits;
|
||||||
import info.nightscout.androidaps.utils.JsonHelper;
|
import info.nightscout.androidaps.utils.JsonHelper;
|
||||||
import info.nightscout.androidaps.utils.NumberPicker;
|
import info.nightscout.androidaps.utils.NumberPicker;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import info.nightscout.androidaps.utils.SafeParse;
|
import info.nightscout.androidaps.utils.SafeParse;
|
||||||
import info.nightscout.androidaps.utils.Translator;
|
import info.nightscout.androidaps.utils.Translator;
|
||||||
|
@ -595,12 +594,12 @@ public class NewNSTreatmentDialog extends AppCompatDialogFragment implements Vie
|
||||||
|
|
||||||
String buildConfirmText(JSONObject data) {
|
String buildConfirmText(JSONObject data) {
|
||||||
String ret = "";
|
String ret = "";
|
||||||
if (data.has("eventType")) {
|
// if (data.has("eventType")) {
|
||||||
ret += MainApp.gs(R.string.careportal_newnstreatment_eventtype);
|
// ret += MainApp.gs(R.string.careportal_newnstreatment_eventtype);
|
||||||
ret += ": ";
|
// ret += ": ";
|
||||||
ret += Translator.translate(JsonHelper.safeGetString(data, "eventType", ""));
|
// ret += Translator.translate(JsonHelper.safeGetString(data, "eventType", ""));
|
||||||
ret += "\n";
|
// ret += "\n";
|
||||||
}
|
// }
|
||||||
if (data.has("glucose")) {
|
if (data.has("glucose")) {
|
||||||
ret += MainApp.gs(R.string.treatments_wizard_bg_label);
|
ret += MainApp.gs(R.string.treatments_wizard_bg_label);
|
||||||
ret += ": ";
|
ret += ": ";
|
||||||
|
@ -697,18 +696,9 @@ public class NewNSTreatmentDialog extends AppCompatDialogFragment implements Vie
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void confirmNSTreatmentCreation() {
|
private void confirmNSTreatmentCreation() {
|
||||||
Context context = getContext();
|
final JSONObject data = gatherData();
|
||||||
if (context != null) {
|
OKDialog.showConfirmation(getContext(), Translator.translate(JsonHelper.safeGetString(data, "eventType", MainApp.gs(R.string.overview_treatment_label))), buildConfirmText(data), () -> createNSTreatment(data));
|
||||||
final JSONObject data = gatherData();
|
|
||||||
final String confirmText = buildConfirmText(data);
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(confirmText);
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> createNSTreatment(data));
|
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.general.food;
|
package info.nightscout.androidaps.plugins.general.food;
|
||||||
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
@ -14,14 +13,11 @@ import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -33,6 +29,7 @@ import info.nightscout.androidaps.events.EventFoodDatabaseChanged;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
import info.nightscout.androidaps.utils.SpinnerHelper;
|
import info.nightscout.androidaps.utils.SpinnerHelper;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
@ -42,43 +39,36 @@ import io.reactivex.disposables.CompositeDisposable;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class FoodFragment extends Fragment {
|
public class FoodFragment extends Fragment {
|
||||||
private static Logger log = LoggerFactory.getLogger(FoodFragment.class);
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
EditText filter;
|
private EditText filter;
|
||||||
ImageView clearFilter;
|
private SpinnerHelper category;
|
||||||
SpinnerHelper category;
|
private SpinnerHelper subcategory;
|
||||||
SpinnerHelper subcategory;
|
private RecyclerView recyclerView;
|
||||||
RecyclerView recyclerView;
|
|
||||||
|
|
||||||
List<Food> unfiltered;
|
private List<Food> unfiltered;
|
||||||
List<Food> filtered;
|
private List<Food> filtered;
|
||||||
ArrayList<CharSequence> categories;
|
|
||||||
ArrayList<CharSequence> subcategories;
|
|
||||||
|
|
||||||
final String EMPTY = MainApp.gs(R.string.none);
|
private final String EMPTY = MainApp.gs(R.string.none);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.food_fragment, container, false);
|
View view = inflater.inflate(R.layout.food_fragment, container, false);
|
||||||
filter = (EditText) view.findViewById(R.id.food_filter);
|
filter = view.findViewById(R.id.food_filter);
|
||||||
clearFilter = (ImageView) view.findViewById(R.id.food_clearfilter);
|
ImageView clearFilter = view.findViewById(R.id.food_clearfilter);
|
||||||
category = new SpinnerHelper(view.findViewById(R.id.food_category));
|
category = new SpinnerHelper(view.findViewById(R.id.food_category));
|
||||||
subcategory = new SpinnerHelper(view.findViewById(R.id.food_subcategory));
|
subcategory = new SpinnerHelper(view.findViewById(R.id.food_subcategory));
|
||||||
recyclerView = (RecyclerView) view.findViewById(R.id.food_recyclerview);
|
recyclerView = view.findViewById(R.id.food_recyclerview);
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
LinearLayoutManager llm = new LinearLayoutManager(view.getContext());
|
LinearLayoutManager llm = new LinearLayoutManager(view.getContext());
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
|
|
||||||
clearFilter.setOnClickListener(new View.OnClickListener() {
|
clearFilter.setOnClickListener(v -> {
|
||||||
@Override
|
filter.setText("");
|
||||||
public void onClick(View v) {
|
category.setSelection(0);
|
||||||
filter.setText("");
|
subcategory.setSelection(0);
|
||||||
category.setSelection(0);
|
filterData();
|
||||||
subcategory.setSelection(0);
|
|
||||||
filterData();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
category.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
category.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
|
@ -149,11 +139,11 @@ public class FoodFragment extends Fragment {
|
||||||
disposable.clear();
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadData() {
|
private void loadData() {
|
||||||
unfiltered = FoodPlugin.getPlugin().getService().getFoodData();
|
unfiltered = FoodPlugin.getPlugin().getService().getFoodData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillCategories() {
|
private void fillCategories() {
|
||||||
Set<CharSequence> catSet = new HashSet<>();
|
Set<CharSequence> catSet = new HashSet<>();
|
||||||
|
|
||||||
for (Food f : unfiltered) {
|
for (Food f : unfiltered) {
|
||||||
|
@ -162,7 +152,7 @@ public class FoodFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
// make it unique
|
// make it unique
|
||||||
categories = new ArrayList<>(catSet);
|
ArrayList<CharSequence> categories = new ArrayList<>(catSet);
|
||||||
categories.add(0, MainApp.gs(R.string.none));
|
categories.add(0, MainApp.gs(R.string.none));
|
||||||
|
|
||||||
ArrayAdapter<CharSequence> adapterCategories = new ArrayAdapter<>(getContext(),
|
ArrayAdapter<CharSequence> adapterCategories = new ArrayAdapter<>(getContext(),
|
||||||
|
@ -170,7 +160,7 @@ public class FoodFragment extends Fragment {
|
||||||
category.setAdapter(adapterCategories);
|
category.setAdapter(adapterCategories);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fillSubcategories() {
|
private void fillSubcategories() {
|
||||||
String categoryFilter = category.getSelectedItem().toString();
|
String categoryFilter = category.getSelectedItem().toString();
|
||||||
|
|
||||||
Set<CharSequence> subCatSet = new HashSet<>();
|
Set<CharSequence> subCatSet = new HashSet<>();
|
||||||
|
@ -184,7 +174,7 @@ public class FoodFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
// make it unique
|
// make it unique
|
||||||
subcategories = new ArrayList<>(subCatSet);
|
ArrayList<CharSequence> subcategories = new ArrayList<>(subCatSet);
|
||||||
subcategories.add(0, MainApp.gs(R.string.none));
|
subcategories.add(0, MainApp.gs(R.string.none));
|
||||||
|
|
||||||
ArrayAdapter<CharSequence> adapterSubcategories = new ArrayAdapter<>(getContext(),
|
ArrayAdapter<CharSequence> adapterSubcategories = new ArrayAdapter<>(getContext(),
|
||||||
|
@ -192,7 +182,7 @@ public class FoodFragment extends Fragment {
|
||||||
subcategory.setAdapter(adapterSubcategories);
|
subcategory.setAdapter(adapterSubcategories);
|
||||||
}
|
}
|
||||||
|
|
||||||
void filterData() {
|
private void filterData() {
|
||||||
String textFilter = filter.getText().toString();
|
String textFilter = filter.getText().toString();
|
||||||
String categoryFilter = category.getSelectedItem().toString();
|
String categoryFilter = category.getSelectedItem().toString();
|
||||||
String subcategoryFilter = subcategory.getSelectedItem().toString();
|
String subcategoryFilter = subcategory.getSelectedItem().toString();
|
||||||
|
@ -227,6 +217,7 @@ public class FoodFragment extends Fragment {
|
||||||
this.foodList = foodList;
|
this.foodList = foodList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public FoodsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
public FoodsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.food_item, viewGroup, false);
|
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.food_item, viewGroup, false);
|
||||||
|
@ -257,7 +248,7 @@ public class FoodFragment extends Fragment {
|
||||||
return foodList.size();
|
return foodList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
class FoodsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
class FoodsViewHolder extends RecyclerView.ViewHolder {
|
||||||
TextView name;
|
TextView name;
|
||||||
TextView portion;
|
TextView portion;
|
||||||
TextView carbs;
|
TextView carbs;
|
||||||
|
@ -269,43 +260,26 @@ public class FoodFragment extends Fragment {
|
||||||
|
|
||||||
FoodsViewHolder(View itemView) {
|
FoodsViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
name = (TextView) itemView.findViewById(R.id.food_name);
|
name = itemView.findViewById(R.id.food_name);
|
||||||
portion = (TextView) itemView.findViewById(R.id.food_portion);
|
portion = itemView.findViewById(R.id.food_portion);
|
||||||
carbs = (TextView) itemView.findViewById(R.id.food_carbs);
|
carbs = itemView.findViewById(R.id.food_carbs);
|
||||||
fat = (TextView) itemView.findViewById(R.id.food_fat);
|
fat = itemView.findViewById(R.id.food_fat);
|
||||||
protein = (TextView) itemView.findViewById(R.id.food_protein);
|
protein = itemView.findViewById(R.id.food_protein);
|
||||||
energy = (TextView) itemView.findViewById(R.id.food_energy);
|
energy = itemView.findViewById(R.id.food_energy);
|
||||||
ns = (TextView) itemView.findViewById(R.id.ns_sign);
|
ns = itemView.findViewById(R.id.ns_sign);
|
||||||
remove = (TextView) itemView.findViewById(R.id.food_remove);
|
remove = itemView.findViewById(R.id.food_remove);
|
||||||
remove.setOnClickListener(this);
|
remove.setOnClickListener(v -> {
|
||||||
|
final Food food = (Food) v.getTag();
|
||||||
|
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.confirmation), MainApp.gs(R.string.removerecord) + "\n" + food.name, (dialog, id) -> {
|
||||||
|
final String _id = food._id;
|
||||||
|
if (_id != null && !_id.equals("")) {
|
||||||
|
NSUpload.removeFoodFromNS(_id);
|
||||||
|
}
|
||||||
|
FoodPlugin.getPlugin().getService().delete(food);
|
||||||
|
}, null);
|
||||||
|
});
|
||||||
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
final Food food = (Food) v.getTag();
|
|
||||||
switch (v.getId()) {
|
|
||||||
|
|
||||||
case R.id.food_remove:
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + food.name);
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
final String _id = food._id;
|
|
||||||
if (_id != null && !_id.equals("")) {
|
|
||||||
NSUpload.removeFoodFromNS(_id);
|
|
||||||
}
|
|
||||||
FoodPlugin.getPlugin().getService().delete(food);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,14 @@ package info.nightscout.androidaps.plugins.general.maintenance;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -39,7 +38,7 @@ import info.nightscout.androidaps.utils.ToastUtils;
|
||||||
|
|
||||||
public class ImportExportPrefs {
|
public class ImportExportPrefs {
|
||||||
private static Logger log = LoggerFactory.getLogger(L.CORE);
|
private static Logger log = LoggerFactory.getLogger(L.CORE);
|
||||||
static File path = new File(Environment.getExternalStorageDirectory().toString());
|
private static File path = new File(Environment.getExternalStorageDirectory().toString());
|
||||||
static public final File file = new File(path, MainApp.gs(R.string.app_name) + "Preferences");
|
static public final File file = new File(path, MainApp.gs(R.string.app_name) + "Preferences");
|
||||||
|
|
||||||
private static final int REQUEST_EXTERNAL_STORAGE = 1;
|
private static final int REQUEST_EXTERNAL_STORAGE = 1;
|
||||||
|
@ -48,21 +47,7 @@ public class ImportExportPrefs {
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void verifyStoragePermissions(Activity activity) {
|
static void verifyStoragePermissions(Fragment fragment) {
|
||||||
// Check if we have write permission
|
|
||||||
int permission = ActivityCompat.checkSelfPermission(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
|
||||||
|
|
||||||
if (permission != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
// We don't have permission so prompt the user
|
|
||||||
ActivityCompat.requestPermissions(
|
|
||||||
activity,
|
|
||||||
PERMISSIONS_STORAGE,
|
|
||||||
REQUEST_EXTERNAL_STORAGE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void verifyStoragePermissions(Fragment fragment) {
|
|
||||||
int permission = ContextCompat.checkSelfPermission(fragment.getContext(),
|
int permission = ContextCompat.checkSelfPermission(fragment.getContext(),
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||||
|
|
||||||
|
@ -73,85 +58,73 @@ public class ImportExportPrefs {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void exportSharedPreferences(final Fragment f) {
|
static void exportSharedPreferences(final Fragment f) {
|
||||||
exportSharedPreferences(f.getContext());
|
exportSharedPreferences(f.getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void exportSharedPreferences(final Context c) {
|
private static void exportSharedPreferences(final Context context) {
|
||||||
|
OKDialog.showConfirmation(context, MainApp.gs(R.string.maintenance), MainApp.gs(R.string.export_to) + " " + file + " ?", () -> {
|
||||||
new AlertDialog.Builder(c)
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
.setMessage(MainApp.gs(R.string.export_to) + " " + file + " ?")
|
try {
|
||||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
|
FileWriter fw = new FileWriter(file);
|
||||||
|
PrintWriter pw = new PrintWriter(fw);
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(c);
|
Map<String, ?> prefsMap = prefs.getAll();
|
||||||
try {
|
for (Map.Entry<String, ?> entry : prefsMap.entrySet()) {
|
||||||
FileWriter fw = new FileWriter(file);
|
pw.println(entry.getKey() + "::" + entry.getValue().toString());
|
||||||
PrintWriter pw = new PrintWriter(fw);
|
}
|
||||||
Map<String, ?> prefsMap = prefs.getAll();
|
pw.close();
|
||||||
for (Map.Entry<String, ?> entry : prefsMap.entrySet()) {
|
fw.close();
|
||||||
pw.println(entry.getKey() + "::" + entry.getValue().toString());
|
ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.exported));
|
||||||
}
|
} catch (FileNotFoundException e) {
|
||||||
pw.close();
|
ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.filenotfound) + " " + file);
|
||||||
fw.close();
|
log.error("Unhandled exception", e);
|
||||||
ToastUtils.showToastInUiThread(c, MainApp.gs(R.string.exported));
|
} catch (IOException e) {
|
||||||
} catch (FileNotFoundException e) {
|
log.error("Unhandled exception", e);
|
||||||
ToastUtils.showToastInUiThread(c, MainApp.gs(R.string.filenotfound) + " " + file);
|
}
|
||||||
log.error("Unhandled exception", e);
|
});
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void importSharedPreferences(final Fragment fragment) {
|
static void importSharedPreferences(final Fragment fragment) {
|
||||||
importSharedPreferences(fragment.getContext());
|
importSharedPreferences(fragment.getContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void importSharedPreferences(final Context context) {
|
public static void importSharedPreferences(final Context context) {
|
||||||
new AlertDialog.Builder(context)
|
OKDialog.showConfirmation(context, MainApp.gs(R.string.maintenance), MainApp.gs(R.string.import_from) + " " + file + " ?", () -> {
|
||||||
.setMessage(MainApp.gs(R.string.import_from) + " " + file + " ?")
|
String line;
|
||||||
.setPositiveButton(android.R.string.yes, (dialog, which) -> {
|
String[] lineParts;
|
||||||
|
try {
|
||||||
|
SP.clear();
|
||||||
|
|
||||||
String line;
|
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||||
String[] lineParts;
|
while ((line = reader.readLine()) != null) {
|
||||||
try {
|
lineParts = line.split("::");
|
||||||
SP.clear();
|
if (lineParts.length == 2) {
|
||||||
|
if (lineParts[1].equals("true") || lineParts[1].equals("false")) {
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
SP.putBoolean(lineParts[0], Boolean.parseBoolean(lineParts[1]));
|
||||||
while ((line = reader.readLine()) != null) {
|
} else {
|
||||||
lineParts = line.split("::");
|
SP.putString(lineParts[0], lineParts[1]);
|
||||||
if (lineParts.length == 2) {
|
|
||||||
if (lineParts[1].equals("true") || lineParts[1].equals("false")) {
|
|
||||||
SP.putBoolean(lineParts[0], Boolean.parseBoolean(lineParts[1]));
|
|
||||||
} else {
|
|
||||||
SP.putString(lineParts[0], lineParts[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
reader.close();
|
|
||||||
SP.putBoolean(R.string.key_setupwizard_processed, true);
|
|
||||||
OKDialog.show(context, MainApp.gs(R.string.setting_imported), MainApp.gs(R.string.restartingapp), () -> {
|
|
||||||
log.debug("Exiting");
|
|
||||||
MainApp.instance().stopKeepAliveService();
|
|
||||||
RxBus.INSTANCE.send(new EventAppExit());
|
|
||||||
MainApp.closeDbHelper();
|
|
||||||
if (context instanceof Activity) {
|
|
||||||
((Activity)context).finish();
|
|
||||||
}
|
|
||||||
System.runFinalization();
|
|
||||||
System.exit(0);
|
|
||||||
});
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.filenotfound) + " " + file);
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
reader.close();
|
||||||
.show();
|
SP.putBoolean(R.string.key_setupwizard_processed, true);
|
||||||
|
OKDialog.show(context, MainApp.gs(R.string.setting_imported), MainApp.gs(R.string.restartingapp), () -> {
|
||||||
|
log.debug("Exiting");
|
||||||
|
MainApp.instance().stopKeepAliveService();
|
||||||
|
RxBus.INSTANCE.send(new EventAppExit());
|
||||||
|
MainApp.closeDbHelper();
|
||||||
|
if (context instanceof Activity) {
|
||||||
|
((Activity) context).finish();
|
||||||
|
}
|
||||||
|
System.runFinalization();
|
||||||
|
System.exit(0);
|
||||||
|
});
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.filenotfound) + " " + file);
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("Unhandled exception", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,81 +2,58 @@ package info.nightscout.androidaps.plugins.general.maintenance;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.fragment.app.Fragment;
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.general.food.FoodPlugin;
|
import info.nightscout.androidaps.plugins.general.food.FoodPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSettingActivity;
|
import info.nightscout.androidaps.plugins.general.maintenance.activities.LogSettingActivity;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MaintenanceFragment extends Fragment {
|
public class MaintenanceFragment extends Fragment {
|
||||||
|
|
||||||
private Fragment f;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
|
|
||||||
this.f = this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
|
|
||||||
this.f = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.maintenance_fragment, container, false);
|
View view = inflater.inflate(R.layout.maintenance_fragment, container, false);
|
||||||
|
|
||||||
final Fragment f = this;
|
|
||||||
|
|
||||||
view.findViewById(R.id.log_send).setOnClickListener(view1 -> MaintenancePlugin.getPlugin().sendLogs());
|
view.findViewById(R.id.log_send).setOnClickListener(view1 -> MaintenancePlugin.getPlugin().sendLogs());
|
||||||
|
|
||||||
view.findViewById(R.id.log_delete).setOnClickListener(view1 -> MaintenancePlugin.getPlugin().deleteLogs());
|
view.findViewById(R.id.log_delete).setOnClickListener(view1 -> MaintenancePlugin.getPlugin().deleteLogs());
|
||||||
|
|
||||||
view.findViewById(R.id.nav_resetdb).setOnClickListener(view1 -> new AlertDialog.Builder(f.getContext())
|
view.findViewById(R.id.nav_resetdb).setOnClickListener(view1 ->
|
||||||
.setTitle(R.string.nav_resetdb)
|
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.maintenance), MainApp.gs(R.string.reset_db_confirm), () -> {
|
||||||
.setMessage(R.string.reset_db_confirm)
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
|
||||||
MainApp.getDbHelper().resetDatabases();
|
MainApp.getDbHelper().resetDatabases();
|
||||||
// should be handled by Plugin-Interface and
|
// should be handled by Plugin-Interface and
|
||||||
// additional service interface and plugin registry
|
// additional service interface and plugin registry
|
||||||
FoodPlugin.getPlugin().getService().resetFood();
|
FoodPlugin.getPlugin().getService().resetFood();
|
||||||
TreatmentsPlugin.getPlugin().getService().resetTreatments();
|
TreatmentsPlugin.getPlugin().getService().resetTreatments();
|
||||||
})
|
})
|
||||||
.create()
|
);
|
||||||
.show());
|
|
||||||
|
|
||||||
view.findViewById(R.id.nav_export).setOnClickListener(view1 -> {
|
view.findViewById(R.id.nav_export).setOnClickListener(view1 -> {
|
||||||
// start activity for checking permissions...
|
// start activity for checking permissions...
|
||||||
ImportExportPrefs.verifyStoragePermissions(f);
|
ImportExportPrefs.verifyStoragePermissions(this);
|
||||||
ImportExportPrefs.exportSharedPreferences(f);
|
ImportExportPrefs.exportSharedPreferences(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
view.findViewById(R.id.nav_import).setOnClickListener(view1 -> {
|
view.findViewById(R.id.nav_import).setOnClickListener(view1 -> {
|
||||||
// start activity for checking permissions...
|
// start activity for checking permissions...
|
||||||
ImportExportPrefs.verifyStoragePermissions(f);
|
ImportExportPrefs.verifyStoragePermissions(this);
|
||||||
ImportExportPrefs.importSharedPreferences(f);
|
ImportExportPrefs.importSharedPreferences(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
view.findViewById(R.id.nav_logsettings).setOnClickListener(view1 -> {
|
view.findViewById(R.id.nav_logsettings).setOnClickListener(view1 -> {
|
||||||
startActivity(new Intent(getActivity(), LogSettingActivity.class));
|
startActivity(new Intent(getActivity(), LogSettingActivity.class));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.nsclient;
|
package info.nightscout.androidaps.plugins.general.nsclient;
|
||||||
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
|
@ -25,6 +22,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientN
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientUpdateGUI;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
@ -113,20 +111,11 @@ public class NSClientFragment extends Fragment implements View.OnClickListener,
|
||||||
NSClientPlugin.getPlugin().clearLog();
|
NSClientPlugin.getPlugin().clearLog();
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_clearqueue:
|
case R.id.nsclientinternal_clearqueue:
|
||||||
final Context context = getContext();
|
OKDialog.showConfirmation(getContext(),MainApp.gs(R.string.nsclientinternal), MainApp.gs(R.string.clearqueueconfirm), () -> {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
UploadQueue.clearQueue();
|
||||||
|
updateGui();
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
FabricPrivacy.getInstance().logCustom("NSClientClearQueue");
|
||||||
builder.setMessage("Clear queue? All data in queue will be lost!");
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
UploadQueue.clearQueue();
|
|
||||||
updateGui();
|
|
||||||
FabricPrivacy.getInstance().logCustom("NSClientClearQueue");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
break;
|
break;
|
||||||
case R.id.nsclientinternal_showqueue:
|
case R.id.nsclientinternal_showqueue:
|
||||||
RxBus.INSTANCE.send(new EventNSClientNewLog("QUEUE", NSClientPlugin.getPlugin().queue().textList()));
|
RxBus.INSTANCE.send(new EventNSClientNewLog("QUEUE", NSClientPlugin.getPlugin().queue().textList()));
|
||||||
|
|
|
@ -61,6 +61,14 @@ import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
|
import info.nightscout.androidaps.dialogs.CalibrationDialog;
|
||||||
|
import info.nightscout.androidaps.dialogs.CarbsDialog;
|
||||||
|
import info.nightscout.androidaps.dialogs.InsulinDialog;
|
||||||
|
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog;
|
||||||
|
import info.nightscout.androidaps.dialogs.ProfileViewerDialog;
|
||||||
|
import info.nightscout.androidaps.dialogs.TempTargetDialog;
|
||||||
|
import info.nightscout.androidaps.dialogs.TreatmentDialog;
|
||||||
|
import info.nightscout.androidaps.dialogs.WizardDialog;
|
||||||
import info.nightscout.androidaps.events.EventAcceptOpenLoopChange;
|
import info.nightscout.androidaps.events.EventAcceptOpenLoopChange;
|
||||||
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
import info.nightscout.androidaps.events.EventCareportalEventChange;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
|
@ -87,13 +95,6 @@ import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus;
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity;
|
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity;
|
||||||
import info.nightscout.androidaps.dialogs.CalibrationDialog;
|
|
||||||
import info.nightscout.androidaps.dialogs.CarbsDialog;
|
|
||||||
import info.nightscout.androidaps.dialogs.InsulinDialog;
|
|
||||||
import info.nightscout.androidaps.dialogs.TreatmentDialog;
|
|
||||||
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog;
|
|
||||||
import info.nightscout.androidaps.dialogs.TempTargetDialog;
|
|
||||||
import info.nightscout.androidaps.dialogs.WizardDialog;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData;
|
import info.nightscout.androidaps.plugins.general.overview.graphData.GraphData;
|
||||||
import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler;
|
import info.nightscout.androidaps.plugins.general.wear.ActionStringHandler;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
||||||
|
@ -105,7 +106,6 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCa
|
||||||
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin;
|
import info.nightscout.androidaps.plugins.source.SourceDexcomPlugin;
|
||||||
import info.nightscout.androidaps.plugins.source.SourceXdripPlugin;
|
import info.nightscout.androidaps.plugins.source.SourceXdripPlugin;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.dialogs.ProfileViewerDialog;
|
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.utils.BolusWizard;
|
import info.nightscout.androidaps.utils.BolusWizard;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
@ -883,10 +883,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
getContext().startActivity(intent);
|
getContext().startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
} catch (ActivityNotFoundException e) {
|
} catch (ActivityNotFoundException e) {
|
||||||
new AlertDialog.Builder(getContext())
|
OKDialog.show(getContext(), "", MainApp.gs(R.string.error_starting_cgm));
|
||||||
.setMessage(R.string.error_starting_cgm)
|
|
||||||
.setPositiveButton("OK", null)
|
|
||||||
.show();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -912,16 +909,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
LoopPlugin.getPlugin().invoke("Accept temp button", false);
|
LoopPlugin.getPlugin().invoke("Accept temp button", false);
|
||||||
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
||||||
if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.isChangeRequested()) {
|
if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.isChangeRequested()) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
OKDialog.showConfirmation(context, MainApp.gs(R.string.pump_tempbasal_label), finalLastRun.constraintsProcessed.toSpanned(), () -> {
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(MainApp.gs(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
|
|
||||||
hideTempRecommendation();
|
hideTempRecommendation();
|
||||||
clearNotification();
|
clearNotification();
|
||||||
LoopPlugin.getPlugin().acceptChangeRequest();
|
LoopPlugin.getPlugin().acceptChangeRequest();
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -941,7 +933,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(quickWizardEntry.carbs())).value();
|
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(quickWizardEntry.carbs())).value();
|
||||||
|
|
||||||
if (Math.abs(wizard.getInsulinAfterConstraints() - wizard.getCalculatedTotalInsulin()) >= pump.getPumpDescription().pumpType.determineCorrectBolusStepSize(wizard.getInsulinAfterConstraints()) || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) {
|
if (Math.abs(wizard.getInsulinAfterConstraints() - wizard.getCalculatedTotalInsulin()) >= pump.getPumpDescription().pumpType.determineCorrectBolusStepSize(wizard.getInsulinAfterConstraints()) || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) {
|
||||||
OKDialog.show(getContext(), MainApp.gs(R.string.treatmentdeliveryerror), MainApp.gs(R.string.constraints_violation) + "\n" + MainApp.gs(R.string.changeyourinput), null);
|
OKDialog.show(getContext(), MainApp.gs(R.string.treatmentdeliveryerror), MainApp.gs(R.string.constraints_violation) + "\n" + MainApp.gs(R.string.changeyourinput));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1170,7 +1162,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
fullText += MainApp.gs(R.string.pump_tempbasal_label) + ": " + activeTemp.toStringFull();
|
fullText += MainApp.gs(R.string.pump_tempbasal_label) + ": " + activeTemp.toStringFull();
|
||||||
}
|
}
|
||||||
OKDialog.show(getActivity(), MainApp.gs(R.string.basal), fullText, null);
|
OKDialog.show(getActivity(), MainApp.gs(R.string.basal), fullText);
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1206,7 +1198,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
extendedBolusView.setText(extendedBolusText);
|
extendedBolusView.setText(extendedBolusText);
|
||||||
if (Config.NSCLIENT) {
|
if (Config.NSCLIENT) {
|
||||||
extendedBolusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.extendedbolus), extendedBolus.toString(), null));
|
extendedBolusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.extended_bolus), extendedBolus.toString()));
|
||||||
}
|
}
|
||||||
if (extendedBolusText.equals(""))
|
if (extendedBolusText.equals(""))
|
||||||
extendedBolusView.setVisibility(Config.NSCLIENT ? View.INVISIBLE : View.GONE);
|
extendedBolusView.setVisibility(Config.NSCLIENT ? View.INVISIBLE : View.GONE);
|
||||||
|
@ -1300,7 +1292,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
String iobtext1 = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U\n"
|
String iobtext1 = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U\n"
|
||||||
+ MainApp.gs(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U\n"
|
+ MainApp.gs(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U\n"
|
||||||
+ MainApp.gs(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U\n";
|
+ MainApp.gs(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U\n";
|
||||||
OKDialog.show(getActivity(), MainApp.gs(R.string.iob), iobtext1, null);
|
OKDialog.show(getActivity(), MainApp.gs(R.string.iob), iobtext1);
|
||||||
});
|
});
|
||||||
} else if (MainApp.sResources.getBoolean(R.bool.isTablet)) {
|
} else if (MainApp.sResources.getBoolean(R.bool.isTablet)) {
|
||||||
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
||||||
|
@ -1352,19 +1344,19 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
// pump status from ns
|
// pump status from ns
|
||||||
if (pumpDeviceStatusView != null) {
|
if (pumpDeviceStatusView != null) {
|
||||||
pumpDeviceStatusView.setText(NSDeviceStatus.getInstance().getPumpStatus());
|
pumpDeviceStatusView.setText(NSDeviceStatus.getInstance().getPumpStatus());
|
||||||
pumpDeviceStatusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.pump), NSDeviceStatus.getInstance().getExtendedPumpStatus(), null));
|
pumpDeviceStatusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.pump), NSDeviceStatus.getInstance().getExtendedPumpStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenAPS status from ns
|
// OpenAPS status from ns
|
||||||
if (openapsDeviceStatusView != null) {
|
if (openapsDeviceStatusView != null) {
|
||||||
openapsDeviceStatusView.setText(NSDeviceStatus.getInstance().getOpenApsStatus());
|
openapsDeviceStatusView.setText(NSDeviceStatus.getInstance().getOpenApsStatus());
|
||||||
openapsDeviceStatusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.openaps), NSDeviceStatus.getInstance().getExtendedOpenApsStatus(), null));
|
openapsDeviceStatusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.openaps), NSDeviceStatus.getInstance().getExtendedOpenApsStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uploader status from ns
|
// Uploader status from ns
|
||||||
if (uploaderDeviceStatusView != null) {
|
if (uploaderDeviceStatusView != null) {
|
||||||
uploaderDeviceStatusView.setText(NSDeviceStatus.getInstance().getUploaderStatusSpanned());
|
uploaderDeviceStatusView.setText(NSDeviceStatus.getInstance().getUploaderStatusSpanned());
|
||||||
uploaderDeviceStatusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.uploader), NSDeviceStatus.getInstance().getExtendedUploaderStatus(), null));
|
uploaderDeviceStatusView.setOnClickListener(v -> OKDialog.show(getActivity(), MainApp.gs(R.string.uploader), NSDeviceStatus.getInstance().getExtendedUploaderStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sensitivity
|
// Sensitivity
|
||||||
|
|
|
@ -116,13 +116,13 @@ object TidepoolUploader {
|
||||||
val call = session.service?.getLogin(it)
|
val call = session.service?.getLogin(it)
|
||||||
|
|
||||||
call?.enqueue(TidepoolCallback<AuthReplyMessage>(session, "Login", {
|
call?.enqueue(TidepoolCallback<AuthReplyMessage>(session, "Login", {
|
||||||
OKDialog.show(rootContext, MainApp.gs(R.string.tidepool), "Successfully logged into Tidepool.", null)
|
OKDialog.show(rootContext, MainApp.gs(R.string.tidepool), "Successfully logged into Tidepool.")
|
||||||
}, {
|
}, {
|
||||||
OKDialog.show(rootContext, MainApp.gs(R.string.tidepool), "Failed to log into Tidepool.\nCheck that your user name and password are correct.", null)
|
OKDialog.show(rootContext, MainApp.gs(R.string.tidepool), "Failed to log into Tidepool.\nCheck that your user name and password are correct.")
|
||||||
}))
|
}))
|
||||||
|
|
||||||
}
|
}
|
||||||
?: OKDialog.show(rootContext, MainApp.gs(R.string.tidepool), "Cannot do login as user credentials have not been set correctly", null)
|
?: OKDialog.show(rootContext, MainApp.gs(R.string.tidepool), "Cannot do login as user credentials have not been set correctly")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.profile.local
|
package info.nightscout.androidaps.plugins.profile.local
|
||||||
|
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
|
@ -14,9 +13,9 @@ import info.nightscout.androidaps.Constants
|
||||||
import info.nightscout.androidaps.MainApp
|
import info.nightscout.androidaps.MainApp
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
|
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.dialogs.ProfileSwitchDialog
|
|
||||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.MIN_DIA
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.MIN_DIA
|
||||||
import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfileChanged
|
import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfileChanged
|
||||||
import info.nightscout.androidaps.utils.*
|
import info.nightscout.androidaps.utils.*
|
||||||
|
@ -107,7 +106,7 @@ class LocalProfileFragment : Fragment() {
|
||||||
// Spinner
|
// Spinner
|
||||||
spinner = SpinnerHelper(view?.findViewById(R.id.localprofile_spinner))
|
spinner = SpinnerHelper(view?.findViewById(R.id.localprofile_spinner))
|
||||||
val profileList: ArrayList<CharSequence> = LocalProfilePlugin.profile?.getProfileList()
|
val profileList: ArrayList<CharSequence> = LocalProfilePlugin.profile?.getProfileList()
|
||||||
?: ArrayList()
|
?: ArrayList()
|
||||||
context?.let { context ->
|
context?.let { context ->
|
||||||
val adapter = ArrayAdapter(context, R.layout.spinner_centered, profileList)
|
val adapter = ArrayAdapter(context, R.layout.spinner_centered, profileList)
|
||||||
spinner?.adapter = adapter
|
spinner?.adapter = adapter
|
||||||
|
@ -120,10 +119,10 @@ class LocalProfileFragment : Fragment() {
|
||||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||||
if (LocalProfilePlugin.isEdited) {
|
if (LocalProfilePlugin.isEdited) {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.doyouwantswitchprofile), {
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.doyouwantswitchprofile), Runnable {
|
||||||
LocalProfilePlugin.currentProfileIndex = position
|
LocalProfilePlugin.currentProfileIndex = position
|
||||||
build()
|
build()
|
||||||
}, {
|
}, Runnable {
|
||||||
spinner?.setSelection(LocalProfilePlugin.currentProfileIndex)
|
spinner?.setSelection(LocalProfilePlugin.currentProfileIndex)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -136,7 +135,7 @@ class LocalProfileFragment : Fragment() {
|
||||||
|
|
||||||
localprofile_profile_add.setOnClickListener {
|
localprofile_profile_add.setOnClickListener {
|
||||||
if (LocalProfilePlugin.isEdited) {
|
if (LocalProfilePlugin.isEdited) {
|
||||||
activity?.let { OKDialog.show(it, "", MainApp.gs(R.string.saveorresetchangesfirst), null) }
|
activity?.let { OKDialog.show(it, "", MainApp.gs(R.string.saveorresetchangesfirst)) }
|
||||||
} else {
|
} else {
|
||||||
LocalProfilePlugin.addNewProfile()
|
LocalProfilePlugin.addNewProfile()
|
||||||
build()
|
build()
|
||||||
|
@ -145,7 +144,7 @@ class LocalProfileFragment : Fragment() {
|
||||||
|
|
||||||
localprofile_profile_clone.setOnClickListener {
|
localprofile_profile_clone.setOnClickListener {
|
||||||
if (LocalProfilePlugin.isEdited) {
|
if (LocalProfilePlugin.isEdited) {
|
||||||
activity?.let { OKDialog.show(it, "", MainApp.gs(R.string.saveorresetchangesfirst), null) }
|
activity?.let { OKDialog.show(it, "", MainApp.gs(R.string.saveorresetchangesfirst)) }
|
||||||
} else {
|
} else {
|
||||||
LocalProfilePlugin.cloneProfile()
|
LocalProfilePlugin.cloneProfile()
|
||||||
build()
|
build()
|
||||||
|
@ -154,7 +153,7 @@ class LocalProfileFragment : Fragment() {
|
||||||
|
|
||||||
localprofile_profile_remove.setOnClickListener {
|
localprofile_profile_remove.setOnClickListener {
|
||||||
activity?.let { activity ->
|
activity?.let { activity ->
|
||||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.deletecurrentprofile), {
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.deletecurrentprofile), Runnable {
|
||||||
LocalProfilePlugin.removeCurrentProfile()
|
LocalProfilePlugin.removeCurrentProfile()
|
||||||
build()
|
build()
|
||||||
}, null)
|
}, null)
|
||||||
|
@ -199,9 +198,9 @@ class LocalProfileFragment : Fragment() {
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable.add(RxBus
|
disposable.add(RxBus
|
||||||
.toObservable(EventLocalProfileChanged::class.java)
|
.toObservable(EventLocalProfileChanged::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({ build() }, { FabricPrivacy.logException(it) })
|
.subscribe({ build() }, { FabricPrivacy.logException(it) })
|
||||||
)
|
)
|
||||||
build()
|
build()
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,11 @@ import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
object LocalProfilePlugin : PluginBase(PluginDescription()
|
object LocalProfilePlugin : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.PROFILE)
|
.mainType(PluginType.PROFILE)
|
||||||
.fragmentClass(LocalProfileFragment::class.java.name)
|
.fragmentClass(LocalProfileFragment::class.java.name)
|
||||||
.pluginName(R.string.localprofile)
|
.pluginName(R.string.localprofile)
|
||||||
.shortName(R.string.localprofile_shortname)
|
.shortName(R.string.localprofile_shortname)
|
||||||
.description(R.string.description_profile_local)), ProfileInterface {
|
.description(R.string.description_profile_local)), ProfileInterface {
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
|
@ -98,7 +98,7 @@ object LocalProfilePlugin : PluginBase(PluginDescription()
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun isValidEditState(): Boolean {
|
fun isValidEditState(): Boolean {
|
||||||
return createProfileStore().getDefaultProfile()?.isValid(MainApp.gs(R.string.localprofile), false)
|
return createProfileStore().getDefaultProfile()?.isValid(MainApp.gs(R.string.localprofile), false)
|
||||||
?: false
|
?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
|
@ -132,7 +132,7 @@ object LocalProfilePlugin : PluginBase(PluginDescription()
|
||||||
rawProfile?.let { NSUpload.uploadProfileStore(it.data) }
|
rawProfile?.let { NSUpload.uploadProfileStore(it.data) }
|
||||||
else
|
else
|
||||||
activity?.let {
|
activity?.let {
|
||||||
OKDialog.show(it,"", MainApp.gs(R.string.profilenamecontainsdot), null)
|
OKDialog.show(it, "", MainApp.gs(R.string.profilenamecontainsdot))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,7 +423,7 @@ object LocalProfilePlugin : PluginBase(PluginDescription()
|
||||||
|
|
||||||
override fun getProfileName(): String {
|
override fun getProfileName(): String {
|
||||||
return DecimalFormatter.to2Decimal(rawProfile?.getDefaultProfile()?.percentageBasalSum()
|
return DecimalFormatter.to2Decimal(rawProfile?.getDefaultProfile()?.percentageBasalSum()
|
||||||
?: 0.0) + "U "
|
?: 0.0) + "U "
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@ import kotlinx.android.synthetic.main.close.*
|
||||||
import kotlinx.android.synthetic.main.nsprofile_fragment.*
|
import kotlinx.android.synthetic.main.nsprofile_fragment.*
|
||||||
import kotlinx.android.synthetic.main.profileviewer_fragment.*
|
import kotlinx.android.synthetic.main.profileviewer_fragment.*
|
||||||
|
|
||||||
|
|
||||||
class NSProfileFragment : Fragment() {
|
class NSProfileFragment : Fragment() {
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
@ -40,10 +39,11 @@ class NSProfileFragment : Fragment() {
|
||||||
val name = nsprofile_spinner.selectedItem?.toString() ?: ""
|
val name = nsprofile_spinner.selectedItem?.toString() ?: ""
|
||||||
NSProfilePlugin.getPlugin().profile?.let { store ->
|
NSProfilePlugin.getPlugin().profile?.let { store ->
|
||||||
store.getSpecificProfile(name)?.let {
|
store.getSpecificProfile(name)?.let {
|
||||||
OKDialog.showConfirmation(activity,
|
activity?.let { activity ->
|
||||||
MainApp.gs(R.string.activate_profile) + ": " + name + " ?"
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.nsprofile),
|
||||||
) {
|
MainApp.gs(R.string.activate_profile) + ": " + name + " ?", Runnable {
|
||||||
ProfileFunctions.doProfileSwitch(store, name, 0, 100, 0, DateUtil.now())
|
ProfileFunctions.doProfileSwitch(store, name, 0, 100, 0, DateUtil.now())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,13 +97,9 @@ class NSProfileFragment : Fragment() {
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable.add(RxBus
|
disposable.add(RxBus
|
||||||
.toObservable(EventNSProfileUpdateGUI::class.java)
|
.toObservable(EventNSProfileUpdateGUI::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({
|
.subscribe({ updateGUI() }, { FabricPrivacy.logException(it) })
|
||||||
updateGUI()
|
|
||||||
}, {
|
|
||||||
FabricPrivacy.logException(it)
|
|
||||||
})
|
|
||||||
)
|
)
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.utils;
|
package info.nightscout.androidaps.plugins.pump.common.utils;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
import android.os.Build;
|
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for checking if location services are enabled on the device.
|
* Helper for checking if location services are enabled on the device.
|
||||||
|
@ -45,18 +44,9 @@ public class LocationHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shamelessly borrowed from http://stackoverflow.com/a/10311877/868533
|
// Shamelessly borrowed from http://stackoverflow.com/a/10311877/868533
|
||||||
|
OKDialog.showConfirmation(parent, MainApp.gs(R.string.location_not_found_title), MainApp.gs(R.string.location_not_found_message), () -> {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parent);
|
parent.startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
|
||||||
builder.setTitle(R.string.location_not_found_title);
|
|
||||||
builder.setMessage(R.string.location_not_found_message);
|
|
||||||
builder.setPositiveButton(R.string.location_yes, new DialogInterface.OnClickListener() {
|
|
||||||
|
|
||||||
public void onClick(DialogInterface dialogInterface, int i) {
|
|
||||||
parent.startActivity(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(R.string.location_no, null);
|
|
||||||
builder.create().show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.source;
|
package info.nightscout.androidaps.plugins.source;
|
||||||
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -9,7 +8,6 @@ import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
@ -25,6 +23,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
import info.nightscout.androidaps.utils.T;
|
import info.nightscout.androidaps.utils.T;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
@ -35,17 +34,17 @@ import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class BGSourceFragment extends Fragment {
|
public class BGSourceFragment extends Fragment {
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
|
|
||||||
final long MILLS_TO_THE_PAST = T.hours(12).msecs();
|
private final long MILLS_TO_THE_PAST = T.hours(12).msecs();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
try {
|
try {
|
||||||
View view = inflater.inflate(R.layout.bgsource_fragment, container, false);
|
View view = inflater.inflate(R.layout.bgsource_fragment, container, false);
|
||||||
|
|
||||||
recyclerView = (RecyclerView) view.findViewById(R.id.bgsource_recyclerview);
|
recyclerView = view.findViewById(R.id.bgsource_recyclerview);
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
LinearLayoutManager llm = new LinearLayoutManager(view.getContext());
|
LinearLayoutManager llm = new LinearLayoutManager(view.getContext());
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
|
@ -91,6 +90,7 @@ public class BGSourceFragment extends Fragment {
|
||||||
this.bgReadings = bgReadings;
|
this.bgReadings = bgReadings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public BgReadingsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
public BgReadingsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.bgsource_item, viewGroup, false);
|
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.bgsource_item, viewGroup, false);
|
||||||
|
@ -113,7 +113,7 @@ public class BGSourceFragment extends Fragment {
|
||||||
return bgReadings.size();
|
return bgReadings.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
class BgReadingsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
class BgReadingsViewHolder extends RecyclerView.ViewHolder {
|
||||||
TextView date;
|
TextView date;
|
||||||
TextView value;
|
TextView value;
|
||||||
TextView direction;
|
TextView direction;
|
||||||
|
@ -123,46 +123,22 @@ public class BGSourceFragment extends Fragment {
|
||||||
|
|
||||||
BgReadingsViewHolder(View itemView) {
|
BgReadingsViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
date = (TextView) itemView.findViewById(R.id.bgsource_date);
|
date = itemView.findViewById(R.id.bgsource_date);
|
||||||
value = (TextView) itemView.findViewById(R.id.bgsource_value);
|
value = itemView.findViewById(R.id.bgsource_value);
|
||||||
direction = (TextView) itemView.findViewById(R.id.bgsource_direction);
|
direction = itemView.findViewById(R.id.bgsource_direction);
|
||||||
invalid = (TextView) itemView.findViewById(R.id.invalid_sign);
|
invalid = itemView.findViewById(R.id.invalid_sign);
|
||||||
ns = (TextView) itemView.findViewById(R.id.ns_sign);
|
ns = itemView.findViewById(R.id.ns_sign);
|
||||||
remove = (TextView) itemView.findViewById(R.id.bgsource_remove);
|
remove = itemView.findViewById(R.id.bgsource_remove);
|
||||||
remove.setOnClickListener(this);
|
remove.setOnClickListener(v -> {
|
||||||
|
final BgReading bgReading = (BgReading) v.getTag();
|
||||||
|
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(ProfileFunctions.getSystemUnits()), () -> {
|
||||||
|
bgReading.isValid = false;
|
||||||
|
MainApp.getDbHelper().update(bgReading);
|
||||||
|
updateGUI();
|
||||||
|
});
|
||||||
|
});
|
||||||
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
final BgReading bgReading = (BgReading) v.getTag();
|
|
||||||
switch (v.getId()) {
|
|
||||||
|
|
||||||
case R.id.bgsource_remove:
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(ProfileFunctions.getSystemUnits()));
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
/* final String _id = bgReading._id;
|
|
||||||
if (NSUpload.isIdValid(_id)) {
|
|
||||||
NSUpload.removeFoodFromNS(_id);
|
|
||||||
} else {
|
|
||||||
UploadQueue.removeID("dbAdd", _id);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
bgReading.isValid = false;
|
|
||||||
MainApp.getDbHelper().update(bgReading);
|
|
||||||
updateGUI();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.treatments.fragments;
|
package info.nightscout.androidaps.plugins.treatments.fragments;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -10,7 +8,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.cardview.widget.CardView;
|
import androidx.cardview.widget.CardView;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
@ -38,24 +36,21 @@ import info.nightscout.androidaps.plugins.treatments.dialogs.WizardInfoDialog;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
import static info.nightscout.androidaps.utils.DateUtil.now;
|
import static info.nightscout.androidaps.utils.DateUtil.now;
|
||||||
|
|
||||||
public class TreatmentsBolusFragment extends Fragment implements View.OnClickListener {
|
public class TreatmentsBolusFragment extends Fragment {
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
LinearLayoutManager llm;
|
|
||||||
|
|
||||||
TextView iobTotal;
|
private TextView iobTotal;
|
||||||
TextView activityTotal;
|
private TextView activityTotal;
|
||||||
Button refreshFromNS;
|
private Button deleteFutureTreatments;
|
||||||
Button deleteFutureTreatments;
|
|
||||||
|
|
||||||
Context context;
|
|
||||||
|
|
||||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TreatmentsViewHolder> {
|
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TreatmentsViewHolder> {
|
||||||
|
|
||||||
|
@ -65,6 +60,7 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
|
||||||
this.treatments = treatments;
|
this.treatments = treatments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public TreatmentsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
public TreatmentsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_bolus_item, viewGroup, false);
|
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_bolus_item, viewGroup, false);
|
||||||
|
@ -72,16 +68,16 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(TreatmentsViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull TreatmentsViewHolder holder, int position) {
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return;
|
return;
|
||||||
Treatment t = treatments.get(position);
|
Treatment t = treatments.get(position);
|
||||||
holder.date.setText(DateUtil.dateAndTimeString(t.date));
|
holder.date.setText(DateUtil.dateAndTimeString(t.date));
|
||||||
holder.insulin.setText(DecimalFormatter.toPumpSupportedBolus(t.insulin) + " U");
|
holder.insulin.setText(MainApp.gs(R.string.formatinsulinunits, t.insulin));
|
||||||
holder.carbs.setText(DecimalFormatter.to0Decimal(t.carbs) + " g");
|
holder.carbs.setText(MainApp.gs(R.string.format_carbs, (int) t.carbs));
|
||||||
Iob iob = t.iobCalc(System.currentTimeMillis(), profile.getDia());
|
Iob iob = t.iobCalc(System.currentTimeMillis(), profile.getDia());
|
||||||
holder.iob.setText(DecimalFormatter.to2Decimal(iob.iobContrib) + " U");
|
holder.iob.setText(MainApp.gs(R.string.formatinsulinunits, iob.iobContrib));
|
||||||
holder.mealOrCorrection.setText(t.isSMB ? "SMB" : t.mealBolus ? MainApp.gs(R.string.mealbolus) : MainApp.gs(R.string.correctionbous));
|
holder.mealOrCorrection.setText(t.isSMB ? "SMB" : t.mealBolus ? MainApp.gs(R.string.mealbolus) : MainApp.gs(R.string.correctionbous));
|
||||||
holder.ph.setVisibility(t.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
holder.ph.setVisibility(t.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
||||||
holder.ns.setVisibility(NSUpload.isIdValid(t._id) ? View.VISIBLE : View.GONE);
|
holder.ns.setVisibility(NSUpload.isIdValid(t._id) ? View.VISIBLE : View.GONE);
|
||||||
|
@ -105,7 +101,7 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||||
super.onAttachedToRecyclerView(recyclerView);
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,19 +120,19 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
|
||||||
|
|
||||||
TreatmentsViewHolder(View itemView) {
|
TreatmentsViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
cv = (CardView) itemView.findViewById(R.id.treatments_cardview);
|
cv = itemView.findViewById(R.id.treatments_cardview);
|
||||||
date = (TextView) itemView.findViewById(R.id.treatments_date);
|
date = itemView.findViewById(R.id.treatments_date);
|
||||||
insulin = (TextView) itemView.findViewById(R.id.treatments_insulin);
|
insulin = itemView.findViewById(R.id.treatments_insulin);
|
||||||
carbs = (TextView) itemView.findViewById(R.id.treatments_carbs);
|
carbs = itemView.findViewById(R.id.treatments_carbs);
|
||||||
iob = (TextView) itemView.findViewById(R.id.treatments_iob);
|
iob = itemView.findViewById(R.id.treatments_iob);
|
||||||
mealOrCorrection = (TextView) itemView.findViewById(R.id.treatments_mealorcorrection);
|
mealOrCorrection = itemView.findViewById(R.id.treatments_mealorcorrection);
|
||||||
ph = (TextView) itemView.findViewById(R.id.pump_sign);
|
ph = itemView.findViewById(R.id.pump_sign);
|
||||||
ns = (TextView) itemView.findViewById(R.id.ns_sign);
|
ns = itemView.findViewById(R.id.ns_sign);
|
||||||
invalid = (TextView) itemView.findViewById(R.id.invalid_sign);
|
invalid = itemView.findViewById(R.id.invalid_sign);
|
||||||
calculation = (TextView) itemView.findViewById(R.id.treatments_calculation);
|
calculation = itemView.findViewById(R.id.treatments_calculation);
|
||||||
calculation.setOnClickListener(this);
|
calculation.setOnClickListener(this);
|
||||||
calculation.setPaintFlags(calculation.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
calculation.setPaintFlags(calculation.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
remove = (TextView) itemView.findViewById(R.id.treatments_remove);
|
remove = itemView.findViewById(R.id.treatments_remove);
|
||||||
remove.setOnClickListener(this);
|
remove.setOnClickListener(this);
|
||||||
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
}
|
}
|
||||||
|
@ -148,28 +144,25 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
|
||||||
return;
|
return;
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.treatments_remove:
|
case R.id.treatments_remove:
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.removerecord),
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
MainApp.gs(R.string.configbuilder_insulin) + ": " + MainApp.gs(R.string.formatinsulinunits, treatment.insulin) +
|
||||||
builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(treatment.date));
|
"\n" + MainApp.gs(R.string.carbs) + ": " + MainApp.gs(R.string.format_carbs, (int) treatment.carbs) +
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
|
"\n" + MainApp.gs(R.string.date) + ": " + DateUtil.dateAndTimeString(treatment.date),
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
(dialog, id) -> {
|
||||||
final String _id = treatment._id;
|
final String _id = treatment._id;
|
||||||
if (treatment.source == Source.PUMP) {
|
if (treatment.source == Source.PUMP) {
|
||||||
treatment.isValid = false;
|
treatment.isValid = false;
|
||||||
TreatmentsPlugin.getPlugin().getService().update(treatment);
|
TreatmentsPlugin.getPlugin().getService().update(treatment);
|
||||||
} else {
|
|
||||||
if (NSUpload.isIdValid(_id)) {
|
|
||||||
NSUpload.removeCareportalEntryFromNS(_id);
|
|
||||||
} else {
|
} else {
|
||||||
UploadQueue.removeID("dbAdd", _id);
|
if (NSUpload.isIdValid(_id)) {
|
||||||
|
NSUpload.removeCareportalEntryFromNS(_id);
|
||||||
|
} else {
|
||||||
|
UploadQueue.removeID("dbAdd", _id);
|
||||||
|
}
|
||||||
|
TreatmentsPlugin.getPlugin().getService().delete(treatment);
|
||||||
}
|
}
|
||||||
TreatmentsPlugin.getPlugin().getService().delete(treatment);
|
updateGui();
|
||||||
}
|
}, null);
|
||||||
updateGui();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
break;
|
break;
|
||||||
case R.id.treatments_calculation:
|
case R.id.treatments_calculation:
|
||||||
FragmentManager manager = getFragmentManager();
|
FragmentManager manager = getFragmentManager();
|
||||||
|
@ -193,71 +186,48 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.treatments_bolus_fragment, container, false);
|
View view = inflater.inflate(R.layout.treatments_bolus_fragment, container, false);
|
||||||
|
|
||||||
recyclerView = (RecyclerView) view.findViewById(R.id.treatments_recyclerview);
|
recyclerView = view.findViewById(R.id.treatments_recyclerview);
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
llm = new LinearLayoutManager(view.getContext());
|
LinearLayoutManager llm = new LinearLayoutManager(view.getContext());
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
|
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getTreatmentsFromHistory());
|
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getTreatmentsFromHistory());
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
iobTotal = (TextView) view.findViewById(R.id.treatments_iobtotal);
|
iobTotal = view.findViewById(R.id.treatments_iobtotal);
|
||||||
activityTotal = (TextView) view.findViewById(R.id.treatments_iobactivitytotal);
|
activityTotal = view.findViewById(R.id.treatments_iobactivitytotal);
|
||||||
|
|
||||||
refreshFromNS = (Button) view.findViewById(R.id.treatments_reshreshfromnightscout);
|
Button refreshFromNS = view.findViewById(R.id.treatments_reshreshfromnightscout);
|
||||||
refreshFromNS.setOnClickListener(this);
|
refreshFromNS.setOnClickListener(v -> OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.refresheventsfromnightscout) + "?", () -> {
|
||||||
|
TreatmentsPlugin.getPlugin().getService().resetTreatments();
|
||||||
|
RxBus.INSTANCE.send(new EventNSClientRestart());
|
||||||
|
}));
|
||||||
|
|
||||||
deleteFutureTreatments = (Button) view.findViewById(R.id.treatments_delete_future_treatments);
|
deleteFutureTreatments = view.findViewById(R.id.treatments_delete_future_treatments);
|
||||||
deleteFutureTreatments.setOnClickListener(this);
|
deleteFutureTreatments.setOnClickListener(v -> {
|
||||||
|
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.overview_treatment_label), MainApp.gs(R.string.deletefuturetreatments) + "?", () -> {
|
||||||
|
final List<Treatment> futureTreatments = TreatmentsPlugin.getPlugin().getService()
|
||||||
|
.getTreatmentDataFromTime(now() + 1000, true);
|
||||||
|
for (Treatment treatment : futureTreatments) {
|
||||||
|
final String _id = treatment._id;
|
||||||
|
if (NSUpload.isIdValid(_id)) {
|
||||||
|
NSUpload.removeCareportalEntryFromNS(_id);
|
||||||
|
} else {
|
||||||
|
UploadQueue.removeID("dbAdd", _id);
|
||||||
|
}
|
||||||
|
TreatmentsPlugin.getPlugin().getService().delete(treatment);
|
||||||
|
}
|
||||||
|
updateGui();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false);
|
boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false);
|
||||||
if (nsUploadOnly)
|
if (nsUploadOnly)
|
||||||
refreshFromNS.setVisibility(View.GONE);
|
refreshFromNS.setVisibility(View.GONE);
|
||||||
|
|
||||||
context = getContext();
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
AlertDialog.Builder builder;
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.treatments_reshreshfromnightscout:
|
|
||||||
builder = new AlertDialog.Builder(this.getContext());
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(MainApp.gs(R.string.refresheventsfromnightscout) + "?");
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
|
|
||||||
TreatmentsPlugin.getPlugin().getService().resetTreatments();
|
|
||||||
RxBus.INSTANCE.send(new EventNSClientRestart());
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
break;
|
|
||||||
case R.id.treatments_delete_future_treatments:
|
|
||||||
builder = new AlertDialog.Builder(this.getContext());
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(MainApp.gs(R.string.deletefuturetreatments) + "?");
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
|
|
||||||
final List<Treatment> futureTreatments = TreatmentsPlugin.getPlugin().getService()
|
|
||||||
.getTreatmentDataFromTime(now() + 1000, true);
|
|
||||||
for (Treatment treatment : futureTreatments) {
|
|
||||||
final String _id = treatment._id;
|
|
||||||
if (NSUpload.isIdValid(_id)) {
|
|
||||||
NSUpload.removeCareportalEntryFromNS(_id);
|
|
||||||
} else {
|
|
||||||
UploadQueue.removeID("dbAdd", _id);
|
|
||||||
}
|
|
||||||
TreatmentsPlugin.getPlugin().getService().delete(treatment);
|
|
||||||
}
|
|
||||||
updateGui();
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void onResume() {
|
public synchronized void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
@ -292,5 +262,4 @@ public class TreatmentsBolusFragment extends Fragment implements View.OnClickLis
|
||||||
deleteFutureTreatments.setVisibility(View.GONE);
|
deleteFutureTreatments.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.treatments.fragments;
|
package info.nightscout.androidaps.plugins.treatments.fragments;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -10,7 +8,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.cardview.widget.CardView;
|
import androidx.cardview.widget.CardView;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
@ -28,6 +26,7 @@ import info.nightscout.androidaps.plugins.general.nsclient.UploadQueue;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import info.nightscout.androidaps.utils.Translator;
|
import info.nightscout.androidaps.utils.Translator;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
|
@ -37,14 +36,10 @@ import io.reactivex.disposables.CompositeDisposable;
|
||||||
* Created by mike on 13/01/17.
|
* Created by mike on 13/01/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class TreatmentsCareportalFragment extends Fragment implements View.OnClickListener {
|
public class TreatmentsCareportalFragment extends Fragment {
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
LinearLayoutManager llm;
|
|
||||||
Button refreshFromNS;
|
|
||||||
|
|
||||||
Context context;
|
|
||||||
|
|
||||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.CareportalEventsViewHolder> {
|
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.CareportalEventsViewHolder> {
|
||||||
|
|
||||||
|
@ -54,11 +49,11 @@ public class TreatmentsCareportalFragment extends Fragment implements View.OnCli
|
||||||
this.careportalEventList = careportalEventList;
|
this.careportalEventList = careportalEventList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public CareportalEventsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
public CareportalEventsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_careportal_item, viewGroup, false);
|
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_careportal_item, viewGroup, false);
|
||||||
CareportalEventsViewHolder CareportalEventsViewHolder = new CareportalEventsViewHolder(v);
|
return new CareportalEventsViewHolder(v);
|
||||||
return CareportalEventsViewHolder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,11 +72,11 @@ public class TreatmentsCareportalFragment extends Fragment implements View.OnCli
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||||
super.onAttachedToRecyclerView(recyclerView);
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CareportalEventsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
class CareportalEventsViewHolder extends RecyclerView.ViewHolder {
|
||||||
CardView cv;
|
CardView cv;
|
||||||
TextView date;
|
TextView date;
|
||||||
TextView type;
|
TextView type;
|
||||||
|
@ -91,38 +86,30 @@ public class TreatmentsCareportalFragment extends Fragment implements View.OnCli
|
||||||
|
|
||||||
CareportalEventsViewHolder(View itemView) {
|
CareportalEventsViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
cv = (CardView) itemView.findViewById(R.id.careportal_cardview);
|
cv = itemView.findViewById(R.id.careportal_cardview);
|
||||||
date = (TextView) itemView.findViewById(R.id.careportal_date);
|
date = itemView.findViewById(R.id.careportal_date);
|
||||||
type = (TextView) itemView.findViewById(R.id.careportal_type);
|
type = itemView.findViewById(R.id.careportal_type);
|
||||||
note = (TextView) itemView.findViewById(R.id.careportal_note);
|
note = itemView.findViewById(R.id.careportal_note);
|
||||||
ns = (TextView) itemView.findViewById(R.id.ns_sign);
|
ns = itemView.findViewById(R.id.ns_sign);
|
||||||
remove = (TextView) itemView.findViewById(R.id.careportal_remove);
|
remove = itemView.findViewById(R.id.careportal_remove);
|
||||||
remove.setOnClickListener(this);
|
remove.setOnClickListener(v -> {
|
||||||
|
final CareportalEvent careportalEvent = (CareportalEvent) v.getTag();
|
||||||
|
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.removerecord),
|
||||||
|
"\n" + MainApp.gs(R.string.careportal_newnstreatment_eventtype) + ": " + Translator.translate(careportalEvent.eventType) +
|
||||||
|
"\n" + MainApp.gs(R.string.careportal_newnstreatment_notes_label) + ": " + careportalEvent.getNotes() +
|
||||||
|
"\n" + MainApp.gs(R.string.date) + ": " + DateUtil.dateAndTimeString(careportalEvent.date),
|
||||||
|
(dialog, id) -> {
|
||||||
|
final String _id = careportalEvent._id;
|
||||||
|
if (NSUpload.isIdValid(_id)) {
|
||||||
|
NSUpload.removeCareportalEntryFromNS(_id);
|
||||||
|
} else {
|
||||||
|
UploadQueue.removeID("dbAdd", _id);
|
||||||
|
}
|
||||||
|
MainApp.getDbHelper().delete(careportalEvent);
|
||||||
|
}, null);
|
||||||
|
});
|
||||||
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
final CareportalEvent careportalEvent = (CareportalEvent) v.getTag();
|
|
||||||
switch (v.getId()) {
|
|
||||||
case R.id.careportal_remove:
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(careportalEvent.date));
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
|
|
||||||
final String _id = careportalEvent._id;
|
|
||||||
if (NSUpload.isIdValid(_id)) {
|
|
||||||
NSUpload.removeCareportalEntryFromNS(_id);
|
|
||||||
} else {
|
|
||||||
UploadQueue.removeID("dbAdd", _id);
|
|
||||||
}
|
|
||||||
MainApp.getDbHelper().delete(careportalEvent);
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,20 +118,23 @@ public class TreatmentsCareportalFragment extends Fragment implements View.OnCli
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.treatments_careportal_fragment, container, false);
|
View view = inflater.inflate(R.layout.treatments_careportal_fragment, container, false);
|
||||||
|
|
||||||
recyclerView = (RecyclerView) view.findViewById(R.id.careportal_recyclerview);
|
recyclerView = view.findViewById(R.id.careportal_recyclerview);
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
llm = new LinearLayoutManager(view.getContext());
|
LinearLayoutManager llm = new LinearLayoutManager(view.getContext());
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
|
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getDbHelper().getCareportalEvents(false));
|
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getDbHelper().getCareportalEvents(false));
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
refreshFromNS = (Button) view.findViewById(R.id.careportal_refreshfromnightscout);
|
Button refreshFromNS = view.findViewById(R.id.careportal_refreshfromnightscout);
|
||||||
refreshFromNS.setOnClickListener(this);
|
refreshFromNS.setOnClickListener(v ->
|
||||||
|
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.careportal), MainApp.gs(R.string.refresheventsfromnightscout) + " ?", () -> {
|
||||||
|
MainApp.getDbHelper().resetCareportalEvents();
|
||||||
|
RxBus.INSTANCE.send(new EventNSClientRestart());
|
||||||
|
}));
|
||||||
|
|
||||||
view.findViewById(R.id.careportal_removeandroidapsstartedevents).setOnClickListener(this);
|
view.findViewById(R.id.careportal_removeandroidapsstartedevents).setOnClickListener(v ->
|
||||||
|
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.careportal), MainApp.gs(R.string.careportal_removestartedevents), this::removeAndroidAPSStatedEvents));
|
||||||
context = getContext();
|
|
||||||
|
|
||||||
boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false);
|
boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false);
|
||||||
if (nsUploadOnly)
|
if (nsUploadOnly)
|
||||||
|
@ -170,36 +160,6 @@ public class TreatmentsCareportalFragment extends Fragment implements View.OnCli
|
||||||
disposable.clear();
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.careportal_refreshfromnightscout:
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(MainApp.gs(R.string.refresheventsfromnightscout) + " ?");
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
MainApp.getDbHelper().resetCareportalEvents();
|
|
||||||
RxBus.INSTANCE.send(new EventNSClientRestart());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
break;
|
|
||||||
case R.id.careportal_removeandroidapsstartedevents:
|
|
||||||
builder = new AlertDialog.Builder(context);
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(MainApp.gs(R.string.careportal_removestartedevents));
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
|
|
||||||
removeAndroidAPSStatedEvents();
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateGui() {
|
private void updateGui() {
|
||||||
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getDbHelper().getCareportalEvents(false)), false);
|
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getDbHelper().getCareportalEvents(false)), false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.treatments.fragments;
|
package info.nightscout.androidaps.plugins.treatments.fragments;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -9,7 +7,7 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.cardview.widget.CardView;
|
import androidx.cardview.widget.CardView;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
@ -31,6 +29,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
|
@ -38,10 +37,7 @@ import io.reactivex.disposables.CompositeDisposable;
|
||||||
public class TreatmentsExtendedBolusesFragment extends Fragment {
|
public class TreatmentsExtendedBolusesFragment extends Fragment {
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
LinearLayoutManager llm;
|
|
||||||
|
|
||||||
Context context;
|
|
||||||
|
|
||||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ExtendedBolusesViewHolder> {
|
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.ExtendedBolusesViewHolder> {
|
||||||
|
|
||||||
|
@ -51,6 +47,7 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
|
||||||
this.extendedBolusList = extendedBolusList;
|
this.extendedBolusList = extendedBolusList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public ExtendedBolusesViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
public ExtendedBolusesViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_extendedbolus_item, viewGroup, false);
|
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_extendedbolus_item, viewGroup, false);
|
||||||
|
@ -101,11 +98,11 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||||
super.onAttachedToRecyclerView(recyclerView);
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ExtendedBolusesViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
class ExtendedBolusesViewHolder extends RecyclerView.ViewHolder {
|
||||||
CardView cv;
|
CardView cv;
|
||||||
TextView date;
|
TextView date;
|
||||||
TextView duration;
|
TextView duration;
|
||||||
|
@ -120,31 +117,22 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
|
||||||
|
|
||||||
ExtendedBolusesViewHolder(View itemView) {
|
ExtendedBolusesViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
cv = (CardView) itemView.findViewById(R.id.extendedboluses_cardview);
|
cv = itemView.findViewById(R.id.extendedboluses_cardview);
|
||||||
date = (TextView) itemView.findViewById(R.id.extendedboluses_date);
|
date = itemView.findViewById(R.id.extendedboluses_date);
|
||||||
duration = (TextView) itemView.findViewById(R.id.extendedboluses_duration);
|
duration = itemView.findViewById(R.id.extendedboluses_duration);
|
||||||
insulin = (TextView) itemView.findViewById(R.id.extendedboluses_insulin);
|
insulin = itemView.findViewById(R.id.extendedboluses_insulin);
|
||||||
realDuration = (TextView) itemView.findViewById(R.id.extendedboluses_realduration);
|
realDuration = itemView.findViewById(R.id.extendedboluses_realduration);
|
||||||
ratio = (TextView) itemView.findViewById(R.id.extendedboluses_ratio);
|
ratio = itemView.findViewById(R.id.extendedboluses_ratio);
|
||||||
insulinSoFar = (TextView) itemView.findViewById(R.id.extendedboluses_netinsulin);
|
insulinSoFar = itemView.findViewById(R.id.extendedboluses_netinsulin);
|
||||||
iob = (TextView) itemView.findViewById(R.id.extendedboluses_iob);
|
iob = itemView.findViewById(R.id.extendedboluses_iob);
|
||||||
ph = (TextView) itemView.findViewById(R.id.pump_sign);
|
ph = itemView.findViewById(R.id.pump_sign);
|
||||||
ns = (TextView) itemView.findViewById(R.id.ns_sign);
|
ns = itemView.findViewById(R.id.ns_sign);
|
||||||
remove = (TextView) itemView.findViewById(R.id.extendedboluses_remove);
|
remove = itemView.findViewById(R.id.extendedboluses_remove);
|
||||||
remove.setOnClickListener(this);
|
remove.setOnClickListener(v -> {
|
||||||
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
final ExtendedBolus extendedBolus = (ExtendedBolus) v.getTag();
|
||||||
}
|
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.removerecord),
|
||||||
|
MainApp.gs(R.string.extended_bolus)
|
||||||
@Override
|
+ "\n" + MainApp.gs(R.string.date) + ": " + DateUtil.dateAndTimeString(extendedBolus.date), (dialog, id) -> {
|
||||||
public void onClick(View v) {
|
|
||||||
final ExtendedBolus extendedBolus = (ExtendedBolus) v.getTag();
|
|
||||||
switch (v.getId()) {
|
|
||||||
case R.id.extendedboluses_remove:
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(extendedBolus.date));
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
final String _id = extendedBolus._id;
|
final String _id = extendedBolus._id;
|
||||||
if (NSUpload.isIdValid(_id)) {
|
if (NSUpload.isIdValid(_id)) {
|
||||||
NSUpload.removeCareportalEntryFromNS(_id);
|
NSUpload.removeCareportalEntryFromNS(_id);
|
||||||
|
@ -152,12 +140,9 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
|
||||||
UploadQueue.removeID("dbAdd", _id);
|
UploadQueue.removeID("dbAdd", _id);
|
||||||
}
|
}
|
||||||
MainApp.getDbHelper().delete(extendedBolus);
|
MainApp.getDbHelper().delete(extendedBolus);
|
||||||
}
|
}, null);
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
builder.show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,16 +152,14 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.treatments_extendedbolus_fragment, container, false);
|
View view = inflater.inflate(R.layout.treatments_extendedbolus_fragment, container, false);
|
||||||
|
|
||||||
recyclerView = (RecyclerView) view.findViewById(R.id.extendedboluses_recyclerview);
|
recyclerView = view.findViewById(R.id.extendedboluses_recyclerview);
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
llm = new LinearLayoutManager(view.getContext());
|
LinearLayoutManager llm = new LinearLayoutManager(view.getContext());
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
|
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory());
|
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory());
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
context = getContext();
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,5 +188,4 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
|
||||||
private void updateGui() {
|
private void updateGui() {
|
||||||
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory()), false);
|
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory()), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import androidx.cardview.widget.CardView
|
import androidx.cardview.widget.CardView
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
@ -42,18 +41,15 @@ class TreatmentsProfileSwitchFragment : Fragment() {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
profileswitch_recyclerview.setHasFixedSize(true)
|
profileswitch_recyclerview.setHasFixedSize(true)
|
||||||
profileswitch_recyclerview.layoutManager = LinearLayoutManager(view.context)
|
profileswitch_recyclerview.layoutManager = LinearLayoutManager(view.context)
|
||||||
profileswitch_recyclerview.adapter = RecyclerProfileViewAdapter(MainApp.getDbHelper().getProfileSwitchData(DateUtil.now() - T.days(30).msecs(),false))
|
profileswitch_recyclerview.adapter = RecyclerProfileViewAdapter(MainApp.getDbHelper().getProfileSwitchData(DateUtil.now() - T.days(30).msecs(), false))
|
||||||
|
|
||||||
profileswitch_refreshfromnightscout.setOnClickListener {
|
profileswitch_refreshfromnightscout.setOnClickListener {
|
||||||
val builder = AlertDialog.Builder(this.context!!)
|
activity?.let { activity ->
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation))
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.refresheventsfromnightscout) + "?", Runnable {
|
||||||
builder.setMessage(MainApp.gs(R.string.refresheventsfromnightscout) + "?")
|
MainApp.getDbHelper().resetProfileSwitch()
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok)) { _ , _->
|
RxBus.send(EventNSClientRestart())
|
||||||
MainApp.getDbHelper().resetProfileSwitch()
|
})
|
||||||
RxBus.send(EventNSClientRestart())
|
|
||||||
}
|
}
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null)
|
|
||||||
builder.show()
|
|
||||||
}
|
}
|
||||||
if (SP.getBoolean(R.string.key_ns_upload_only, false)) profileswitch_refreshfromnightscout.visibility = View.GONE
|
if (SP.getBoolean(R.string.key_ns_upload_only, false)) profileswitch_refreshfromnightscout.visibility = View.GONE
|
||||||
|
|
||||||
|
@ -63,9 +59,9 @@ class TreatmentsProfileSwitchFragment : Fragment() {
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
disposable.add(RxBus
|
disposable.add(RxBus
|
||||||
.toObservable(EventProfileNeedsUpdate::class.java)
|
.toObservable(EventProfileNeedsUpdate::class.java)
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe({ updateGUI() }) { FabricPrivacy.logException(it) }
|
.subscribe({ updateGUI() }) { FabricPrivacy.logException(it) }
|
||||||
)
|
)
|
||||||
updateGUI()
|
updateGUI()
|
||||||
}
|
}
|
||||||
|
@ -77,7 +73,7 @@ class TreatmentsProfileSwitchFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateGUI() =
|
fun updateGUI() =
|
||||||
profileswitch_recyclerview?.swapAdapter(RecyclerProfileViewAdapter(MainApp.getDbHelper().getProfileSwitchData(DateUtil.now() - T.days(30).msecs(),false)), false)
|
profileswitch_recyclerview?.swapAdapter(RecyclerProfileViewAdapter(MainApp.getDbHelper().getProfileSwitchData(DateUtil.now() - T.days(30).msecs(), false)), false)
|
||||||
|
|
||||||
inner class RecyclerProfileViewAdapter(private var profileSwitchList: List<ProfileSwitch>) : RecyclerView.Adapter<ProfileSwitchViewHolder>() {
|
inner class RecyclerProfileViewAdapter(private var profileSwitchList: List<ProfileSwitch>) : RecyclerView.Adapter<ProfileSwitchViewHolder>() {
|
||||||
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ProfileSwitchViewHolder {
|
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): ProfileSwitchViewHolder {
|
||||||
|
@ -121,21 +117,28 @@ class TreatmentsProfileSwitchFragment : Fragment() {
|
||||||
override fun onClick(v: View) {
|
override fun onClick(v: View) {
|
||||||
val profileSwitch = v.tag as ProfileSwitch
|
val profileSwitch = v.tag as ProfileSwitch
|
||||||
when (v.id) {
|
when (v.id) {
|
||||||
R.id.profileswitch_remove ->
|
R.id.profileswitch_remove ->
|
||||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.removerecord) + "\n" + profileSwitch.profileName + "\n" + DateUtil.dateAndTimeString(profileSwitch.date)) {
|
activity?.let { activity ->
|
||||||
val id = profileSwitch._id
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.removerecord),
|
||||||
if (NSUpload.isIdValid(id)) NSUpload.removeCareportalEntryFromNS(id)
|
MainApp.gs(R.string.careportal_profileswitch) + ": " + profileSwitch.profileName +
|
||||||
else UploadQueue.removeID("dbAdd", id)
|
"\n" + MainApp.gs(R.string.date) + ": " + DateUtil.dateAndTimeString(profileSwitch.date), Runnable {
|
||||||
MainApp.getDbHelper().delete(profileSwitch)
|
val id = profileSwitch._id
|
||||||
|
if (NSUpload.isIdValid(id)) NSUpload.removeCareportalEntryFromNS(id)
|
||||||
|
else UploadQueue.removeID("dbAdd", id)
|
||||||
|
MainApp.getDbHelper().delete(profileSwitch)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
R.id.profileswitch_clone ->
|
R.id.profileswitch_clone ->
|
||||||
OKDialog.showConfirmation(activity, MainApp.gs(R.string.copytolocalprofile) + "\n" + profileSwitch.customizedName + "\n" + DateUtil.dateAndTimeString(profileSwitch.date)) {
|
activity?.let { activity ->
|
||||||
profileSwitch.profileObject?.let {
|
OKDialog.showConfirmation(activity, MainApp.gs(R.string.careportal_profileswitch), MainApp.gs(R.string.copytolocalprofile) + "\n" + profileSwitch.customizedName + "\n" + DateUtil.dateAndTimeString(profileSwitch.date), Runnable {
|
||||||
val nonCustomized = it.convertToNonCustomizedProfile()
|
profileSwitch.profileObject?.let {
|
||||||
LocalProfilePlugin.addProfile(LocalProfilePlugin.SingleProfile().copyFrom(nonCustomized, profileSwitch.customizedName + " " + DateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_")))
|
val nonCustomized = it.convertToNonCustomizedProfile()
|
||||||
RxBus.send(EventLocalProfileChanged())
|
LocalProfilePlugin.addProfile(LocalProfilePlugin.SingleProfile().copyFrom(nonCustomized, profileSwitch.customizedName + " " + DateUtil.dateAndTimeString(profileSwitch.date).replace(".", "_")))
|
||||||
}
|
RxBus.send(EventLocalProfileChanged())
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
R.id.profileswitch_date, R.id.profileswitch_name -> {
|
R.id.profileswitch_date, R.id.profileswitch_name -> {
|
||||||
val args = Bundle()
|
val args = Bundle()
|
||||||
args.putLong("time", (v.tag as ProfileSwitch).date)
|
args.putLong("time", (v.tag as ProfileSwitch).date)
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.treatments.fragments;
|
package info.nightscout.androidaps.plugins.treatments.fragments;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -11,7 +8,7 @@ import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.cardview.widget.CardView;
|
import androidx.cardview.widget.CardView;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
@ -33,6 +30,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
@ -41,14 +39,10 @@ import io.reactivex.disposables.CompositeDisposable;
|
||||||
* Created by mike on 13/01/17.
|
* Created by mike on 13/01/17.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class TreatmentsTempTargetFragment extends Fragment implements View.OnClickListener {
|
public class TreatmentsTempTargetFragment extends Fragment {
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
LinearLayoutManager llm;
|
|
||||||
Button refreshFromNS;
|
|
||||||
|
|
||||||
Context context;
|
|
||||||
|
|
||||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TempTargetsViewHolder> {
|
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TempTargetsViewHolder> {
|
||||||
|
|
||||||
|
@ -60,11 +54,11 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
|
||||||
currentlyActiveTarget = tempTargetList.getValueByInterval(System.currentTimeMillis());
|
currentlyActiveTarget = tempTargetList.getValueByInterval(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public TempTargetsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
public TempTargetsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_temptarget_item, viewGroup, false);
|
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_temptarget_item, viewGroup, false);
|
||||||
TempTargetsViewHolder TempTargetsViewHolder = new TempTargetsViewHolder(v);
|
return new TempTargetsViewHolder(v);
|
||||||
return TempTargetsViewHolder;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -104,11 +98,11 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||||
super.onAttachedToRecyclerView(recyclerView);
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TempTargetsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
class TempTargetsViewHolder extends RecyclerView.ViewHolder {
|
||||||
CardView cv;
|
CardView cv;
|
||||||
TextView date;
|
TextView date;
|
||||||
TextView duration;
|
TextView duration;
|
||||||
|
@ -123,31 +117,23 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
|
||||||
|
|
||||||
TempTargetsViewHolder(View itemView) {
|
TempTargetsViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
cv = (CardView) itemView.findViewById(R.id.temptargetrange_cardview);
|
cv = itemView.findViewById(R.id.temptargetrange_cardview);
|
||||||
date = (TextView) itemView.findViewById(R.id.temptargetrange_date);
|
date = itemView.findViewById(R.id.temptargetrange_date);
|
||||||
duration = (TextView) itemView.findViewById(R.id.temptargetrange_duration);
|
duration = itemView.findViewById(R.id.temptargetrange_duration);
|
||||||
low = (TextView) itemView.findViewById(R.id.temptargetrange_low);
|
low = itemView.findViewById(R.id.temptargetrange_low);
|
||||||
high = (TextView) itemView.findViewById(R.id.temptargetrange_high);
|
high = itemView.findViewById(R.id.temptargetrange_high);
|
||||||
reason = (TextView) itemView.findViewById(R.id.temptargetrange_reason);
|
reason = itemView.findViewById(R.id.temptargetrange_reason);
|
||||||
reasonLabel = (TextView) itemView.findViewById(R.id.temptargetrange_reason_label);
|
reasonLabel = itemView.findViewById(R.id.temptargetrange_reason_label);
|
||||||
reasonColon = (TextView) itemView.findViewById(R.id.temptargetrange_reason_colon);
|
reasonColon = itemView.findViewById(R.id.temptargetrange_reason_colon);
|
||||||
ph = (TextView) itemView.findViewById(R.id.pump_sign);
|
ph = itemView.findViewById(R.id.pump_sign);
|
||||||
ns = (TextView) itemView.findViewById(R.id.ns_sign);
|
ns = itemView.findViewById(R.id.ns_sign);
|
||||||
remove = (TextView) itemView.findViewById(R.id.temptargetrange_remove);
|
remove = itemView.findViewById(R.id.temptargetrange_remove);
|
||||||
remove.setOnClickListener(this);
|
remove.setOnClickListener(v -> {
|
||||||
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
final TempTarget tempTarget = (TempTarget) v.getTag();
|
||||||
}
|
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.removerecord),
|
||||||
|
MainApp.gs(R.string.careportal_temporarytarget) + ": " + tempTarget.friendlyDescription(ProfileFunctions.getSystemUnits()) +
|
||||||
@Override
|
"\n" + DateUtil.dateAndTimeString(tempTarget.date),
|
||||||
public void onClick(View v) {
|
(dialog, id) -> {
|
||||||
final TempTarget tempTarget = (TempTarget) v.getTag();
|
|
||||||
switch (v.getId()) {
|
|
||||||
case R.id.temptargetrange_remove:
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(tempTarget.date));
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
final String _id = tempTarget._id;
|
final String _id = tempTarget._id;
|
||||||
if (NSUpload.isIdValid(_id)) {
|
if (NSUpload.isIdValid(_id)) {
|
||||||
NSUpload.removeCareportalEntryFromNS(_id);
|
NSUpload.removeCareportalEntryFromNS(_id);
|
||||||
|
@ -155,12 +141,9 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
|
||||||
UploadQueue.removeID("dbAdd", _id);
|
UploadQueue.removeID("dbAdd", _id);
|
||||||
}
|
}
|
||||||
MainApp.getDbHelper().delete(tempTarget);
|
MainApp.getDbHelper().delete(tempTarget);
|
||||||
}
|
}, null);
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
builder.show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,18 +153,20 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.treatments_temptarget_fragment, container, false);
|
View view = inflater.inflate(R.layout.treatments_temptarget_fragment, container, false);
|
||||||
|
|
||||||
recyclerView = (RecyclerView) view.findViewById(R.id.temptargetrange_recyclerview);
|
recyclerView = view.findViewById(R.id.temptargetrange_recyclerview);
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
llm = new LinearLayoutManager(view.getContext());
|
LinearLayoutManager llm = new LinearLayoutManager(view.getContext());
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
|
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getTempTargetsFromHistory());
|
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getTempTargetsFromHistory());
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
refreshFromNS = (Button) view.findViewById(R.id.temptargetrange_refreshfromnightscout);
|
Button refreshFromNS = view.findViewById(R.id.temptargetrange_refreshfromnightscout);
|
||||||
refreshFromNS.setOnClickListener(this);
|
refreshFromNS.setOnClickListener(v ->
|
||||||
|
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.refresheventsfromnightscout) + " ?", () -> {
|
||||||
context = getContext();
|
MainApp.getDbHelper().resetTempTargets();
|
||||||
|
RxBus.INSTANCE.send(new EventNSClientRestart());
|
||||||
|
}));
|
||||||
|
|
||||||
boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false);
|
boolean nsUploadOnly = SP.getBoolean(R.string.key_ns_upload_only, false);
|
||||||
if (nsUploadOnly)
|
if (nsUploadOnly)
|
||||||
|
@ -207,26 +192,6 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
|
||||||
disposable.clear();
|
disposable.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.temptargetrange_refreshfromnightscout:
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(MainApp.gs(R.string.refresheventsfromnightscout) + " ?");
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
MainApp.getDbHelper().resetTempTargets();
|
|
||||||
RxBus.INSTANCE.send(new EventNSClientRestart());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateGui() {
|
private void updateGui() {
|
||||||
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getTempTargetsFromHistory()), false);
|
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getTempTargetsFromHistory()), false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.treatments.fragments;
|
package info.nightscout.androidaps.plugins.treatments.fragments;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -9,7 +8,6 @@ import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.cardview.widget.CardView;
|
import androidx.cardview.widget.CardView;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
@ -33,6 +31,7 @@ import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
|
import info.nightscout.androidaps.utils.OKDialog;
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
|
@ -40,12 +39,9 @@ import io.reactivex.disposables.CompositeDisposable;
|
||||||
public class TreatmentsTemporaryBasalsFragment extends Fragment {
|
public class TreatmentsTemporaryBasalsFragment extends Fragment {
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
RecyclerView recyclerView;
|
private RecyclerView recyclerView;
|
||||||
LinearLayoutManager llm;
|
|
||||||
|
|
||||||
TextView tempBasalTotalView;
|
private TextView tempBasalTotalView;
|
||||||
|
|
||||||
Context context;
|
|
||||||
|
|
||||||
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TempBasalsViewHolder> {
|
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TempBasalsViewHolder> {
|
||||||
|
|
||||||
|
@ -55,6 +51,7 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
|
||||||
this.tempBasalList = tempBasalList;
|
this.tempBasalList = tempBasalList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public TempBasalsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
public TempBasalsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
|
||||||
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_tempbasals_item, viewGroup, false);
|
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.treatments_tempbasals_item, viewGroup, false);
|
||||||
|
@ -123,11 +120,11 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||||
super.onAttachedToRecyclerView(recyclerView);
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TempBasalsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
class TempBasalsViewHolder extends RecyclerView.ViewHolder {
|
||||||
CardView cv;
|
CardView cv;
|
||||||
TextView date;
|
TextView date;
|
||||||
TextView duration;
|
TextView duration;
|
||||||
|
@ -144,45 +141,37 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
|
||||||
|
|
||||||
TempBasalsViewHolder(View itemView) {
|
TempBasalsViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
cv = (CardView) itemView.findViewById(R.id.tempbasals_cardview);
|
cv = itemView.findViewById(R.id.tempbasals_cardview);
|
||||||
date = (TextView) itemView.findViewById(R.id.tempbasals_date);
|
date = itemView.findViewById(R.id.tempbasals_date);
|
||||||
duration = (TextView) itemView.findViewById(R.id.tempbasals_duration);
|
duration = itemView.findViewById(R.id.tempbasals_duration);
|
||||||
absolute = (TextView) itemView.findViewById(R.id.tempbasals_absolute);
|
absolute = itemView.findViewById(R.id.tempbasals_absolute);
|
||||||
percent = (TextView) itemView.findViewById(R.id.tempbasals_percent);
|
percent = itemView.findViewById(R.id.tempbasals_percent);
|
||||||
realDuration = (TextView) itemView.findViewById(R.id.tempbasals_realduration);
|
realDuration = itemView.findViewById(R.id.tempbasals_realduration);
|
||||||
netRatio = (TextView) itemView.findViewById(R.id.tempbasals_netratio);
|
netRatio = itemView.findViewById(R.id.tempbasals_netratio);
|
||||||
netInsulin = (TextView) itemView.findViewById(R.id.tempbasals_netinsulin);
|
netInsulin = itemView.findViewById(R.id.tempbasals_netinsulin);
|
||||||
iob = (TextView) itemView.findViewById(R.id.tempbasals_iob);
|
iob = itemView.findViewById(R.id.tempbasals_iob);
|
||||||
extendedFlag = (TextView) itemView.findViewById(R.id.tempbasals_extendedflag);
|
extendedFlag = itemView.findViewById(R.id.tempbasals_extendedflag);
|
||||||
ph = (TextView) itemView.findViewById(R.id.pump_sign);
|
ph = itemView.findViewById(R.id.pump_sign);
|
||||||
ns = (TextView) itemView.findViewById(R.id.ns_sign);
|
ns = itemView.findViewById(R.id.ns_sign);
|
||||||
remove = (TextView) itemView.findViewById(R.id.tempbasals_remove);
|
remove = itemView.findViewById(R.id.tempbasals_remove);
|
||||||
remove.setOnClickListener(this);
|
remove.setOnClickListener(v -> {
|
||||||
|
final TemporaryBasal tempBasal = (TemporaryBasal) v.getTag();
|
||||||
|
OKDialog.showConfirmation(getContext(), MainApp.gs(R.string.removerecord),
|
||||||
|
MainApp.gs(R.string.pump_tempbasal_label) + ": " + tempBasal.toStringFull() +
|
||||||
|
"\n" + MainApp.gs(R.string.date) + ": " + DateUtil.dateAndTimeString(tempBasal.date),
|
||||||
|
((dialog, id) -> {
|
||||||
|
final String _id = tempBasal._id;
|
||||||
|
if (NSUpload.isIdValid(_id)) {
|
||||||
|
NSUpload.removeCareportalEntryFromNS(_id);
|
||||||
|
} else {
|
||||||
|
UploadQueue.removeID("dbAdd", _id);
|
||||||
|
}
|
||||||
|
MainApp.getDbHelper().delete(tempBasal);
|
||||||
|
}), null);
|
||||||
|
});
|
||||||
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
remove.setPaintFlags(remove.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
final TemporaryBasal tempBasal = (TemporaryBasal) v.getTag();
|
|
||||||
switch (v.getId()) {
|
|
||||||
case R.id.tempbasals_remove:
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(tempBasal.date));
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
|
|
||||||
final String _id = tempBasal._id;
|
|
||||||
if (NSUpload.isIdValid(_id)) {
|
|
||||||
NSUpload.removeCareportalEntryFromNS(_id);
|
|
||||||
} else {
|
|
||||||
UploadQueue.removeID("dbAdd", _id);
|
|
||||||
}
|
|
||||||
MainApp.getDbHelper().delete(tempBasal);
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,17 +180,15 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.treatments_tempbasals_fragment, container, false);
|
View view = inflater.inflate(R.layout.treatments_tempbasals_fragment, container, false);
|
||||||
|
|
||||||
recyclerView = (RecyclerView) view.findViewById(R.id.tempbasals_recyclerview);
|
recyclerView = view.findViewById(R.id.tempbasals_recyclerview);
|
||||||
recyclerView.setHasFixedSize(true);
|
recyclerView.setHasFixedSize(true);
|
||||||
llm = new LinearLayoutManager(view.getContext());
|
LinearLayoutManager llm = new LinearLayoutManager(view.getContext());
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
|
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getTemporaryBasalsFromHistory());
|
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getTemporaryBasalsFromHistory());
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
tempBasalTotalView = (TextView) view.findViewById(R.id.tempbasals_totaltempiob);
|
tempBasalTotalView = view.findViewById(R.id.tempbasals_totaltempiob);
|
||||||
|
|
||||||
context = getContext();
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
|
@ -295,7 +295,7 @@ public class SWDefinition {
|
||||||
.validator(() -> LocalProfilePlugin.INSTANCE.getProfile() != null && LocalProfilePlugin.INSTANCE.getProfile().getDefaultProfile() != null && LocalProfilePlugin.INSTANCE.getProfile().getDefaultProfile().isValid("StartupWizard"))
|
.validator(() -> LocalProfilePlugin.INSTANCE.getProfile() != null && LocalProfilePlugin.INSTANCE.getProfile().getDefaultProfile() != null && LocalProfilePlugin.INSTANCE.getProfile().getDefaultProfile().isValid("StartupWizard"))
|
||||||
.visibility(() -> LocalProfilePlugin.INSTANCE.isEnabled(PluginType.PROFILE));
|
.visibility(() -> LocalProfilePlugin.INSTANCE.isEnabled(PluginType.PROFILE));
|
||||||
|
|
||||||
private SWScreen screenProfileSwitch = new SWScreen(R.string.profileswitch)
|
private SWScreen screenProfileSwitch = new SWScreen(R.string.careportal_profileswitch)
|
||||||
.skippable(false)
|
.skippable(false)
|
||||||
.add(new SWInfotext()
|
.add(new SWInfotext()
|
||||||
.label(R.string.profileswitch_ismissing))
|
.label(R.string.profileswitch_ismissing))
|
||||||
|
|
|
@ -8,13 +8,10 @@ import android.widget.LinearLayout;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainActivity;
|
import info.nightscout.androidaps.MainActivity;
|
||||||
|
@ -37,8 +34,6 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
||||||
//logging
|
|
||||||
private static Logger log = LoggerFactory.getLogger(SetupWizardActivity.class);
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
ScrollView scrollView;
|
ScrollView scrollView;
|
||||||
|
@ -54,7 +49,7 @@ public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
||||||
LocaleHelper.INSTANCE.update(getApplicationContext());
|
LocaleHelper.INSTANCE.update(getApplicationContext());
|
||||||
setContentView(R.layout.activity_setupwizard);
|
setContentView(R.layout.activity_setupwizard);
|
||||||
|
|
||||||
scrollView = (ScrollView) findViewById(R.id.sw_scrollview);
|
scrollView = findViewById(R.id.sw_scrollview);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
currentWizardPage = intent.getIntExtra(SetupWizardActivity.INTENT_MESSAGE, 0);
|
currentWizardPage = intent.getIntExtra(SetupWizardActivity.INTENT_MESSAGE, 0);
|
||||||
|
@ -62,7 +57,7 @@ public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
||||||
SWScreen currentScreen = screens.get(currentWizardPage);
|
SWScreen currentScreen = screens.get(currentWizardPage);
|
||||||
|
|
||||||
//Set screen name
|
//Set screen name
|
||||||
TextView screenName = (TextView) findViewById(R.id.sw_content);
|
TextView screenName = findViewById(R.id.sw_content);
|
||||||
screenName.setText(currentScreen.getHeader());
|
screenName.setText(currentScreen.getHeader());
|
||||||
|
|
||||||
swDefinition.setActivity(this);
|
swDefinition.setActivity(this);
|
||||||
|
@ -187,7 +182,7 @@ public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
||||||
return page;
|
return page;
|
||||||
page++;
|
page++;
|
||||||
}
|
}
|
||||||
return Math.min(currentWizardPage, screens.size() -1);
|
return Math.min(currentWizardPage, screens.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int previousPage() {
|
private int previousPage() {
|
||||||
|
@ -201,17 +196,14 @@ public class SetupWizardActivity extends NoSplashAppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
if (permissions.length != 0) {
|
if (permissions.length != 0) {
|
||||||
if (ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED) {
|
if (ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED) {
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case AndroidPermission.CASE_STORAGE:
|
case AndroidPermission.CASE_STORAGE:
|
||||||
//show dialog after permission is granted
|
//show dialog after permission is granted
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(this);
|
OKDialog.show(this, MainApp.gs(R.string.permission), MainApp.gs(R.string.alert_dialog_storage_permission_text));
|
||||||
alert.setMessage(R.string.alert_dialog_storage_permission_text);
|
|
||||||
alert.setPositiveButton(R.string.ok, null);
|
|
||||||
alert.show();
|
|
||||||
break;
|
break;
|
||||||
case AndroidPermission.CASE_LOCATION:
|
case AndroidPermission.CASE_LOCATION:
|
||||||
case AndroidPermission.CASE_SMS:
|
case AndroidPermission.CASE_SMS:
|
||||||
|
|
|
@ -2,9 +2,9 @@ package info.nightscout.androidaps.utils
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import info.nightscout.androidaps.MainApp
|
import info.nightscout.androidaps.MainApp
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.db.CareportalEvent
|
import info.nightscout.androidaps.db.CareportalEvent
|
||||||
|
@ -20,7 +20,6 @@ import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||||
import info.nightscout.androidaps.activities.ErrorHelperActivity
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
@ -127,8 +126,8 @@ class BolusWizard @JvmOverloads constructor(val profile: Profile,
|
||||||
if (useBg && bg > 0) {
|
if (useBg && bg > 0) {
|
||||||
bgDiff = when {
|
bgDiff = when {
|
||||||
bg in targetBGLow..targetBGHigh -> 0.0
|
bg in targetBGLow..targetBGHigh -> 0.0
|
||||||
bg <= targetBGLow -> bg - targetBGLow
|
bg <= targetBGLow -> bg - targetBGLow
|
||||||
else -> bg - targetBGHigh
|
else -> bg - targetBGHigh
|
||||||
}
|
}
|
||||||
insulinFromBG = bgDiff / sens
|
insulinFromBG = bgDiff / sens
|
||||||
}
|
}
|
||||||
|
@ -142,7 +141,6 @@ class BolusWizard @JvmOverloads constructor(val profile: Profile,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Insulin from carbs
|
// Insulin from carbs
|
||||||
ic = profile.ic
|
ic = profile.ic
|
||||||
insulinFromCarbs = carbs / ic
|
insulinFromCarbs = carbs / ic
|
||||||
|
@ -185,7 +183,7 @@ class BolusWizard @JvmOverloads constructor(val profile: Profile,
|
||||||
}
|
}
|
||||||
|
|
||||||
val bolusStep = ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription?.bolusStep
|
val bolusStep = ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription?.bolusStep
|
||||||
?: 0.1
|
?: 0.1
|
||||||
calculatedTotalInsulin = Round.roundTo(calculatedTotalInsulin, bolusStep)
|
calculatedTotalInsulin = Round.roundTo(calculatedTotalInsulin, bolusStep)
|
||||||
|
|
||||||
insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(Constraint(calculatedTotalInsulin)).value()
|
insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(Constraint(calculatedTotalInsulin)).value()
|
||||||
|
@ -236,7 +234,7 @@ class BolusWizard @JvmOverloads constructor(val profile: Profile,
|
||||||
|
|
||||||
private fun confirmMessageAfterConstraints(pump: PumpInterface): String {
|
private fun confirmMessageAfterConstraints(pump: PumpInterface): String {
|
||||||
|
|
||||||
var confirmMessage = MainApp.gs(R.string.entertreatmentquestion)
|
var confirmMessage = ""
|
||||||
if (insulinAfterConstraints > 0) {
|
if (insulinAfterConstraints > 0) {
|
||||||
val pct = if (percentageCorrection != 100.0) " (" + percentageCorrection.toInt() + "%)" else ""
|
val pct = if (percentageCorrection != 100.0) " (" + percentageCorrection.toInt() + "%)" else ""
|
||||||
confirmMessage += "<br/>" + MainApp.gs(R.string.bolus) + ": " + "<font color='" + MainApp.gc(R.color.bolus) + "'>" + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints) + "U" + pct + "</font>"
|
confirmMessage += "<br/>" + MainApp.gs(R.string.bolus) + ": " + "<font color='" + MainApp.gc(R.color.bolus) + "'>" + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints) + "U" + pct + "</font>"
|
||||||
|
@ -268,89 +266,83 @@ class BolusWizard @JvmOverloads constructor(val profile: Profile,
|
||||||
val pump = ConfigBuilderPlugin.getPlugin().activePump ?: return
|
val pump = ConfigBuilderPlugin.getPlugin().activePump ?: return
|
||||||
|
|
||||||
if (calculatedTotalInsulin > 0.0 || carbs > 0.0) {
|
if (calculatedTotalInsulin > 0.0 || carbs > 0.0) {
|
||||||
|
if (accepted) {
|
||||||
|
log.debug("guarding: already accepted")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
accepted = true
|
||||||
|
|
||||||
val confirmMessage = confirmMessageAfterConstraints(pump)
|
val confirmMessage = confirmMessageAfterConstraints(pump)
|
||||||
|
|
||||||
val builder = AlertDialog.Builder(context)
|
OKDialog.showConfirmation(context, MainApp.gs(R.string.boluswizard), HtmlHelper.fromHtml(confirmMessage), Runnable {
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation))
|
if (insulinAfterConstraints > 0 || carbs > 0) {
|
||||||
builder.setMessage(HtmlHelper.fromHtml(confirmMessage))
|
if (useSuperBolus) {
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok)) { _, _ ->
|
val loopPlugin = LoopPlugin.getPlugin()
|
||||||
synchronized(builder) {
|
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
if (accepted) {
|
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000)
|
||||||
log.debug("guarding: already accepted")
|
RxBus.send(EventRefreshOverview("WizardDialog"))
|
||||||
return@setPositiveButton
|
|
||||||
}
|
|
||||||
accepted = true
|
|
||||||
if (insulinAfterConstraints > 0 || carbs > 0) {
|
|
||||||
if (useSuperBolus) {
|
|
||||||
val loopPlugin = LoopPlugin.getPlugin()
|
|
||||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
|
||||||
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000)
|
|
||||||
RxBus.send(EventRefreshOverview("WizardDialog"))
|
|
||||||
}
|
|
||||||
|
|
||||||
val pump1 = ConfigBuilderPlugin.getPlugin().activePump
|
|
||||||
|
|
||||||
if (pump1?.pumpDescription?.tempBasalStyle == PumpDescription.ABSOLUTE) {
|
|
||||||
ConfigBuilderPlugin.getPlugin().commandQueue.tempBasalAbsolute(0.0, 120, true, profile, object : Callback() {
|
|
||||||
override fun run() {
|
|
||||||
if (!result.success) {
|
|
||||||
val i = Intent(MainApp.instance(), ErrorHelperActivity::class.java)
|
|
||||||
i.putExtra("soundid", R.raw.boluserror)
|
|
||||||
i.putExtra("status", result.comment)
|
|
||||||
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror))
|
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
MainApp.instance().startActivity(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
|
|
||||||
ConfigBuilderPlugin.getPlugin().commandQueue.tempBasalPercent(0, 120, true, profile, object : Callback() {
|
|
||||||
override fun run() {
|
|
||||||
if (!result.success) {
|
|
||||||
val i = Intent(MainApp.instance(), ErrorHelperActivity::class.java)
|
|
||||||
i.putExtra("soundid", R.raw.boluserror)
|
|
||||||
i.putExtra("status", result.comment)
|
|
||||||
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror))
|
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
||||||
MainApp.instance().startActivity(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val detailedBolusInfo = DetailedBolusInfo()
|
|
||||||
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD
|
val pump1 = ConfigBuilderPlugin.getPlugin().activePump
|
||||||
detailedBolusInfo.insulin = insulinAfterConstraints
|
|
||||||
detailedBolusInfo.carbs = carbs.toDouble()
|
if (pump1?.pumpDescription?.tempBasalStyle == PumpDescription.ABSOLUTE) {
|
||||||
detailedBolusInfo.context = context
|
ConfigBuilderPlugin.getPlugin().commandQueue.tempBasalAbsolute(0.0, 120, true, profile, object : Callback() {
|
||||||
detailedBolusInfo.glucose = bg
|
|
||||||
detailedBolusInfo.glucoseType = "Manual"
|
|
||||||
detailedBolusInfo.carbTime = carbTime
|
|
||||||
detailedBolusInfo.boluscalc = nsJSON()
|
|
||||||
detailedBolusInfo.source = Source.USER
|
|
||||||
detailedBolusInfo.notes = notes
|
|
||||||
if (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription?.storesCarbInfo == true) {
|
|
||||||
ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
val i = Intent(MainApp.instance(), ErrorHelperActivity::class.java)
|
val i = Intent(MainApp.instance(), ErrorHelperActivity::class.java)
|
||||||
i.putExtra("soundid", R.raw.boluserror)
|
i.putExtra("soundid", R.raw.boluserror)
|
||||||
i.putExtra("status", result.comment)
|
i.putExtra("status", result.comment)
|
||||||
i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror))
|
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror))
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
MainApp.instance().startActivity(i)
|
MainApp.instance().startActivity(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false)
|
|
||||||
|
ConfigBuilderPlugin.getPlugin().commandQueue.tempBasalPercent(0, 120, true, profile, object : Callback() {
|
||||||
|
override fun run() {
|
||||||
|
if (!result.success) {
|
||||||
|
val i = Intent(MainApp.instance(), ErrorHelperActivity::class.java)
|
||||||
|
i.putExtra("soundid", R.raw.boluserror)
|
||||||
|
i.putExtra("status", result.comment)
|
||||||
|
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror))
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
MainApp.instance().startActivity(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
val detailedBolusInfo = DetailedBolusInfo()
|
||||||
|
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD
|
||||||
|
detailedBolusInfo.insulin = insulinAfterConstraints
|
||||||
|
detailedBolusInfo.carbs = carbs.toDouble()
|
||||||
|
detailedBolusInfo.context = context
|
||||||
|
detailedBolusInfo.glucose = bg
|
||||||
|
detailedBolusInfo.glucoseType = "Manual"
|
||||||
|
detailedBolusInfo.carbTime = carbTime
|
||||||
|
detailedBolusInfo.boluscalc = nsJSON()
|
||||||
|
detailedBolusInfo.source = Source.USER
|
||||||
|
detailedBolusInfo.notes = notes
|
||||||
|
if (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription?.storesCarbInfo == true) {
|
||||||
|
ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||||
|
override fun run() {
|
||||||
|
if (!result.success) {
|
||||||
|
val i = Intent(MainApp.instance(), ErrorHelperActivity::class.java)
|
||||||
|
i.putExtra("soundid", R.raw.boluserror)
|
||||||
|
i.putExtra("status", result.comment)
|
||||||
|
i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror))
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
MainApp.instance().startActivity(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null)
|
|
||||||
builder.show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,127 +0,0 @@
|
||||||
package info.nightscout.androidaps.utils;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.SystemClock;
|
|
||||||
import android.text.Spanned;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.appcompat.view.ContextThemeWrapper;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
|
|
||||||
public class OKDialog {
|
|
||||||
public static void show(final Context context, String title, String message, final Runnable runnable) {
|
|
||||||
if (title.isEmpty()) title = MainApp.gs(R.string.message);
|
|
||||||
View titleLayout = LayoutInflater.from(context).inflate(R.layout.dialog_alert_custom, null);
|
|
||||||
((TextView)titleLayout.findViewById(R.id.alertdialog_title)).setText(title);
|
|
||||||
((ImageView)titleLayout.findViewById(R.id.alertdialog_icon)).setImageResource(R.drawable.ic_check_while_48dp);
|
|
||||||
|
|
||||||
new AlertDialog.Builder(new ContextThemeWrapper(context, R.style.AppTheme))
|
|
||||||
.setCustomTitle(titleLayout)
|
|
||||||
.setMessage(message)
|
|
||||||
.setPositiveButton(MainApp.gs(R.string.ok), (dialog, which) -> {
|
|
||||||
dialog.dismiss();
|
|
||||||
if (runnable != null) {
|
|
||||||
SystemClock.sleep(100);
|
|
||||||
runOnUiThread(runnable);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show()
|
|
||||||
.setCanceledOnTouchOutside(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean runOnUiThread(Runnable theRunnable) {
|
|
||||||
final Handler mainHandler = new Handler(MainApp.instance().getApplicationContext().getMainLooper());
|
|
||||||
return mainHandler.post(theRunnable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void show(final Activity activity, String title, Spanned message, final Runnable runnable) {
|
|
||||||
if (title.isEmpty()) title = MainApp.gs(R.string.message);
|
|
||||||
View titleLayout = activity.getLayoutInflater().inflate(R.layout.dialog_alert_custom, null);
|
|
||||||
((TextView)titleLayout.findViewById(R.id.alertdialog_title)).setText(title);
|
|
||||||
((ImageView)titleLayout.findViewById(R.id.alertdialog_icon)).setImageResource(R.drawable.ic_check_while_48dp);
|
|
||||||
|
|
||||||
new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.AppTheme))
|
|
||||||
.setCustomTitle(titleLayout)
|
|
||||||
.setMessage(message)
|
|
||||||
.setPositiveButton(MainApp.gs(R.string.ok), (dialog, which) -> {
|
|
||||||
dialog.dismiss();
|
|
||||||
if (runnable != null) {
|
|
||||||
SystemClock.sleep(100);
|
|
||||||
activity.runOnUiThread(runnable);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show()
|
|
||||||
.setCanceledOnTouchOutside(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showConfirmation(final Activity activity, String message, final Runnable ok) {
|
|
||||||
showConfirmation(activity, message, ok, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showConfirmation(final Activity activity, Spanned message, final Runnable ok) {
|
|
||||||
showConfirmation(activity, message, ok, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showConfirmation(final Activity activity, Spanned message, final Runnable ok, final Runnable cancel) {
|
|
||||||
View titleLayout = activity.getLayoutInflater().inflate(R.layout.dialog_alert_custom, null);
|
|
||||||
((TextView)titleLayout.findViewById(R.id.alertdialog_title)).setText(R.string.confirmation);
|
|
||||||
((ImageView)titleLayout.findViewById(R.id.alertdialog_icon)).setImageResource(R.drawable.ic_check_while_48dp);
|
|
||||||
|
|
||||||
new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.AppTheme))
|
|
||||||
.setMessage(message)
|
|
||||||
.setCustomTitle(titleLayout)
|
|
||||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
|
||||||
dialog.dismiss();
|
|
||||||
if (ok != null) {
|
|
||||||
SystemClock.sleep(100);
|
|
||||||
activity.runOnUiThread(ok);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(android.R.string.cancel, (dialog, which) -> {
|
|
||||||
dialog.dismiss();
|
|
||||||
if (cancel != null) {
|
|
||||||
SystemClock.sleep(100);
|
|
||||||
activity.runOnUiThread(cancel);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(android.R.string.cancel, null)
|
|
||||||
.show()
|
|
||||||
.setCanceledOnTouchOutside(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showConfirmation(final Activity activity, String message, final Runnable ok, final Runnable cancel) {
|
|
||||||
View titleLayout = activity.getLayoutInflater().inflate(R.layout.dialog_alert_custom, null);
|
|
||||||
((TextView)titleLayout.findViewById(R.id.alertdialog_title)).setText(R.string.confirmation);
|
|
||||||
((ImageView)titleLayout.findViewById(R.id.alertdialog_icon)).setImageResource(R.drawable.ic_check_while_48dp);
|
|
||||||
|
|
||||||
new AlertDialog.Builder(new ContextThemeWrapper(activity, R.style.AppTheme))
|
|
||||||
.setMessage(message)
|
|
||||||
.setCustomTitle(titleLayout)
|
|
||||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
|
||||||
dialog.dismiss();
|
|
||||||
if (ok != null) {
|
|
||||||
SystemClock.sleep(100);
|
|
||||||
activity.runOnUiThread(ok);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setNegativeButton(android.R.string.cancel, (dialog, which) -> {
|
|
||||||
dialog.dismiss();
|
|
||||||
if (cancel != null) {
|
|
||||||
SystemClock.sleep(100);
|
|
||||||
activity.runOnUiThread(cancel);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show()
|
|
||||||
.setCanceledOnTouchOutside(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
203
app/src/main/java/info/nightscout/androidaps/utils/OKDialog.kt
Normal file
203
app/src/main/java/info/nightscout/androidaps/utils/OKDialog.kt
Normal file
|
@ -0,0 +1,203 @@
|
||||||
|
package info.nightscout.androidaps.utils
|
||||||
|
|
||||||
|
import android.app.Activity
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.DialogInterface
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.SystemClock
|
||||||
|
import android.text.Spanned
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.appcompat.view.ContextThemeWrapper
|
||||||
|
import info.nightscout.androidaps.MainApp
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
|
||||||
|
object OKDialog {
|
||||||
|
@JvmStatic
|
||||||
|
@JvmOverloads
|
||||||
|
fun show(context: Context, title: String, message: String, runnable: Runnable? = null) {
|
||||||
|
var notEmptytitle = title
|
||||||
|
if (notEmptytitle.isEmpty()) notEmptytitle = MainApp.gs(R.string.message)
|
||||||
|
val titleLayout = LayoutInflater.from(context).inflate(R.layout.dialog_alert_custom, null)
|
||||||
|
(titleLayout.findViewById<View>(R.id.alertdialog_title) as TextView).text = notEmptytitle
|
||||||
|
(titleLayout.findViewById<View>(R.id.alertdialog_icon) as ImageView).setImageResource(R.drawable.ic_check_while_48dp)
|
||||||
|
AlertDialog.Builder(ContextThemeWrapper(context, R.style.AppTheme))
|
||||||
|
.setCustomTitle(titleLayout)
|
||||||
|
.setMessage(message)
|
||||||
|
.setPositiveButton(MainApp.gs(R.string.ok)) { dialog: DialogInterface, _: Int ->
|
||||||
|
dialog.dismiss()
|
||||||
|
SystemClock.sleep(100)
|
||||||
|
runOnUiThread(runnable)
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
.setCanceledOnTouchOutside(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun runOnUiThread(theRunnable: Runnable?) {
|
||||||
|
val mainHandler = Handler(MainApp.instance().applicationContext.mainLooper)
|
||||||
|
theRunnable?.let { mainHandler.post(it) }
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JvmOverloads
|
||||||
|
fun show(activity: Activity, title: String, message: Spanned, runnable: Runnable? = null) {
|
||||||
|
var notEmptytitle = title
|
||||||
|
if (notEmptytitle.isEmpty()) notEmptytitle = MainApp.gs(R.string.message)
|
||||||
|
val titleLayout = activity.layoutInflater.inflate(R.layout.dialog_alert_custom, null)
|
||||||
|
(titleLayout.findViewById<View>(R.id.alertdialog_title) as TextView).text = notEmptytitle
|
||||||
|
(titleLayout.findViewById<View>(R.id.alertdialog_icon) as ImageView).setImageResource(R.drawable.ic_check_while_48dp)
|
||||||
|
AlertDialog.Builder(ContextThemeWrapper(activity, R.style.AppTheme))
|
||||||
|
.setCustomTitle(titleLayout)
|
||||||
|
.setMessage(message)
|
||||||
|
.setPositiveButton(MainApp.gs(R.string.ok)) { dialog: DialogInterface, _: Int ->
|
||||||
|
dialog.dismiss()
|
||||||
|
SystemClock.sleep(100)
|
||||||
|
runnable?.let { activity.runOnUiThread(it) }
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
.setCanceledOnTouchOutside(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JvmOverloads
|
||||||
|
fun showConfirmation(activity: Activity, message: String, ok: Runnable?) {
|
||||||
|
showConfirmation(activity, MainApp.gs(R.string.confirmation), message, ok, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JvmOverloads
|
||||||
|
fun showConfirmation(activity: Activity, message: Spanned, ok: Runnable?) {
|
||||||
|
showConfirmation(activity, MainApp.gs(R.string.confirmation), message, ok, null)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JvmOverloads
|
||||||
|
fun showConfirmation(activity: Activity, title: String, message: Spanned, ok: Runnable?, cancel: Runnable? = null) {
|
||||||
|
val titleLayout = activity.layoutInflater.inflate(R.layout.dialog_alert_custom, null)
|
||||||
|
(titleLayout.findViewById<View>(R.id.alertdialog_title) as TextView).text = title
|
||||||
|
(titleLayout.findViewById<View>(R.id.alertdialog_icon) as ImageView).setImageResource(R.drawable.ic_check_while_48dp)
|
||||||
|
AlertDialog.Builder(ContextThemeWrapper(activity, R.style.AppTheme))
|
||||||
|
.setMessage(message)
|
||||||
|
.setCustomTitle(titleLayout)
|
||||||
|
.setPositiveButton(android.R.string.ok) { dialog: DialogInterface, _: Int ->
|
||||||
|
dialog.dismiss()
|
||||||
|
SystemClock.sleep(100)
|
||||||
|
ok?.let { activity.runOnUiThread(it) }
|
||||||
|
}
|
||||||
|
.setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, _: Int ->
|
||||||
|
dialog.dismiss()
|
||||||
|
SystemClock.sleep(100)
|
||||||
|
cancel?.let { activity.runOnUiThread(it) }
|
||||||
|
}
|
||||||
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
.show()
|
||||||
|
.setCanceledOnTouchOutside(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun showConfirmation(activity: Activity, title: String, message: String, ok: Runnable?, cancel: Runnable? = null) {
|
||||||
|
val titleLayout = activity.layoutInflater.inflate(R.layout.dialog_alert_custom, null)
|
||||||
|
(titleLayout.findViewById<View>(R.id.alertdialog_title) as TextView).text = title
|
||||||
|
(titleLayout.findViewById<View>(R.id.alertdialog_icon) as ImageView).setImageResource(R.drawable.ic_check_while_48dp)
|
||||||
|
AlertDialog.Builder(ContextThemeWrapper(activity, R.style.AppTheme))
|
||||||
|
.setMessage(message)
|
||||||
|
.setCustomTitle(titleLayout)
|
||||||
|
.setPositiveButton(android.R.string.ok) { dialog: DialogInterface, _: Int ->
|
||||||
|
dialog.dismiss()
|
||||||
|
SystemClock.sleep(100)
|
||||||
|
ok?.let { activity.runOnUiThread(it) }
|
||||||
|
}
|
||||||
|
.setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, _: Int ->
|
||||||
|
dialog.dismiss()
|
||||||
|
SystemClock.sleep(100)
|
||||||
|
cancel?.let { activity.runOnUiThread(it) }
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
.setCanceledOnTouchOutside(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JvmOverloads
|
||||||
|
fun showConfirmation(context: Context, message: Spanned, ok: Runnable?, cancel: Runnable? = null) {
|
||||||
|
showConfirmation(context, MainApp.gs(R.string.confirmation), message, ok, cancel)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JvmOverloads
|
||||||
|
fun showConfirmation(context: Context, title: String, message: Spanned, ok: Runnable?, cancel: Runnable? = null) {
|
||||||
|
val titleLayout = LayoutInflater.from(context).inflate(R.layout.dialog_alert_custom, null)
|
||||||
|
(titleLayout.findViewById<View>(R.id.alertdialog_title) as TextView).text = title
|
||||||
|
(titleLayout.findViewById<View>(R.id.alertdialog_icon) as ImageView).setImageResource(R.drawable.ic_check_while_48dp)
|
||||||
|
AlertDialog.Builder(ContextThemeWrapper(context, R.style.AppTheme))
|
||||||
|
.setMessage(message)
|
||||||
|
.setCustomTitle(titleLayout)
|
||||||
|
.setPositiveButton(android.R.string.ok) { dialog: DialogInterface, _: Int ->
|
||||||
|
dialog.dismiss()
|
||||||
|
SystemClock.sleep(100)
|
||||||
|
runOnUiThread(ok)
|
||||||
|
}
|
||||||
|
.setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, _: Int ->
|
||||||
|
dialog.dismiss()
|
||||||
|
SystemClock.sleep(100)
|
||||||
|
runOnUiThread(cancel)
|
||||||
|
}
|
||||||
|
.setNegativeButton(android.R.string.cancel, null)
|
||||||
|
.show()
|
||||||
|
.setCanceledOnTouchOutside(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JvmOverloads
|
||||||
|
fun showConfirmation(context: Context, message: String, ok: Runnable?, cancel: Runnable? = null) {
|
||||||
|
showConfirmation(context, MainApp.gs(R.string.confirmation), message, ok, cancel)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JvmOverloads
|
||||||
|
fun showConfirmation(context: Context, title: String, message: String, ok: Runnable?, cancel: Runnable? = null) {
|
||||||
|
val titleLayout = LayoutInflater.from(context).inflate(R.layout.dialog_alert_custom, null)
|
||||||
|
(titleLayout.findViewById<View>(R.id.alertdialog_title) as TextView).text = title
|
||||||
|
(titleLayout.findViewById<View>(R.id.alertdialog_icon) as ImageView).setImageResource(R.drawable.ic_check_while_48dp)
|
||||||
|
AlertDialog.Builder(ContextThemeWrapper(context, R.style.AppTheme))
|
||||||
|
.setMessage(message)
|
||||||
|
.setCustomTitle(titleLayout)
|
||||||
|
.setPositiveButton(android.R.string.ok) { dialog: DialogInterface, _: Int ->
|
||||||
|
dialog.dismiss()
|
||||||
|
SystemClock.sleep(100)
|
||||||
|
runOnUiThread(ok)
|
||||||
|
}
|
||||||
|
.setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, _: Int ->
|
||||||
|
dialog.dismiss()
|
||||||
|
SystemClock.sleep(100)
|
||||||
|
runOnUiThread(cancel)
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
.setCanceledOnTouchOutside(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@JvmOverloads
|
||||||
|
fun showConfirmation(context: Context, title: String, message: String, ok: DialogInterface.OnClickListener?, cancel: DialogInterface.OnClickListener? = null) {
|
||||||
|
val titleLayout = LayoutInflater.from(context).inflate(R.layout.dialog_alert_custom, null)
|
||||||
|
(titleLayout.findViewById<View>(R.id.alertdialog_title) as TextView).text = title
|
||||||
|
(titleLayout.findViewById<View>(R.id.alertdialog_icon) as ImageView).setImageResource(R.drawable.ic_check_while_48dp)
|
||||||
|
AlertDialog.Builder(ContextThemeWrapper(context, R.style.AppTheme))
|
||||||
|
.setMessage(message)
|
||||||
|
.setCustomTitle(titleLayout)
|
||||||
|
.setPositiveButton(android.R.string.ok) { dialog: DialogInterface, which: Int ->
|
||||||
|
dialog.dismiss()
|
||||||
|
SystemClock.sleep(100)
|
||||||
|
ok?.onClick(dialog, which)
|
||||||
|
}
|
||||||
|
.setNegativeButton(android.R.string.cancel) { dialog: DialogInterface, which: Int ->
|
||||||
|
dialog.dismiss()
|
||||||
|
SystemClock.sleep(100)
|
||||||
|
cancel?.onClick(dialog, which)
|
||||||
|
}
|
||||||
|
.show()
|
||||||
|
.setCanceledOnTouchOutside(false)
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,10 +2,10 @@ package info.nightscout.androidaps.utils;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
@ -18,10 +18,7 @@ import info.nightscout.androidaps.R;
|
||||||
public class PasswordProtection {
|
public class PasswordProtection {
|
||||||
static public boolean isLocked(String preference) {
|
static public boolean isLocked(String preference) {
|
||||||
final String password = SP.getString(preference, "");
|
final String password = SP.getString(preference, "");
|
||||||
if (password.equals("")) {
|
return !password.equals("");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void QueryPassword(final Context context, int stringID, String preference, final Runnable ok, final Runnable fail) {
|
static public void QueryPassword(final Context context, int stringID, String preference, final Runnable ok, final Runnable fail) {
|
||||||
|
@ -30,39 +27,38 @@ public class PasswordProtection {
|
||||||
if (ok != null) ok.run();
|
if (ok != null) ok.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LayoutInflater li = LayoutInflater.from(context);
|
View promptsView = LayoutInflater.from(context).inflate(R.layout.passwordprompt, null);
|
||||||
View promptsView = li.inflate(R.layout.passwordprompt, null);
|
|
||||||
|
View titleLayout = LayoutInflater.from(context).inflate(R.layout.dialog_alert_custom, null);
|
||||||
|
((TextView) titleLayout.findViewById(R.id.alertdialog_title)).setText(R.string.confirmation);
|
||||||
|
((ImageView) titleLayout.findViewById(R.id.alertdialog_icon)).setImageResource(R.drawable.ic_check_while_48dp);
|
||||||
|
|
||||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
|
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
|
||||||
alertDialogBuilder.setView(promptsView);
|
alertDialogBuilder.setView(promptsView);
|
||||||
|
alertDialogBuilder.setCustomTitle(titleLayout);
|
||||||
|
|
||||||
final TextView label = (TextView) promptsView.findViewById(R.id.passwordprompt_text);
|
final TextView label = promptsView.findViewById(R.id.passwordprompt_text);
|
||||||
label.setText(MainApp.gs(stringID));
|
label.setText(MainApp.gs(stringID));
|
||||||
final EditText userInput = (EditText) promptsView.findViewById(R.id.passwordprompt_pass);
|
final EditText userInput = promptsView.findViewById(R.id.passwordprompt_pass);
|
||||||
|
|
||||||
// set dialog message
|
// set dialog message
|
||||||
alertDialogBuilder
|
alertDialogBuilder
|
||||||
.setCancelable(false)
|
.setCancelable(false)
|
||||||
.setPositiveButton("OK",
|
.setPositiveButton(android.R.string.ok,
|
||||||
new DialogInterface.OnClickListener() {
|
(dialog, id) -> {
|
||||||
public void onClick(DialogInterface dialog,int id) {
|
String enteredPassword = userInput.getText().toString();
|
||||||
String enteredPassword = userInput.getText().toString();
|
if (password.equals(enteredPassword)) {
|
||||||
if (password.equals(enteredPassword)) {
|
if (ok != null) ok.run();
|
||||||
if (ok != null) ok.run();
|
} else {
|
||||||
} else {
|
ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.wrongpassword));
|
||||||
ToastUtils.showToastInUiThread(context, MainApp.gs(R.string.wrongpassword));
|
if (fail != null) fail.run();
|
||||||
if (fail != null) fail.run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton("Cancel",
|
.setNegativeButton(android.R.string.cancel,
|
||||||
new DialogInterface.OnClickListener() {
|
(dialog, id) -> dialog.cancel());
|
||||||
public void onClick(DialogInterface dialog,int id) {
|
|
||||||
dialog.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
AlertDialog alertDialog = alertDialogBuilder.create();
|
||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
|
alertDialog.setCanceledOnTouchOutside(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
package info.nightscout.androidaps.utils;
|
package info.nightscout.androidaps.utils;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -25,20 +23,10 @@ import info.nightscout.androidaps.services.Intents;
|
||||||
public class XdripCalibrations {
|
public class XdripCalibrations {
|
||||||
private static Logger log = LoggerFactory.getLogger(XdripCalibrations.class);
|
private static Logger log = LoggerFactory.getLogger(XdripCalibrations.class);
|
||||||
|
|
||||||
public static void confirmAndSendCalibration(final Double bg, Context parentContext) {
|
public static void confirmAndSendCalibration(final Double bg, final Context parentContext) {
|
||||||
if (parentContext != null) {
|
if (parentContext != null) {
|
||||||
String confirmMessage = String.format(MainApp.gs(R.string.send_calibration), bg);
|
String confirmMessage = String.format(MainApp.gs(R.string.send_calibration), bg);
|
||||||
|
OKDialog.showConfirmation(parentContext, confirmMessage, () -> sendIntent(bg));
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(parentContext);
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(confirmMessage);
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
sendIntent(bg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:paddingRight="5dp"
|
android:paddingRight="5dp"
|
||||||
android:text="@string/extendedbolus" />
|
android:text="@string/extended_bolus" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/treatments_tempbasals"
|
android:id="@+id/treatments_tempbasals"
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:paddingRight="5dp"
|
android:paddingRight="5dp"
|
||||||
android:text="@string/tempbasal" />
|
android:text="@string/pump_tempbasal_label" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/treatments_temptargets"
|
android:id="@+id/treatments_temptargets"
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:paddingRight="5dp"
|
android:paddingRight="5dp"
|
||||||
android:text="@string/temptarget" />
|
android:text="@string/careportal_temporarytarget" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/treatments_profileswitches"
|
android:id="@+id/treatments_profileswitches"
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
android:gravity="center_vertical|center_horizontal"
|
android:gravity="center_vertical|center_horizontal"
|
||||||
android:paddingLeft="5dp"
|
android:paddingLeft="5dp"
|
||||||
android:paddingRight="5dp"
|
android:paddingRight="5dp"
|
||||||
android:text="@string/profileswitch" />
|
android:text="@string/careportal_profileswitch" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/treatments_careportal"
|
android:id="@+id/treatments_careportal"
|
||||||
|
|
|
@ -136,7 +136,6 @@
|
||||||
<string name="overview">Overview</string>
|
<string name="overview">Overview</string>
|
||||||
<string name="nsprofile">NS Profile</string>
|
<string name="nsprofile">NS Profile</string>
|
||||||
<string name="simpleprofile">Simple profile</string>
|
<string name="simpleprofile">Simple profile</string>
|
||||||
<string name="tempbasal">TempBasal</string>
|
|
||||||
<string name="treatments">Treatments</string>
|
<string name="treatments">Treatments</string>
|
||||||
<string name="virtualpump">Virtual Pump</string>
|
<string name="virtualpump">Virtual Pump</string>
|
||||||
<string name="careportal">Careportal</string>
|
<string name="careportal">Careportal</string>
|
||||||
|
@ -177,14 +176,12 @@
|
||||||
<string name="overview_calculator_label">Calculator</string>
|
<string name="overview_calculator_label">Calculator</string>
|
||||||
<string name="constraintapllied">Constraint applied!</string>
|
<string name="constraintapllied">Constraint applied!</string>
|
||||||
<string name="confirmation">Confirmation</string>
|
<string name="confirmation">Confirmation</string>
|
||||||
<string name="entertreatmentquestion">Enter new treatment:</string>
|
|
||||||
<string name="bolus">Bolus</string>
|
<string name="bolus">Bolus</string>
|
||||||
<string name="sms_bolus">Bolus:</string>
|
<string name="sms_bolus">Bolus:</string>
|
||||||
<string name="basal">Basal</string>
|
<string name="basal">Basal</string>
|
||||||
<string name="sms_basal">Basal:</string>
|
<string name="sms_basal">Basal:</string>
|
||||||
<string name="carbs">Carbs</string>
|
<string name="carbs">Carbs</string>
|
||||||
<string name="changeyourinput">Change your input!</string>
|
<string name="changeyourinput">Change your input!</string>
|
||||||
<string name="setextendedbolusquestion">Set new extended bolus:</string>
|
|
||||||
<string name="configbuilder_bgsource">BG Source</string>
|
<string name="configbuilder_bgsource">BG Source</string>
|
||||||
<string name="configbuilder_bgsource_description">Where should AndroidAPS gain it\'s data from?</string>
|
<string name="configbuilder_bgsource_description">Where should AndroidAPS gain it\'s data from?</string>
|
||||||
<string name="xdrip">xDrip</string>
|
<string name="xdrip">xDrip</string>
|
||||||
|
@ -213,7 +210,7 @@
|
||||||
<string name="careportal_cgmsensorinsert">CGM Sensor Insert</string>
|
<string name="careportal_cgmsensorinsert">CGM Sensor Insert</string>
|
||||||
<string name="careportal_cgmsensorstart">CGM Sensor Start</string>
|
<string name="careportal_cgmsensorstart">CGM Sensor Start</string>
|
||||||
<string name="careportal_insulincartridgechange">Insulin Cartridge Change</string>
|
<string name="careportal_insulincartridgechange">Insulin Cartridge Change</string>
|
||||||
<string name="careportal_profileswitch">Profile Switch</string>
|
<string name="careportal_profileswitch">Profile switch</string>
|
||||||
<string name="careportal_snackbolus">Snack Bolus</string>
|
<string name="careportal_snackbolus">Snack Bolus</string>
|
||||||
<string name="careportal_mealbolus">Meal Bolus</string>
|
<string name="careportal_mealbolus">Meal Bolus</string>
|
||||||
<string name="careportal_correctionbolus">Correction Bolus</string>
|
<string name="careportal_correctionbolus">Correction Bolus</string>
|
||||||
|
@ -312,8 +309,8 @@
|
||||||
<string name="glucosetype_finger">Finger</string>
|
<string name="glucosetype_finger">Finger</string>
|
||||||
<string name="glucosetype_sensor">Sensor</string>
|
<string name="glucosetype_sensor">Sensor</string>
|
||||||
<string name="manual">Manual</string>
|
<string name="manual">Manual</string>
|
||||||
<string name="careportal_temporarytarget">Temporary Target</string>
|
<string name="careportal_temporarytarget">Temporary target</string>
|
||||||
<string name="careportal_temporarytargetcancel">Temporary Target Cancel</string>
|
<string name="careportal_temporarytargetcancel">Temporary target cancel</string>
|
||||||
<string name="danarprofile">DanaR profile settings</string>
|
<string name="danarprofile">DanaR profile settings</string>
|
||||||
<string name="danarprofile_dia">DIA [h]</string>
|
<string name="danarprofile_dia">DIA [h]</string>
|
||||||
<string name="danarprofile_dia_summary">Duration of Insulin Activity</string>
|
<string name="danarprofile_dia_summary">Duration of Insulin Activity</string>
|
||||||
|
@ -453,7 +450,7 @@
|
||||||
<string name="eatingsoon">Eating Soon</string>
|
<string name="eatingsoon">Eating Soon</string>
|
||||||
<string name="hypo">Hypo</string>
|
<string name="hypo">Hypo</string>
|
||||||
<string name="activity">Activity</string>
|
<string name="activity">Activity</string>
|
||||||
<string name="removerecord">Remove record:</string>
|
<string name="removerecord">Remove record</string>
|
||||||
<string name="danar_stats">DanaR Stats</string>
|
<string name="danar_stats">DanaR Stats</string>
|
||||||
<string name="danar_stats_cumulative_tdd">Cumulative TDD</string>
|
<string name="danar_stats_cumulative_tdd">Cumulative TDD</string>
|
||||||
<string name="danar_stats_expweight">Exponentially Weighted TDD</string>
|
<string name="danar_stats_expweight">Exponentially Weighted TDD</string>
|
||||||
|
@ -648,15 +645,12 @@
|
||||||
<string name="key_ns_noupload" translatable="false">ns_noupload</string>
|
<string name="key_ns_noupload" translatable="false">ns_noupload</string>
|
||||||
<string name="basal_step">Basal Step</string>
|
<string name="basal_step">Basal Step</string>
|
||||||
<string name="bolus_step">Bolus Step</string>
|
<string name="bolus_step">Bolus Step</string>
|
||||||
<string name="extendedbolus">ExtendedBolus</string>
|
|
||||||
<string name="temptarget">TempTarget</string>
|
|
||||||
<string name="overview_extendedbolus_cancel_button">Cancel Extended Bolus</string>
|
<string name="overview_extendedbolus_cancel_button">Cancel Extended Bolus</string>
|
||||||
<string name="careportal_sensorage_label">Sensor age</string>
|
<string name="careportal_sensorage_label">Sensor age</string>
|
||||||
<string name="careportal_canulaage_label">Canula age</string>
|
<string name="careportal_canulaage_label">Canula age</string>
|
||||||
<string name="careportal_insulinage_label">Insulin age</string>
|
<string name="careportal_insulinage_label">Insulin age</string>
|
||||||
<string name="hours">hours</string>
|
<string name="hours">hours</string>
|
||||||
<string name="invalidprofile">Invalid profile !!!</string>
|
<string name="invalidprofile">Invalid profile !!!</string>
|
||||||
<string name="profileswitch">ProfileSwitch</string>
|
|
||||||
<string name="doprofileswitch">Do Profile Switch</string>
|
<string name="doprofileswitch">Do Profile Switch</string>
|
||||||
<string name="careportal_pbage_label">Pump battery age</string>
|
<string name="careportal_pbage_label">Pump battery age</string>
|
||||||
<string name="careportal_pumpbatterychange">Pump Battery Change</string>
|
<string name="careportal_pumpbatterychange">Pump Battery Change</string>
|
||||||
|
@ -1692,5 +1686,6 @@
|
||||||
<string name="automation_event">Automation event</string>
|
<string name="automation_event">Automation event</string>
|
||||||
<string name="alreadyset">Already set</string>
|
<string name="alreadyset">Already set</string>
|
||||||
<string name="message">Message</string>
|
<string name="message">Message</string>
|
||||||
|
<string name="clearqueueconfirm">Clear queue? All data in queue will be lost!</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue