diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index f740fa5070..7ef621de3b 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -35,8 +35,6 @@ import info.nightscout.androidaps.events.EventAppExit import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.events.EventRebuildTabs import info.nightscout.androidaps.interfaces.* -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.logging.UserEntryLogger import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker @@ -53,9 +51,10 @@ import info.nightscout.androidaps.utils.extensions.isRunningRealPumpTest import info.nightscout.androidaps.utils.locale.LocaleHelper import info.nightscout.androidaps.utils.protection.ProtectionCheck import info.nightscout.androidaps.utils.rx.AapsSchedulers -import info.nightscout.shared.sharedPreferences.SP import info.nightscout.androidaps.utils.tabs.TabPageAdapter import info.nightscout.androidaps.utils.ui.UIRunnable +import info.nightscout.shared.logging.LTag +import info.nightscout.shared.sharedPreferences.SP import io.reactivex.disposables.CompositeDisposable import io.reactivex.rxkotlin.plusAssign import java.util.* @@ -66,7 +65,6 @@ class MainActivity : NoSplashAppCompatActivity() { private val disposable = CompositeDisposable() - @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var rxBus: RxBus @Inject lateinit var androidPermission: AndroidPermission @@ -145,6 +143,7 @@ class MainActivity : NoSplashAppCompatActivity() { if (config.PUMPDRIVERS) { androidPermission.notifyForSMSPermissions(this, smsCommunicatorPlugin) androidPermission.notifyForSystemWindowPermissions(this) + androidPermission.notifyForBtConnectPermission(this) } } diff --git a/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt index 6812d0b648..7883c4ecd2 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt @@ -22,8 +22,6 @@ import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.Config import info.nightscout.androidaps.interfaces.Loop import info.nightscout.androidaps.interfaces.ProfileFunction -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus import info.nightscout.androidaps.plugins.general.overview.OverviewData @@ -35,9 +33,14 @@ import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventIobCa import info.nightscout.androidaps.plugins.sensitivity.SensitivityAAPSPlugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin import info.nightscout.androidaps.plugins.sensitivity.SensitivityWeightedAveragePlugin -import info.nightscout.androidaps.utils.* +import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.DefaultValueHelper +import info.nightscout.androidaps.utils.FabricPrivacy +import info.nightscout.androidaps.utils.T +import info.nightscout.androidaps.utils.Translator import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.rx.AapsSchedulers +import info.nightscout.shared.logging.LTag import info.nightscout.shared.sharedPreferences.SP import io.reactivex.disposables.CompositeDisposable import io.reactivex.rxkotlin.plusAssign @@ -48,7 +51,6 @@ import kotlin.math.min class HistoryBrowseActivity : NoSplashAppCompatActivity() { @Inject lateinit var injector: HasAndroidInjector - @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var aapsSchedulers: AapsSchedulers @Inject lateinit var rxBus: RxBus @Inject lateinit var sp: SP @@ -89,8 +91,41 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { setContentView(binding.root) // We don't want to use injected singletons but own instance working on top of different data - iobCobCalculator = IobCobCalculatorPlugin(injector, aapsLogger, aapsSchedulers, rxBus, sp, rh, profileFunction, activePlugin, sensitivityOref1Plugin, sensitivityAAPSPlugin, sensitivityWeightedAveragePlugin, fabricPrivacy, dateUtil, repository) - overviewData = OverviewData(injector, aapsLogger, rh, dateUtil, sp, activePlugin, defaultValueHelper, profileFunction, config, loop, nsDeviceStatus, repository, overviewMenus, iobCobCalculator, translator) + iobCobCalculator = + IobCobCalculatorPlugin( + injector, + aapsLogger, + aapsSchedulers, + rxBus, + sp, + rh, + profileFunction, + activePlugin, + sensitivityOref1Plugin, + sensitivityAAPSPlugin, + sensitivityWeightedAveragePlugin, + fabricPrivacy, + dateUtil, + repository + ) + overviewData = + OverviewData( + injector, + aapsLogger, + rh, + dateUtil, + sp, + activePlugin, + defaultValueHelper, + profileFunction, + config, + loop, + nsDeviceStatus, + repository, + overviewMenus, + iobCobCalculator, + translator + ) binding.left.setOnClickListener { adjustTimeRange(overviewData.fromTime - T.hours(rangeToDisplay.toLong()).msecs()) @@ -143,10 +178,11 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { binding.date.setOnClickListener { val cal = Calendar.getInstance() cal.timeInMillis = overviewData.fromTime - DatePickerDialog(this, dateSetListener, - cal.get(Calendar.YEAR), - cal.get(Calendar.MONTH), - cal.get(Calendar.DAY_OF_MONTH) + DatePickerDialog( + this, dateSetListener, + cal.get(Calendar.YEAR), + cal.get(Calendar.MONTH), + cal.get(Calendar.DAY_OF_MONTH) ).show() } @@ -389,14 +425,14 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { for (g in 0 until min(secondaryGraphs.size, menuChartSettings.size + 1)) { secondaryGraphsLabel[g].text = overviewMenus.enabledTypes(g + 1) secondaryGraphs[g].visibility = ( - menuChartSettings[g + 1][OverviewMenus.CharType.ABS.ordinal] || - menuChartSettings[g + 1][OverviewMenus.CharType.IOB.ordinal] || - menuChartSettings[g + 1][OverviewMenus.CharType.COB.ordinal] || - menuChartSettings[g + 1][OverviewMenus.CharType.DEV.ordinal] || - menuChartSettings[g + 1][OverviewMenus.CharType.BGI.ordinal] || - menuChartSettings[g + 1][OverviewMenus.CharType.SEN.ordinal] || - menuChartSettings[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal] - ).toVisibility() + menuChartSettings[g + 1][OverviewMenus.CharType.ABS.ordinal] || + menuChartSettings[g + 1][OverviewMenus.CharType.IOB.ordinal] || + menuChartSettings[g + 1][OverviewMenus.CharType.COB.ordinal] || + menuChartSettings[g + 1][OverviewMenus.CharType.DEV.ordinal] || + menuChartSettings[g + 1][OverviewMenus.CharType.BGI.ordinal] || + menuChartSettings[g + 1][OverviewMenus.CharType.SEN.ordinal] || + menuChartSettings[g + 1][OverviewMenus.CharType.DEVSLOPE.ordinal] + ).toVisibility() secondaryGraphsData[g].performUpdate() } } diff --git a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt index 87e91df1fd..1f45202ab0 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt @@ -10,8 +10,6 @@ import android.widget.PopupMenu import info.nightscout.androidaps.R import info.nightscout.androidaps.data.ProfileSealed import info.nightscout.androidaps.data.PureProfile -import info.nightscout.androidaps.utils.defaultProfile.DefaultProfile -import info.nightscout.androidaps.utils.defaultProfile.DefaultProfileDPV import info.nightscout.androidaps.database.AppRepository import info.nightscout.androidaps.database.entities.EffectiveProfileSwitch import info.nightscout.androidaps.databinding.ActivityProfilehelperBinding @@ -19,7 +17,6 @@ import info.nightscout.androidaps.dialogs.ProfileViewerDialog import info.nightscout.androidaps.extensions.toVisibility import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ProfileFunction -import info.nightscout.shared.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.profile.local.LocalProfilePlugin import info.nightscout.androidaps.plugins.profile.local.events.EventLocalProfileChanged @@ -27,13 +24,14 @@ import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.ToastUtils import info.nightscout.androidaps.utils.alertDialogs.OKDialog +import info.nightscout.androidaps.utils.defaultProfile.DefaultProfile +import info.nightscout.androidaps.utils.defaultProfile.DefaultProfileDPV import info.nightscout.androidaps.utils.stats.TddCalculator import java.text.DecimalFormat import javax.inject.Inject class ProfileHelperActivity : NoSplashAppCompatActivity() { - @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var tddCalculator: TddCalculator @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var defaultProfile: DefaultProfile @@ -142,10 +140,13 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { else defaultProfileDPV.profile(age, tdd, pct / 100.0, profileFunction.getUnits()) profile?.let { OKDialog.showConfirmation(this, rh.gs(R.string.careportal_profileswitch), rh.gs(R.string.copytolocalprofile), Runnable { - localProfilePlugin.addProfile(localProfilePlugin.copyFrom(it, "DefaultProfile " + - dateUtil.dateAndTimeAndSecondsString(dateUtil.now()) - .replace(".", "/") - )) + localProfilePlugin.addProfile( + localProfilePlugin.copyFrom( + it, "DefaultProfile " + + dateUtil.dateAndTimeAndSecondsString(dateUtil.now()) + .replace(".", "/") + ) + ) rxBus.send(EventLocalProfileChanged()) }) } @@ -221,7 +222,16 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { it.putInt("mode", ProfileViewerDialog.Mode.PROFILE_COMPARE.ordinal) it.putString("customProfile", profile0.jsonObject.toString()) it.putString("customProfile2", profile1.jsonObject.toString()) - it.putString("customProfileName", getProfileName(ageUsed[0], tddUsed[0], weightUsed[0], pctUsed[0] / 100.0, 0) + "\n" + getProfileName(ageUsed[1], tddUsed[1], weightUsed[1], pctUsed[1] / 100.0, 1)) + it.putString( + "customProfileName", + getProfileName(ageUsed[0], tddUsed[0], weightUsed[0], pctUsed[0] / 100.0, 0) + "\n" + getProfileName( + ageUsed[1], + tddUsed[1], + weightUsed[1], + pctUsed[1] / 100.0, + 1 + ) + ) } }.show(supportFragmentManager, "ProfileViewDialog") return@setOnClickListener @@ -279,7 +289,8 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { ProfileType.CURRENT -> rh.gs(R.string.currentprofile) ProfileType.AVAILABLE_PROFILE -> rh.gs(R.string.availableprofile) ProfileType.PROFILE_SWITCH -> rh.gs(R.string.careportal_profileswitch) - }) + } + ) binding.defaultProfile.visibility = (newContent == ProfileType.MOTOL_DEFAULT || newContent == ProfileType.DPV_DEFAULT).toVisibility() binding.currentProfile.visibility = (newContent == ProfileType.CURRENT).toVisibility() binding.availableProfile.visibility = (newContent == ProfileType.AVAILABLE_PROFILE).toVisibility() diff --git a/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt index 96afe449a7..a147e26ea2 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/SurveyActivity.kt @@ -5,25 +5,23 @@ import android.widget.ArrayAdapter import com.google.firebase.auth.FirebaseAuth import com.google.firebase.database.FirebaseDatabase import info.nightscout.androidaps.R -import info.nightscout.androidaps.utils.defaultProfile.DefaultProfile import info.nightscout.androidaps.databinding.ActivitySurveyBinding import info.nightscout.androidaps.dialogs.ProfileViewerDialog import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.ProfileFunction -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.utils.ActivityMonitor import info.nightscout.androidaps.utils.DateUtil import info.nightscout.androidaps.utils.InstanceId -import info.nightscout.shared.SafeParse import info.nightscout.androidaps.utils.ToastUtils +import info.nightscout.androidaps.utils.defaultProfile.DefaultProfile import info.nightscout.androidaps.utils.stats.TddCalculator import info.nightscout.androidaps.utils.stats.TirCalculator +import info.nightscout.shared.SafeParse +import info.nightscout.shared.logging.LTag import javax.inject.Inject class SurveyActivity : NoSplashAppCompatActivity() { - @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var tddCalculator: TddCalculator @Inject lateinit var tirCalculator: TirCalculator @@ -72,7 +70,7 @@ class SurveyActivity : NoSplashAppCompatActivity() { it.putLong("time", dateUtil.now()) it.putInt("mode", ProfileViewerDialog.Mode.PROFILE_COMPARE.ordinal) it.putString("customProfile", runningProfile.toPureNsJson(dateUtil).toString()) - it.putString("customProfile2", profile.jsonObject.toString()) + it.putString("customProfile2", profile.jsonObject.toString()) it.putString("customProfileName", "Age: $age TDD: $tdd Weight: $weight") } }.show(supportFragmentManager, "ProfileViewDialog") diff --git a/app/src/main/java/info/nightscout/androidaps/utils/AndroidPermission.kt b/app/src/main/java/info/nightscout/androidaps/utils/AndroidPermission.kt index 0ef2e351b6..e0b5d12414 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/AndroidPermission.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/AndroidPermission.kt @@ -3,6 +3,7 @@ package info.nightscout.androidaps.utils import android.Manifest import android.annotation.SuppressLint import android.annotation.TargetApi +import android.bluetooth.BluetoothAdapter import android.content.ActivityNotFoundException import android.content.Context import android.content.Intent @@ -82,11 +83,7 @@ class AndroidPermission @Inject constructor( if (smsCommunicatorPlugin.isEnabled()) { if (permissionNotGranted(activity, Manifest.permission.RECEIVE_SMS)) { val notification = NotificationWithAction(injector, Notification.PERMISSION_SMS, rh.gs(R.string.smscommunicator_missingsmspermission), Notification.URGENT) - notification.action(R.string.request) { - askForPermission(activity, arrayOf(Manifest.permission.RECEIVE_SMS, - Manifest.permission.SEND_SMS, - Manifest.permission.RECEIVE_MMS)) - } + notification.action(R.string.request) { askForPermission(activity, arrayOf(Manifest.permission.RECEIVE_SMS, Manifest.permission.SEND_SMS, Manifest.permission.RECEIVE_MMS)) } rxBus.send(EventNewNotification(notification)) } else rxBus.send(EventDismissNotification(Notification.PERMISSION_SMS)) // Following is a bug in Android 8 @@ -98,6 +95,19 @@ class AndroidPermission @Inject constructor( } } + @Synchronized + fun notifyForBtConnectPermission(activity: FragmentActivity) { + activity.startActivity(Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)) + if (Build.VERSION.SDK_INT >= /*Build.VERSION_CODES.S*/31) { + // Manifest.permission.BLUETOOTH_CONNECT + if (permissionNotGranted(activity, "android.permission.BLUETOOTH_CONNECT") || permissionNotGranted(activity, "android.permission.BLUETOOTH_SCAN")) { + val notification = NotificationWithAction(injector, Notification.PERMISSION_BT, rh.gs(R.string.needconnectpermission), Notification.URGENT) + notification.action(R.string.request) { askForPermission(activity, arrayOf("android.permission.BLUETOOTH_SCAN", "android.permission.BLUETOOTH_CONNECT")) } + rxBus.send(EventNewNotification(notification)) + } else rxBus.send(EventDismissNotification(Notification.PERMISSION_BT)) + } + } + @Synchronized fun notifyForBatteryOptimizationPermission(activity: FragmentActivity) { if (permissionNotGranted(activity, Manifest.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)) { @@ -110,10 +120,7 @@ class AndroidPermission @Inject constructor( @Synchronized fun notifyForStoragePermission(activity: FragmentActivity) { if (permissionNotGranted(activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)) { val notification = NotificationWithAction(injector, Notification.PERMISSION_STORAGE, rh.gs(R.string.needstoragepermission), Notification.URGENT) - notification.action(R.string.request) { - askForPermission(activity, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE)) - } + notification.action(R.string.request) { askForPermission(activity, arrayOf(Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)) } rxBus.send(EventNewNotification(notification)) } else rxBus.send(EventDismissNotification(Notification.PERMISSION_STORAGE)) } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 36a40d0fd8..a34eb64e49 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -797,6 +797,7 @@ Application needs system window permission for notifications Application needs location permission for BT scan and WiFi identification Application needs storage permission to be able store log files and export settings + Application needs bluetooth permission Request Open navigation Close navigation diff --git a/core/src/main/java/info/nightscout/androidaps/activities/DaggerAppCompatActivityWithResult.kt b/core/src/main/java/info/nightscout/androidaps/activities/DaggerAppCompatActivityWithResult.kt index 3f210e79d6..554f4a959c 100644 --- a/core/src/main/java/info/nightscout/androidaps/activities/DaggerAppCompatActivityWithResult.kt +++ b/core/src/main/java/info/nightscout/androidaps/activities/DaggerAppCompatActivityWithResult.kt @@ -11,12 +11,15 @@ import info.nightscout.androidaps.plugins.general.maintenance.PrefsFileContract import info.nightscout.androidaps.utils.alertDialogs.OKDialog import info.nightscout.androidaps.utils.permissions.OptimizationPermissionContract import info.nightscout.androidaps.utils.resources.ResourceHelper +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag import javax.inject.Inject open class DaggerAppCompatActivityWithResult : DaggerAppCompatActivity() { @Inject lateinit var rh: ResourceHelper @Inject lateinit var importExportPrefs: ImportExportPrefs + @Inject lateinit var aapsLogger: AAPSLogger val callForPrefFile = registerForActivityResult(PrefsFileContract()) { it?.let { @@ -30,6 +33,7 @@ open class DaggerAppCompatActivityWithResult : DaggerAppCompatActivity() { val requestMultiplePermissions = registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { permissions -> permissions.entries.forEach { + aapsLogger.info(LTag.CORE, "Permission ${it.key} ${it.value}") if (it.value) if (ActivityCompat.checkSelfPermission(this, it.key) == PackageManager.PERMISSION_GRANTED) { when (it.key) { diff --git a/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt b/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt index 8e7e37cb1d..2bca9c0a55 100644 --- a/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt +++ b/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt @@ -25,15 +25,14 @@ import info.nightscout.androidaps.extensions.total import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.CommandQueue import info.nightscout.androidaps.interfaces.ProfileFunction -import info.nightscout.shared.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.pump.common.defs.PumpType import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.rx.AapsSchedulers -import info.nightscout.shared.sharedPreferences.SP import info.nightscout.shared.SafeParse +import info.nightscout.shared.sharedPreferences.SP import io.reactivex.disposables.CompositeDisposable import java.text.DateFormat import java.text.DecimalFormat @@ -45,7 +44,6 @@ import kotlin.math.roundToInt class TDDStatsActivity : NoSplashAppCompatActivity() { - @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var rxBus: RxBus @Inject lateinit var sp: SP @Inject lateinit var profileFunction: ProfileFunction diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.kt index bf5f8d2998..fc0d025e80 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/notifications/Notification.kt @@ -129,6 +129,7 @@ open class Notification { const val INVALID_PROFILE_NOT_ACCEPTED = 75 const val MDT_INVALID_HISTORY_DATA = 76 const val IDENTIFICATION_NOT_SET = 77 + const val PERMISSION_BT = 78 const val USER_MESSAGE = 1000 diff --git a/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaHistoryActivity.kt b/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaHistoryActivity.kt index c7e815770d..320dfc76cc 100644 --- a/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaHistoryActivity.kt +++ b/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaHistoryActivity.kt @@ -22,8 +22,6 @@ import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.CommandQueue import info.nightscout.androidaps.interfaces.Profile import info.nightscout.androidaps.interfaces.ProfileFunction -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.pump.common.defs.PumpType import info.nightscout.androidaps.queue.Callback @@ -32,6 +30,7 @@ import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.rx.AapsSchedulers +import info.nightscout.shared.logging.LTag import io.reactivex.disposables.CompositeDisposable import io.reactivex.rxkotlin.plusAssign import java.util.* @@ -40,7 +39,6 @@ import javax.inject.Inject class DanaHistoryActivity : NoSplashAppCompatActivity() { @Inject lateinit var rxBus: RxBus - @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var activePlugin: ActivePlugin diff --git a/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt b/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt index ed8fe73f20..467e6c0f71 100644 --- a/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt +++ b/dana/src/main/java/info/nightscout/androidaps/dana/activities/DanaUserOptionsActivity.kt @@ -11,13 +11,12 @@ import info.nightscout.androidaps.dana.databinding.DanarUserOptionsActivityBindi import info.nightscout.androidaps.events.EventInitializationChanged import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.CommandQueue -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.plugins.pump.common.defs.PumpType import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.rx.AapsSchedulers +import info.nightscout.shared.logging.LTag import io.reactivex.disposables.CompositeDisposable import io.reactivex.rxkotlin.plusAssign import java.text.DecimalFormat @@ -27,7 +26,6 @@ import kotlin.math.min class DanaUserOptionsActivity : NoSplashAppCompatActivity() { - @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var rxBus: RxBus @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var context: Context @@ -80,16 +78,17 @@ class DanaUserOptionsActivity : NoSplashAppCompatActivity() { + "\nlcdOnTimeSec:" + danaPump.lcdOnTimeSec + "\nbackLight:" + danaPump.backlightOnTimeSec + "\npumpUnits:" + danaPump.units - + "\nlowReservoir:" + danaPump.lowReservoirRate) + + "\nlowReservoir:" + danaPump.lowReservoirRate + ) binding.screentimeout.setParams(danaPump.lcdOnTimeSec.toDouble(), 5.0, 240.0, 5.0, DecimalFormat("1"), false, binding.saveUserOptions) binding.backlight.setParams(danaPump.backlightOnTimeSec.toDouble(), minBacklight.toDouble(), 60.0, 1.0, DecimalFormat("1"), false, binding.saveUserOptions) binding.shutdown.setParams(danaPump.shutdownHour.toDouble(), 0.0, 24.0, 1.0, DecimalFormat("1"), true, binding.saveUserOptions) binding.lowreservoir.setParams(danaPump.lowReservoirRate.toDouble(), 10.0, 50.0, 10.0, DecimalFormat("10"), false, binding.saveUserOptions) when (danaPump.beepAndAlarm) { - 0b01 -> binding.pumpalarmSound.isChecked = true - 0b10 -> binding.pumpalarmVibrate.isChecked = true - 0b11 -> binding.pumpalarmBoth.isChecked = true + 0b01 -> binding.pumpalarmSound.isChecked = true + 0b10 -> binding.pumpalarmVibrate.isChecked = true + 0b11 -> binding.pumpalarmBoth.isChecked = true 0b101 -> { binding.pumpalarmSound.isChecked = true diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8HistoryActivity.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8HistoryActivity.kt index 0ccffda239..2e90ef42a1 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8HistoryActivity.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8HistoryActivity.kt @@ -19,7 +19,6 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.CommandQueue import info.nightscout.androidaps.interfaces.ProfileFunction -import info.nightscout.shared.logging.AAPSLogger import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.DateUtil @@ -27,8 +26,6 @@ import info.nightscout.androidaps.utils.DecimalFormatter import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.T import info.nightscout.androidaps.utils.rx.AapsSchedulers - - import io.reactivex.disposables.CompositeDisposable import io.reactivex.rxkotlin.plusAssign import java.util.* @@ -37,7 +34,6 @@ import javax.inject.Inject class DiaconnG8HistoryActivity : NoSplashAppCompatActivity() { @Inject lateinit var rxBus: RxBus - @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var activePlugin: ActivePlugin @@ -138,7 +134,7 @@ class DiaconnG8HistoryActivity : NoSplashAppCompatActivity() { holder.duration.text = DecimalFormatter.to0Decimal(record.duration.toDouble()) holder.alarm.text = record.alarm when (showingType) { - RecordTypes.RECORD_TYPE_ALARM -> { + RecordTypes.RECORD_TYPE_ALARM -> { holder.time.visibility = View.VISIBLE holder.value.visibility = View.VISIBLE holder.stringValue.visibility = View.VISIBLE @@ -150,7 +146,7 @@ class DiaconnG8HistoryActivity : NoSplashAppCompatActivity() { holder.alarm.visibility = View.VISIBLE } - RecordTypes.RECORD_TYPE_BOLUS -> { + RecordTypes.RECORD_TYPE_BOLUS -> { holder.time.visibility = View.VISIBLE holder.value.visibility = View.VISIBLE holder.stringValue.visibility = View.VISIBLE @@ -162,7 +158,7 @@ class DiaconnG8HistoryActivity : NoSplashAppCompatActivity() { holder.alarm.visibility = View.GONE } - RecordTypes.RECORD_TYPE_DAILY -> { + RecordTypes.RECORD_TYPE_DAILY -> { holder.dailyBasal.text = rh.gs(R.string.formatinsulinunits, record.dailyBasal) holder.dailyBolus.text = rh.gs(R.string.formatinsulinunits, record.dailyBolus) holder.dailyTotal.text = rh.gs(R.string.formatinsulinunits, record.dailyBolus + record.dailyBasal) @@ -189,7 +185,8 @@ class DiaconnG8HistoryActivity : NoSplashAppCompatActivity() { holder.dailyTotal.visibility = View.GONE holder.alarm.visibility = View.GONE } - RecordTypes.RECORD_TYPE_REFILL -> { + + RecordTypes.RECORD_TYPE_REFILL -> { holder.time.visibility = View.VISIBLE holder.value.visibility = View.VISIBLE holder.stringValue.visibility = View.VISIBLE @@ -201,7 +198,7 @@ class DiaconnG8HistoryActivity : NoSplashAppCompatActivity() { holder.alarm.visibility = View.GONE } - RecordTypes.RECORD_TYPE_TB -> { + RecordTypes.RECORD_TYPE_TB -> { holder.time.visibility = View.VISIBLE holder.value.visibility = View.VISIBLE holder.stringValue.visibility = View.VISIBLE @@ -213,7 +210,7 @@ class DiaconnG8HistoryActivity : NoSplashAppCompatActivity() { holder.alarm.visibility = View.GONE } - RecordTypes.RECORD_TYPE_SUSPEND -> { + RecordTypes.RECORD_TYPE_SUSPEND -> { holder.time.visibility = View.VISIBLE holder.value.visibility = View.GONE holder.stringValue.visibility = View.VISIBLE diff --git a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8UserOptionsActivity.kt b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8UserOptionsActivity.kt index 65a75e880d..f8e213921c 100644 --- a/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8UserOptionsActivity.kt +++ b/diaconn/src/main/java/info/nightscout/androidaps/diaconn/activities/DiaconnG8UserOptionsActivity.kt @@ -8,20 +8,16 @@ import android.widget.AdapterView import android.widget.ArrayAdapter import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.activities.NoSplashAppCompatActivity - - import info.nightscout.androidaps.diaconn.DiaconnG8Pump import info.nightscout.androidaps.diaconn.R import info.nightscout.androidaps.diaconn.databinding.DiaconnG8UserOptionsActivityBinding - import info.nightscout.androidaps.interfaces.ActivePlugin import info.nightscout.androidaps.interfaces.CommandQueue -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.queue.Callback import info.nightscout.androidaps.utils.FabricPrivacy import info.nightscout.androidaps.utils.ToastUtils +import info.nightscout.shared.logging.LTag import info.nightscout.shared.sharedPreferences.SP import io.reactivex.disposables.CompositeDisposable import java.text.DecimalFormat @@ -29,7 +25,6 @@ import javax.inject.Inject class DiaconnG8UserOptionsActivity : NoSplashAppCompatActivity() { - @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var rxBus: RxBus @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var context: Context @@ -74,7 +69,8 @@ class DiaconnG8UserOptionsActivity : NoSplashAppCompatActivity() { + "\nbeepAndAlarm:" + diaconnG8Pump.beepAndAlarm + "\nalarmIntesity:" + diaconnG8Pump.alarmIntesity + "\nlanguage:" + diaconnG8Pump.selectedLanguage - + "\nlcdOnTimeSec:" + diaconnG8Pump.lcdOnTimeSec) + + "\nlcdOnTimeSec:" + diaconnG8Pump.lcdOnTimeSec + ) fillSoundCategory() fillSoundSubCategory() @@ -84,8 +80,9 @@ class DiaconnG8UserOptionsActivity : NoSplashAppCompatActivity() { binding.beepAndAlarm.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) { - binding.alarmIntesity.visibility = if("silent" == binding.beepAndAlarm.getItemAtPosition(position).toString()) View.GONE else View.VISIBLE + binding.alarmIntesity.visibility = if ("silent" == binding.beepAndAlarm.getItemAtPosition(position).toString()) View.GONE else View.VISIBLE } + override fun onNothingSelected(parent: AdapterView<*>?) {} } @@ -117,10 +114,10 @@ class DiaconnG8UserOptionsActivity : NoSplashAppCompatActivity() { diaconnG8Pump.setUserOptionType = DiaconnG8Pump.LCD diaconnG8Pump.lcdOnTimeSec = when { - binding.pumpscreentimeout10.isChecked -> 1 - binding.pumpscreentimeout20.isChecked -> 2 - binding.pumpscreentimeout30.isChecked -> 3 - else -> 1 + binding.pumpscreentimeout10.isChecked -> 1 + binding.pumpscreentimeout20.isChecked -> 2 + binding.pumpscreentimeout30.isChecked -> 3 + else -> 1 } onSaveClick() @@ -131,10 +128,10 @@ class DiaconnG8UserOptionsActivity : NoSplashAppCompatActivity() { diaconnG8Pump.setUserOptionType = DiaconnG8Pump.LANG diaconnG8Pump.selectedLanguage = when { - binding.pumplangChiness.isChecked -> 1 - binding.pumplangKorean.isChecked -> 2 - binding.pumplangEnglish.isChecked -> 3 - else -> 2 + binding.pumplangChiness.isChecked -> 1 + binding.pumplangKorean.isChecked -> 2 + binding.pumplangEnglish.isChecked -> 3 + else -> 2 } onSaveClick() diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt index 08d01febce..29224a3f78 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/ui/DashPodHistoryActivity.kt @@ -1,6 +1,5 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.ui -// import info.nightscout.androidaps.plugins.pump.omnipod.dash.definition.PodHistoryEntryType; -// import info.nightscout.androidaps.plugins.pump.omnipod.dash.util.AapsOmnipodUtil; + import android.os.Bundle import android.os.SystemClock import android.view.LayoutInflater @@ -13,8 +12,6 @@ import android.widget.TextView import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import info.nightscout.androidaps.activities.NoSplashAppCompatActivity -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag import info.nightscout.androidaps.plugins.pump.common.defs.PumpHistoryEntryGroup import info.nightscout.androidaps.plugins.pump.common.defs.PumpType import info.nightscout.androidaps.plugins.pump.common.utils.DateTimeUtil @@ -24,12 +21,12 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.R import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.DashHistory import info.nightscout.androidaps.plugins.pump.omnipod.dash.history.data.* import info.nightscout.androidaps.utils.rx.AapsSchedulers +import info.nightscout.shared.logging.LTag import java.util.* import javax.inject.Inject class DashPodHistoryActivity : NoSplashAppCompatActivity() { - @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var dashHistory: DashHistory @Inject lateinit var aapsSchedulers: AapsSchedulers @@ -56,44 +53,44 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { private fun groupForCommandType(type: OmnipodCommandType): PumpHistoryEntryGroup { return when (type) { - OmnipodCommandType.INITIALIZE_POD -> + OmnipodCommandType.INITIALIZE_POD -> PumpHistoryEntryGroup.Prime - OmnipodCommandType.INSERT_CANNULA -> + OmnipodCommandType.INSERT_CANNULA -> PumpHistoryEntryGroup.Prime - OmnipodCommandType.DEACTIVATE_POD -> + OmnipodCommandType.DEACTIVATE_POD -> PumpHistoryEntryGroup.Prime - OmnipodCommandType.DISCARD_POD -> + OmnipodCommandType.DISCARD_POD -> PumpHistoryEntryGroup.Prime OmnipodCommandType.CANCEL_TEMPORARY_BASAL -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.SET_BASAL_PROFILE -> + OmnipodCommandType.SET_BASAL_PROFILE -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.SET_TEMPORARY_BASAL -> + OmnipodCommandType.SET_TEMPORARY_BASAL -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.RESUME_DELIVERY -> + OmnipodCommandType.RESUME_DELIVERY -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.SUSPEND_DELIVERY -> + OmnipodCommandType.SUSPEND_DELIVERY -> PumpHistoryEntryGroup.Basal - OmnipodCommandType.SET_BOLUS -> + OmnipodCommandType.SET_BOLUS -> PumpHistoryEntryGroup.Bolus - OmnipodCommandType.CANCEL_BOLUS -> + OmnipodCommandType.CANCEL_BOLUS -> PumpHistoryEntryGroup.Bolus - OmnipodCommandType.ACKNOWLEDGE_ALERTS -> + OmnipodCommandType.ACKNOWLEDGE_ALERTS -> PumpHistoryEntryGroup.Alarm - OmnipodCommandType.CONFIGURE_ALERTS -> + OmnipodCommandType.CONFIGURE_ALERTS -> PumpHistoryEntryGroup.Alarm - OmnipodCommandType.PLAY_TEST_BEEP -> + OmnipodCommandType.PLAY_TEST_BEEP -> PumpHistoryEntryGroup.Alarm - OmnipodCommandType.GET_POD_STATUS -> + OmnipodCommandType.GET_POD_STATUS -> PumpHistoryEntryGroup.Configuration - OmnipodCommandType.SET_TIME -> + OmnipodCommandType.SET_TIME -> PumpHistoryEntryGroup.Configuration - OmnipodCommandType.READ_POD_PULSE_LOG -> + OmnipodCommandType.READ_POD_PULSE_LOG -> PumpHistoryEntryGroup.Unknown } } @@ -225,13 +222,13 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { OmnipodCommandType.DISCARD_POD, OmnipodCommandType.SUSPEND_DELIVERY, OmnipodCommandType.RESUME_DELIVERY, - OmnipodCommandType.SET_BASAL_PROFILE -> { + OmnipodCommandType.SET_BASAL_PROFILE -> { android.graphics.Color.CYAN } // User action OmnipodCommandType.PLAY_TEST_BEEP, OmnipodCommandType.ACKNOWLEDGE_ALERTS, - OmnipodCommandType.CANCEL_BOLUS -> { + OmnipodCommandType.CANCEL_BOLUS -> { android.graphics.Color.GREEN } // Insulin treatment @@ -240,7 +237,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { android.graphics.Color.WHITE } - else -> + else -> // Other android.graphics.Color.LTGRAY } @@ -268,7 +265,7 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { } } - OmnipodCommandType.SET_BOLUS -> { + OmnipodCommandType.SET_BOLUS -> { val bolus = historyEntry.record as BolusRecord bolus.let { rh.gs(R.string.omnipod_common_history_bolus_value, it.amout) @@ -278,12 +275,12 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { OmnipodCommandType.SET_BASAL_PROFILE, OmnipodCommandType.SET_TIME, OmnipodCommandType.INSERT_CANNULA, - OmnipodCommandType.RESUME_DELIVERY -> { + OmnipodCommandType.RESUME_DELIVERY -> { val basal = historyEntry.record as BasalValuesRecord ProfileUtil.getBasalProfilesDisplayable(basal.segments.toTypedArray(), PumpType.OMNIPOD_DASH) } - else -> + else -> "" } // Set some color @@ -306,12 +303,12 @@ class DashPodHistoryActivity : NoSplashAppCompatActivity() { return when { historyEntry.initialResult == InitialResult.FAILURE_SENDING -> R.string.omnipod_dash_failed_to_send - historyEntry.initialResult == InitialResult.NOT_SENT -> + historyEntry.initialResult == InitialResult.NOT_SENT -> R.string.omnipod_dash_command_not_sent historyEntry.initialResult == InitialResult.SENT && - historyEntry.resolvedResult == ResolvedResult.FAILURE -> + historyEntry.resolvedResult == ResolvedResult.FAILURE -> R.string.omnipod_dash_command_not_received_by_the_pod - else -> + else -> R.string.omnipod_dash_unknown } } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEConfigActivity.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEConfigActivity.kt index 29435bd123..c1ba52579e 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEConfigActivity.kt +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/dialog/RileyLinkBLEConfigActivity.kt @@ -29,7 +29,6 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.GattAttributes import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.databinding.RileyLinkBleConfigActivityBinding import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkPumpDevice -import info.nightscout.shared.logging.AAPSLogger import info.nightscout.shared.logging.LTag import info.nightscout.shared.sharedPreferences.SP import org.apache.commons.lang3.StringUtils @@ -39,7 +38,6 @@ import javax.inject.Inject // IMPORTANT: This activity needs to be called from RileyLinkSelectPreference (see pref_medtronic.xml as example) class RileyLinkBLEConfigActivity : NoSplashAppCompatActivity() { - @Inject lateinit var aapsLogger: AAPSLogger @Inject lateinit var sp: SP @Inject lateinit var blePreCheck: BlePreCheck @Inject lateinit var rileyLinkUtil: RileyLinkUtil