Merge pull request #25 from AdrianLxM/wear-prepare-final

wear merge current master
This commit is contained in:
AdrianLxM 2016-11-29 13:17:21 +01:00 committed by GitHub
commit 1eacf35e47
6 changed files with 145 additions and 11 deletions

View file

@ -1,12 +1,16 @@
package info.nightscout.androidaps; package info.nightscout.androidaps;
import android.Manifest;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
@ -22,6 +26,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.events.EventRefreshGui;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService; import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService;
@ -36,6 +41,11 @@ public class MainActivity extends AppCompatActivity {
private static KeepAliveReceiver keepAliveReceiver; private static KeepAliveReceiver keepAliveReceiver;
static final int CASE_STORAGE = 0x1;
static final int CASE_SMS = 0x2;
private boolean askForSMS = false;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -43,6 +53,10 @@ public class MainActivity extends AppCompatActivity {
LocaleHelper.onCreate(this, "en"); LocaleHelper.onCreate(this, "en");
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
checkEula(); checkEula();
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
askForPermission(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE}, CASE_STORAGE);
}
if (Config.logFunctionCalls) if (Config.logFunctionCalls)
log.debug("onCreate"); log.debug("onCreate");
@ -162,7 +176,6 @@ public class MainActivity extends AppCompatActivity {
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
private void registerBus() { private void registerBus() {
try { try {
MainApp.bus().unregister(this); MainApp.bus().unregister(this);
@ -181,4 +194,70 @@ public class MainActivity extends AppCompatActivity {
} }
} }
//check for sms permission if enable in prefernces
@Subscribe
public void onStatusEvent(final EventPreferenceChange ev) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
SharedPreferences smssettings = PreferenceManager.getDefaultSharedPreferences(this);
synchronized (this){
if (smssettings.getBoolean("smscommunicator_remotecommandsallowed", false)) {
setAskForSMS();
}
}
}
}
private synchronized void setAskForSMS() {
askForSMS = true;
}
@Override
protected void onResume(){
super.onResume();
askForSMSPermissions();
}
private synchronized void askForSMSPermissions(){
if (askForSMS) { //only when settings were changed an MainActivity resumes.
askForSMS = false;
SharedPreferences smssettings = PreferenceManager.getDefaultSharedPreferences(this);
if (smssettings.getBoolean("smscommunicator_remotecommandsallowed", false)) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) {
askForPermission(new String[]{Manifest.permission.RECEIVE_SMS,
Manifest.permission.SEND_SMS,
Manifest.permission.RECEIVE_MMS}, CASE_SMS);
}
}
}
}
private void askForPermission(String[] permission, Integer requestCode) {
boolean test = false;
for (int i=0; i < permission.length; i++) {
test = test || (ContextCompat.checkSelfPermission(this, permission[i]) != PackageManager.PERMISSION_GRANTED);
}
if (test) {
ActivityCompat.requestPermissions(this, permission, requestCode);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (permissions.length != 0) {
if (ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED) {
switch (requestCode) {
case CASE_STORAGE:
//show dialog after permission is granted
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setMessage(R.string.alert_dialog_storage_permission_text);
alert.setPositiveButton(R.string.ok, null);
alert.show();
break;
case CASE_SMS:
break;
}
}
}
}
} }

View file

@ -78,7 +78,7 @@ public class Treatment implements DataPointWithLabelInterface {
} else if (minAgo < end) { } else if (minAgo < end) {
Double x2 = (minAgo - 75) / 5; Double x2 = (minAgo - 75) / 5;
result.iobContrib = this.insulin * (0.001323 * x2 * x2 - 0.054233 * x2 + 0.55556); result.iobContrib = this.insulin * (0.001323 * x2 * x2 - 0.054233 * x2 + 0.55556);
result.activityContrib = this.insulin * (2 / dia / 60 - (minAgo - peak) * 2 / dia / 60 / (60 * dia - peak)); result.activityContrib = this.insulin * (2 / dia / 60 - (minAgo - peak) * 2 / dia / 60 / (60 * 3 - peak));
} }
} }
return result; return result;

View file

