diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4f40d65323..ff5347fce5 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -126,9 +126,6 @@ - - - diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt index 479bd6045c..9a5d86db99 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.kt @@ -70,7 +70,6 @@ class MainActivity : NoSplashAppCompatActivity() { private val disposable = CompositeDisposable() @Inject lateinit var aapsSchedulers: AapsSchedulers - @Inject lateinit var rxBus: RxBus @Inject lateinit var androidPermission: AndroidPermission @Inject lateinit var sp: SP @Inject lateinit var versionCheckerUtils: VersionCheckerUtils diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.kt b/app/src/main/java/info/nightscout/androidaps/MainApp.kt index b78b3084d7..bd01ce6abc 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.kt +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.kt @@ -7,6 +7,10 @@ import android.net.ConnectivityManager import android.net.wifi.WifiManager import android.os.Build import androidx.lifecycle.ProcessLifecycleOwner +import androidx.work.Data +import androidx.work.ExistingPeriodicWorkPolicy +import androidx.work.PeriodicWorkRequest +import androidx.work.WorkManager import com.uber.rxdogtag.RxDogTag import dagger.android.AndroidInjector import dagger.android.DaggerApplication @@ -27,14 +31,11 @@ import info.nightscout.androidaps.plugins.constraints.versionChecker.VersionChec import info.nightscout.androidaps.plugins.general.overview.notifications.Notification import info.nightscout.androidaps.plugins.general.overview.notifications.NotificationStore import info.nightscout.androidaps.plugins.general.themes.ThemeSwitcherPlugin -import info.nightscout.androidaps.receivers.BTReceiver -import info.nightscout.androidaps.receivers.ChargingStateReceiver -import info.nightscout.androidaps.receivers.KeepAliveReceiver.KeepAliveManager -import info.nightscout.androidaps.receivers.NetworkChangeReceiver -import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver +import info.nightscout.androidaps.receivers.* import info.nightscout.androidaps.services.AlarmSoundServiceHelper import info.nightscout.androidaps.utils.ActivityMonitor import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.LocalAlertUtils import info.nightscout.androidaps.utils.ProcessLifecycleListener import info.nightscout.androidaps.utils.buildHelper.BuildHelper import info.nightscout.androidaps.utils.locale.LocaleHelper @@ -48,6 +49,7 @@ import io.reactivex.rxjava3.plugins.RxJavaPlugins import net.danlew.android.joda.JodaTimeAndroid import java.io.IOException import java.net.SocketException +import java.util.concurrent.TimeUnit import javax.inject.Inject class MainApp : DaggerApplication() { @@ -62,7 +64,6 @@ class MainApp : DaggerApplication() { @Inject lateinit var config: Config @Inject lateinit var buildHelper: BuildHelper @Inject lateinit var configBuilder: ConfigBuilder - @Inject lateinit var keepAliveManager: KeepAliveManager @Inject lateinit var plugins: List<@JvmSuppressWildcards PluginBase> @Inject lateinit var compatDBHelper: CompatDBHelper @Inject lateinit var repository: AppRepository @@ -73,6 +74,7 @@ class MainApp : DaggerApplication() { @Inject lateinit var notificationStore: NotificationStore @Inject lateinit var processLifecycleListener: ProcessLifecycleListener @Inject lateinit var profileSwitchPlugin: ThemeSwitcherPlugin + @Inject lateinit var localAlertUtils: LocalAlertUtils override fun onCreate() { super.onCreate() @@ -118,7 +120,17 @@ class MainApp : DaggerApplication() { // Register all tabs in app here pluginStore.plugins = plugins configBuilder.initialize() - keepAliveManager.setAlarm(this) + + WorkManager.getInstance(this).enqueueUniquePeriodicWork( + "KeepAlive", + ExistingPeriodicWorkPolicy.REPLACE, + PeriodicWorkRequest.Builder(KeepAliveWorker::class.java, 15, TimeUnit.MINUTES) + .setInputData(Data.Builder().putString("schedule", "KeepAlive").build()) + .setInitialDelay(5, TimeUnit.SECONDS) + .build() + ) + localAlertUtils.shortenSnoozeInterval() + localAlertUtils.preSnoozeAlarms() doMigrations() uel.log(UserEntry.Action.START_AAPS, UserEntry.Sources.Aaps) } @@ -190,7 +202,6 @@ class MainApp : DaggerApplication() { override fun onTerminate() { aapsLogger.debug(LTag.CORE, "onTerminate") unregisterActivityLifecycleCallbacks(activityMonitor) - keepAliveManager.cancelAlarm(this) alarmSoundServiceHelper.stopService(this) super.onTerminate() } 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 66be4af5c9..94063a611f 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt @@ -54,7 +54,6 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { @Inject lateinit var injector: HasAndroidInjector @Inject lateinit var aapsSchedulers: AapsSchedulers - @Inject lateinit var rxBus: RxBus @Inject lateinit var sp: SP @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var defaultValueHelper: DefaultValueHelper diff --git a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt index 5da167b74b..57b39e4622 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/MyPreferenceFragment.kt @@ -372,7 +372,7 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang if (sp.getString(pref.key, "").startsWith("hmac:")) { pref.summary = "******" } else { - if (pref.getKey().contains("pin")) { + if (pref.key.contains("pin")) { pref.summary = rh.gs(R.string.pin_not_set) }else { pref.summary = rh.gs(R.string.password_not_set) diff --git a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt index ed149949a0..60f0f5006a 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/PreferencesActivity.kt @@ -65,7 +65,7 @@ class PreferencesActivity : NoSplashAppCompatActivity(), PreferenceFragmentCompa } override fun onOptionsItemSelected(item: MenuItem): Boolean { - when (item.getItemId()) { + when (item.itemId) { android.R.id.home -> { onBackPressed() return true 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 22322c5bb9..03c3362d9a 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/ProfileHelperActivity.kt @@ -38,7 +38,6 @@ class ProfileHelperActivity : NoSplashAppCompatActivity() { @Inject lateinit var defaultProfile: DefaultProfile @Inject lateinit var defaultProfileDPV: DefaultProfileDPV @Inject lateinit var localProfilePlugin: LocalProfilePlugin - @Inject lateinit var rxBus: RxBus @Inject lateinit var dateUtil: DateUtil @Inject lateinit var activePlugin: ActivePlugin @Inject lateinit var repository: AppRepository diff --git a/app/src/main/java/info/nightscout/androidaps/di/ReceiversModule.kt b/app/src/main/java/info/nightscout/androidaps/di/ReceiversModule.kt index 9d6615a362..72edb82bc1 100644 --- a/app/src/main/java/info/nightscout/androidaps/di/ReceiversModule.kt +++ b/app/src/main/java/info/nightscout/androidaps/di/ReceiversModule.kt @@ -2,12 +2,11 @@ package info.nightscout.androidaps.di import dagger.Module import dagger.android.ContributesAndroidInjector +import info.nightscout.androidaps.plugins.aps.loop.CarbSuggestionReceiver import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkBluetoothStateReceiver import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.RileyLinkBroadcastReceiver -import info.nightscout.androidaps.plugins.aps.loop.CarbSuggestionReceiver import info.nightscout.androidaps.receivers.* - @Module @Suppress("unused") abstract class ReceiversModule { @@ -16,8 +15,7 @@ abstract class ReceiversModule { @ContributesAndroidInjector abstract fun contributesBTReceiver(): BTReceiver @ContributesAndroidInjector abstract fun contributesChargingStateReceiver(): ChargingStateReceiver @ContributesAndroidInjector abstract fun contributesDataReceiver(): DataReceiver - @ContributesAndroidInjector abstract fun contributesKeepAliveReceiver(): KeepAliveReceiver - @ContributesAndroidInjector abstract fun contributesKeepAliveWorker(): KeepAliveReceiver.KeepAliveWorker + @ContributesAndroidInjector abstract fun contributesKeepAliveWorker(): KeepAliveWorker @ContributesAndroidInjector abstract fun contributesRileyLinkBluetoothStateReceiver(): RileyLinkBluetoothStateReceiver @ContributesAndroidInjector abstract fun contributesSmsReceiver(): SmsReceiver @ContributesAndroidInjector abstract fun contributesTimeDateOrTZChangeReceiver(): TimeDateOrTZChangeReceiver diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt index cb26aa1a5a..3d6e2850fd 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/FillDialog.kt @@ -116,16 +116,16 @@ class FillDialog : DialogFragmentWithDate() { if (insulinAfterConstraints > 0) { actions.add(rh.gs(R.string.fillwarning)) actions.add("") - actions.add(rh.gs(R.string.bolus) + ": " + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints, activePlugin.activePump, rh).formatColor(rh, R.color.colorInsulinButton)) + actions.add(rh.gs(R.string.bolus) + ": " + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints, activePlugin.activePump, rh).formatColor(context, rh, R.attr.insulinButtonColor)) if (abs(insulinAfterConstraints - insulin) > 0.01) - actions.add(rh.gs(R.string.bolusconstraintappliedwarn, insulin, insulinAfterConstraints).formatColor(rh, R.color.warning)) + actions.add(rh.gs(R.string.bolusconstraintappliedwarn, insulin, insulinAfterConstraints).formatColor(context, rh, R.attr.warningColor)) } val siteChange = binding.fillCatheterChange.isChecked if (siteChange) - actions.add(rh.gs(R.string.record_pump_site_change).formatColor(rh, R.color.actionsConfirm)) + actions.add(rh.gs(R.string.record_pump_site_change).formatColor(context, rh, R.attr.actionsConfirmColor)) val insulinChange = binding.fillCartridgeChange.isChecked if (insulinChange) - actions.add(rh.gs(R.string.record_insulin_cartridge_change).formatColor(rh, R.color.actionsConfirm)) + actions.add(rh.gs(R.string.record_insulin_cartridge_change).formatColor(context, rh, R.attr.actionsConfirmColor)) val notes: String = binding.notesLayout.notes.text.toString() if (notes.isNotEmpty()) actions.add(rh.gs(R.string.notes_label) + ": " + notes) diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt index a4172a8727..53e5474dd1 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/InsulinDialog.kt @@ -172,16 +172,17 @@ class InsulinDialog : DialogFragmentWithDate() { val eatingSoonChecked = binding.startEatingSoonTt.isChecked if (insulinAfterConstraints > 0) { - actions.add(rh.gs(R.string.bolus) + ": " + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints, activePlugin.activePump, rh).formatColor(rh, R.color.bolus)) + actions.add(rh.gs(R.string.bolus) + ": " + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints, activePlugin.activePump, rh).formatColor(context, rh, R.attr.bolusColor)) if (recordOnlyChecked) - actions.add(rh.gs(R.string.bolusrecordedonly).formatColor(rh, R.color.warning)) + actions.add(rh.gs(R.string.bolusrecordedonly).formatColor(context, rh, R.attr.warningColor)) if (abs(insulinAfterConstraints - insulin) > pumpDescription.pumpType.determineCorrectBolusStepSize(insulinAfterConstraints)) - actions.add(rh.gs(R.string.bolusconstraintappliedwarn, insulin, insulinAfterConstraints).formatColor(rh, R.color.warning)) + actions.add(rh.gs(R.string.bolusconstraintappliedwarn, insulin, insulinAfterConstraints).formatColor(context, rh, R.attr.warningColor)) } val eatingSoonTTDuration = defaultValueHelper.determineEatingSoonTTDuration() val eatingSoonTT = defaultValueHelper.determineEatingSoonTT() if (eatingSoonChecked) - actions.add(rh.gs(R.string.temptargetshort) + ": " + (DecimalFormatter.to1Decimal(eatingSoonTT) + " " + unitLabel + " (" + rh.gs(R.string.format_mins, eatingSoonTTDuration) + ")").formatColor(rh, R.color.tempTargetConfirmation)) + actions.add(rh.gs(R.string.temptargetshort) + ": " + (DecimalFormatter.to1Decimal(eatingSoonTT) + " " + unitLabel + " (" + rh.gs(R.string.format_mins, eatingSoonTTDuration) + ")") + .formatColor(context, rh, R.attr.tempTargetConfirmation)) val timeOffset = binding.time.value.toInt() val time = dateUtil.now() + T.mins(timeOffset.toLong()).msecs() diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt index aba8fb579f..438ed77193 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TempBasalDialog.kt @@ -118,7 +118,7 @@ class TempBasalDialog : DialogFragmentWithDate() { actions.add(rh.gs(R.string.tempbasal_label) + ": " + rh.gs(R.string.pump_basebasalrate, absolute)) actions.add(rh.gs(R.string.duration) + ": " + rh.gs(R.string.format_mins, durationInMinutes)) if (abs(absolute - basalAbsoluteInput) > 0.01) - actions.add(rh.gs(R.string.constraintapllied).formatColor(rh, R.color.warning)) + actions.add(rh.gs(R.string.constraintapllied).formatColor(context, rh, R.attr.warningColor)) } activity?.let { activity -> OKDialog.showConfirmation(activity, rh.gs(R.string.tempbasal_label), HtmlHelper.fromHtml(Joiner.on("
").join(actions)), { diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt index 55fd9a773b..5ca98c146b 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/TreatmentDialog.kt @@ -128,16 +128,16 @@ class TreatmentDialog : DialogFragmentWithDate() { val carbsAfterConstraints = constraintChecker.applyCarbsConstraints(Constraint(carbs)).value() if (insulinAfterConstraints > 0) { - actions.add(rh.gs(R.string.bolus) + ": " + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints, activePlugin.activePump, rh).formatColor(rh, R.color.bolus)) + actions.add(rh.gs(R.string.bolus) + ": " + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints, activePlugin.activePump, rh).formatColor(context, rh, R.attr.bolusColor)) if (recordOnlyChecked) - actions.add(rh.gs(R.string.bolusrecordedonly).formatColor(rh, R.color.warning)) + actions.add(rh.gs(R.string.bolusrecordedonly).formatColor(context, rh, R.attr.warningColor)) if (abs(insulinAfterConstraints - insulin) > pumpDescription.pumpType.determineCorrectBolusStepSize(insulinAfterConstraints)) - actions.add(rh.gs(R.string.bolusconstraintappliedwarn, insulin, insulinAfterConstraints).formatColor(rh, R.color.warning)) + actions.add(rh.gs(R.string.bolusconstraintappliedwarn, insulin, insulinAfterConstraints).formatColor(context, rh, R.attr.warningColor)) } if (carbsAfterConstraints > 0) { - actions.add(rh.gs(R.string.carbs) + ": " + rh.gs(R.string.format_carbs, carbsAfterConstraints).formatColor(rh, R.color.carbs)) + actions.add(rh.gs(R.string.carbs) + ": " + rh.gs(R.string.format_carbs, carbsAfterConstraints).formatColor(context, rh, R.attr.carbsColor)) if (carbsAfterConstraints != carbs) - actions.add(rh.gs(R.string.carbsconstraintapplied).formatColor(rh, R.color.warning)) + actions.add(rh.gs(R.string.carbsconstraintapplied).formatColor(context, rh, R.attr.warningColor)) } if (insulinAfterConstraints > 0 || carbsAfterConstraints > 0) { activity?.let { activity -> diff --git a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt index 86e139c647..e5ff65ffda 100644 --- a/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt +++ b/app/src/main/java/info/nightscout/androidaps/dialogs/WizardDialog.kt @@ -468,12 +468,12 @@ class WizardDialog : DaggerDialogFragment() { } if (wizard.calculatedTotalInsulin > 0.0 || carbsAfterConstraint > 0.0) { - val insulinText = if (wizard.calculatedTotalInsulin > 0.0) rh.gs(R.string.formatinsulinunits, wizard.calculatedTotalInsulin).formatColor(rh, R.color.bolus) else "" - val carbsText = if (carbsAfterConstraint > 0.0) rh.gs(R.string.format_carbs, carbsAfterConstraint).formatColor(rh, R.color.carbs) else "" + val insulinText = if (wizard.calculatedTotalInsulin > 0.0) rh.gs(R.string.formatinsulinunits, wizard.calculatedTotalInsulin).formatColor(context, rh, R.attr.bolusColor) else "" + val carbsText = if (carbsAfterConstraint > 0.0) rh.gs(R.string.format_carbs, carbsAfterConstraint).formatColor(context, rh, R.attr.carbsColor) else "" binding.total.text = HtmlHelper.fromHtml(rh.gs(R.string.result_insulin_carbs, insulinText, carbsText)) binding.okcancel.ok.visibility = View.VISIBLE } else { - binding.total.text = HtmlHelper.fromHtml(rh.gs(R.string.missing_carbs, wizard.carbsEquivalent.toInt()).formatColor(rh, R.color.carbs)) + binding.total.text = HtmlHelper.fromHtml(rh.gs(R.string.missing_carbs, wizard.carbsEquivalent.toInt()).formatColor(context, rh, R.attr.carbsColor)) binding.okcancel.ok.visibility = View.INVISIBLE } binding.percentUsed.text = rh.gs(R.string.format_percent, wizard.percentageCorrection) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.kt b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.kt index ecef4ad3aa..d45fbfe26c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/aps/openAPSSMB/DetermineBasalResultSMB.kt @@ -51,7 +51,7 @@ class DetermineBasalResultSMB private constructor(injector: HasAndroidInjector) aapsLogger.error(LTag.APS, "Error parsing 'deliverAt' date: $date", e) } } - if (result.has("variable_sens")) variableSens = result.getDouble("variable_sens"); + if (result.has("variable_sens")) variableSens = result.getDouble("variable_sens") } catch (e: JSONException) { aapsLogger.error(LTag.APS, "Error parsing determine-basal result JSON", e) } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt index 982a662d4a..f25e01c0db 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt @@ -142,7 +142,7 @@ class OverviewData @Inject constructor( fun lastBgColor(context: Context?): Int { return when { isLow -> rh.gac(context, R.attr.bgLow) - isHigh -> rh.gac(context, R.attr.bgHigh) + isHigh -> rh.gac(context, R.attr.highColor) else -> rh.gac(context, R.attr.bgInRange) } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt index 254901adc5..f3455580ee 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/StatusLightHandler.kt @@ -66,7 +66,7 @@ class StatusLightHandler @Inject constructor( handleLevel(careportal_battery_level, R.string.key_statuslights_bat_critical, 26.0, R.string.key_statuslights_bat_warning, 51.0, pump.batteryLevel.toDouble(), "%") } else { careportal_battery_level?.text = rh.gs(R.string.notavailable) - careportal_battery_level?.setTextColor(Color.WHITE) + careportal_battery_level?.setTextColor(rh.gac(careportal_battery_level.context, R.attr.defaultTextColor)) } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt index f3f7b150bb..680bbd2727 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/smsCommunicator/activities/SmsCommunicatorOtpActivity.kt @@ -31,7 +31,6 @@ import javax.inject.Inject class SmsCommunicatorOtpActivity : NoSplashAppCompatActivity() { @Inject lateinit var fabricPrivacy: FabricPrivacy - @Inject lateinit var rxBus: RxBus @Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin @Inject lateinit var otp: OneTimePassword @Inject lateinit var uel: UserEntryLogger diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/SendToDataLayerThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/SendToDataLayerThread.java index ee4c30e0d1..0852b0a6aa 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/SendToDataLayerThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/wear/wearintegration/SendToDataLayerThread.java @@ -120,7 +120,7 @@ class SendToDataLayerThread extends AsyncTask { } state = 0; } catch (Exception e) { - Log.e(TAG, logPrefix + "Got exception in sendToWear: " + e.toString()); + Log.e(TAG, logPrefix + "Got exception in sendToWear: " + e); } finally { lastlock = 0; lock.unlock(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt index 8860bcc635..46f0323149 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/IobCobCalculatorPlugin.kt @@ -589,17 +589,17 @@ class IobCobCalculatorPlugin @Inject constructor( override fun getTempBasalIncludingConvertedExtended(timestamp: Long): TemporaryBasal? { val tb = repository.getTemporaryBasalActiveAt(timestamp).blockingGet() if (tb is ValueWrapper.Existing) return tb.value - return getConvertedExtended(timestamp); + return getConvertedExtended(timestamp) } override fun getTempBasalIncludingConvertedExtendedForRange(startTime: Long, endTime: Long, calculationStep: Long): Map { - val tempBasals = HashMap(); + val tempBasals = HashMap() val tbs = repository.getTemporaryBasalsDataActiveBetweenTimeAndTime(startTime, endTime).blockingGet() for (t in startTime until endTime step calculationStep) { val tb = tbs.firstOrNull { basal -> basal.timestamp <= t && (basal.timestamp + basal.duration) > t } tempBasals[t] = tb ?: getConvertedExtended(t) } - return tempBasals; + return tempBasals } override fun calculateAbsoluteIobFromBaseBasals(toTime: Long): IobTotal { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt index 1eb807dbfc..ea85e983b5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpFragment.kt @@ -52,10 +52,6 @@ class VirtualPumpFragment : DaggerFragment() { return binding.root } - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - } - @Synchronized override fun onResume() { super.onResume() diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt index c4249955ed..264a999eb8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/source/BGSourceFragment.kt @@ -143,7 +143,7 @@ class BGSourceFragment : DaggerFragment() { val previous = glucoseValues[position - 1] val diff = previous.timestamp - glucoseValue.timestamp if (diff < T.secs(20).msecs()) - holder.binding.root.setBackgroundColor(rh.gc(R.color.errorAlertBackground)) + holder.binding.root.setBackgroundColor(rh.gac(context, R.attr.bgsourceError)) } holder.binding.root.setOnLongClickListener { diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt deleted file mode 100644 index e20ebcb414..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.kt +++ /dev/null @@ -1,198 +0,0 @@ -package info.nightscout.androidaps.receivers - -import android.app.AlarmManager -import android.app.PendingIntent -import android.app.PendingIntent.CanceledException -import android.app.PendingIntent.FLAG_IMMUTABLE -import android.content.Context -import android.content.Intent -import android.os.SystemClock -import androidx.work.* -import com.google.common.util.concurrent.ListenableFuture -import dagger.android.DaggerBroadcastReceiver -import dagger.android.HasAndroidInjector -import info.nightscout.androidaps.BuildConfig -import info.nightscout.androidaps.R -import info.nightscout.androidaps.data.ProfileSealed -import info.nightscout.androidaps.database.AppRepository -import info.nightscout.androidaps.events.EventProfileSwitchChanged -import info.nightscout.androidaps.extensions.buildDeviceStatus -import info.nightscout.androidaps.interfaces.* -import info.nightscout.shared.logging.AAPSLogger -import info.nightscout.shared.logging.LTag -import info.nightscout.androidaps.plugins.bus.RxBus -import info.nightscout.androidaps.plugins.configBuilder.RunningConfiguration -import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin -import info.nightscout.androidaps.queue.commands.Command -import info.nightscout.androidaps.utils.DateUtil -import info.nightscout.androidaps.utils.FabricPrivacy -import info.nightscout.androidaps.utils.LocalAlertUtils -import info.nightscout.androidaps.utils.T -import info.nightscout.androidaps.utils.resources.ResourceHelper -import javax.inject.Inject -import kotlin.math.abs - -class KeepAliveReceiver : DaggerBroadcastReceiver() { - - @Inject lateinit var aapsLogger: AAPSLogger - - companion object { - - private val KEEP_ALIVE_MILLISECONDS = T.mins(5).msecs() - } - - override fun onReceive(context: Context, intent: Intent) { - super.onReceive(context, intent) - aapsLogger.debug(LTag.CORE, "KeepAlive received") - - WorkManager.getInstance(context) - .enqueue(OneTimeWorkRequest.Builder(KeepAliveWorker::class.java).build()) - } - - class KeepAliveWorker( - private val context: Context, - params: WorkerParameters - ) : Worker(context, params) { - - @Inject lateinit var aapsLogger: AAPSLogger - @Inject lateinit var localAlertUtils: LocalAlertUtils - @Inject lateinit var repository: AppRepository - @Inject lateinit var config: Config - @Inject lateinit var iobCobCalculator: IobCobCalculator - @Inject lateinit var loop: Loop - @Inject lateinit var dateUtil: DateUtil - @Inject lateinit var activePlugin: ActivePlugin - @Inject lateinit var profileFunction: ProfileFunction - @Inject lateinit var runningConfiguration: RunningConfiguration - @Inject lateinit var receiverStatusStore: ReceiverStatusStore - @Inject lateinit var rxBus: RxBus - @Inject lateinit var commandQueue: CommandQueue - @Inject lateinit var fabricPrivacy: FabricPrivacy - @Inject lateinit var maintenancePlugin: MaintenancePlugin - @Inject lateinit var rh: ResourceHelper - - init { - (context.applicationContext as HasAndroidInjector).androidInjector().inject(this) - } - - companion object { - - private val STATUS_UPDATE_FREQUENCY = T.mins(15).msecs() - private const val IOB_UPDATE_FREQUENCY_IN_MINUTES = 5L - - private var lastReadStatus: Long = 0 - private var lastRun: Long = 0 - private var lastIobUpload: Long = 0 - - } - - override fun doWork(): Result { - localAlertUtils.shortenSnoozeInterval() - localAlertUtils.checkStaleBGAlert() - checkPump() - checkAPS() - maintenancePlugin.deleteLogs(30) - workerDbStatus() - - return Result.success() - } - - // When Worker DB grows too much, work operations become slow - // Library is cleaning DB every 7 days which may not be sufficient for NSClient full sync - private fun workerDbStatus() { - val workQuery = WorkQuery.Builder - .fromStates(listOf(WorkInfo.State.FAILED, WorkInfo.State.SUCCEEDED)) - .build() - - val workInfo: ListenableFuture> = WorkManager.getInstance(context).getWorkInfos(workQuery) - aapsLogger.debug(LTag.CORE, "WorkManager size is ${workInfo.get().size}") - if (workInfo.get().size > 1000) { - WorkManager.getInstance(context).pruneWork() - aapsLogger.debug(LTag.CORE, "WorkManager pruning ....") - } - } - - // Usually deviceStatus is uploaded through LoopPlugin after every loop cycle. - // if there is no BG available, we have to upload anyway to have correct - // IOB displayed in NS - private fun checkAPS() { - var shouldUploadStatus = false - if (config.NSCLIENT) return - if (config.PUMPCONTROL) shouldUploadStatus = true - else if (!(loop as PluginBase).isEnabled() || iobCobCalculator.ads.actualBg() == null) - shouldUploadStatus = true - else if (dateUtil.isOlderThan(activePlugin.activeAPS.lastAPSRun, 5)) shouldUploadStatus = true - if (dateUtil.isOlderThan(lastIobUpload, IOB_UPDATE_FREQUENCY_IN_MINUTES) && shouldUploadStatus) { - lastIobUpload = dateUtil.now() - buildDeviceStatus(dateUtil, loop, iobCobCalculator, profileFunction, - activePlugin.activePump, receiverStatusStore, runningConfiguration, - BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION)?.also { - repository.insert(it) - } - } - } - - private fun checkPump() { - val pump = activePlugin.activePump - val ps = profileFunction.getRequestedProfile() ?: return - val requestedProfile = ProfileSealed.PS(ps) - val runningProfile = profileFunction.getProfile() - val lastConnection = pump.lastDataTime() - val isStatusOutdated = lastConnection + STATUS_UPDATE_FREQUENCY < System.currentTimeMillis() - val isBasalOutdated = abs(requestedProfile.getBasal() - pump.baseBasalRate) > pump.pumpDescription.basalStep - aapsLogger.debug(LTag.CORE, "Last connection: " + dateUtil.dateAndTimeString(lastConnection)) - // sometimes keep alive broadcast stops - // as as workaround test if readStatus was requested before an alarm is generated - if (lastReadStatus != 0L && lastReadStatus > System.currentTimeMillis() - T.mins(5).msecs()) { - localAlertUtils.checkPumpUnreachableAlarm(lastConnection, isStatusOutdated, loop.isDisconnected) - } - if (loop.isDisconnected) { - // do nothing if pump is disconnected - } else if (runningProfile == null || ((!pump.isThisProfileSet(requestedProfile) || !requestedProfile.isEqual(runningProfile)) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE))) { - rxBus.send(EventProfileSwitchChanged()) - } else if (isStatusOutdated && !pump.isBusy()) { - lastReadStatus = System.currentTimeMillis() - commandQueue.readStatus(rh.gs(R.string.keepalive_status_outdated), null) - } else if (isBasalOutdated && !pump.isBusy()) { - lastReadStatus = System.currentTimeMillis() - commandQueue.readStatus(rh.gs(R.string.keepalive_basal_outdated), null) - } - if (lastRun != 0L && System.currentTimeMillis() - lastRun > T.mins(10).msecs()) { - aapsLogger.error(LTag.CORE, "KeepAlive fail") - fabricPrivacy.logCustom("KeepAliveFail") - } - lastRun = System.currentTimeMillis() - } - } - - class KeepAliveManager @Inject constructor( - private val aapsLogger: AAPSLogger, - private val localAlertUtils: LocalAlertUtils - ) { - - //called by MainApp at first app start - fun setAlarm(context: Context) { - aapsLogger.debug(LTag.CORE, "KeepAlive scheduled") - SystemClock.sleep(5000) // wait for app initialization - localAlertUtils.shortenSnoozeInterval() - localAlertUtils.preSnoozeAlarms() - val am = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager - val i = Intent(context, KeepAliveReceiver::class.java) - val pi = PendingIntent.getBroadcast(context, 0, i, FLAG_IMMUTABLE) - try { - pi.send() - } catch (e: CanceledException) { - } - am.cancel(pi) - am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), KEEP_ALIVE_MILLISECONDS, pi) - } - - fun cancelAlarm(context: Context) { - aapsLogger.debug(LTag.CORE, "KeepAlive canceled") - val intent = Intent(context, KeepAliveReceiver::class.java) - val sender = PendingIntent.getBroadcast(context, 0, intent, FLAG_IMMUTABLE) - val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager - alarmManager.cancel(sender) - } - } -} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveWorker.kt b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveWorker.kt new file mode 100644 index 0000000000..dc705c4a84 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveWorker.kt @@ -0,0 +1,167 @@ +package info.nightscout.androidaps.receivers + +import android.content.Context +import androidx.work.* +import com.google.common.util.concurrent.ListenableFuture +import dagger.android.HasAndroidInjector +import info.nightscout.androidaps.BuildConfig +import info.nightscout.androidaps.R +import info.nightscout.androidaps.data.ProfileSealed +import info.nightscout.androidaps.database.AppRepository +import info.nightscout.androidaps.events.EventProfileSwitchChanged +import info.nightscout.androidaps.extensions.buildDeviceStatus +import info.nightscout.androidaps.interfaces.* +import info.nightscout.androidaps.plugins.bus.RxBus +import info.nightscout.androidaps.plugins.configBuilder.RunningConfiguration +import info.nightscout.androidaps.plugins.general.maintenance.MaintenancePlugin +import info.nightscout.androidaps.queue.commands.Command +import info.nightscout.androidaps.utils.DateUtil +import info.nightscout.androidaps.utils.FabricPrivacy +import info.nightscout.androidaps.utils.LocalAlertUtils +import info.nightscout.androidaps.utils.T +import info.nightscout.androidaps.utils.resources.ResourceHelper +import info.nightscout.shared.logging.AAPSLogger +import info.nightscout.shared.logging.LTag +import java.util.concurrent.TimeUnit +import javax.inject.Inject +import kotlin.math.abs + +class KeepAliveWorker( + private val context: Context, + params: WorkerParameters +) : Worker(context, params) { + + @Inject lateinit var aapsLogger: AAPSLogger + @Inject lateinit var localAlertUtils: LocalAlertUtils + @Inject lateinit var repository: AppRepository + @Inject lateinit var config: Config + @Inject lateinit var iobCobCalculator: IobCobCalculator + @Inject lateinit var loop: Loop + @Inject lateinit var dateUtil: DateUtil + @Inject lateinit var activePlugin: ActivePlugin + @Inject lateinit var profileFunction: ProfileFunction + @Inject lateinit var runningConfiguration: RunningConfiguration + @Inject lateinit var receiverStatusStore: ReceiverStatusStore + @Inject lateinit var rxBus: RxBus + @Inject lateinit var commandQueue: CommandQueue + @Inject lateinit var fabricPrivacy: FabricPrivacy + @Inject lateinit var maintenancePlugin: MaintenancePlugin + @Inject lateinit var rh: ResourceHelper + + init { + (context.applicationContext as HasAndroidInjector).androidInjector().inject(this) + } + + companion object { + + private val STATUS_UPDATE_FREQUENCY = T.mins(15).msecs() + private const val IOB_UPDATE_FREQUENCY_IN_MINUTES = 5L + + private var lastReadStatus: Long = 0 + private var lastRun: Long = 0 + private var lastIobUpload: Long = 0 + + } + + override fun doWork(): Result { + aapsLogger.debug(LTag.CORE, "KeepAlive received from: " + inputData.getString("schedule")) + + // 15 min interval is WorkManager minimum so schedule another instances to have 5 min interval + if (inputData.getString("schedule") == "KeepAlive") { + WorkManager.getInstance(context).enqueueUniqueWork( + "KeepAlive_5", + ExistingWorkPolicy.REPLACE, + OneTimeWorkRequest.Builder(KeepAliveWorker::class.java) + .setInputData(Data.Builder().putString("schedule", "KeepAlive_5").build()) + .setInitialDelay(5, TimeUnit.MINUTES) + .build() + ) + WorkManager.getInstance(context).enqueueUniqueWork( + "KeepAlive_10", + ExistingWorkPolicy.REPLACE, + OneTimeWorkRequest.Builder(KeepAliveWorker::class.java) + .setInputData(Data.Builder().putString("schedule", "KeepAlive_10").build()) + .setInitialDelay(10, TimeUnit.MINUTES) + .build() + ) + } + + localAlertUtils.shortenSnoozeInterval() + localAlertUtils.checkStaleBGAlert() + checkPump() + checkAPS() + maintenancePlugin.deleteLogs(30) + workerDbStatus() + + return Result.success() + } + + // When Worker DB grows too much, work operations become slow + // Library is cleaning DB every 7 days which may not be sufficient for NSClient full sync + private fun workerDbStatus() { + val workQuery = WorkQuery.Builder + .fromStates(listOf(WorkInfo.State.FAILED, WorkInfo.State.SUCCEEDED)) + .build() + + val workInfo: ListenableFuture> = WorkManager.getInstance(context).getWorkInfos(workQuery) + aapsLogger.debug(LTag.CORE, "WorkManager size is ${workInfo.get().size}") + if (workInfo.get().size > 1000) { + WorkManager.getInstance(context).pruneWork() + aapsLogger.debug(LTag.CORE, "WorkManager pruning ....") + } + } + + // Usually deviceStatus is uploaded through LoopPlugin after every loop cycle. + // if there is no BG available, we have to upload anyway to have correct + // IOB displayed in NS + private fun checkAPS() { + var shouldUploadStatus = false + if (config.NSCLIENT) return + if (config.PUMPCONTROL) shouldUploadStatus = true + else if (!(loop as PluginBase).isEnabled() || iobCobCalculator.ads.actualBg() == null) + shouldUploadStatus = true + else if (dateUtil.isOlderThan(activePlugin.activeAPS.lastAPSRun, 5)) shouldUploadStatus = true + if (dateUtil.isOlderThan(lastIobUpload, IOB_UPDATE_FREQUENCY_IN_MINUTES) && shouldUploadStatus) { + lastIobUpload = dateUtil.now() + buildDeviceStatus( + dateUtil, loop, iobCobCalculator, profileFunction, + activePlugin.activePump, receiverStatusStore, runningConfiguration, + BuildConfig.VERSION_NAME + "-" + BuildConfig.BUILDVERSION + )?.also { + repository.insert(it) + } + } + } + + private fun checkPump() { + val pump = activePlugin.activePump + val ps = profileFunction.getRequestedProfile() ?: return + val requestedProfile = ProfileSealed.PS(ps) + val runningProfile = profileFunction.getProfile() + val lastConnection = pump.lastDataTime() + val isStatusOutdated = lastConnection + STATUS_UPDATE_FREQUENCY < System.currentTimeMillis() + val isBasalOutdated = abs(requestedProfile.getBasal() - pump.baseBasalRate) > pump.pumpDescription.basalStep + aapsLogger.debug(LTag.CORE, "Last connection: " + dateUtil.dateAndTimeString(lastConnection)) + // sometimes keep alive broadcast stops + // as as workaround test if readStatus was requested before an alarm is generated + if (lastReadStatus != 0L && lastReadStatus > System.currentTimeMillis() - T.mins(5).msecs()) { + localAlertUtils.checkPumpUnreachableAlarm(lastConnection, isStatusOutdated, loop.isDisconnected) + } + if (loop.isDisconnected) { + // do nothing if pump is disconnected + } else if (runningProfile == null || ((!pump.isThisProfileSet(requestedProfile) || !requestedProfile.isEqual(runningProfile)) && !commandQueue.isRunning(Command.CommandType.BASAL_PROFILE))) { + rxBus.send(EventProfileSwitchChanged()) + } else if (isStatusOutdated && !pump.isBusy()) { + lastReadStatus = System.currentTimeMillis() + commandQueue.readStatus(rh.gs(R.string.keepalive_status_outdated), null) + } else if (isBasalOutdated && !pump.isBusy()) { + lastReadStatus = System.currentTimeMillis() + commandQueue.readStatus(rh.gs(R.string.keepalive_basal_outdated), null) + } + if (lastRun != 0L && System.currentTimeMillis() - lastRun > T.mins(10).msecs()) { + aapsLogger.error(LTag.CORE, "KeepAlive fail") + fabricPrivacy.logCustom("KeepAliveFail") + } + lastRun = System.currentTimeMillis() + } +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt index 090b9ae07d..a5d157707f 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SetupWizardActivity.kt @@ -34,7 +34,6 @@ class SetupWizardActivity : NoSplashAppCompatActivity() { @Inject lateinit var injector: HasAndroidInjector @Inject lateinit var localProfilePlugin: LocalProfilePlugin @Inject lateinit var swDefinition: SWDefinition - @Inject lateinit var rxBus: RxBus @Inject lateinit var sp: SP @Inject lateinit var fabricPrivacy: FabricPrivacy @Inject lateinit var aapsSchedulers: AapsSchedulers diff --git a/app/src/main/res/drawable/ic_actions_cancelextbolus.xml b/app/src/main/res/drawable/ic_actions_cancelextbolus.xml index 913b1b9aeb..92998ff78e 100644 --- a/app/src/main/res/drawable/ic_actions_cancelextbolus.xml +++ b/app/src/main/res/drawable/ic_actions_cancelextbolus.xml @@ -5,14 +5,14 @@ android:viewportHeight="24"> + android:fillColor="?attr/extBolusStopColor"/> + android:fillColor="?attr/extBolusStopColor"/> + android:fillColor="?attr/extBolusStopColor"/> + android:fillColor="?attr/extBolusStopColor"/> diff --git a/app/src/main/res/drawable/ic_byoda.xml b/app/src/main/res/drawable/ic_byoda.xml index 1bf06ca7d8..da63bef0df 100644 --- a/app/src/main/res/drawable/ic_byoda.xml +++ b/app/src/main/res/drawable/ic_byoda.xml @@ -5,5 +5,5 @@ android:viewportHeight="24"> + android:fillColor="@color/byodagray"/> diff --git a/app/src/main/res/drawable/ic_cancelbasal.xml b/app/src/main/res/drawable/ic_cancelbasal.xml index 76640a4534..dcc01452e3 100644 --- a/app/src/main/res/drawable/ic_cancelbasal.xml +++ b/app/src/main/res/drawable/ic_cancelbasal.xml @@ -4,7 +4,8 @@ android:viewportHeight="24" android:viewportWidth="24" xmlns:android="http://schemas.android.com/apk/res/android"> - - - + + + diff --git a/app/src/main/res/drawable/ic_cp_age_battery.xml b/app/src/main/res/drawable/ic_cp_age_battery.xml index cc36e585a0..2316d660aa 100644 --- a/app/src/main/res/drawable/ic_cp_age_battery.xml +++ b/app/src/main/res/drawable/ic_cp_age_battery.xml @@ -6,11 +6,11 @@ diff --git a/app/src/main/res/drawable/ic_cp_age_cannula.xml b/app/src/main/res/drawable/ic_cp_age_cannula.xml index f2578fa72b..58b450d81f 100644 --- a/app/src/main/res/drawable/ic_cp_age_cannula.xml +++ b/app/src/main/res/drawable/ic_cp_age_cannula.xml @@ -6,6 +6,6 @@ diff --git a/app/src/main/res/drawable/ic_cp_age_insulin.xml b/app/src/main/res/drawable/ic_cp_age_insulin.xml index 701e31cee3..7e96c91e7a 100644 --- a/app/src/main/res/drawable/ic_cp_age_insulin.xml +++ b/app/src/main/res/drawable/ic_cp_age_insulin.xml @@ -6,6 +6,6 @@ diff --git a/app/src/main/res/drawable/ic_cp_age_sensor.xml b/app/src/main/res/drawable/ic_cp_age_sensor.xml index 08134cc20b..64c684320c 100644 --- a/app/src/main/res/drawable/ic_cp_age_sensor.xml +++ b/app/src/main/res/drawable/ic_cp_age_sensor.xml @@ -6,16 +6,16 @@ diff --git a/app/src/main/res/drawable/ic_loop_disabled.xml b/app/src/main/res/drawable/ic_loop_disabled.xml index 685118b92d..e8004f78fe 100644 --- a/app/src/main/res/drawable/ic_loop_disabled.xml +++ b/app/src/main/res/drawable/ic_loop_disabled.xml @@ -5,11 +5,11 @@ android:viewportHeight="24"> + android:fillColor="?attr/loopDisabled"/> + android:fillColor="?attr/loopDisabled"/> + android:fillColor="?attr/loopDisabled"/> diff --git a/app/src/main/res/drawable/ic_loop_disconnected.xml b/app/src/main/res/drawable/ic_loop_disconnected.xml index ea2cd137f4..3753c6a451 100644 --- a/app/src/main/res/drawable/ic_loop_disconnected.xml +++ b/app/src/main/res/drawable/ic_loop_disconnected.xml @@ -5,8 +5,8 @@ android:viewportHeight="24"> + android:fillColor="?attr/loopDisconnected"/> + android:fillColor="?attr/loopDisconnected"/> diff --git a/app/src/main/res/drawable/ic_loop_lgs.xml b/app/src/main/res/drawable/ic_loop_lgs.xml index c570403dbf..23a4ddf300 100644 --- a/app/src/main/res/drawable/ic_loop_lgs.xml +++ b/app/src/main/res/drawable/ic_loop_lgs.xml @@ -5,20 +5,20 @@ android:viewportHeight="24"> + android:fillColor="?attr/loopClosed"/> + android:fillColor="?attr/loopClosed"/> + android:fillColor="?attr/loopClosed"/> + android:fillColor="?attr/loopClosed"/> + android:fillColor="?attr/loopClosed"/> + android:fillColor="?attr/loopClosed"/> diff --git a/app/src/main/res/drawable/ic_loop_open.xml b/app/src/main/res/drawable/ic_loop_open.xml index 6f97953808..c7b4f00e3b 100644 --- a/app/src/main/res/drawable/ic_loop_open.xml +++ b/app/src/main/res/drawable/ic_loop_open.xml @@ -5,23 +5,23 @@ android:viewportHeight="24"> + android:fillColor="?attr/loopOpened"/> + android:fillColor="?attr/loopOpened"/> + android:fillColor="?attr/loopOpened"/> + android:fillColor="?attr/loopOpened"/> + android:fillColor="?attr/loopOpened"/> + android:fillColor="?attr/loopOpened"/> + android:fillColor="?attr/loopOpened"/> diff --git a/app/src/main/res/drawable/ic_loop_paused.xml b/app/src/main/res/drawable/ic_loop_paused.xml index c49d3084c3..372b6a7d61 100644 --- a/app/src/main/res/drawable/ic_loop_paused.xml +++ b/app/src/main/res/drawable/ic_loop_paused.xml @@ -5,11 +5,11 @@ android:viewportHeight="24"> + android:fillColor="?attr/loopDisabled"/> + android:fillColor="?attr/loopDisabled"/> + android:fillColor="?attr/loopDisabled"/> diff --git a/app/src/main/res/drawable/ic_loop_reconnect.xml b/app/src/main/res/drawable/ic_loop_reconnect.xml index f61d0f97b1..ca8e54fa6c 100644 --- a/app/src/main/res/drawable/ic_loop_reconnect.xml +++ b/app/src/main/res/drawable/ic_loop_reconnect.xml @@ -5,8 +5,8 @@ android:viewportHeight="24"> + android:fillColor="?attr/loopClosed"/> + android:fillColor="?attr/loopClosed"/> diff --git a/app/src/main/res/drawable/ic_loop_resume.xml b/app/src/main/res/drawable/ic_loop_resume.xml index ade6ba2f8d..cf80f79567 100644 --- a/app/src/main/res/drawable/ic_loop_resume.xml +++ b/app/src/main/res/drawable/ic_loop_resume.xml @@ -5,8 +5,8 @@ android:viewportHeight="24"> + android:fillColor="?attr/loopClosed"/> + android:fillColor="?attr/loopClosed"/> diff --git a/app/src/main/res/drawable/ic_loop_superbolus.xml b/app/src/main/res/drawable/ic_loop_superbolus.xml index 2f94edf2c4..fd9223c587 100644 --- a/app/src/main/res/drawable/ic_loop_superbolus.xml +++ b/app/src/main/res/drawable/ic_loop_superbolus.xml @@ -5,8 +5,8 @@ android:viewportHeight="24"> + android:fillColor="?attr/loopSuperBolus"/> + android:fillColor="?attr/loopSuperBolus"/> diff --git a/app/src/main/res/drawable/ic_patch_pump_outline.xml b/app/src/main/res/drawable/ic_patch_pump_outline.xml index 6e95a27545..6a86ec1503 100644 --- a/app/src/main/res/drawable/ic_patch_pump_outline.xml +++ b/app/src/main/res/drawable/ic_patch_pump_outline.xml @@ -6,7 +6,7 @@ diff --git a/app/src/main/res/drawable/ic_target_activity.xml b/app/src/main/res/drawable/ic_target_activity.xml index 4439597b75..4873b388cc 100644 --- a/app/src/main/res/drawable/ic_target_activity.xml +++ b/app/src/main/res/drawable/ic_target_activity.xml @@ -5,14 +5,14 @@ android:viewportHeight="24"> + android:fillColor="?attr/exerciseColor"/> - - + android:fillColor="?attr/exerciseColor"/> + + diff --git a/app/src/main/res/drawable/ic_target_cancel.xml b/app/src/main/res/drawable/ic_target_cancel.xml index 50d7304662..c00ad238f7 100644 --- a/app/src/main/res/drawable/ic_target_cancel.xml +++ b/app/src/main/res/drawable/ic_target_cancel.xml @@ -5,11 +5,11 @@ android:viewportHeight="24"> - - + android:fillColor="?attr/tempTargetConfirmation"/> + + diff --git a/app/src/main/res/drawable/ic_target_eatingsoon.xml b/app/src/main/res/drawable/ic_target_eatingsoon.xml index 54b6162546..70d0ab72d4 100644 --- a/app/src/main/res/drawable/ic_target_eatingsoon.xml +++ b/app/src/main/res/drawable/ic_target_eatingsoon.xml @@ -5,17 +5,17 @@ android:viewportHeight="24"> + android:fillColor="?attr/carbsColor"/> + android:fillColor="?attr/carbsColor"/> - - + android:fillColor="?attr/carbsColor"/> + + diff --git a/app/src/main/res/drawable/ic_target_hypo.xml b/app/src/main/res/drawable/ic_target_hypo.xml index 30721cbf14..eab6df8e3f 100644 --- a/app/src/main/res/drawable/ic_target_hypo.xml +++ b/app/src/main/res/drawable/ic_target_hypo.xml @@ -5,17 +5,17 @@ android:viewportHeight="24"> + android:fillColor="?attr/lowColor"/> + android:fillColor="?attr/lowColor"/> + android:fillColor="?attr/lowColor"/> + android:fillColor="?attr/bgInRange"/> + android:fillColor="?attr/tempTargetConfirmation"/> diff --git a/app/src/main/res/drawable/ic_xdrip.xml b/app/src/main/res/drawable/ic_xdrip.xml index 54f88823ba..bf2ee9b482 100644 --- a/app/src/main/res/drawable/ic_xdrip.xml +++ b/app/src/main/res/drawable/ic_xdrip.xml @@ -4,5 +4,6 @@ android:viewportHeight="24" android:viewportWidth="24" xmlns:android="http://schemas.android.com/apk/res/android"> - + diff --git a/app/src/main/res/layout/activity_setupwizard.xml b/app/src/main/res/layout/activity_setupwizard.xml index d70bd1063c..c84e5f652d 100644 --- a/app/src/main/res/layout/activity_setupwizard.xml +++ b/app/src/main/res/layout/activity_setupwizard.xml @@ -62,7 +62,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom|center_horizontal" - android:background="@color/black_overlay" + android:background="@color/black_alpha_40" android:orientation="horizontal" android:paddingLeft="16dp" android:paddingRight="16dp"> diff --git a/app/src/main/res/layout/careportal_stats_fragment_lowres.xml b/app/src/main/res/layout/careportal_stats_fragment_lowres.xml deleted file mode 100644 index da803e3354..0000000000 --- a/app/src/main/res/layout/careportal_stats_fragment_lowres.xml +++ /dev/null @@ -1,224 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/overview_buttons_layout.xml b/app/src/main/res/layout/overview_buttons_layout.xml index 872963859e..d4142c46b1 100644 --- a/app/src/main/res/layout/overview_buttons_layout.xml +++ b/app/src/main/res/layout/overview_buttons_layout.xml @@ -45,7 +45,7 @@ android:layout_weight="0.5" android:drawableTop="@drawable/icon_insulin_carbs" android:text="@string/overview_treatment_label" - android:textColor="?attr/treatmentButton" + android:textColor="?attr/icTreatmentColor" android:textSize="10sp" android:visibility="gone" tools:ignore="SmallSp" /> @@ -59,7 +59,7 @@ android:layout_weight="0.5" android:drawableTop="@drawable/ic_bolus" android:text="@string/overview_insulin_label" - android:textColor="?attr/insulinButtonColor" + android:textColor="?attr/icBolusColor" android:textSize="10sp" tools:ignore="SmallSp" /> @@ -72,7 +72,7 @@ android:layout_weight="0.5" android:drawableTop="@drawable/ic_cp_bolus_carbs" android:text="@string/treatments_wizard_carbs_label" - android:textColor="?attr/carbsButtonColor" + android:textColor="?attr/icBolusCarbsColor" android:textSize="10sp" tools:ignore="SmallSp" /> @@ -85,7 +85,7 @@ android:layout_weight="0.5" android:drawableTop="@drawable/ic_calculator" android:text="@string/overview_calculator_label" - android:textColor="?attr/calculatorButtonColor" + android:textColor="?attr/icCalculatorColor" android:textSize="10sp" tools:ignore="SmallSp" /> @@ -98,7 +98,7 @@ android:layout_weight="0.5" android:drawableTop="@drawable/ic_calibration" android:text="@string/overview_calibration" - android:textColor="?attr/calibrationButtonColor" + android:textColor="?attr/icCalibrationColor" android:textSize="10sp" android:visibility="gone" tools:ignore="SmallSp" /> @@ -112,7 +112,7 @@ android:layout_weight="0.5" android:drawableTop="@drawable/ic_xdrip" android:text="@string/overview_cgm" - android:textColor="?attr/calibrationButtonColor" + android:textColor="?attr/icCalibrationColor" android:textSize="10sp" android:visibility="gone" tools:ignore="SmallSp" /> @@ -127,7 +127,7 @@ android:drawableTop="@drawable/ic_quick_wizard" android:text="@string/quickwizard" android:hint="@string/quickwizard" - android:textColor="?attr/quickWizardButtonColor" + android:textColor="?attr/icQuickWizardColor" android:textSize="10sp" tools:ignore="SmallSp" /> diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml index 7f059cc5ca..29b08629f0 100644 --- a/app/src/main/res/layout/overview_fragment.xml +++ b/app/src/main/res/layout/overview_fragment.xml @@ -135,7 +135,7 @@ android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:layout_marginRight="5dp" - android:background="@color/pumpStatusBackground" + android:background="?attr/pumpStatusBackground" android:gravity="center_vertical|center_horizontal" android:paddingTop="6dp" android:paddingBottom="6dp" diff --git a/app/src/main/res/values-cs-rCZ/strings.xml b/app/src/main/res/values-cs-rCZ/strings.xml index 191ee91193..170b013f80 100644 --- a/app/src/main/res/values-cs-rCZ/strings.xml +++ b/app/src/main/res/values-cs-rCZ/strings.xml @@ -985,6 +985,8 @@ Neznámý příkaz k akci: Procentní podíl Výchozí nastavení aplikace + Zobrazit zneplatněné / odstraněné záznamy + Skrýt zneplatněné / odstraněné záznamy Vyberte profil pro úpravu Obnovit z Nightscoutu Odstranit zvolené položky @@ -1001,4 +1003,6 @@ Pod V rozsahu Nad + Zobrazit záznamy smyčky + Skrýt záznamy smyčky diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index b39d75b6fb..bd6ac852d9 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -435,7 +435,7 @@ OpenAPS SMB ISF Dinámico Factor de ajuste de ISF Dinámico % - Porcentaje del factor de ajuste para ISF Dinámico. Establece valores por encima del 100%, para correcciones más agresivas y por debajo para correcciones menos agresivas + Porcentaje del factor de ajuste de ISF Dinámico\n Valor predeterminado: 100\nEstablecer valores por encima del 100% para que el algoritmo aplique correcciones más agresivas y valores por debajo del 100% para correcciones menos agresivas. Activar UAM Activar SMB Usar microbolos en lugar de basales temporales, para corregir más rápidamente @@ -985,6 +985,8 @@ Comando de acción desconocido: Porcentaje Aplicación por defecto + Mostrar registros eliminados o invalidados + Ocultar registros eliminados o invalidados Seleccione el perfil a editar Actualizar de Nightscout Eliminar los elementos seleccionados @@ -1001,4 +1003,6 @@ Bajo En rango Alto + Mostrar registros del lazo + Ocultar registros del lazo diff --git a/app/src/main/res/values-no-rNO/strings.xml b/app/src/main/res/values-no-rNO/strings.xml index f2d63fcc6c..ad83fa9cbd 100644 --- a/app/src/main/res/values-no-rNO/strings.xml +++ b/app/src/main/res/values-no-rNO/strings.xml @@ -985,6 +985,8 @@ Ukjent kommando: Prosent Standardverdi + Vis ugyldige / slettede registreringer + Skjul ugyldige / slettede registreringer Velg profil du vil redigere Oppdater fra Nightscout Fjern valgte elementer @@ -1001,4 +1003,6 @@ Under I målområdet Over + Vis loop registreringer + Skjul loop registreringer diff --git a/app/src/main/res/values-ru-rRU/strings.xml b/app/src/main/res/values-ru-rRU/strings.xml index 4e1d0bbecd..3d1f1a1f6c 100644 --- a/app/src/main/res/values-ru-rRU/strings.xml +++ b/app/src/main/res/values-ru-rRU/strings.xml @@ -161,6 +161,7 @@ лицензионное соглашение с пользователем НЕ ДОЛЖНО ИСПОЛЬЗОВАТЬСЯ ДЛЯ ПРИНЯТИЯ МЕДИЦИНСКИХ РЕШЕНИЙ. ПРОГРАММА НЕ ДАЕТ ГАРАНТИЙ В РАМКАХ СУЩЕСТВУЮЩЕГО ЗАКОНОДАТЕЛЬСТВА. ПРЕДОСТАВЛЯЕТСЯ \"КАК ЕСТЬ\" БЕЗ ЯВНЫХ ИЛИ СКРЫТЫХ ГАРАНТИЙ ВКЛЮЧАЯ НО НЕ ОГРАНИЧИВАЯСЬ ВОЗМОЖНОСТЬЮ КОММЕРЧЕСКОГО ИСПОЛЬЗОВАНИ ИЛИ СООТВЕТСТВИЯ КАКИМ-ЛИБО ЦЕЛЯМ. ВСЕ РИСКИ ЛОЖАТСЯ НА ВАС. В СЛУЧАЕ НЕРАБОТОСПОСОБНОСТИ ПРОГРАММЫ ВЫ НЕСЕТЕ ВСЕ РАСХОДЫ СВЯЗАННЫЕ С ОБСЛУЖИВАНИЕМ РЕМОНТОМ ИЛИ КОРРЕКТИРОВКОЙ. я понимаю и принимаю + Сохранить обновить профиль SMS коммуникатор разрешенные телефонные номера @@ -432,6 +433,8 @@ Активировать локальную передачу Супер микро болюс OpenAPS Динамический ISF + Коэффициент регулировки динамического диапазона чувствительности ISF % + Коэффициент корректировки динамического диапазона чувствительности ISF. Установите более 100% для более агрессивных доз коррекции и менее 100% для менее агрессивной коррекции. Включить непредвиденный прием пищи UAM Включить супер микро болюс SMB Для ускорения действия используйте супер микро болюсы SMB вместо временного базала @@ -664,6 +667,7 @@ Показать недействительные Скрыть недействительные Удалить элементы + Сортировать элементы Найдены сохраненные параметры Внимание: Если вы активируете подключение к невиртуальной помпе, AndroidAPS скопирует настройки базала в профиль помпы, перезаписывая существующие настройки, хранящиеся в ней. Убедитесь, что настройки базала в AndroidAPS корректны. Если вы не уверены или не хотите перезаписать настройки базала на помпу, нажмите отменить и повторите подключение в другое время. Данные терапии неполные @@ -878,6 +882,7 @@ Принимать переключения профиля, введенные через NS или NSClient Принимать события APS автономно Принимать события APS введенные через NS или клиент NS автономно + Получать временную базальную скорость TBR и пролонгированный болюс EB Принимать инсулин Принимать инсулин, введенный через NS или NSClient (не подается, только рассчитывается как активный IOB) Принимать углеводы diff --git a/app/src/main/res/values-tr-rTR/strings.xml b/app/src/main/res/values-tr-rTR/strings.xml index e0fe1138c7..15d6716138 100644 --- a/app/src/main/res/values-tr-rTR/strings.xml +++ b/app/src/main/res/values-tr-rTR/strings.xml @@ -986,6 +986,8 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d Bilinmeyen eylem komutu: Yüzde Uygulama varsayılanı + Geçersiz kılınan / kaldırılan kayıtları göster + Geçersiz kılınan / kaldırılan kayıtları gizle Düzenlenecek profili seç Nightscout\'tan Yenile Seçili nesneleri kaldır @@ -998,7 +1000,10 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden d Döngüyü göster %1$d seçildi Sırala + İletişim kutusu iptal edildi Altında Aralık içinde Üstünde + Döngü kayıtlarını göster + Döngü kayıtlarını gizle diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 4ec05a9e7a..df0ace5e89 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -997,6 +997,7 @@ 显示闭环 已选中 %1$d 排序 + 对话框已取消 底部 在范围内 上方 diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt index 15d72f6682..c27f843e97 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/AutomationFragment.kt @@ -173,10 +173,10 @@ class AutomationFragment : DaggerFragment(), OnStartDragListener { override fun onBindViewHolder(holder: ViewHolder, position: Int) { val automation = automationPlugin.at(position) holder.binding.rootLayout.setBackgroundColor( - rh.gc( - if (automation.userAction) R.color.mdtp_line_dark - else if (automation.areActionsValid()) R.color.ribbonDefault - else R.color.errorAlertBackground + rh.gac( context, + if (automation.userAction) R.attr.userAction + else if (automation.areActionsValid()) R.attr.validActions + else R.attr.actionsError ) ) holder.binding.eventTitle.text = automation.title diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabel.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabel.kt index 57ef1c09c7..2e31509ff8 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabel.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/elements/StaticLabel.kt @@ -4,6 +4,7 @@ import android.graphics.Typeface import android.view.ViewGroup import android.widget.LinearLayout import android.widget.TextView +import info.nightscout.androidaps.automation.R import info.nightscout.androidaps.plugins.general.automation.triggers.Trigger import info.nightscout.androidaps.utils.resources.ResourceHelper @@ -28,7 +29,7 @@ class StaticLabel(private val rh: ResourceHelper) : Element() { LinearLayout(root.context).apply { orientation = LinearLayout.HORIZONTAL layoutParams = LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) - setBackgroundColor(rh.gc(android.R.color.black)) + setBackgroundColor(rh.gac(context, R.attr.automationBackgroundColor)) addView( TextView(root.context).apply { text = label diff --git a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt index 31de36e247..65f910a658 100644 --- a/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt +++ b/automation/src/main/java/info/nightscout/androidaps/plugins/general/automation/triggers/TriggerConnector.kt @@ -165,7 +165,7 @@ class TriggerConnector(injector: HasAndroidInjector) : Trigger(injector) { text = rh.gs(connectorType.stringRes) gravity = gravity or Gravity.CENTER_VERTICAL setTypeface(typeface, Typeface.BOLD) - setBackgroundColor(rh.gc(R.color.black_overlay)) + setBackgroundColor(rh.gac(context, R.attr.automationOverlayColor)) layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT).also { ll -> ll.setMargins(rh.dpToPx(3), rh.dpToPx(3), rh.dpToPx(3), rh.dpToPx(3)) } diff --git a/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboFragment.java b/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboFragment.java index abc3f676f5..b0fc0d809c 100644 --- a/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboFragment.java +++ b/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboFragment.java @@ -134,33 +134,33 @@ public class ComboFragment extends DaggerFragment { PumpState ps = comboPlugin.getPump().state; if (ps.insulinState == PumpState.EMPTY || ps.batteryState == PumpState.EMPTY || ps.activeAlert != null && ps.activeAlert.errorCode != null) { - stateView.setTextColor(Color.RED); + stateView.setTextColor(rh.gac(getContext(), R.attr.warningColor)); stateView.setTypeface(null, Typeface.BOLD); } else if (comboPlugin.getPump().state.suspended || ps.activeAlert != null && ps.activeAlert.warningCode != null) { - stateView.setTextColor(Color.YELLOW); + stateView.setTextColor(rh.gac(getContext(), R.attr.omniYellowColor)); stateView.setTypeface(null, Typeface.BOLD); } else { - stateView.setTextColor(Color.WHITE); + stateView.setTextColor(rh.gac(getContext(), R.attr.defaultTextColor)); stateView.setTypeface(null, Typeface.NORMAL); } // activity String activity = comboPlugin.getPump().activity; if (activity != null) { - activityView.setTextColor(Color.WHITE); + activityView.setTextColor(rh.gac(getContext(), R.attr.defaultTextColor)); activityView.setTextSize(14); activityView.setText(activity); } else if (commandQueue.size() > 0) { - activityView.setTextColor(Color.WHITE); + activityView.setTextColor(rh.gac(getContext(), R.attr.defaultTextColor)); activityView.setTextSize(14); activityView.setText(""); } else if (comboPlugin.isInitialized()) { - activityView.setTextColor(Color.WHITE); + activityView.setTextColor(rh.gac(getContext(), R.attr.defaultTextColor)); activityView.setTextSize(20); activityView.setText("{fa-bed}"); } else { - activityView.setTextColor(Color.RED); + activityView.setTextColor(rh.gac(getContext(), R.attr.warningColor)); activityView.setTextSize(14); activityView.setText(rh.gs(R.string.pump_unreachable)); } @@ -170,10 +170,10 @@ public class ComboFragment extends DaggerFragment { batteryView.setTextSize(20); if (ps.batteryState == PumpState.EMPTY) { batteryView.setText("{fa-battery-empty}"); - batteryView.setTextColor(Color.RED); + batteryView.setTextColor(rh.gac(getContext(), R.attr.warningColor)); } else if (ps.batteryState == PumpState.LOW) { batteryView.setText("{fa-battery-quarter}"); - batteryView.setTextColor(Color.YELLOW); + batteryView.setTextColor(rh.gac(getContext(), R.attr.omniYellowColor)); } else { batteryView.setText("{fa-battery-full}"); batteryView.setTextColor(Color.WHITE); @@ -192,16 +192,16 @@ public class ComboFragment extends DaggerFragment { } if (ps.insulinState == PumpState.UNKNOWN) { - reservoirView.setTextColor(Color.WHITE); + reservoirView.setTextColor(rh.gac(getContext(), R.attr.defaultTextColor)); reservoirView.setTypeface(null, Typeface.NORMAL); } else if (ps.insulinState == PumpState.LOW) { - reservoirView.setTextColor(Color.YELLOW); + reservoirView.setTextColor(rh.gac(getContext(), R.attr.omniYellowColor)); reservoirView.setTypeface(null, Typeface.BOLD); } else if (ps.insulinState == PumpState.EMPTY) { - reservoirView.setTextColor(Color.RED); + reservoirView.setTextColor(rh.gac(getContext(), R.attr.warningColor)); reservoirView.setTypeface(null, Typeface.BOLD); } else { - reservoirView.setTextColor(Color.WHITE); + reservoirView.setTextColor(rh.gac(getContext(), R.attr.defaultTextColor)); reservoirView.setTypeface(null, Typeface.NORMAL); } @@ -210,13 +210,13 @@ public class ComboFragment extends DaggerFragment { long min = (System.currentTimeMillis() - comboPlugin.getPump().lastSuccessfulCmdTime) / 1000 / 60; if (comboPlugin.getPump().lastSuccessfulCmdTime + 60 * 1000 > System.currentTimeMillis()) { lastConnectionView.setText(R.string.combo_pump_connected_now); - lastConnectionView.setTextColor(Color.WHITE); + lastConnectionView.setTextColor(rh.gac(getContext(), R.attr.defaultTextColor)); } else if (comboPlugin.getPump().lastSuccessfulCmdTime + 30 * 60 * 1000 < System.currentTimeMillis()) { lastConnectionView.setText(rh.gs(R.string.combo_no_pump_connection, min)); - lastConnectionView.setTextColor(Color.RED); + lastConnectionView.setTextColor(rh.gac(getContext(), R.attr.warningColor)); } else { lastConnectionView.setText(minAgo); - lastConnectionView.setTextColor(Color.WHITE); + lastConnectionView.setTextColor(rh.gac(getContext(), R.attr.defaultTextColor)); } // last bolus diff --git a/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ruffyscripter/commands/ReadHistoryCommand.java b/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ruffyscripter/commands/ReadHistoryCommand.java index d3f03ac6a2..b5dfb4044d 100644 --- a/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ruffyscripter/commands/ReadHistoryCommand.java +++ b/combo/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ruffyscripter/commands/ReadHistoryCommand.java @@ -109,25 +109,25 @@ public class ReadHistoryCommand extends BaseCommand { if (!history.bolusHistory.isEmpty()) { aapsLogger.debug(LTag.PUMP, "Read bolus history (" + history.bolusHistory.size() + "):"); for (Bolus bolus : history.bolusHistory) { - aapsLogger.debug(LTag.PUMP, new Date(bolus.timestamp) + ": " + bolus.toString()); + aapsLogger.debug(LTag.PUMP, new Date(bolus.timestamp) + ": " + bolus); } } if (!history.pumpAlertHistory.isEmpty()) { aapsLogger.debug(LTag.PUMP, "Read error history (" + history.pumpAlertHistory.size() + "):"); for (PumpAlert pumpAlert : history.pumpAlertHistory) { - aapsLogger.debug(LTag.PUMP, new Date(pumpAlert.timestamp) + ": " + pumpAlert.toString()); + aapsLogger.debug(LTag.PUMP, new Date(pumpAlert.timestamp) + ": " + pumpAlert); } } if (!history.tddHistory.isEmpty()) { aapsLogger.debug(LTag.PUMP, "Read TDD history (" + history.tddHistory.size() + "):"); for (Tdd tdd : history.tddHistory) { - aapsLogger.debug(LTag.PUMP, new Date(tdd.timestamp) + ": " + tdd.toString()); + aapsLogger.debug(LTag.PUMP, new Date(tdd.timestamp) + ": " + tdd); } } if (!history.tbrHistory.isEmpty()) { aapsLogger.debug(LTag.PUMP, "Read TBR history (" + history.tbrHistory.size() + "):"); for (Tbr tbr : history.tbrHistory) { - aapsLogger.debug(LTag.PUMP, new Date(tbr.timestamp) + ": " + tbr.toString()); + aapsLogger.debug(LTag.PUMP, new Date(tbr.timestamp) + ": " + tbr); } } diff --git a/core/src/main/java/info/nightscout/androidaps/activities/NoSplashAppCompatActivity.kt b/core/src/main/java/info/nightscout/androidaps/activities/NoSplashAppCompatActivity.kt index c8f9888ec6..430c562448 100644 --- a/core/src/main/java/info/nightscout/androidaps/activities/NoSplashAppCompatActivity.kt +++ b/core/src/main/java/info/nightscout/androidaps/activities/NoSplashAppCompatActivity.kt @@ -1,15 +1,33 @@ package info.nightscout.androidaps.activities - import android.content.Context import android.os.Bundle import info.nightscout.androidaps.core.R +import info.nightscout.androidaps.events.EventThemeSwitch +import info.nightscout.androidaps.plugins.bus.RxBus import info.nightscout.androidaps.utils.locale.LocaleHelper +import io.reactivex.rxjava3.disposables.CompositeDisposable +import javax.inject.Inject + open class NoSplashAppCompatActivity : DaggerAppCompatActivityWithResult() { - override fun onCreate(savedInstanceState: Bundle?) { + @Inject lateinit var rxBus: RxBus + + private val compositeDisposable = CompositeDisposable() + + public override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setTheme(R.style.AppTheme_NoActionBar) + + compositeDisposable.add(rxBus.toObservable(EventThemeSwitch::class.java).subscribe { + recreate() + }) + + } + + override fun onDestroy() { + compositeDisposable.clear() + super.onDestroy() } override fun attachBaseContext(newBase: Context) { 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 c5bfd4a69b..b07f66f893 100644 --- a/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt +++ b/core/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.kt @@ -44,7 +44,6 @@ import kotlin.math.roundToInt class TDDStatsActivity : NoSplashAppCompatActivity() { - @Inject lateinit var rxBus: RxBus @Inject lateinit var sp: SP @Inject lateinit var profileFunction: ProfileFunction @Inject lateinit var activePlugin: ActivePlugin @@ -89,27 +88,27 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { // add stats headers to tables binding.mainTable.addView( TableRow(this).also { trHead -> - trHead.setBackgroundColor(Color.DKGRAY) + trHead.setBackgroundColor(rh.gac(this, R.attr.tddHeaderBackground)) trHead.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) trHead.addView(TextView(this).also { labelDate -> labelDate.text = rh.gs(R.string.date) - labelDate.setTextColor(Color.WHITE) + labelDate.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) trHead.addView(TextView(this).also { labelBasalRate -> labelBasalRate.text = rh.gs(R.string.basalrate) - labelBasalRate.setTextColor(Color.WHITE) + labelBasalRate.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) trHead.addView(TextView(this).also { labelBolus -> labelBolus.text = rh.gs(R.string.bolus) - labelBolus.setTextColor(Color.WHITE) + labelBolus.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) trHead.addView(TextView(this).also { labelTdd -> labelTdd.text = rh.gs(R.string.tdd) - labelTdd.setTextColor(Color.WHITE) + labelTdd.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) trHead.addView(TextView(this).also { labelRatio -> labelRatio.text = rh.gs(R.string.ratio) - labelRatio.setTextColor(Color.WHITE) + labelRatio.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) ) @@ -117,19 +116,19 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { // cumulative table binding.cumulativeTable.addView( TableRow(this).also { ctrHead -> - ctrHead.setBackgroundColor(Color.DKGRAY) + ctrHead.setBackgroundColor(rh.gac(this, R.attr.tddHeaderBackground)) ctrHead.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) ctrHead.addView(TextView(this).also { labelCumAmountDays -> labelCumAmountDays.text = rh.gs(R.string.amount_days) - labelCumAmountDays.setTextColor(Color.WHITE) + labelCumAmountDays.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) ctrHead.addView(TextView(this).also { labelCumTdd -> labelCumTdd.text = rh.gs(R.string.tdd) - labelCumTdd.setTextColor(Color.WHITE) + labelCumTdd.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) ctrHead.addView(TextView(this).also { labelCumRatio -> labelCumRatio.text = rh.gs(R.string.ratio) - labelCumRatio.setTextColor(Color.WHITE) + labelCumRatio.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) ) @@ -137,19 +136,19 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { // exponential table binding.expweightTable.addView( TableRow(this).also { etrHead -> - etrHead.setBackgroundColor(Color.DKGRAY) + etrHead.setBackgroundColor(rh.gac(this, R.attr.tddHeaderBackground)) etrHead.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) etrHead.addView(TextView(this).also { labelExpWeight -> labelExpWeight.text = rh.gs(R.string.weight) - labelExpWeight.setTextColor(Color.WHITE) + labelExpWeight.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) etrHead.addView(TextView(this).also { labelExpTdd -> labelExpTdd.text = rh.gs(R.string.tdd) - labelExpTdd.setTextColor(Color.WHITE) + labelExpTdd.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) etrHead.addView(TextView(this).also { labelExpRatio -> labelExpRatio.text = rh.gs(R.string.ratio) - labelExpRatio.setTextColor(Color.WHITE) + labelExpRatio.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) ) @@ -285,9 +284,9 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { // Create the table row binding.mainTable.addView( TableRow(this@TDDStatsActivity).also { tr -> - if (i % 2 != 0) tr.setBackgroundColor(Color.DKGRAY) + if (i % 2 != 0) tr.setBackgroundColor(rh.gac(this, R.attr.tddHeaderBackground)) if (dummies.contains(record)) - tr.setBackgroundColor(Color.argb(125, 255, 0, 0)) + tr.setBackgroundColor(rh.gac(this, R.attr.dummyBackground)) tr.id = 100 + i tr.layoutParams = TableLayout.LayoutParams( @@ -299,27 +298,27 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { tr.addView(TextView(this@TDDStatsActivity).also { labelDATE -> labelDATE.id = 200 + i labelDATE.text = df1.format(Date(record.timestamp)) - labelDATE.setTextColor(Color.WHITE) + labelDATE.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) tr.addView(TextView(this@TDDStatsActivity).also { labelBASAL -> labelBASAL.id = 300 + i labelBASAL.text = rh.gs(R.string.formatinsulinunits, record.basalAmount) - labelBASAL.setTextColor(Color.WHITE) + labelBASAL.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) tr.addView(TextView(this@TDDStatsActivity).also { labelBOLUS -> labelBOLUS.id = 400 + i labelBOLUS.text = rh.gs(R.string.formatinsulinunits, record.bolusAmount) - labelBOLUS.setTextColor(Color.WHITE) + labelBOLUS.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) tr.addView(TextView(this@TDDStatsActivity).also { labelTDD -> labelTDD.id = 500 + i labelTDD.text = rh.gs(R.string.formatinsulinunits, tdd) - labelTDD.setTextColor(Color.WHITE) + labelTDD.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) tr.addView(TextView(this@TDDStatsActivity).also { labelRATIO -> labelRATIO.id = 600 + i labelRATIO.text = (100 * tdd / magicNumber).roundToInt().toString() + "%" - labelRATIO.setTextColor(Color.WHITE) + labelRATIO.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) ) @@ -338,7 +337,7 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { // Create the cumulative table row binding.cumulativeTable.addView( TableRow(this@TDDStatsActivity).also { ctr -> - if (i % 2 == 0) ctr.setBackgroundColor(Color.DKGRAY) + if (i % 2 == 0) ctr.setBackgroundColor(rh.gac(this, R.attr.tddHeaderBackground)) ctr.id = 700 + i ctr.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) @@ -346,19 +345,19 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { ctr.addView(TextView(this@TDDStatsActivity).also { labelDAYS -> labelDAYS.id = 800 + i labelDAYS.text = i.toString() - labelDAYS.setTextColor(Color.WHITE) + labelDAYS.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) ctr.addView(TextView(this@TDDStatsActivity).also { labelCUMTDD -> labelCUMTDD.id = 900 + i labelCUMTDD.text = rh.gs(R.string.formatinsulinunits, sum / i) - labelCUMTDD.setTextColor(Color.WHITE) + labelCUMTDD.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) ctr.addView(TextView(this@TDDStatsActivity).also { labelCUMRATIO -> labelCUMRATIO.id = 1000 + i labelCUMRATIO.text = (100 * sum / i / magicNumber).roundToInt().toString() + "%" - labelCUMRATIO.setTextColor(Color.WHITE) + labelCUMRATIO.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) ) @@ -366,7 +365,7 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { if (isOldData(historyList) && activePlugin.activePump.pumpDescription.needsManualTDDLoad) { binding.message.visibility = View.VISIBLE binding.message.text = rh.gs(R.string.olddata_Message) - } else binding.mainTable.setBackgroundColor(Color.TRANSPARENT) + } else binding.mainTable.setBackgroundColor(rh.gac(this, R.attr.mainTableBackground)) if (historyList.isNotEmpty() && df1.format(Date(historyList[0].timestamp)) == df1.format(Date())) { //Today should not be included historyList.removeAt(0) @@ -390,7 +389,7 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { // Create the exponential table row binding.expweightTable.addView( TableRow(this@TDDStatsActivity).also { etr -> - if (i % 2 != 0) etr.setBackgroundColor(Color.DKGRAY) + if (i % 2 != 0) etr.setBackgroundColor(rh.gac(this, R.attr.tddHeaderBackground)) etr.id = 1100 + i etr.layoutParams = TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) @@ -398,7 +397,7 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { etr.addView(TextView(this@TDDStatsActivity).also { labelWEIGHT -> labelWEIGHT.id = 1200 + i labelWEIGHT.text = "0.3\n0.5\n0.7" - labelWEIGHT.setTextColor(Color.WHITE) + labelWEIGHT.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) etr.addView(TextView(this@TDDStatsActivity).also { labelEXPTDD -> labelEXPTDD.id = 1300 + i @@ -407,7 +406,7 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { ${rh.gs(R.string.formatinsulinunits, weighted05)} ${rh.gs(R.string.formatinsulinunits, weighted07)} """.trimIndent() - labelEXPTDD.setTextColor(Color.WHITE) + labelEXPTDD.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) etr.addView(TextView(this@TDDStatsActivity).also { labelEXPRATIO -> labelEXPRATIO.id = 1400 + i @@ -416,7 +415,7 @@ class TDDStatsActivity : NoSplashAppCompatActivity() { ${(100 * weighted05 / magicNumber).roundToInt()}% ${(100 * weighted07 / magicNumber).roundToInt()}% """.trimIndent() - labelEXPRATIO.setTextColor(Color.WHITE) + labelEXPRATIO.setTextColor(rh.gac(this, R.attr.defaultTextColor)) }) }, TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT, TableLayout.LayoutParams.WRAP_CONTENT) ) diff --git a/app/src/main/java/info/nightscout/androidaps/events/EventThemeSwitch.kt b/core/src/main/java/info/nightscout/androidaps/events/EventThemeSwitch.kt similarity index 96% rename from app/src/main/java/info/nightscout/androidaps/events/EventThemeSwitch.kt rename to core/src/main/java/info/nightscout/androidaps/events/EventThemeSwitch.kt index 37cbef5ae3..8876540f00 100644 --- a/app/src/main/java/info/nightscout/androidaps/events/EventThemeSwitch.kt +++ b/core/src/main/java/info/nightscout/androidaps/events/EventThemeSwitch.kt @@ -1,3 +1,3 @@ -package info.nightscout.androidaps.events - -class EventThemeSwitch : Event() +package info.nightscout.androidaps.events + +class EventThemeSwitch : Event() diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt index 74be8377e4..040a3d65cd 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/maintenance/activities/PrefImportListActivity.kt @@ -87,8 +87,8 @@ class PrefImportListActivity : DaggerAppCompatActivity() { prefFile.metadata[PrefsMetadataKey.AAPS_FLAVOUR]?.let { metaVariantFormat.text = it.value - val color = if (it.status == PrefsStatus.OK) R.color.metadataOk else R.color.metadataTextWarning - metaVariantFormat.setTextColor(rh.gc(color)) + val colorattr = if (it.status == PrefsStatus.OK) R.attr.metadataTextOkColor else R.attr.metadataTextWarningColor + metaVariantFormat.setTextColor(rh.gac( metaVariantFormat.context, colorattr)) } prefFile.metadata[PrefsMetadataKey.CREATED_AT]?.let { @@ -97,8 +97,8 @@ class PrefImportListActivity : DaggerAppCompatActivity() { prefFile.metadata[PrefsMetadataKey.AAPS_VERSION]?.let { metaAppVersion.text = it.value - val color = if (it.status == PrefsStatus.OK) R.color.metadataOk else R.color.metadataTextWarning - metaAppVersion.setTextColor(rh.gc(color)) + val colorattr = if (it.status == PrefsStatus.OK) R.attr.metadataTextOkColor else R.attr.metadataTextWarningColor + metaAppVersion.setTextColor(rh.gac( metaVariantFormat.context, colorattr)) } prefFile.metadata[PrefsMetadataKey.DEVICE_NAME]?.let { diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java index 4067810b2c..1a657c01c2 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java @@ -163,10 +163,8 @@ public class PointsWithLabelGraphSeries e double x = graphWidth * ratX; // overdraw - boolean overdraw = false; - if (x > graphWidth) { // end right - overdraw = true; - } + boolean overdraw = x > graphWidth; + // end right if (y < 0) { // end bottom overdraw = true; } diff --git a/core/src/main/java/info/nightscout/androidaps/utils/WarnColors.kt b/core/src/main/java/info/nightscout/androidaps/utils/WarnColors.kt index 0114d51601..477b092343 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/WarnColors.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/WarnColors.kt @@ -1,6 +1,5 @@ package info.nightscout.androidaps.utils -import android.graphics.Color import android.widget.TextView import info.nightscout.androidaps.core.R import info.nightscout.androidaps.database.entities.TherapyEvent @@ -12,28 +11,25 @@ import javax.inject.Singleton @Singleton class WarnColors @Inject constructor(val rh: ResourceHelper) { - private val normalColor = Color.WHITE - private val warnColor = Color.YELLOW - private val urgentColor = Color.RED fun setColor(view: TextView?, value: Double, warnLevel: Double, urgentLevel: Double) = - view?.setTextColor(when { - value >= urgentLevel -> urgentColor - value >= warnLevel -> warnColor - else -> normalColor - }) + view?.setTextColor( rh.gac( view.context ,when { + value >= urgentLevel -> R.attr.urgentColor + value >= warnLevel -> R.attr.warnColor + else -> R.attr.defaultTextColor + })) fun setColorInverse(view: TextView?, value: Double, warnLevel: Double, urgentLevel: Double) = - view?.setTextColor(when { - value <= urgentLevel -> urgentColor - value <= warnLevel -> warnColor - else -> normalColor - }) + view?.setTextColor( rh.gac( view.context , when { + value <= urgentLevel -> R.attr.urgentColor + value <= warnLevel -> R.attr.warnColor + else -> R.attr.defaultTextColor + })) fun setColorByAge(view: TextView?, therapyEvent: TherapyEvent, warnThreshold: Double, urgentThreshold: Double) = - view?.setTextColor(when { - therapyEvent.isOlderThan(urgentThreshold) -> rh.gc(R.color.low) - therapyEvent.isOlderThan(warnThreshold) -> rh.gc(R.color.high) - else -> Color.WHITE - }) + view?.setTextColor( rh.gac( view.context , when { + therapyEvent.isOlderThan(urgentThreshold) -> R.attr.lowColor + therapyEvent.isOlderThan(warnThreshold) -> R.attr.highColor + else -> R.attr.defaultTextColor + })) } \ No newline at end of file diff --git a/core/src/main/res/drawable-hdpi/background_total.xml b/core/src/main/res/drawable-hdpi/background_total.xml index 0a84006dee..e37fbd2035 100644 --- a/core/src/main/res/drawable-hdpi/background_total.xml +++ b/core/src/main/res/drawable-hdpi/background_total.xml @@ -3,6 +3,6 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> - + \ No newline at end of file diff --git a/core/src/main/res/drawable-hdpi/border_gray.xml b/core/src/main/res/drawable-hdpi/border_gray.xml index 7635f80234..a67f54bf90 100644 --- a/core/src/main/res/drawable-hdpi/border_gray.xml +++ b/core/src/main/res/drawable-hdpi/border_gray.xml @@ -3,7 +3,7 @@ - + diff --git a/core/src/main/res/drawable/ic_actions_startextbolus.xml b/core/src/main/res/drawable/ic_actions_startextbolus.xml index 35aa4cfb27..8d7f5bc3db 100644 --- a/core/src/main/res/drawable/ic_actions_startextbolus.xml +++ b/core/src/main/res/drawable/ic_actions_startextbolus.xml @@ -4,6 +4,7 @@ android:viewportHeight="24" android:viewportWidth="24" xmlns:android="http://schemas.android.com/apk/res/android"> - - + + diff --git a/core/src/main/res/drawable/ic_bolus.xml b/core/src/main/res/drawable/ic_bolus.xml index 6bbe19f3fc..83b67c9989 100644 --- a/core/src/main/res/drawable/ic_bolus.xml +++ b/core/src/main/res/drawable/ic_bolus.xml @@ -4,6 +4,6 @@ android:viewportWidth="24" android:viewportHeight="24"> diff --git a/core/src/main/res/drawable/ic_calculator.xml b/core/src/main/res/drawable/ic_calculator.xml index 300e971bf4..3bd3d2e78d 100644 --- a/core/src/main/res/drawable/ic_calculator.xml +++ b/core/src/main/res/drawable/ic_calculator.xml @@ -4,11 +4,12 @@ android:viewportHeight="24" android:viewportWidth="24" xmlns:android="http://schemas.android.com/apk/res/android"> - - - - - - - + + + + + + + diff --git a/core/src/main/res/drawable/ic_calibration.xml b/core/src/main/res/drawable/ic_calibration.xml index cf3f592a41..3a1b98bcd4 100644 --- a/core/src/main/res/drawable/ic_calibration.xml +++ b/core/src/main/res/drawable/ic_calibration.xml @@ -5,11 +5,11 @@ android:viewportHeight="24"> + android:fillColor="?attr/icCalibrationColor"/> + android:fillColor="?attr/icCalibrationColor"/> + android:fillColor="?attr/icCalibrationColor"/> diff --git a/core/src/main/res/drawable/ic_cp_announcement.xml b/core/src/main/res/drawable/ic_cp_announcement.xml index 3799ad551c..1488a6e33a 100644 --- a/core/src/main/res/drawable/ic_cp_announcement.xml +++ b/core/src/main/res/drawable/ic_cp_announcement.xml @@ -5,17 +5,17 @@ android:viewportHeight="24"> + android:fillColor="?attr/announcementColor"/> + android:fillColor="?attr/announcementColor"/> + android:fillColor="?attr/announcementColor"/> + android:fillColor="?attr/announcementColor"/> + android:fillColor="?attr/announcementColor"/> diff --git a/core/src/main/res/drawable/ic_cp_bgcheck.xml b/core/src/main/res/drawable/ic_cp_bgcheck.xml index 76a9bbe22f..9448450909 100644 --- a/core/src/main/res/drawable/ic_cp_bgcheck.xml +++ b/core/src/main/res/drawable/ic_cp_bgcheck.xml @@ -5,11 +5,11 @@ android:viewportHeight="24"> + android:fillColor="?attr/calibrationButtonColor"/> + android:fillColor="?attr/calibrationButtonColor"/> + android:fillColor="?attr/calibrationButtonColor"/> diff --git a/core/src/main/res/drawable/ic_cp_bolus_carbs.xml b/core/src/main/res/drawable/ic_cp_bolus_carbs.xml index e21b236b4e..dc22cbd2b5 100644 --- a/core/src/main/res/drawable/ic_cp_bolus_carbs.xml +++ b/core/src/main/res/drawable/ic_cp_bolus_carbs.xml @@ -4,5 +4,6 @@ android:viewportHeight="24" android:viewportWidth="24" xmlns:android="http://schemas.android.com/apk/res/android"> - + diff --git a/core/src/main/res/drawable/ic_cp_cgm_insert.xml b/core/src/main/res/drawable/ic_cp_cgm_insert.xml index 30107ac8fe..20e16e9b7d 100644 --- a/core/src/main/res/drawable/ic_cp_cgm_insert.xml +++ b/core/src/main/res/drawable/ic_cp_cgm_insert.xml @@ -5,8 +5,8 @@ android:viewportHeight="24"> + android:fillColor="?attr/cgmInsertColor"/> + android:fillColor="?attr/cgmInsertColor"/> diff --git a/core/src/main/res/drawable/ic_cp_exercise.xml b/core/src/main/res/drawable/ic_cp_exercise.xml index de04c4ecce..60b246221d 100644 --- a/core/src/main/res/drawable/ic_cp_exercise.xml +++ b/core/src/main/res/drawable/ic_cp_exercise.xml @@ -5,8 +5,8 @@ android:viewportHeight="24"> + android:fillColor="?attr/exerciseColor"/> + android:fillColor="?attr/exerciseColor"/> diff --git a/core/src/main/res/drawable/ic_cp_note.xml b/core/src/main/res/drawable/ic_cp_note.xml index 8308aabedf..9b0459d1bb 100644 --- a/core/src/main/res/drawable/ic_cp_note.xml +++ b/core/src/main/res/drawable/ic_cp_note.xml @@ -5,5 +5,5 @@ android:viewportHeight="24"> + android:fillColor="?attr/noteColor"/> diff --git a/core/src/main/res/drawable/ic_cp_pump_battery.xml b/core/src/main/res/drawable/ic_cp_pump_battery.xml index e83067fded..f83d3289c1 100644 --- a/core/src/main/res/drawable/ic_cp_pump_battery.xml +++ b/core/src/main/res/drawable/ic_cp_pump_battery.xml @@ -5,8 +5,8 @@ android:viewportHeight="24"> + android:fillColor="?attr/pumpBatteryColor"/> + android:fillColor="?attr/pumpBatteryColor"/> diff --git a/core/src/main/res/drawable/ic_cp_pump_canula.xml b/core/src/main/res/drawable/ic_cp_pump_canula.xml index b43de7ceaa..7e8bce4d17 100644 --- a/core/src/main/res/drawable/ic_cp_pump_canula.xml +++ b/core/src/main/res/drawable/ic_cp_pump_canula.xml @@ -5,5 +5,5 @@ android:viewportHeight="24"> + android:fillColor="?attr/pumpCanulaColor"/> diff --git a/core/src/main/res/drawable/ic_cp_question.xml b/core/src/main/res/drawable/ic_cp_question.xml index fc6d14c656..11e4f2cff6 100644 --- a/core/src/main/res/drawable/ic_cp_question.xml +++ b/core/src/main/res/drawable/ic_cp_question.xml @@ -5,8 +5,8 @@ android:viewportHeight="24"> + android:fillColor="?attr/questionColor"/> + android:fillColor="?attr/questionColor"/> diff --git a/core/src/main/res/drawable/ic_fortyfiveup.xml b/core/src/main/res/drawable/ic_fortyfiveup.xml index 930857ec66..cb3fa33a08 100644 --- a/core/src/main/res/drawable/ic_fortyfiveup.xml +++ b/core/src/main/res/drawable/ic_fortyfiveup.xml @@ -5,5 +5,5 @@ android:viewportHeight="24"> + android:fillColor="?attr/icCheckboxTrendColor"/> diff --git a/core/src/main/res/drawable/ic_loop_closed.xml b/core/src/main/res/drawable/ic_loop_closed.xml index 9bddec63b6..110a3537ee 100644 --- a/core/src/main/res/drawable/ic_loop_closed.xml +++ b/core/src/main/res/drawable/ic_loop_closed.xml @@ -5,5 +5,5 @@ android:viewportHeight="24"> + android:fillColor="?attr/loopClosed"/> diff --git a/core/src/main/res/drawable/ic_pump_history.xml b/core/src/main/res/drawable/ic_pump_history.xml index d4ef6ac5f0..fbd047a23a 100644 --- a/core/src/main/res/drawable/ic_pump_history.xml +++ b/core/src/main/res/drawable/ic_pump_history.xml @@ -5,8 +5,8 @@ android:viewportHeight="24"> + android:fillColor="?attr/pumpHistoryColor"/> + android:fillColor="?attr/pumpHistoryColor"/> diff --git a/core/src/main/res/drawable/ic_quick_wizard.xml b/core/src/main/res/drawable/ic_quick_wizard.xml index b2d1f2569b..8e5d42cd3e 100644 --- a/core/src/main/res/drawable/ic_quick_wizard.xml +++ b/core/src/main/res/drawable/ic_quick_wizard.xml @@ -4,9 +4,10 @@ android:viewportHeight="24" android:viewportWidth="24" xmlns:android="http://schemas.android.com/apk/res/android"> - - - - - + + + + + diff --git a/core/src/main/res/drawable/ic_temptarget_high.xml b/core/src/main/res/drawable/ic_temptarget_high.xml index 9fbfe2eb08..ae0e9799ca 100644 --- a/core/src/main/res/drawable/ic_temptarget_high.xml +++ b/core/src/main/res/drawable/ic_temptarget_high.xml @@ -5,8 +5,8 @@ android:viewportHeight="24"> + android:fillColor="?attr/bgInRange"/> + android:fillColor="?attr/tempTargetConfirmation"/> diff --git a/core/src/main/res/layout/activity_tdd_stats.xml b/core/src/main/res/layout/activity_tdd_stats.xml index 5f1d7dad33..850d7e0e3a 100644 --- a/core/src/main/res/layout/activity_tdd_stats.xml +++ b/core/src/main/res/layout/activity_tdd_stats.xml @@ -179,7 +179,7 @@ %1$.0f%% Bazál Bazál % + Vybráno: %1$d + Seřadit + Odebrat položky + Seřadit položky + Odebrat vybrané položky %1$d den %1$d dnů diff --git a/core/src/main/res/values-es-rES/strings.xml b/core/src/main/res/values-es-rES/strings.xml index 484f00440b..bee8dee661 100644 --- a/core/src/main/res/values-es-rES/strings.xml +++ b/core/src/main/res/values-es-rES/strings.xml @@ -460,6 +460,11 @@ %1$.0f%% Basal Basal % + %1$d seleccionados + Ordenar + Eliminar elementos + Ordenar elementos + Eliminar los elementos seleccionados %1$d día %1$d días diff --git a/core/src/main/res/values-night/colors.xml b/core/src/main/res/values-night/colors.xml index f667f08368..ba771afa38 100644 --- a/core/src/main/res/values-night/colors.xml +++ b/core/src/main/res/values-night/colors.xml @@ -9,7 +9,6 @@ #808080 #d8d8d8 #212121 - #66000000 #BBBBBB #FF000000 #FFFFFFFF @@ -172,6 +171,7 @@ #77dd77 #66FC0000 @color/colorPrimaryDark + #7DFF0000 #77dd77 #67DFE8 @@ -204,17 +204,83 @@ #000000 + #FEAF05 + #CF8BFE + #67dfe8 + #67dfe8 + #36FF00 + #FEAF05 + #CF8BFE + #FEAF05 + #67DFE8 + #323232 #424242 #3C3C3C #666666 + #999999 #8c8c8c #72000000 #c8666666 - #B2B2B2 + #B2B2B2 #4dB1B1B1 #33969696 #EBEBEA + + #FFFF00 + #00FFFF + #00FF00 + + + #9E9E9E + + + #0099CC + #ff669900 + #77DD77 + + + #FF4444 + @color/pod_icon_outline + #4CAF50 + @color/pod_icon_outline + @color/pod_icon_outline + #42A5F5 + @color/pod_icon_outline + #67E86A + @color/pod_icon_outline + #B39DDB + @color/pod_icon_outline + #ffbf00 + @color/pod_icon_outline + + + #67E86A + @color/pod_icon_outline + #FF4444 + @color/pod_icon_outline + #85F803 + @color/pod_icon_outline + #ffbf00 + @color/pod_icon_outline + #4DD0E1 + @color/pod_icon_outline + #FB8C00 + @color/pod_icon_outline + + + #b9d2d2 + #66BB6A + #FF7043 + + + @color/rl_board_shape + @color/rl_icon_outline + + + @color/rl_board_shape + @color/rl_icon_outline + diff --git a/core/src/main/res/values-night/styles.xml b/core/src/main/res/values-night/styles.xml index 65d6daa4fc..b55dc56cb4 100644 --- a/core/src/main/res/values-night/styles.xml +++ b/core/src/main/res/values-night/styles.xml @@ -29,7 +29,6 @@ @color/notificationLow @color/notificationInfo @color/notificationAnnouncement - @drawable/ic_close @color/bolus @@ -47,14 +46,10 @@ @color/colorSetTempButton @color/cardColorBackground - - @color/carbs @color/exercise @color/low - - @color/tempTargetConfirmation @color/colorSetExtendedButton @color/colorActive @@ -121,11 +116,11 @@ @color/white_alpha_20 @color/tempTargetBackground - @color/colorLightGray + @color/byodagray @color/colorCalibrationButton @color/low - @color/high + @color/high @color/inrange @color/helperProfile @@ -142,6 +137,72 @@ @color/info @color/cobAlert + + @color/actionsConfirm + + @color/prediction + @color/omni_yellow + @color/omni_cyan + @color/omni_green + @color/midgray + @color/omnipod_wizard_finish_button + + @color/omni_yellow + @color/alarm + + @color/mdtp_line_dark + @color/ribbonDefault + @color/errorAlertBackground + @color/black + @color/black_alpha_40 + + @color/errorAlertBackground + + @android:color/darker_gray + @android:color/transparent + @color/dummy_background + + @color/white + + @color/colorInsulinButton + @color/colorCarbsButton + @color/colorCalculatorButton + @color/colorQuickWizardButton + @color/colorCalibrationButton + @color/colorTreatmentButton + + @color/iob + + @color/basal + + @color/carbs + + @color/tempTargetConfirmation + + + @color/loopSuspended + + @color/loopClosed + + @color/loopDisabled + + @color/loopDisconnected + + @color/loopOpened + + @color/carbs + + @color/extendedBolus + @color/extBolusStop + @color/actionBasal + @color/actionBasal + @color/pumpCanula + @color/cgmInsert + @color/pumpBattery + @color/note + @color/announcement + @color/question + @color/pumpHistory