fix #205 : Watch and notification : option to specify minimum time interval between two events or two notifications.

This is not completely as requested in the issue https://github.com/JohanDegraeve/xdripswift/issues/205

It does allow watch/Libre 2 users to have a new reading every minute.
It also allows all users to have specify the minimum time between to calendar events on the watch, or to have a notification with a reading.

For the notification : an overrule of the interval is done if there's been a dis/reconnect, which means if there was a disconnect/reconnect, the next reading will generate a notification, no matter the value of the interval.

Default value for the interval = 0
This commit is contained in:
Johan Degraeve 2021-03-29 23:11:32 +02:00
parent 54f8da3a00
commit 9a91de757b
24 changed files with 133 additions and 69 deletions

View File

@ -54,7 +54,4 @@ enum ConstantsNotifications {
/// notification identifier for xDripErrors received in RootViewController's cgmTransmitterDelegate
static let notificationIdentifierForxCGMTransmitterDelegatexDripError = "notificationIdentifierForxCGMTransmitterDelegatexDripError"
/// if the time between the last and last but one reading is less than minimiumTimeBetweenTwoReadingsInMinutes, then there will bd no notification created - except if there's been a disconnect in between these two readings
static let minimiumTimeBetweenTwoReadingsInMinutes = 4.75
}

View File

@ -3,6 +3,8 @@ import Foundation
enum ConstantsSpeakReading {
/// if the time between the last and last but one reading is less than minimiumTimeBetweenTwoReadingsInMinutes, then the reading will not be spoken - except if there's been a disconnect in between these two readings
///
/// UserDefaults.standard.speakInterval overrules this value
static let minimiumTimeBetweenTwoReadingsInMinutes = 4.75
}

View File

@ -5,7 +5,4 @@ enum ConstantsWatch {
/// text to add as notes in glucose events
static let textInCreatedEvent = "created by xdrip"
/// if the time between the last and last but one reading is less than minimiumTimeBetweenTwoReadingsInMinutes, then no new event will be created - except if there's been a disconnect in between these two readings
static let minimiumTimeBetweenTwoReadingsInMinutes = 4.75
}

View File

