From 2d54a068ad2fa831cabaf81a291f1aa24f0a010c Mon Sep 17 00:00:00 2001 From: warstar2187 Date: Fri, 11 Nov 2016 23:07:32 +0900 Subject: [PATCH 01/11] Update strings.xml --- app/src/main/res/values-ko/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 2681be63bb..59018292ed 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -183,7 +183,7 @@ Glucose type 아직 NS에서 프로파일을 로드하지 못했습니다. 임시기초주입 - 확장식사 + 확장식사주입 NSClient 버전: Nightscout 버전: 보내기 @@ -243,7 +243,7 @@ 허가된 전화번호 +XXXXXXXXXX;+YYYYYYYYYY 식사주입 %.2fU 을 실행하려면 %s 를 입력하고 답장하세요 - 식사주입 실패 + Bolus failed Bolus %.2fU delivered successfully %.2fU 주입중 SMS 원격 명령 사용하기 @@ -315,10 +315,10 @@ 원격 기초주입설정이 허가되지 않았습니다 기초주입 %.2fU/h 을 실행하려면 %s 를 입력하고 답장하세요 Temp basal %.2fU/h for %d min started successfully - 임시기초주입이 실패하였습니다 + Temp basal start failed 임시기초주입을 중지하려면 %s 를 입력하고 답장하세요 Temp basal canceled - 임시기초주입 취소가 실패하였습니다 + Canceling temp basal failed 알려지지 않은 명령이거나 잘못된 답장입니다 퀵마법사 From 2365dbac860a8ff6e2dae613addbbd8b2da69568 Mon Sep 17 00:00:00 2001 From: warstar2187 Date: Sun, 13 Nov 2016 01:54:28 +0900 Subject: [PATCH 02/11] Update strings.xml --- app/src/main/res/values-ko/strings.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 59018292ed..d81f82769c 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -333,4 +333,16 @@ Corr 한국어 액션 + AndroidAPS 시작 + NS upload only (disabled sync) + NS upload only. 로컬소스(xDrip)가 선택되지 않으면 SGV에는 효력이 없습니다. NS프로파일이 사용중이라면 프로파일에는 효력이 없습니다. + 이 기능을 사용하시려면 "NS upload only"을 비활성화 하세요. + 펌프가 초기화 되지 않았습니다! + Prime/Fill + Please make sure the amount matches the specification of your infusion set! + Other + Fill/Prime standard insulin amounts. + Button 1 + Button 2 + Button 3 From da861a710845fd52d446b0deea18e71d79817dc1 Mon Sep 17 00:00:00 2001 From: ecorman Date: Wed, 23 Nov 2016 23:59:11 +0100 Subject: [PATCH 03/11] Note basal start / end to see note in Xdrip+ with data --- .../ConfigBuilder/ConfigBuilderPlugin.java | 3 ++ app/src/main/res/values-es/strings.xml | 47 +++++++++++++++++-- app/src/main/res/values/strings.xml | 2 + 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index 65660492be..c99bd18f37 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -738,6 +738,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain data.put("absolute", absolute); data.put("created_at", DateUtil.toISOString(new Date())); 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.putString("action", "dbAdd"); bundle.putString("collection", "treatments"); @@ -767,6 +768,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain data.put("percent", percent - 100); data.put("created_at", DateUtil.toISOString(new Date())); 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.putString("action", "dbAdd"); bundle.putString("collection", "treatments"); @@ -789,6 +791,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain data.put("eventType", "Temp Basal"); data.put("created_at", DateUtil.toISOString(new Date())); 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.putString("action", "dbAdd"); bundle.putString("collection", "treatments"); diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 4e8a0d3a59..5af78b08cf 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -12,7 +12,7 @@ Salida Usar bolos extendidos para> 200% DanaR dispositivo Bluetooth - Utilizar siempre valores basales absolutos + Usar siempre valor basal absoluto Objetivo: Meta: @@ -39,11 +39,11 @@ IOB Total: Insulina [U] Carbohidratos [g] - Glucosa en sangre + Glucosa Hidratos Carbono Corrección U - bolo IOB + Bolo IOB TOTAL Ejecutar ahora BOMBA VIRTUAL @@ -174,7 +174,7 @@ Duración Dosis Absoluto - min + min Notas Fecha Hora Perfil @@ -210,7 +210,7 @@ Conectando Conectado Desconectado - Sincronizar perfil Nightscout a bomba + Sincronizar perfil NS a bomba Ajustes de la bomba DanaR Nightscout Acuerdo de licencia de usuario final @@ -305,5 +305,42 @@ Valor objetivo para los cálculos Sin perfil seleccionado Korean + Acciones + Corr + Loop Inactivo + Bolo Comida + Valor %s fuera de limites + Botón Texto: + Carbs: + Validar: + Añadir + Editar + Eliminar + Asistente + Ajustes asistente + Loop se ha desactivado + Loop se ha activado + Loop inactivo + loop activo + Basal temporal cancelada + Fallo cancelación basal temporal + Fallo inicio basal temporal + Basal temporal %.2fU/h para %d min iniciada correctamente + Permitir comandos SMS remotos + Para parar basal temporal responder con codigo %s + AndroidAPS iniciado + Español + NS solo subida (sinc. inactiva) + Por favor desactiva \"NS solo subida\" para usar esta característica. + NS solo subida. No efectivo con SGV salvo que este seleccionada una fuente local como xDrip. No efectivo en perfiles usando perfiles NS + Otros + ¡Bomba no iniciada! + No permitidos ajustes basales remotos + ¿Realmente quiere resetear la base de datos? + Comando desconocido o respuesta incorrecta + ¡Por favor asegurar que la cantidad coincide con la especificación del set de infusión! + Para iniciar basal %.2fU/h responder con código %s + Inicio Basal Temporal + Fin Basal Temporal diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0b7b4db0f7..7619906ec0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -361,4 +361,6 @@ Edit Base-IC: Base Profile: CircadianPercentageProfile + Basal Temp End + Basal Temp Start From f25715d87c7850a07591f238660b1b2797cec723 Mon Sep 17 00:00:00 2001 From: LadyViktoria Date: Thu, 24 Nov 2016 18:46:16 +0100 Subject: [PATCH 04/11] Android 6+ Permissions --- .../nightscout/androidaps/MainActivity.java | 55 ++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index aead928e52..d8356dec9b 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -1,11 +1,14 @@ package info.nightscout.androidaps; +import android.Manifest; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; +import android.os.Build; import android.os.Bundle; import android.preference.PreferenceManager; +import android.support.v4.app.ActivityCompat; import android.support.v4.app.Fragment; import android.support.v4.view.ViewPager; import android.support.v7.app.AlertDialog; @@ -39,6 +42,7 @@ public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + checkPermission(); Iconify.with(new FontAwesomeModule()); LocaleHelper.onCreate(this, "en"); setContentView(R.layout.activity_main); @@ -162,7 +166,6 @@ public class MainActivity extends AppCompatActivity { return super.onOptionsItemSelected(item); } - private void registerBus() { try { MainApp.bus().unregister(this); @@ -181,4 +184,52 @@ public class MainActivity extends AppCompatActivity { } } -} + private void checkPermission() { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { + if (!checkIfAlreadyhavePermission()) {requestForSpecificPermission();} + } + } + + private boolean checkIfAlreadyhavePermission() { + if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { + return true; + } + else if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { + return true; + } + else if (ActivityCompat.checkSelfPermission(this, Manifest.permission.RECEIVE_SMS) == PackageManager.PERMISSION_GRANTED) { + return true; + } + else if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED) { + return true; + } + else { + AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this); + alert.setTitle("Restart"); + alert.setMessage("Please Restart Android APS \notherwise Android APS will not work proper!"); + alert.setPositiveButton("OK",null); + alert.show(); + return false; + } + } + + public void requestForSpecificPermission(){ + ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECEIVE_SMS, Manifest.permission.READ_SMS, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 101); + } + + @Override + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { + switch (requestCode) { + case 101: + if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { + //granted + } + else { + //not granted + } + break; + default: + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + } + } +} \ No newline at end of file From dd02fcaa8508d4c61d5cbaaf5d8b97442e9de72c Mon Sep 17 00:00:00 2001 From: viktoria Date: Fri, 25 Nov 2016 01:47:59 +0100 Subject: [PATCH 05/11] Android 6+ Permissions #2 --- .../nightscout/androidaps/MainActivity.java | 70 ++++++++----------- 1 file changed, 31 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index d8356dec9b..31b3ea5956 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -10,6 +10,7 @@ import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.ActivityCompat; import android.support.v4.app.Fragment; +import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; @@ -25,6 +26,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.events.EventAppExit; +import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventRefreshGui; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.plugins.DanaR.Services.ExecutionService; @@ -39,14 +41,19 @@ public class MainActivity extends AppCompatActivity { private static KeepAliveReceiver keepAliveReceiver; + static final Integer STORAGE = 0x1; + static final Integer SMS = 0x2; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - checkPermission(); Iconify.with(new FontAwesomeModule()); LocaleHelper.onCreate(this, "en"); setContentView(R.layout.activity_main); checkEula(); + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { + askForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, STORAGE); + } if (Config.logFunctionCalls) log.debug("onCreate"); @@ -184,52 +191,37 @@ public class MainActivity extends AppCompatActivity { } } - private void checkPermission() { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - if (!checkIfAlreadyhavePermission()) {requestForSpecificPermission();} + @Subscribe + public void onStatusEvent(final EventPreferenceChange ev) { + SharedPreferences smssettings = PreferenceManager.getDefaultSharedPreferences(this); + if (smssettings.getBoolean("smscommunicator_remotecommandsallowed", false)) { + if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { + askForPermission(Manifest.permission.RECEIVE_SMS, SMS); + } } } - private boolean checkIfAlreadyhavePermission() { - if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { - return true; + private void askForPermission(String permission, Integer requestCode) { + if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, new String[]{permission}, requestCode); } - else if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { - return true; - } - else if (ActivityCompat.checkSelfPermission(this, Manifest.permission.RECEIVE_SMS) == PackageManager.PERMISSION_GRANTED) { - return true; - } - else if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_SMS) == PackageManager.PERMISSION_GRANTED) { - return true; - } - else { - AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this); - alert.setTitle("Restart"); - alert.setMessage("Please Restart Android APS \notherwise Android APS will not work proper!"); - alert.setPositiveButton("OK",null); - alert.show(); - return false; - } - } - - public void requestForSpecificPermission(){ - ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.RECEIVE_SMS, Manifest.permission.READ_SMS, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 101); } @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { - switch (requestCode) { - case 101: - if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { - //granted - } - else { - //not granted - } - break; - default: - super.onRequestPermissionsResult(requestCode, permissions, grantResults); + super.onRequestPermissionsResult(requestCode, permissions, grantResults); + if(ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED){ + switch (requestCode) { + case 1: + AlertDialog.Builder alert = new AlertDialog.Builder(this); + alert.setTitle("Restart"); + alert.setMessage("Please Restart Android APS \notherwise Android APS will not work proper!"); + alert.setPositiveButton("OK",null); + alert.show(); + break; + case 2: + break; + } } } } \ No newline at end of file From 1967602c70f7e873bf372954310881e1da4b0616 Mon Sep 17 00:00:00 2001 From: LadyViktoria Date: Fri, 25 Nov 2016 10:13:27 +0100 Subject: [PATCH 06/11] Android 6+ Permissions #3 --- .../info/nightscout/androidaps/MainActivity.java | 15 ++++++++------- app/src/main/res/values/strings.xml | 2 ++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 31b3ea5956..4470e2312c 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -41,8 +41,8 @@ public class MainActivity extends AppCompatActivity { private static KeepAliveReceiver keepAliveReceiver; - static final Integer STORAGE = 0x1; - static final Integer SMS = 0x2; + static final Integer CASE_STORAGE = 0x1; + static final Integer CASE_SMS = 0x2; @Override protected void onCreate(Bundle savedInstanceState) { @@ -52,7 +52,7 @@ public class MainActivity extends AppCompatActivity { setContentView(R.layout.activity_main); checkEula(); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - askForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, STORAGE); + askForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, CASE_STORAGE); } if (Config.logFunctionCalls) log.debug("onCreate"); @@ -191,12 +191,13 @@ public class MainActivity extends AppCompatActivity { } } + //check for sms permission if enable in prefernces @Subscribe public void onStatusEvent(final EventPreferenceChange ev) { SharedPreferences smssettings = PreferenceManager.getDefaultSharedPreferences(this); if (smssettings.getBoolean("smscommunicator_remotecommandsallowed", false)) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - askForPermission(Manifest.permission.RECEIVE_SMS, SMS); + askForPermission(Manifest.permission.RECEIVE_SMS, CASE_SMS); } } } @@ -213,10 +214,10 @@ public class MainActivity extends AppCompatActivity { if(ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED){ switch (requestCode) { case 1: + //show dialog after permission is granted AlertDialog.Builder alert = new AlertDialog.Builder(this); - alert.setTitle("Restart"); - alert.setMessage("Please Restart Android APS \notherwise Android APS will not work proper!"); - alert.setPositiveButton("OK",null); + alert.setMessage(R.string.alert_dialog_storage_permission_text); + alert.setPositiveButton(R.string.alert_dialog_positive_button,null); alert.show(); break; case 2: diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0b7b4db0f7..060d12ce20 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,6 +14,8 @@ Use extended boluses for >200% DanaR Bluetooth device Always use basal absolute values + OK + Please Restart Android APS \notherwise Android APS will not work proper! Objective: Gate: From 33d783e9b0d50a9cfd6af5eb4e360040d4f92afc Mon Sep 17 00:00:00 2001 From: LadyViktoria Date: Fri, 25 Nov 2016 11:24:56 +0100 Subject: [PATCH 07/11] Android 6+ Permissions #4 --- .../nightscout/androidaps/MainActivity.java | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 4470e2312c..8d83e309d2 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -52,7 +52,8 @@ public class MainActivity extends AppCompatActivity { setContentView(R.layout.activity_main); checkEula(); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - askForPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, CASE_STORAGE); + askForPermission(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE}, CASE_STORAGE); } if (Config.logFunctionCalls) log.debug("onCreate"); @@ -197,14 +198,20 @@ public class MainActivity extends AppCompatActivity { SharedPreferences smssettings = PreferenceManager.getDefaultSharedPreferences(this); if (smssettings.getBoolean("smscommunicator_remotecommandsallowed", false)) { if (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1) { - askForPermission(Manifest.permission.RECEIVE_SMS, CASE_SMS); + askForPermission(new String[]{Manifest.permission.RECEIVE_SMS, + Manifest.permission.SEND_SMS, + Manifest.permission.RECEIVE_MMS}, CASE_SMS); } } } - private void askForPermission(String permission, Integer requestCode) { - if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) { - ActivityCompat.requestPermissions(this, new String[]{permission}, requestCode); + 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); } } @@ -212,16 +219,18 @@ public class MainActivity extends AppCompatActivity { public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); if(ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED){ - switch (requestCode) { - case 1: - //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.alert_dialog_positive_button,null); - alert.show(); - break; - case 2: - break; + if(permissions.length != 0){ + switch (requestCode) { + case 1: + //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.alert_dialog_positive_button,null); + alert.show(); + break; + case 2: + break; + } } } } From ff29a795db561361263349779d45ca0ed2c9d090 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Fri, 25 Nov 2016 12:00:15 +0100 Subject: [PATCH 08/11] SMS permission crashfix --- .../nightscout/androidaps/MainActivity.java | 48 ++++++++++++++----- 1 file changed, 37 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 8d83e309d2..7bb7dac557 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -41,8 +41,10 @@ public class MainActivity extends AppCompatActivity { private static KeepAliveReceiver keepAliveReceiver; - static final Integer CASE_STORAGE = 0x1; - static final Integer CASE_SMS = 0x2; + static final int CASE_STORAGE = 0x1; + static final int CASE_SMS = 0x2; + + private boolean askForSMS = false; @Override protected void onCreate(Bundle savedInstanceState) { @@ -195,12 +197,36 @@ public class MainActivity extends AppCompatActivity { //check for sms permission if enable in prefernces @Subscribe public void onStatusEvent(final EventPreferenceChange ev) { - 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); + 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); + } } } } @@ -221,17 +247,17 @@ public class MainActivity extends AppCompatActivity { if(ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED){ if(permissions.length != 0){ switch (requestCode) { - case 1: + 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.alert_dialog_positive_button,null); alert.show(); break; - case 2: + case CASE_SMS: break; } } } } -} \ No newline at end of file +} From 39be1bb4c72cc266395a92388dd6e512cc91172a Mon Sep 17 00:00:00 2001 From: LadyViktoria Date: Fri, 25 Nov 2016 12:42:24 +0100 Subject: [PATCH 09/11] Android 6+ Permissions #6 --- app/src/main/java/info/nightscout/androidaps/MainActivity.java | 2 +- app/src/main/res/values/strings.xml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 7bb7dac557..6a4bacc2b7 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -251,7 +251,7 @@ public class MainActivity extends AppCompatActivity { //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.alert_dialog_positive_button,null); + alert.setPositiveButton(R.string.ok,null); alert.show(); break; case CASE_SMS: diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 060d12ce20..67aa4f6a12 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -14,8 +14,7 @@ Use extended boluses for >200% DanaR Bluetooth device Always use basal absolute values - OK - Please Restart Android APS \notherwise Android APS will not work proper! + 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)! Objective: Gate: From b2d2f462f68f45d47ffce326063097ce9adaf848 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Fri, 25 Nov 2016 12:49:41 +0100 Subject: [PATCH 10/11] first check if element exist, then access it --- .../main/java/info/nightscout/androidaps/MainActivity.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 6a4bacc2b7..faf0c259fe 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -244,14 +244,14 @@ public class MainActivity extends AppCompatActivity { @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if(ActivityCompat.checkSelfPermission(this, permissions[0]) == PackageManager.PERMISSION_GRANTED){ - if(permissions.length != 0){ + 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.setPositiveButton(R.string.ok, null); alert.show(); break; case CASE_SMS: From 7f97b232da6ad509468b1da7ce175cffe91ea3be Mon Sep 17 00:00:00 2001 From: warstar2187 Date: Tue, 29 Nov 2016 12:08:45 +0900 Subject: [PATCH 11/11] Update Treatment.java --- app/src/main/java/info/nightscout/androidaps/db/Treatment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/db/Treatment.java b/app/src/main/java/info/nightscout/androidaps/db/Treatment.java index 3c08789f80..f7a40284d6 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/Treatment.java +++ b/app/src/main/java/info/nightscout/androidaps/db/Treatment.java @@ -78,7 +78,7 @@ public class Treatment implements DataPointWithLabelInterface { } else if (minAgo < end) { Double x2 = (minAgo - 75) / 5; 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;