@ -738,6 +738,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
data.put("absolute", absolute); data.put("absolute", absolute);
data.put("created_at", DateUtil.toISOString(new Date())); data.put("created_at", DateUtil.toISOString(new Date()));
data.put("enteredBy", MainApp.instance().getString(R.string.app_name)); data.put("enteredBy", MainApp.instance().getString(R.string.app_name));
data.put("notes", MainApp.sResources.getString(R.string.androidaps_tempbasalstartnote) + " " + absolute + "u/h " + durationInMinutes +" min"); // ECOR
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("action", "dbAdd"); bundle.putString("action", "dbAdd");
bundle.putString("collection", "treatments"); bundle.putString("collection", "treatments");
@ -767,6 +768,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
data.put("percent", percent - 100); data.put("percent", percent - 100);
data.put("created_at", DateUtil.toISOString(new Date())); data.put("created_at", DateUtil.toISOString(new Date()));
data.put("enteredBy", MainApp.instance().getString(R.string.app_name)); data.put("enteredBy", MainApp.instance().getString(R.string.app_name));
data.put("notes", MainApp.sResources.getString(R.string.androidaps_tempbasalstartnote) + " " + percent + "% " + durationInMinutes +" min"); // ECOR
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("action", "dbAdd"); bundle.putString("action", "dbAdd");
bundle.putString("collection", "treatments"); bundle.putString("collection", "treatments");
@ -789,6 +791,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
data.put("eventType", "Temp Basal"); data.put("eventType", "Temp Basal");
data.put("created_at", DateUtil.toISOString(new Date())); data.put("created_at", DateUtil.toISOString(new Date()));
data.put("enteredBy", MainApp.instance().getString(R.string.app_name)); data.put("enteredBy", MainApp.instance().getString(R.string.app_name));
data.put("notes", MainApp.sResources.getString(R.string.androidaps_tempbasalendnote)); // ECOR
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString("action", "dbAdd"); bundle.putString("action", "dbAdd");
bundle.putString("collection", "treatments"); bundle.putString("collection", "treatments");

View file