@ -32,6 +32,9 @@ extension UserDefaults {
/// should reading by multiplied by 10
case multipleAppBadgeValueWith10 = "multipleAppBadgeValueWith10"
/// minimum time between two notifications, set by user
case notificationInterval = "notificationInterval"
// Home Screen and graph settings
/// show the objectives and make them display on the graph? Or just hide it all because it's too complicated to waste time with?
@ -162,6 +165,9 @@ extension UserDefaults {
/// should units be displayed yes or no
case displayUnitInCalendarEvent = "displayUnits"
/// calendar interval
case calendarInterval = "calendarInterval"
// Other Settings (not user configurable)
/// - in case missed reading alert settings are changed by user, this value will be set to true
@ -302,6 +308,16 @@ extension UserDefaults {
set(!newValue, forKey: Key.showReadingInNotification.rawValue)
}
}
/// speak readings interval in minutes
@objc dynamic var notificationInterval: Int {
get {
return integer(forKey: Key.notificationInterval.rawValue)
}
set {
set(newValue, forKey: Key.notificationInterval.rawValue)
}
}
/// should reading be shown in app badge yes or no
@objc dynamic var showReadingInAppBadge: Bool {
@ -1009,6 +1025,18 @@ extension UserDefaults {
}
}
/// speak readings interval in minutes
@objc dynamic var calendarInterval: Int {
get {
return integer(forKey: Key.calendarInterval.rawValue)
}
set {
set(newValue, forKey: Key.calendarInterval.rawValue)
}
}
// MARK: - ===== Other Settings ======
/// - in case missed reading alert settings are changed by user, this value will be set to true

View File

@ -59,6 +59,17 @@ class WatchManager: NSObject {
return
}
// if an interval is defined, and if time since last created event is less than interval, then don't create a new event
// substract 10 seconds, because user will probably select a multiple of 5, and also readings usually arrive every 5 minutes
// example user selects 10 minutes interval, next reading will arrive in exactly 10 minutes, time interval to be checked will be 590 seconds
if Int(Date().timeIntervalSince(timeStampLastProcessedReading)) < (UserDefaults.standard.calendarInterval * 60 - 10) {
trace("in createCalendarEvent, less than %{public}@ minutes since last event, will not create a new event", log: log, category: ConstantsLog.categoryWatchManager, type: .info, UserDefaults.standard.calendarInterval.description)
return
}
// get 2 last Readings, with a calculatedValue
let lastReading = bgReadingsAccessor.get2LatestBgReadings(minimumTimeIntervalInMinutes: 4.0)
@ -68,15 +79,6 @@ class WatchManager: NSObject {
return
}
// check if timeStampLastProcessedReading is at least minimiumTimeBetweenTwoReadingsInMinutes earlier than now (or it's at least minimiumTimeBetweenTwoReadingsInMinutes minutes ago that event was created for reading) - otherwise don't create event
// exception : there's been a disconnect/reconnect after the last processed reading (if lastConnectionStatusChangeTimeStamp != nil)
if (abs(timeStampLastProcessedReading.timeIntervalSince(Date())) < ConstantsWatch.minimiumTimeBetweenTwoReadingsInMinutes * 60.0 && (lastConnectionStatusChangeTimeStamp != nil ? lastConnectionStatusChangeTimeStamp! : Date(timeIntervalSince1970: 0)).timeIntervalSince(timeStampLastProcessedReading) < 0) {
trace("in createCalendarEvent, no new calendar event will be created because it's too close to previous event", log: log, category: ConstantsLog.categoryWatchManager, type: .info)
return
}
// latest reading should be less than 5 minutes old
guard abs(lastReading[0].timeStamp.timeIntervalSinceNow) < 5 * 60 else {
trace("in createCalendarEvent, the latest reading is older than 5 minutes", log: log, category: ConstantsLog.categoryWatchManager, type: .info)

View File

@ -47,8 +47,8 @@
"settingsviews_speakreadingslanguageselection" = "اختر اللغة";
"settingsviews_speakTrend" = "نطق الاتجاه؟";
"settingsviews_speakDelta" = "نطق الفرق؟";
"settingsviews_speakInterval" = "الفاصل الزمني:";
"settingsviews_speakIntervalMessage" = "الفاصل الزمني الأدنى بين قراءتين بالدقائق";
"settingsviews_IntervalTitle" = "الفاصل الزمني:";
"settingsviews_IntervalMessage" = "الفاصل الزمني الأدنى بين قراءتين بالدقائق";
"settingsviews_Version" = "الإصدار:";
"settingsviews_license" = "رخصة";
"settingsviews_build" = "رقم الإصدار:";

View File

@ -131,8 +131,8 @@
/// nightscout settings, port to use
"nightScoutPort" = "Port (Optional):";
/// speak settings, where user can set the speak interval, speak each reading, each two readings ...
"settingsviews_speakInterval" = "Intervall:";
/// When clicking the interval setting, a pop up asks for minimum number of minutes between two readings, this is the pop up message - this is used for setting the interval between two readings in BG notifications, Speak readings, Apple Watch
"settingsviews_IntervalTitle" = "Intervall:";
/// general settings, literally follower
"settingsviews_follower" = "Follower";
@ -212,8 +212,8 @@
/// dexcom share settings, where user can set the dexcom share account name
"settingsviews_dexcomShareAccountName" = "Benutzer Name:";
/// When clicking the interval setting, a pop up asks for number of minutes between two spoken readings, this is the message displayed in the pop up
"settingsviews_speakIntervalMessage" = "Mindestabstand zwischen zwei vorgelesenen Werten in Minuten";
/// When clicking the interval setting, a pop up asks for minimum number of minutes between two readings, this is the pop up message - this is used for setting the interval between two readings in BG notifications, Speak readings, Apple Watch
"settingsviews_IntervalMessage" = "Mindestabstand zwischen zwei Werten in Minuten";
/// shown on top of the first settings screen
"m5stack_settingsviews_settingstitle" = "M5 Stack Einstellungen";

View File

@ -57,8 +57,8 @@
"settingsviews_speakreadingslanguageselection" = "Select Language";
"settingsviews_speakTrend" = "Speak Trend?";
"settingsviews_speakDelta" = "Speak Delta?";
"settingsviews_speakInterval" = "Interval:";
"settingsviews_speakIntervalMessage" = "Minimum interval between two readings, in minutes";
"settingsviews_IntervalTitle" = "Interval:";
"settingsviews_IntervalMessage" = "Minimum interval between two readings, in minutes";
"settingsviews_sectiontitleAbout" = "About %@";
"settingsviews_Version" = "Version:";
"settingsviews_license" = "License";

View File

@ -55,8 +55,8 @@
"settingsviews_speakreadingslanguageselection" = "Seleccionar Idioma";
"settingsviews_speakTrend" = "Anunciar Tendencia";
"settingsviews_speakDelta" = "Anunciar Delta";
"settingsviews_speakInterval" = "Intervalo";
"settingsviews_speakIntervalMessage" = "Intervalo mínimo entre dos lecturas (mins)";
"settingsviews_IntervalTitle" = "Intervalo";
"settingsviews_IntervalMessage" = "Intervalo mínimo entre dos lecturas (mins)";
"settingsviews_Version" = "Versión:";
"settingsviews_license" = "Licencia";
"settingsviews_build" = "Compilación:";

View File

@ -54,8 +54,8 @@
"settingsviews_speakreadingslanguageselection" = "Valitse kieli";
"settingsviews_speakTrend" = "Puhu suunta?";
"settingsviews_speakDelta" = "Puhu erotus?";
"settingsviews_speakInterval" = "Intervalli:";
"settingsviews_speakIntervalMessage" = "Kahden lukeman välinen vähimmäisväli minuutteina";
"settingsviews_IntervalTitle" = "Intervalli:";
"settingsviews_IntervalMessage" = "Kahden lukeman välinen vähimmäisväli minuutteina";
"settingsviews_sectiontitleAbout" = "%@ info";
"settingsviews_Version" = "Versio:";
"settingsviews_license" = "Lisenssi";

View File

@ -49,8 +49,8 @@
"settingsviews_speakreadingslanguageselection" = "Sélectionner la langue";
"settingsviews_speakTrend" = "Lire la tendance?";
"settingsviews_speakDelta" = "Lire la variation?";
"settingsviews_speakInterval" = "Intervalle";
"settingsviews_speakIntervalMessage" = "Intervalle minimum entre deux lectures, en minutes";
"settingsviews_IntervalTitle" = "Intervalle";
"settingsviews_IntervalMessage" = "Intervalle minimum entre deux lectures, en minutes";
"settingsviews_Version" = "Version";
"settingsviews_license" = "License";
"settingsviews_build" = "Build";

View File

@ -12,8 +12,8 @@
/// nightscout settings, port to use
"nightScoutPort" = "Port (optional):";
/// speak settings, where user can set the speak interval, speak each reading, each two readings ...
"settingsviews_speakInterval" = "Interval:";
/// When clicking the interval setting, a pop up asks for minimum number of minutes between two readings, this is the pop up title - this is used for setting the interval between two readings in BG notifications, Speak readings, Apple Watch
"settingsviews_IntervalTitle" = "Interval:";
/// home screen settings, urgent high value
"settingsviews_urgentHighValue" = "Urgent High Value:";
@ -45,8 +45,8 @@
/// shown on top of the first settings screen, literally 'Settings'
"settingsviews_settingstitle" = "Settings";
/// When clicking the interval setting, a pop up asks for number of minutes between two spoken readings, this is the message displayed in the pop up
"settingsviews_speakIntervalMessage" = "Minimum interval between two readings, in minutes";
/// When clicking the interval setting, a pop up asks for minimum number of minutes between two readings, this is the pop up message - this is used for setting the interval between two readings in BG notifications, Speak readings, Apple Watch
"settingsviews_IntervalMessage" = "Minimum interval between two readings, in minutes";
/// Apple Watch Settings - text in row where create event is enabled or disabled
"createCalendarEvent" = "Create Calendar Events?";

View File

@ -58,8 +58,8 @@
"settingsviews_speakreadingslanguageselection" = "Selecteer Taal";
"settingsviews_speakTrend" = "Spreek Trend Uit?";
"settingsviews_speakDelta" = "Spreek Delta Uit?";
"settingsviews_speakInterval" = "Interval:";
"settingsviews_speakIntervalMessage" = "Minimum interval tussen twee metingen, in minuten";
"settingsviews_IntervalTitle" = "Interval:";
"settingsviews_IntervalMessage" = "Minimum interval tussen twee metingen, in minuten";
"settingsviews_sectiontitleAbout" = "Over %@";
"settingsviews_Version" = "Versie:";
"settingsviews_license" = "Licentie";

View File

@ -12,8 +12,8 @@
/// nightscout settings, port to use
"nightScoutPort" = "Port (optional):";
/// speak settings, where user can set the speak interval, speak each reading, each two readings ...
"settingsviews_speakInterval" = "Interval:";
/// When clicking the interval setting, a pop up asks for minimum number of minutes between two readings, this is the pop up title - this is used for setting the interval between two readings in BG notifications, Speak readings, Apple Watch
"settingsviews_IntervalTitle" = "Interval:";
/// home screen settings, urgent high value
"settingsviews_urgentHighValue" = "Urgent High Value:";
@ -45,8 +45,8 @@
/// shown on top of the first settings screen, literally 'Settings'
"settingsviews_settingstitle" = "Settings";
/// When clicking the interval setting, a pop up asks for number of minutes between two spoken readings, this is the message displayed in the pop up
"settingsviews_speakIntervalMessage" = "Minimum interval between two readings, in minutes";
/// When clicking the interval setting, a pop up asks for minimum number of minutes between two readings, this is the pop up message - this is used for setting the interval between two readings in BG notifications, Speak readings, Apple Watch
"settingsviews_IntervalMessage" = "Minimum interval between two readings, in minutes";
/// Apple Watch Settings - text in row where create event is enabled or disabled
"createCalendarEvent" = "Create Calendar Events?";

View File

@ -57,8 +57,8 @@
"settingsviews_speakreadingslanguageselection" = "Escolher Idioma";
"settingsviews_speakTrend" = "Falar Tendência?";
"settingsviews_speakDelta" = "Falar Delta?";
"settingsviews_speakInterval" = "Intervalo:";
"settingsviews_speakIntervalMessage" = "Intervalo minímo entre duas leituras, em minutos";
"settingsviews_IntervalTitle" = "Intervalo:";
"settingsviews_IntervalMessage" = "Intervalo minímo entre duas leituras, em minutos";
"settingsviews_sectiontitleAbout" = "Sobre %@";
"settingsviews_Version" = "Versão:";
"settingsviews_license" = "Licença";

View File

@ -12,8 +12,8 @@
/// nightscout settings, port to use
"nightScoutPort" = "Port (optional):";
/// speak settings, where user can set the speak interval, speak each reading, each two readings ...
"settingsviews_speakInterval" = "Interval:";
/// When clicking the interval setting, a pop up asks for minimum number of minutes between two readings, this is the pop up title - this is used for setting the interval between two readings in BG notifications, Speak readings, Apple Watch
"settingsviews_IntervalTitle" = "Interval:";
/// home screen settings, urgent high value
"settingsviews_urgentHighValue" = "Urgent High Value:";
@ -45,8 +45,8 @@
/// shown on top of the first settings screen, literally 'Settings'
"settingsviews_settingstitle" = "Settings";
/// When clicking the interval setting, a pop up asks for number of minutes between two spoken readings, this is the message displayed in the pop up
"settingsviews_speakIntervalMessage" = "Minimum interval between two readings, in minutes";
/// When clicking the interval setting, a pop up asks for minimum number of minutes between two readings, this is the pop up message - this is used for setting the interval between two readings in BG notifications, Speak readings, Apple Watch
"settingsviews_IntervalMessage" = "Minimum interval between two readings, in minutes";
/// Apple Watch Settings - text in row where create event is enabled or disabled
"createCalendarEvent" = "Create Calendar Events?";

View File

@ -12,8 +12,8 @@
/// nightscout settings, port to use
"nightScoutPort" = "Port (optional):";
/// speak settings, where user can set the speak interval, speak each reading, each two readings ...
"settingsviews_speakInterval" = "Interval:";
/// When clicking the interval setting, a pop up asks for minimum number of minutes between two readings, this is the pop up message - this is used for setting the interval between two readings in BG notifications, Speak readings, Apple Watch
"settingsviews_IntervalTitle" = "Interval:";
/// home screen settings, urgent high value
"settingsviews_urgentHighValue" = "Urgent High Value:";
@ -45,8 +45,8 @@
/// shown on top of the first settings screen, literally 'Settings'
"settingsviews_settingstitle" = "Settings";
/// When clicking the interval setting, a pop up asks for number of minutes between two spoken readings, this is the message displayed in the pop up
"settingsviews_speakIntervalMessage" = "Minimum interval between two readings, in minutes";
/// When clicking the interval setting, a pop up asks for minimum number of minutes between two readings, this is the pop up message - this is used for setting the interval between two readings in BG notifications, Speak readings, Apple Watch
"settingsviews_IntervalMessage" = "Minimum interval between two readings, in minutes";
/// Apple Watch Settings - text in row where create event is enabled or disabled
"createCalendarEvent" = "Create Calendar Events?";

View File

@ -57,8 +57,8 @@
"settingsviews_speakreadingslanguageselection" = "Välj språk";
"settingsviews_speakTrend" = "Läs upp trend?";
"settingsviews_speakDelta" = "Läs upp delta?";
"settingsviews_speakInterval" = "Intervall:";
"settingsviews_speakIntervalMessage" = "Minsta intervall mellan två avläsningar, i minuter";
"settingsviews_IntervalTitle" = "Intervall:";
"settingsviews_IntervalMessage" = "Minsta intervall mellan två avläsningar, i minuter";
"settingsviews_sectiontitleAbout" = "Om %@";
"settingsviews_Version" = "Version:";
"settingsviews_license" = "Licens";

View File

@ -30,7 +30,7 @@
"settingsviews_speakBgReadings" = "语音播报血糖值";
"settingsviews_speakTrend" = "语音播报趋势";
"settingsviews_speakDelta" = "语音播报偏移量";
"settingsviews_speakInterval" = "间隔时间";
"settingsviews_IntervalTitle" = "间隔时间";
"settingsviews_masterorfollower" = "主控端或者关注者 ?";
"settingsviews_master" = "主控端";
"settingsviews_follower" = "关注者";
@ -63,8 +63,8 @@
/// Apple Watch Settings - text in row where user needs to say if unit should be displayed or not
"displayUnitInCalendarEvent" = "Display Unit?";
/// When clicking the interval setting, a pop up asks for number of minutes between two spoken readings, this is the message displayed in the pop up
"settingsviews_speakIntervalMessage" = "Minimum interval between two readings, in minutes";
/// When clicking the interval setting, a pop up asks for minimum number of minutes between two readings, this is the pop up message - this is used for setting the interval between two readings in BG notifications, Speak readings, Apple Watch
"settingsviews_IntervalMessage" = "Minimum interval between two readings, in minutes";
/// Apple Watch Settings - text in row where create event is enabled or disabled
"createCalendarEvent" = "Create Calendar Events?";

View File

@ -267,12 +267,12 @@ class Texts_SettingsView {
return NSLocalizedString("settingsviews_speakDelta", tableName: filename, bundle: Bundle.main, value: "Speak Delta?", comment: "speak settings, where user can enable or disable speak delta")
}()
static let labelSpeakInterval = {
return NSLocalizedString("settingsviews_speakInterval", tableName: filename, bundle: Bundle.main, value: "Interval:", comment: "speak settings, where user can set the speak interval, speak each reading, each two readings ...")
static let settingsviews_IntervalTitle = {
return NSLocalizedString("settingsviews_IntervalTitle", tableName: filename, bundle: Bundle.main, value: "Interval:", comment: "When clicking the interval setting, a pop up asks for minimum number of minutes between two readings, this is the pop up message - this is used for setting the interval between two readings in BG notifications, Speak readings, Apple Watch")
}()
static let speakIntervalMessage = {
return NSLocalizedString("settingsviews_speakIntervalMessage", tableName: filename, bundle: Bundle.main, value: "Minimum interval between two readings (mins)", comment: "When clicking the interval setting, a pop up asks for number of minutes between two spoken readings, this is the message displayed in the pop up")
static let settingsviews_IntervalMessage = {
return NSLocalizedString("settingsviews_IntervalMessage", tableName: filename, bundle: Bundle.main, value: "Minimum interval between two readings (mins)", comment: "When clicking the interval setting, a pop up asks for minimum number of minutes between two readings, this is the pop up message - this is used for setting the interval between two readings in BG notifications, Speak readings, Apple Watch")
}()
// MARK: - Section About Info

View File

@ -1242,8 +1242,8 @@ final class RootViewController: UIViewController {
if readingValueForBadge <= 40.0 {readingValueForBadge = 40.0}
// check if notification on home screen is enabled in the settings
// and also if last notification was long enough ago (longer than ConstantsNotifications.minimiumTimeBetweenTwoReadingsInMinutes), except if there would have been a disconnect since previous notification (simply because I like getting a new reading with a notification by disabling/reenabling bluetooth
if UserDefaults.standard.showReadingInNotification && !overrideShowReadingInNotification && (abs(timeStampLastBGNotification.timeIntervalSince(Date())) > ConstantsNotifications.minimiumTimeBetweenTwoReadingsInMinutes * 60.0 || lastConnectionStatusChangeTimeStamp().timeIntervalSince(timeStampLastBGNotification) > 0) {
// and also if last notification was long enough ago (longer than UserDefaults.standard.notificationInterval), except if there would have been a disconnect since previous notification (simply because I like getting a new reading with a notification by disabling/reenabling bluetooth
if UserDefaults.standard.showReadingInNotification && !overrideShowReadingInNotification && (abs(timeStampLastBGNotification.timeIntervalSince(Date())) > Double(UserDefaults.standard.notificationInterval) * 60.0 || lastConnectionStatusChangeTimeStamp().timeIntervalSince(timeStampLastBGNotification) > 0) {
// Create Notification Content
let notificationContent = UNMutableNotificationContent()

View File

@ -20,6 +20,9 @@ fileprivate enum Setting:Int, CaseIterable {
/// should units be displayed yes or no
case displayUnits = 4
/// minimum time between two readings, for which event should be created (in minutes)
case calendarInterval = 5
}
class SettingsViewAppleWatchSettingsViewModel: SettingsViewModelProtocol {
@ -62,6 +65,9 @@ class SettingsViewAppleWatchSettingsViewModel: SettingsViewModelProtocol {
case .displayUnits:
return Texts_SettingsView.displayUnitInCalendarEvent
case .calendarInterval:
return Texts_SettingsView.settingsviews_IntervalTitle
}
@ -104,6 +110,9 @@ class SettingsViewAppleWatchSettingsViewModel: SettingsViewModelProtocol {
case .displayTrend, .displayDelta, .displayUnits:
return UITableViewCell.AccessoryType.none
case .calendarInterval:
return UITableViewCell.AccessoryType.disclosureIndicator
}
}
@ -118,6 +127,9 @@ class SettingsViewAppleWatchSettingsViewModel: SettingsViewModelProtocol {
case .createCalendarEvent, .displayTrend, .displayDelta, .displayUnits:
return nil
case .calendarInterval:
return UserDefaults.standard.calendarInterval.description
}
}
@ -194,6 +206,9 @@ class SettingsViewAppleWatchSettingsViewModel: SettingsViewModelProtocol {
case .displayUnits:
return UISwitch(isOn: UserDefaults.standard.displayUnitInCalendarEvent, action: {(isOn:Bool) in UserDefaults.standard.displayUnitInCalendarEvent = isOn})
case .calendarInterval:
return nil
}
}
@ -284,6 +299,10 @@ class SettingsViewAppleWatchSettingsViewModel: SettingsViewModelProtocol {
}
}, cancelHandler: nil, didSelectRowHandler: nil)
case .calendarInterval:
return SettingsSelectedRowAction.askText(title: Texts_SettingsView.settingsviews_IntervalTitle, message: Texts_SettingsView.settingsviews_IntervalMessage, keyboardType: .numberPad, text: UserDefaults.standard.calendarInterval.description, placeHolder: "0", actionTitle: nil, cancelTitle: nil, actionHandler: {(interval:String) in if let interval = Int(interval) {UserDefaults.standard.calendarInterval = Int(interval)}}, cancelHandler: nil, inputValidator: nil)
}
}

View File

@ -2,20 +2,24 @@ import UIKit
fileprivate enum Setting:Int, CaseIterable {
//blood glucose unit
/// blood glucose unit
case bloodGlucoseUnit = 0
// choose between master and follower
/// choose between master and follower
case masterFollower = 1
// should reading be shown in notification
/// should reading be shown in notification
case showReadingInNotification = 2
// show reading in app badge
case showReadingInAppBadge = 3
/// - minimum time between two readings, for which notification should be created (in minutes)
/// - except if there's been a disconnect, in that case this value is not taken into account
case notificationInterval = 3
// if reading is shown in app badge, should value be multiplied with 10 yes or no
case multipleAppBadgeValueWith10 = 4
/// show reading in app badge
case showReadingInAppBadge = 4
/// if reading is shown in app badge, should value be multiplied with 10 yes or no
case multipleAppBadgeValueWith10 = 5
}
@ -111,6 +115,10 @@ class SettingsViewGeneralSettingsViewModel: SettingsViewModelProtocol {
case .showReadingInNotification, .showReadingInAppBadge, .multipleAppBadgeValueWith10:
return SettingsSelectedRowAction.nothing
case .notificationInterval:
return SettingsSelectedRowAction.askText(title: Texts_SettingsView.settingsviews_IntervalTitle, message: Texts_SettingsView.settingsviews_IntervalMessage, keyboardType: .numberPad, text: UserDefaults.standard.notificationInterval.description, placeHolder: "0", actionTitle: nil, cancelTitle: nil, actionHandler: {(interval:String) in if let interval = Int(interval) {UserDefaults.standard.notificationInterval = Int(interval)}}, cancelHandler: nil, inputValidator: nil)
}
}
@ -150,6 +158,9 @@ class SettingsViewGeneralSettingsViewModel: SettingsViewModelProtocol {
case .multipleAppBadgeValueWith10:
return Texts_SettingsView.multipleAppBadgeValueWith10
case .notificationInterval:
return Texts_SettingsView.settingsviews_IntervalTitle
}
}
@ -167,6 +178,9 @@ class SettingsViewGeneralSettingsViewModel: SettingsViewModelProtocol {
case .showReadingInNotification, .showReadingInAppBadge, .multipleAppBadgeValueWith10:
return UITableViewCell.AccessoryType.none
case .notificationInterval:
return UITableViewCell.AccessoryType.disclosureIndicator
}
}
@ -184,6 +198,8 @@ class SettingsViewGeneralSettingsViewModel: SettingsViewModelProtocol {
case .showReadingInNotification, .showReadingInAppBadge, .multipleAppBadgeValueWith10:
return nil
case .notificationInterval:
return UserDefaults.standard.notificationInterval.description
}
}
@ -208,6 +224,9 @@ class SettingsViewGeneralSettingsViewModel: SettingsViewModelProtocol {
case .bloodGlucoseUnit, .masterFollower:
return nil
case .notificationInterval:
return nil
}
}

