remove :core:main dependency

This commit is contained in:
Milos Kozak 2022-11-28 17:09:07 +01:00
parent 146e2a8559
commit 1a135087fc
21 changed files with 122 additions and 115 deletions

View file

@ -20,24 +20,24 @@ import info.nightscout.androidaps.receivers.BTReceiver
import info.nightscout.androidaps.receivers.ChargingStateReceiver
import info.nightscout.androidaps.receivers.KeepAliveWorker
import info.nightscout.androidaps.receivers.TimeDateOrTZChangeReceiver
import info.nightscout.core.services.AlarmSoundServiceHelper
import info.nightscout.implementation.lifecycle.ProcessLifecycleListener
import info.nightscout.core.ui.locale.LocaleHelper
import info.nightscout.implementation.receivers.NetworkChangeReceiver
import info.nightscout.interfaces.versionChecker.VersionCheckerUtils
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.InsertIfNewByTimestampTherapyEventTransaction
import info.nightscout.database.impl.transactions.VersionChangeTransaction
import info.nightscout.implementation.db.CompatDBHelper
import info.nightscout.implementation.lifecycle.ProcessLifecycleListener
import info.nightscout.implementation.plugin.PluginStore
import info.nightscout.implementation.receivers.NetworkChangeReceiver
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.ConfigBuilder
import info.nightscout.interfaces.LocalAlertUtils
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.interfaces.versionChecker.VersionCheckerUtils
import info.nightscout.plugins.general.overview.notifications.NotificationStore
import info.nightscout.plugins.general.themes.ThemeSwitcherPlugin
import info.nightscout.rx.logging.AAPSLogger
@ -74,7 +74,7 @@ class MainApp : DaggerApplication() {
@Inject lateinit var dateUtil: DateUtil
@Suppress("unused") @Inject lateinit var staticInjector: info.nightscout.plugins.aps.utils.StaticInjector// TODO avoid , here fake only to initialize
@Inject lateinit var uel: UserEntryLogger
@Inject lateinit var alarmSoundServiceHelper: AlarmSoundServiceHelper
@Inject lateinit var activityNames: ActivityNames
@Inject lateinit var notificationStore: NotificationStore
@Inject lateinit var processLifecycleListener: Provider<ProcessLifecycleListener>
@Inject lateinit var profileSwitchPlugin: ThemeSwitcherPlugin
@ -247,7 +247,7 @@ class MainApp : DaggerApplication() {
override fun onTerminate() {
aapsLogger.debug(LTag.CORE, "onTerminate")
unregisterActivityLifecycleCallbacks(activityMonitor)
alarmSoundServiceHelper.stopService(this, "onTerminate")
activityNames.stopAlarm("onTerminate")
super.onTerminate()
}
}

View file

@ -12,9 +12,10 @@ import info.nightscout.androidaps.R
import info.nightscout.androidaps.activities.HistoryBrowseActivity
import info.nightscout.androidaps.activities.MyPreferenceFragment
import info.nightscout.androidaps.activities.PreferencesActivity
import info.nightscout.core.services.AlarmSoundService
import info.nightscout.configuration.activities.SingleFragmentActivity
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.services.AlarmSoundService
import info.nightscout.core.services.AlarmSoundServiceHelper
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.nsclient.NSAlarm
@ -41,7 +42,9 @@ import info.nightscout.ui.dialogs.WizardDialog
import javax.inject.Inject
class ActivityNamesImpl @Inject constructor(
private val rxBus: RxBus
private val rxBus: RxBus,
private val injector: HasAndroidInjector,
private val alarmSoundServiceHelper: AlarmSoundServiceHelper
) : ActivityNames {
override val mainActivity: Class<*> = MainActivity::class.java
@ -177,9 +180,30 @@ class ActivityNamesImpl @Inject constructor(
rxBus.send(EventNewNotification(NotificationWithAction(injector, nsAlarm)))
}
override fun addNotificationWithAction(id: Int, text: String, level: Int, buttonText: Int, action: Runnable, @RawRes soundId: Int?, date: Long) {
rxBus.send(
EventNewNotification(
NotificationWithAction(injector, id, text, level)
.action(buttonText, action)
.also {
it.date = date
it.soundId = soundId
}
)
)
}
override fun showToastAndNotification(ctx: Context?, string: String?, soundID: Int) {
ToastUtils.showToastInUiThread(ctx, string)
ToastUtils.playSound(ctx, soundID)
addNotification(Notification.TOAST_ALARM, string!!, Notification.URGENT)
}
override fun startAlarm(@RawRes sound: Int, reason: String) {
alarmSoundServiceHelper.startAlarm(sound, reason)
}
override fun stopAlarm(reason: String) {
alarmSoundServiceHelper.stopAlarm(reason)
}
}

View file

@ -5,12 +5,14 @@ import android.content.Context
import android.content.Intent
import android.content.ServiceConnection
import android.os.IBinder
import androidx.annotation.RawRes
import info.nightscout.interfaces.NotificationHolder
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import javax.inject.Inject
import javax.inject.Singleton
import dagger.Lazy
/*
This code replaces following
@ -25,10 +27,11 @@ import javax.inject.Singleton
@Singleton
class AlarmSoundServiceHelper @Inject constructor(
private val aapsLogger: AAPSLogger,
private val notificationHolder: NotificationHolder
private val notificationHolder: Lazy<NotificationHolder>,
private val context: Context
) {
fun startAlarm(context: Context, sound: Int, reason: String) {
fun startAlarm(@RawRes sound: Int, reason: String) {
aapsLogger.debug(LTag.CORE, "Starting alarm from $reason")
val connection = object : ServiceConnection {
override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
@ -41,7 +44,7 @@ class AlarmSoundServiceHelper @Inject constructor(
// This is the key: Without waiting Android Framework to call this method
// inside Service.onCreate(), immediately call here to post the notification.
alarmSoundService.startForeground(notificationHolder.notificationID, notificationHolder.notification)
alarmSoundService.startForeground(notificationHolder.get().notificationID, notificationHolder.get().notification)
// Release the connection to prevent leaks.
context.unbindService(this)
@ -62,13 +65,13 @@ class AlarmSoundServiceHelper @Inject constructor(
}
}
fun stopService(context: Context, reason: String) {
fun stopAlarm(reason: String) {
aapsLogger.debug(LTag.CORE, "Stopping alarm from $reason")
val alarm = Intent(context, AlarmSoundService::class.java)
context.stopService(alarm)
}
private fun getServiceIntent(context: Context, sound: Int): Intent {
private fun getServiceIntent(context: Context, @RawRes sound: Int): Intent {
val alarm = Intent(context, AlarmSoundService::class.java)
alarm.putExtra(AlarmSoundService.SOUND_ID, sound)
return alarm

View file

@ -10,7 +10,6 @@
<string name="format_mins">%1$d mins</string>
<string name="objectives">Objectives</string>
<string name="please_wait">Please wait…</string>
<string name="mute">Mute</string>
<string name="stop">Stop</string>
<string name="carbs">Carbs</string>
<string name="invalid_profile">Invalid profile!</string>
@ -202,7 +201,6 @@
<!-- PumpEnactResult-->
<string name="enacted">Enacted</string>
<string name="comment">Comment</string>
<string name="success">Success</string>
<string name="percent">Percent</string>
<string name="absolute">Absolute</string>
<string name="waitingforpumpresult">Waiting for result</string>
@ -228,8 +226,6 @@
<!-- Ntp-->
<string name="timedetection">Time detection</string>
<string name="mute5min">Mute for 5 minutes</string>
<!-- User Entry -->
<string name="uel_bolus">BOLUS</string>
<string name="uel_bolus_calculator">BOLUS CALCULATOR</string>

View file

@ -67,5 +67,9 @@ interface ActivityNames {
fun addNotificationWithSound(id: Int, text: String, level: Int, @RawRes soundId: Int)
fun addNotificationValidTo(id: Int, date: Long, text: String, level: Int, validTo: Long)
fun addNotificationWithAction(injector: HasAndroidInjector, nsAlarm: NSAlarm)
fun addNotificationWithAction(id: Int, text: String, level: Int, buttonText: Int, action: Runnable, @RawRes soundId: Int? = null, date: Long = System.currentTimeMillis())
fun showToastAndNotification(ctx: Context?, string: String?, @RawRes soundID: Int)
fun startAlarm(@RawRes sound: Int, reason: String)
fun stopAlarm(reason: String)
}

View file

@ -42,7 +42,9 @@
<string name="pump">Pump</string>
<string name="missed_bg_readings">Missed BG readings</string>
<string name="treatments_iob_label_string">IOB:</string>
<string name="mute5min">Mute for 5 minutes</string>
<string name="mute">Mute</string>
<string name="success">Success</string>
<!-- Protection-->
<string name="unlock_settings">Unlock settings</string>

View file

@ -320,7 +320,7 @@ public class InsightAlertService extends DaggerService implements InsightConnect
case ACTIVE:
Intent muteIntent = new Intent(this, InsightAlertService.class).putExtra("command", "mute");
PendingIntent mutePendingIntent = PendingIntent.getService(this, 1, muteIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
notificationBuilder.addAction(0, rh.gs(R.string.mute_alert), mutePendingIntent);
notificationBuilder.addAction(0, rh.gs(R.string.mute), mutePendingIntent);
case SNOOZED:
Intent confirmIntent = new Intent(this, InsightAlertService.class).putExtra("command", "confirm");
PendingIntent confirmPendingIntent = PendingIntent.getService(this, 2, confirmIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);

View file

@ -61,7 +61,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="muteClicked"
android:text="@string/mute_alert" />
android:text="@string/mute" />
<com.google.android.material.button.MaterialButton
android:id="@+id/confirm"

View file

@ -58,7 +58,6 @@
<string name="short_status_tdd">TDD: %1$.2f</string>
<string name="short_status_reservoir">Reser.: %1$.2f U</string>
<string name="short_status_battery">Batt.: %1$d%%</string>
<string name="mute_alert">Mute</string>
<string name="release_software_version">Release software version</string>
<string name="ui_processor_software_version">UI processor software version</string>
<string name="pc_processor_software_version">PC processor software version</string>

View file

@ -12,10 +12,10 @@ import android.view.View
import android.view.ViewGroup
import androidx.core.app.NotificationCompat
import androidx.recyclerview.widget.RecyclerView
import info.nightscout.core.services.AlarmSoundServiceHelper
import info.nightscout.interfaces.NotificationHolder
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.interfaces.ui.IconsProvider
import info.nightscout.plugins.R
import info.nightscout.plugins.databinding.OverviewNotificationItemBinding
@ -36,7 +36,7 @@ class NotificationStore @Inject constructor(
private val rh: ResourceHelper,
private val context: Context,
private val iconsProvider: IconsProvider,
private val alarmSoundServiceHelper: AlarmSoundServiceHelper,
private val activityNames: ActivityNames,
private val dateUtil: DateUtil,
private val notificationHolder: NotificationHolder,
private val activePlugin: ActivePlugin
@ -69,7 +69,7 @@ class NotificationStore @Inject constructor(
store.add(n)
if (sp.getBoolean(R.string.key_raise_notifications_as_android_notifications, true) && n !is NotificationWithAction)
raiseSystemNotification(n)
if (n.soundId != null && n.soundId != 0) alarmSoundServiceHelper.startAlarm(context, n.soundId!!, n.text)
if (n.soundId != null && n.soundId != 0) activityNames.startAlarm(n.soundId!!, n.text)
Collections.sort(store, NotificationComparator())
return true
}
@ -78,7 +78,7 @@ class NotificationStore @Inject constructor(
fun remove(id: Int): Boolean {
for (i in store.indices) {
if (store[i].id == id) {
if (store[i].soundId != null) alarmSoundServiceHelper.stopService(context, "Removed " + store[i].text)
if (store[i].soundId != null) activityNames.stopAlarm("Removed " + store[i].text)
aapsLogger.debug(LTag.NOTIFICATION, "Notification removed: " + store[i].text)
store.removeAt(i)
return true
@ -93,7 +93,7 @@ class NotificationStore @Inject constructor(
while (i < store.size) {
val n = store[i]
if (n.validTo != 0L && n.validTo < System.currentTimeMillis()) {
if (store[i].soundId != null) alarmSoundServiceHelper.stopService(context, "Expired " + store[i].text)
if (store[i].soundId != null) activityNames.stopAlarm("Expired " + store[i].text)
aapsLogger.debug(LTag.NOTIFICATION, "Notification expired: " + store[i].text)
store.removeAt(i)
i--

View file

@ -70,9 +70,10 @@ class NotificationWithAction constructor(
}
}
fun action(buttonText: Int, action: Runnable) {
fun action(buttonText: Int, action: Runnable): NotificationWithAction {
this.buttonText = buttonText
this.action = action
return this
}
}

View file

@ -7,14 +7,12 @@ import info.nightscout.core.extensions.convertedToAbsolute
import info.nightscout.core.extensions.toStringShort
import info.nightscout.core.extensions.valueToUnits
import info.nightscout.core.extensions.valueToUnitsString
import info.nightscout.core.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.core.services.AlarmSoundServiceHelper
import info.nightscout.core.graph.data.GlucoseValueDataPoint
import info.nightscout.core.iob.generateCOBString
import info.nightscout.core.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.core.iob.round
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.core.wizard.BolusWizard
import info.nightscout.core.wizard.QuickWizard
import info.nightscout.core.wizard.QuickWizardEntry
@ -38,6 +36,7 @@ import info.nightscout.interfaces.constraints.Constraint
import info.nightscout.interfaces.constraints.Constraints
import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.plugin.PluginBase
import info.nightscout.interfaces.profile.DefaultValueHelper
@ -46,11 +45,12 @@ import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.pump.DetailedBolusInfo
import info.nightscout.interfaces.queue.Callback
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.interfaces.utils.HardLimits
import info.nightscout.interfaces.utils.TrendCalculator
import info.nightscout.plugins.R
import info.nightscout.interfaces.nsclient.ProcessedDeviceStatusData
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventMobileToWear
@ -101,7 +101,7 @@ class DataHandlerMobile @Inject constructor(
private val activePlugin: ActivePlugin,
private val commandQueue: CommandQueue,
private val fabricPrivacy: FabricPrivacy,
private val alarmSoundServiceHelper: AlarmSoundServiceHelper
private val activityNames: ActivityNames
) {
private val disposable = CompositeDisposable()
@ -293,7 +293,7 @@ class DataHandlerMobile @Inject constructor(
.observeOn(aapsSchedulers.io)
.subscribe({
aapsLogger.debug(LTag.WEAR, "SnoozeAlert received $it from ${it.sourceNodeId}")
alarmSoundServiceHelper.stopService(context, "Muted from wear")
activityNames.stopAlarm("Muted from wear")
}, fabricPrivacy::logException)
disposable += rxBus
.toObservable(EventData.WearException::class.java)

View file

@ -25,11 +25,12 @@ dependencies {
implementation project(':app-wear-shared:shared')
implementation project(':database:entities')
implementation project(':database:impl')
implementation project(':core:core-main')
implementation project(':core:interfaces')
implementation project(':core:utils')
implementation project(':core:ui')
api 'com.google.guava:guava:31.1-jre'
//RxAndroidBle
implementation "com.polidea.rxandroidble3:rxandroidble:1.17.2"
implementation "com.jakewharton.rx3:replaying-share:3.0.0"

View file

@ -1,23 +0,0 @@
package info.nightscout.androidaps.plugins.pump.eopatch
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.rx.logging.AAPSLogger
import javax.inject.Inject
class EONotification constructor() : Notification() {
@Inject lateinit var aapsLogger: AAPSLogger
constructor(id: Int, text: String, level: Int) : this() {
this.id = id
date = System.currentTimeMillis()
this.text = text
this.level = level
}
fun action(buttonText: Int, action: Runnable) {
this.buttonText = buttonText
this.action = action
}
}

View file

@ -9,7 +9,6 @@ import info.nightscout.androidaps.plugins.pump.eopatch.code.BolusExDuration
import info.nightscout.androidaps.plugins.pump.eopatch.code.SettingKeys
import info.nightscout.androidaps.plugins.pump.eopatch.ui.EopatchOverviewFragment
import info.nightscout.androidaps.plugins.pump.eopatch.vo.TempBasal
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.PluginDescription
@ -27,6 +26,7 @@ import info.nightscout.interfaces.pump.defs.PumpDescription
import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.queue.CustomCommand
import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.interfaces.utils.TimeChangeType
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
@ -60,7 +60,8 @@ class EopatchPumpPlugin @Inject constructor(
private val pumpSync: PumpSync,
private val patchManager: IPatchManager,
private val alarmManager: IAlarmManager,
private val preferenceManager: IPreferenceManager
private val preferenceManager: IPreferenceManager,
private val activityNames: ActivityNames
) : PumpPluginBase(
PluginDescription()
.mainType(PluginType.PUMP)
@ -203,7 +204,7 @@ class EopatchPumpPlugin @Inject constructor(
disposable.dispose()
aapsLogger.info(LTag.PUMP, "Basal Profile was set: ${isSuccess ?: false}")
if (isSuccess == true) {
rxBus.send(EventNewNotification(Notification(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60)))
activityNames.addNotificationValidFor(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60)
return PumpEnactResult(injector).success(true).enacted(true)
} else {
return PumpEnactResult(injector)
@ -212,7 +213,7 @@ class EopatchPumpPlugin @Inject constructor(
} else {
preferenceManager.getNormalBasalManager().setNormalBasal(profile)
preferenceManager.flushNormalBasalManager()
rxBus.send(EventNewNotification(Notification(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60)))
activityNames.addNotificationValidFor(Notification.PROFILE_SET_OK, rh.gs(R.string.profile_set_ok), Notification.INFO, 60)
return PumpEnactResult(injector).success(true).enacted(true)
}
}

View file

@ -2,7 +2,6 @@ package info.nightscout.androidaps.plugins.pump.eopatch.alarm
import android.content.Context
import android.content.Intent
import info.nightscout.androidaps.plugins.pump.eopatch.EONotification
import info.nightscout.androidaps.plugins.pump.eopatch.EoPatchRxBus
import info.nightscout.androidaps.plugins.pump.eopatch.R
import info.nightscout.androidaps.plugins.pump.eopatch.alarm.AlarmCode.A005
@ -17,13 +16,13 @@ import info.nightscout.androidaps.plugins.pump.eopatch.code.AlarmCategory
import info.nightscout.androidaps.plugins.pump.eopatch.event.EventEoPatchAlarm
import info.nightscout.androidaps.plugins.pump.eopatch.ui.AlarmHelperActivity
import info.nightscout.androidaps.plugins.pump.eopatch.vo.Alarms
import info.nightscout.core.events.EventNewNotification
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.interfaces.notifications.Notification
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.interfaces.pump.PumpSync
import info.nightscout.interfaces.pump.defs.PumpType
import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger
@ -59,7 +58,7 @@ class AlarmManager @Inject constructor() : IAlarmManager {
@Inject lateinit var sp: SP
@Inject lateinit var context: Context
@Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var activityNames: ActivityNames
@Inject lateinit var pm: IPreferenceManager
@Inject lateinit var mAlarmRegistry: IAlarmRegistry
@ -157,9 +156,12 @@ class AlarmManager @Inject constructor() : IAlarmManager {
val expireTimeString = SimpleDateFormat(resourceHelper.gs(R.string.date_format_yyyy_m_d_e_a_hh_mm_comma), Locale.US).format(expireTimeValue)
alarmMsg = resourceHelper.gs(alarmCode.resId, expireTimeString)
}
val notification = EONotification(Notification.EOELOW_PATCH_ALERTS + (alarmCode.aeCode + 10000), alarmMsg, Notification.URGENT)
notification.action(R.string.confirm) {
activityNames.addNotificationWithAction(
id = Notification.EOELOW_PATCH_ALERTS + (alarmCode.aeCode + 10000),
text = alarmMsg,
level = Notification.URGENT,
buttonText = R.string.confirm,
action = {
compositeDisposable.add(
Single.just(isValid(alarmCode))
.flatMap { isValid ->
@ -178,13 +180,19 @@ class AlarmManager @Inject constructor() : IAlarmManager {
}
updateState(alarmCode, AlarmState.HANDLE)
} else {
rxBus.send(EventNewNotification(notification))
activityNames.addNotification(
id = Notification.EOELOW_PATCH_ALERTS + (alarmCode.aeCode + 10000),
text = alarmMsg,
level = Notification.URGENT
)
}
})
}
notification.soundId = R.raw.error
notification.date = pm.getPatchConfig().patchWakeupTimestamp + TimeUnit.SECONDS.toMillis(timeOffset)
rxBus.send(EventNewNotification(notification))
)
},
soundId = R.raw.error,
date = pm.getPatchConfig().patchWakeupTimestamp + TimeUnit.SECONDS.toMillis(timeOffset)
)
}
private fun updateState(alarmCode: AlarmCode, state: AlarmState){

View file

@ -1,6 +1,5 @@
package info.nightscout.androidaps.plugins.pump.eopatch.ui.dialogs
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.HandlerThread
@ -17,8 +16,8 @@ import info.nightscout.androidaps.plugins.pump.eopatch.bindingadapters.setOnSafe
import info.nightscout.androidaps.plugins.pump.eopatch.ble.IPatchManager
import info.nightscout.androidaps.plugins.pump.eopatch.databinding.DialogAlarmBinding
import info.nightscout.androidaps.plugins.pump.eopatch.ui.AlarmHelperActivity
import info.nightscout.core.services.AlarmSoundServiceHelper
import info.nightscout.core.ui.R
import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger
@ -28,7 +27,7 @@ import javax.inject.Inject
class AlarmDialog : DaggerDialogFragment() {
@Inject lateinit var alarmSoundServiceHelper: AlarmSoundServiceHelper
@Inject lateinit var activityNames: ActivityNames
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var patchManager: IPatchManager
@Inject lateinit var rxBus: RxBus
@ -159,16 +158,10 @@ class AlarmDialog : DaggerDialogFragment() {
}
private fun startAlarm(reason: String) {
if (sound != 0) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context?.let { context -> alarmSoundServiceHelper.startAlarm(context, sound, reason) }
}
}
if (sound != 0) activityNames.startAlarm(sound, reason)
}
private fun stopAlarm(reason: String) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context?.let { context -> alarmSoundServiceHelper.stopService(context, reason) }
}
activityNames.stopAlarm(reason)
}
}

View file

@ -21,9 +21,9 @@ dependencies {
implementation project(':core:core-main')
implementation project(':core:interfaces')
implementation project(':core:ui')
implementation project(':core:utils')
implementation project(':pump:pump-common')
implementation project(':pump:pump-core')
implementation project(':pump:rileylink')
implementation project(path: ':core:utils')
testImplementation project(path: ':database:impl')
testImplementation project(':database:impl')
}

View file

@ -18,8 +18,8 @@ android {
dependencies {
implementation project(':core:libraries')
implementation project(':core:core-main')
implementation project(':core:interfaces')
implementation project(':core:ui')
implementation project(':core:utils')
implementation project(':app-wear-shared:shared')

View file

@ -1,6 +1,5 @@
package info.nightscout.ui.alertDialogs
import android.content.Context
import android.content.res.Resources
import android.os.Bundle
import android.os.Handler
@ -11,12 +10,12 @@ import android.view.ViewGroup
import android.view.Window
import android.view.WindowManager
import dagger.android.support.DaggerDialogFragment
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.core.services.AlarmSoundServiceHelper
import info.nightscout.core.ui.activities.DialogAppCompatActivity
import info.nightscout.core.main.R
import info.nightscout.core.ui.activities.DialogAppCompatActivity
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources
import info.nightscout.interfaces.logging.UserEntryLogger
import info.nightscout.interfaces.ui.ActivityNames
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.utils.T
import info.nightscout.ui.databinding.DialogErrorBinding
@ -24,10 +23,9 @@ import javax.inject.Inject
class ErrorDialog : DaggerDialogFragment() {
@Inject lateinit var alarmSoundServiceHelper: AlarmSoundServiceHelper
@Inject lateinit var activityNames: ActivityNames
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var uel: UserEntryLogger
@Inject lateinit var ctx: Context
var helperActivity: DialogAppCompatActivity? = null
var status: String = ""
@ -115,9 +113,9 @@ class ErrorDialog : DaggerDialogFragment() {
private fun startAlarm() {
if (sound != 0)
alarmSoundServiceHelper.startAlarm(ctx, sound, "$title:$status")
activityNames.startAlarm(sound, "$title:$status")
}
private fun stopAlarm(reason: String) =
alarmSoundServiceHelper.stopService(ctx, reason)
activityNames.stopAlarm(reason)
}