@ -12,7 +12,7 @@
<string name="nav_exit">Salida</string> <string name="nav_exit">Salida</string>
<string name="danar_useextended_title">Usar bolos extendidos para&gt; 200%</string> <string name="danar_useextended_title">Usar bolos extendidos para&gt; 200%</string>
<string name="danar_bt_name_title">DanaR dispositivo Bluetooth</string> <string name="danar_bt_name_title">DanaR dispositivo Bluetooth</string>
<string name="ns_sync_use_absolute_title">Utilizar siempre valores basales absolutos</string> <string name="ns_sync_use_absolute_title">Usar siempre valor basal absoluto</string>
<string name="objectives_objective_label_string">Objetivo:</string> <string name="objectives_objective_label_string">Objetivo:</string>
<string name="objectives_gate_label_string">Meta:</string> <string name="objectives_gate_label_string">Meta:</string>
@ -39,11 +39,11 @@
<string name="tempbasals_iobtotal_label_string">IOB Total:</string> <string name="tempbasals_iobtotal_label_string">IOB Total:</string>
<string name="treatments_newtreatment_insulinamount_label">Insulina [U]</string> <string name="treatments_newtreatment_insulinamount_label">Insulina [U]</string>
<string name="treatments_newtreatment_carbsamount_label">Carbohidratos [g]</string> <string name="treatments_newtreatment_carbsamount_label">Carbohidratos [g]</string>
<string name="treatments_wizard_bg_label">Glucosa en sangre</string> <string name="treatments_wizard_bg_label">Glucosa</string>
<string name="treatments_wizard_carbs_label">Hidratos Carbono</string> <string name="treatments_wizard_carbs_label">Hidratos Carbono</string>
<string name="treatments_wizard_correction_label">Corrección</string> <string name="treatments_wizard_correction_label">Corrección</string>
<string name="treatments_wizard_unit_label">U</string> <string name="treatments_wizard_unit_label">U</string>
<string name="treatments_wizard_bolusiob_label">bolo IOB</string> <string name="treatments_wizard_bolusiob_label">Bolo IOB</string>
<string name="treatments_wizard_total_label">TOTAL</string> <string name="treatments_wizard_total_label">TOTAL</string>
<string name="openapsma_run">Ejecutar ahora</string> <string name="openapsma_run">Ejecutar ahora</string>
<string name="vitualpump_label">BOMBA VIRTUAL</string> <string name="vitualpump_label">BOMBA VIRTUAL</string>
@ -174,7 +174,7 @@
<string name="careportal_newnstreatment_duration_label">Duración</string> <string name="careportal_newnstreatment_duration_label">Duración</string>
<string name="careportal_newnstreatment_percent_label">Dosis</string> <string name="careportal_newnstreatment_percent_label">Dosis</string>
<string name="careportal_newnstreatment_absolute_label">Absoluto</string> <string name="careportal_newnstreatment_absolute_label">Absoluto</string>
<string name="careportal_newnstreatment_duration_min">min</string> <string name="careportal_newnstreatment_duration_min"> min</string>
<string name="careportal_newnstreatment_notes_label">Notas</string> <string name="careportal_newnstreatment_notes_label">Notas</string>
<string name="careportal_newnstreatment_eventtime_label">Fecha Hora</string> <string name="careportal_newnstreatment_eventtime_label">Fecha Hora</string>
<string name="careportal_newnstreatment_profile_label">Perfil</string> <string name="careportal_newnstreatment_profile_label">Perfil</string>
@ -210,7 +210,7 @@
<string name="connecting">Conectando</string> <string name="connecting">Conectando</string>
<string name="connected">Conectado</string> <string name="connected">Conectado</string>
<string name="disconnected">Desconectado</string> <string name="disconnected">Desconectado</string>
<string name="syncprofiletopump_title">Sincronizar perfil Nightscout a bomba</string> <string name="syncprofiletopump_title">Sincronizar perfil NS a bomba</string>
<string name="danar_pump_settings">Ajustes de la bomba DanaR</string> <string name="danar_pump_settings">Ajustes de la bomba DanaR</string>
<string name="nightscout">Nightscout</string> <string name="nightscout">Nightscout</string>
<string name="end_user_license_agreement">Acuerdo de licencia de usuario final</string> <string name="end_user_license_agreement">Acuerdo de licencia de usuario final</string>
@ -305,5 +305,42 @@
<string name="openapsma_target_bg">Valor objetivo para los cálculos</string> <string name="openapsma_target_bg">Valor objetivo para los cálculos</string>
<string name="noprofileselected">Sin perfil seleccionado</string> <string name="noprofileselected">Sin perfil seleccionado</string>
<string name="ko_lang">Korean</string> <string name="ko_lang">Korean</string>
<string name="actions">Acciones</string>
<string name="correctionbous">Corr</string>
<string name="disabledloop">Loop Inactivo</string>
<string name="mealbolus">Bolo Comida</string>
<string name="openapsma_valueoutofrange">Valor %s fuera de limites</string>
<string name="overview_editquickwizard_buttontext">Botón Texto:</string>
<string name="overview_editquickwizard_carbs">Carbs:</string>
<string name="overview_editquickwizard_valid">Validar:</string>
<string name="overview_editquickwizardlistactivity_add">Añadir</string>
<string name="overview_quickwizard_item_edit_button">Editar</string>
<string name="overview_quickwizard_item_remove_button">Eliminar</string>
<string name="quickwizard">Asistente</string>
<string name="quickwizardsettings">Ajustes asistente</string>
<string name="smscommunicator_loophasbeendisabled">Loop se ha desactivado</string>
<string name="smscommunicator_loophasbeenenabled">Loop se ha activado</string>
<string name="smscommunicator_loopisdisabled">Loop inactivo</string>
<string name="smscommunicator_loopisenabled">loop activo</string>
<string name="smscommunicator_tempbasalcanceled">Basal temporal cancelada</string>
<string name="smscommunicator_tempbasalcancelfailed">Fallo cancelación basal temporal</string>
<string name="smscommunicator_tempbasalfailed">Fallo inicio basal temporal</string>
<string formatted="false" name="smscommunicator_tempbasalset">Basal temporal %.2fU/h para %d min iniciada correctamente</string>
<string name="smscommunicator_remotecommandsallowed">Permitir comandos SMS remotos</string>
<string name="smscommunicator_basalstopreplywithcode">Para parar basal temporal responder con codigo %s</string>
<string name="androidaps_start">AndroidAPS iniciado</string>
<string name="es_lang">Español</string>
<string name="ns_upload_only">NS solo subida (sinc. inactiva)</string>
<string name="ns_upload_only_enabled">Por favor desactiva \"NS solo subida\" para usar esta característica.</string>
<string name="ns_upload_only_summary">NS solo subida. No efectivo con SGV salvo que este seleccionada una fuente local como xDrip. No efectivo en perfiles usando perfiles NS</string>
<string name="othersettings_title">Otros</string>
<string name="pumpNotInitialized">¡Bomba no iniciada!</string>
<string name="remotebasalnotallowed">No permitidos ajustes basales remotos</string>
<string name="reset_db_confirm">¿Realmente quiere resetear la base de datos?</string>
<string name="smscommunicator_unknowncommand">Comando desconocido o respuesta incorrecta</string>
<string name="fillwarning">¡Por favor asegurar que la cantidad coincide con la especificación del set de infusión!</string>
<string formatted="false" name="smscommunicator_basalreplywithcode">Para iniciar basal %.2fU/h responder con código %s</string>
<string name="androidaps_tempbasalstartnote">Inicio Basal Temporal</string>
<string name="androidaps_tempbasalendnote">Fin Basal Temporal</string>
</resources> </resources>