View File

@ -49,7 +49,7 @@ class SettingsViewSpeakSettingsViewModel:SettingsViewModelProtocol {
case .speakDelta:
return .nothing
case .speakInterval:
return SettingsSelectedRowAction.askText(title: Texts_SettingsView.labelSpeakInterval, message: Texts_SettingsView.speakIntervalMessage, keyboardType: .numberPad, text: UserDefaults.standard.speakInterval.description, placeHolder: "0", actionTitle: nil, cancelTitle: nil, actionHandler: {(interval:String) in if let interval = Int(interval) {UserDefaults.standard.speakInterval = Int(interval)}}, cancelHandler: nil, inputValidator: nil)
return SettingsSelectedRowAction.askText(title: Texts_SettingsView.settingsviews_IntervalTitle, message: Texts_SettingsView.settingsviews_IntervalMessage, keyboardType: .numberPad, text: UserDefaults.standard.speakInterval.description, placeHolder: "0", actionTitle: nil, cancelTitle: nil, actionHandler: {(interval:String) in if let interval = Int(interval) {UserDefaults.standard.speakInterval = Int(interval)}}, cancelHandler: nil, inputValidator: nil)
case .speakBgReadingLanguage:
//find index for languageCode type currently stored in userdefaults
@ -95,7 +95,7 @@ class SettingsViewSpeakSettingsViewModel:SettingsViewModelProtocol {
case .speakDelta:
return Texts_SettingsView.labelSpeakDelta
case .speakInterval:
return Texts_SettingsView.labelSpeakInterval
return Texts_SettingsView.settingsviews_IntervalTitle
}
}