View file

@ -183,7 +183,7 @@
<string name="careportal_newnstreatment_glucosetype">Glucose type</string> <string name="careportal_newnstreatment_glucosetype">Glucose type</string>
<string name="noprofile">아직 NS에서 프로파일을 로드하지 못했습니다.</string> <string name="noprofile">아직 NS에서 프로파일을 로드하지 못했습니다.</string>
<string name="overview_tempbasal_button">임시기초주입</string> <string name="overview_tempbasal_button">임시기초주입</string>
<string name="overview_extendedbolus_button">확장식사</string> <string name="overview_extendedbolus_button">확장식사주입</string>
<string name="configbuilder_nsclientversion_label">NSClient 버전:</string> <string name="configbuilder_nsclientversion_label">NSClient 버전:</string>
<string name="configbuilder_nightscoutversion_label">Nightscout 버전:</string> <string name="configbuilder_nightscoutversion_label">Nightscout 버전:</string>
<string name="send">보내기</string> <string name="send">보내기</string>
@ -243,7 +243,7 @@
<string name="smscommunicator_allowednumbers">허가된 전화번호</string> <string name="smscommunicator_allowednumbers">허가된 전화번호</string>
<string name="smscommunicator_allowednumbers_summary">+XXXXXXXXXX;+YYYYYYYYYY</string> <string name="smscommunicator_allowednumbers_summary">+XXXXXXXXXX;+YYYYYYYYYY</string>
<string name="smscommunicator_bolusreplywithcode" formatted="false">식사주입 %.2fU 을 실행하려면 %s 를 입력하고 답장하세요</string> <string name="smscommunicator_bolusreplywithcode" formatted="false">식사주입 %.2fU 을 실행하려면 %s 를 입력하고 답장하세요</string>
<string name="bolusfailed">식사주입 실패</string> <string name="bolusfailed">Bolus failed</string>
<string name="bolusdelivered" formatted="false">Bolus %.2fU delivered successfully</string> <string name="bolusdelivered" formatted="false">Bolus %.2fU delivered successfully</string>
<string name="bolusdelivering" formatted="false">%.2fU 주입중</string> <string name="bolusdelivering" formatted="false">%.2fU 주입중</string>
<string name="smscommunicator_remotecommandsallowed">SMS 원격 명령 사용하기</string> <string name="smscommunicator_remotecommandsallowed">SMS 원격 명령 사용하기</string>
@ -315,10 +315,10 @@
<string name="remotebasalnotallowed">원격 기초주입설정이 허가되지 않았습니다</string> <string name="remotebasalnotallowed">원격 기초주입설정이 허가되지 않았습니다</string>
<string name="smscommunicator_basalreplywithcode" formatted="false">기초주입 %.2fU/h 을 실행하려면 %s 를 입력하고 답장하세요</string> <string name="smscommunicator_basalreplywithcode" formatted="false">기초주입 %.2fU/h 을 실행하려면 %s 를 입력하고 답장하세요</string>
<string name="smscommunicator_tempbasalset" formatted="false">Temp basal %.2fU/h for %d min started successfully</string> <string name="smscommunicator_tempbasalset" formatted="false">Temp basal %.2fU/h for %d min started successfully</string>
<string name="smscommunicator_tempbasalfailed">임시기초주입이 실패하였습니다</string> <string name="smscommunicator_tempbasalfailed">Temp basal start failed</string>
<string name="smscommunicator_basalstopreplywithcode" formatted="false">임시기초주입을 중지하려면 %s 를 입력하고 답장하세요</string> <string name="smscommunicator_basalstopreplywithcode" formatted="false">임시기초주입을 중지하려면 %s 를 입력하고 답장하세요</string>
<string name="smscommunicator_tempbasalcanceled">Temp basal canceled</string> <string name="smscommunicator_tempbasalcanceled">Temp basal canceled</string>
<string name="smscommunicator_tempbasalcancelfailed">임시기초주입 취소가 실패하였습니다</string> <string name="smscommunicator_tempbasalcancelfailed">Canceling temp basal failed</string>
<string name="smscommunicator_unknowncommand">알려지지 않은 명령이거나 잘못된 답장입니다</string> <string name="smscommunicator_unknowncommand">알려지지 않은 명령이거나 잘못된 답장입니다</string>
<string name="quickwizard">퀵마법사</string> <string name="quickwizard">퀵마법사</string>
@ -333,4 +333,16 @@
<string name="correctionbous">Corr</string> <string name="correctionbous">Corr</string>
<string name="ko_lang">한국어</string> <string name="ko_lang">한국어</string>
<string name="actions">액션</string> <string name="actions">액션</string>
<string name="androidaps_start">AndroidAPS 시작</string>
<string name="ns_upload_only">NS upload only (disabled sync)</string>
<string name="ns_upload_only_summary">NS upload only. 로컬소스(xDrip)가 선택되지 않으면 SGV에는 효력이 없습니다. NS프로파일이 사용중이라면 프로파일에는 효력이 없습니다.</string>
<string name="ns_upload_only_enabled">이 기능을 사용하시려면 "NS upload only"을 비활성화 하세요.</string>
<string name="pumpNotInitialized">펌프가 초기화 되지 않았습니다!</string>
<string name="primefill">Prime/Fill</string>
<string name="fillwarning">Please make sure the amount matches the specification of your infusion set!</string>
<string name="othersettings_title">Other</string>
<string name="fillbolus_title">Fill/Prime standard insulin amounts.</string>
<string name="button1">Button 1</string>
<string name="button2">Button 2</string>
<string name="button3">Button 3</string>
</resources> </resources>

View file

@ -14,6 +14,7 @@
<string name="danar_useextended_title">Use extended boluses for >200%</string> <string name="danar_useextended_title">Use extended boluses for >200%</string>
<string name="danar_bt_name_title">DanaR Bluetooth device</string> <string name="danar_bt_name_title">DanaR Bluetooth device</string>
<string name="ns_sync_use_absolute_title">Always use basal absolute values</string> <string name="ns_sync_use_absolute_title">Always use basal absolute values</string>
<string name="alert_dialog_storage_permission_text">Please reboot your phone or restart AndroidAPS from the System Settings \notherwise Android APS will not have logging (important to track and verify that the algorithms are working correctly)!</string>
<string name="objectives_objective_label_string">Objective:</string> <string name="objectives_objective_label_string">Objective:</string>
<string name="objectives_gate_label_string">Gate:</string> <string name="objectives_gate_label_string">Gate:</string>
@ -361,4 +362,6 @@
<string name="edit_base_ic">Edit Base-IC:</string> <string name="edit_base_ic">Edit Base-IC:</string>
<string name="base_profile_label">Base Profile:</string> <string name="base_profile_label">Base Profile:</string>
<string name="circadian_percentage_profile">CircadianPercentageProfile</string> <string name="circadian_percentage_profile">CircadianPercentageProfile</string>
<string name="androidaps_tempbasalendnote">Basal Temp End</string>
<string name="androidaps_tempbasalstartnote">Basal Temp Start</string>
</resources> </resources>