diff --git a/Sources/EQNNotificationService/NotificationService.m b/Sources/EQNNotificationService/NotificationService.m index 116edf5..bc031fe 100644 --- a/Sources/EQNNotificationService/NotificationService.m +++ b/Sources/EQNNotificationService/NotificationService.m @@ -76,7 +76,7 @@ if ([[userInfo objectForKey:@"type"] isEqualToString:@"eqn"]) { - self.bestAttemptContent.sound = [UNNotificationSound soundNamed:[EQNAllertaSismica center].tonoAllarme]; + self.bestAttemptContent.sound = [UNNotificationSound soundNamed:[EQNAllertaSismica sharedInstance].tonoAllarme]; NSString *intensity = [userInfo objectForKey:@"intensity"]; diff --git a/Sources/Earthquake Network.xcodeproj/project.pbxproj b/Sources/Earthquake Network.xcodeproj/project.pbxproj index d8e1ca1..a9aeef5 100644 --- a/Sources/Earthquake Network.xcodeproj/project.pbxproj +++ b/Sources/Earthquake Network.xcodeproj/project.pbxproj @@ -21,9 +21,6 @@ 8C465D9E21F7BD8700F04673 /* PastquakesAnnotation.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C602249218EDBE200C799C2 /* PastquakesAnnotation.m */; }; 8C465D9F21F7BE0600F04673 /* Assets.xcassets in Sources */ = {isa = PBXBuildFile; fileRef = 8CBD3DD12149B9AD0070C963 /* Assets.xcassets */; }; 8C483C9721FA662900259FD2 /* alert_star_trek.wav in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CF12CC721DE43A400613AC5 /* alert_star_trek.wav */; }; - 8C483C9A21FA664000259FD2 /* EQNAllertaSismica.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C14113621EE502800A59729 /* EQNAllertaSismica.m */; }; - 8C483C9B21FA665C00259FD2 /* EQNAllertaSismica.h in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C14113521EE502800A59729 /* EQNAllertaSismica.h */; }; - 8C483C9C21FA665C00259FD2 /* EQNAllertaSismica.m in Frameworks */ = {isa = PBXBuildFile; fileRef = 8C14113621EE502800A59729 /* EQNAllertaSismica.m */; }; 8C483CA521FBC06D00259FD2 /* alerta_japanese.m4r in Resources */ = {isa = PBXBuildFile; fileRef = 8C483CA421FBC06D00259FD2 /* alerta_japanese.m4r */; }; 8C483CA621FBC06D00259FD2 /* alerta_japanese.m4r in Resources */ = {isa = PBXBuildFile; fileRef = 8C483CA421FBC06D00259FD2 /* alerta_japanese.m4r */; }; 8C483CA721FBC06D00259FD2 /* alerta_japanese.m4r in Resources */ = {isa = PBXBuildFile; fileRef = 8C483CA421FBC06D00259FD2 /* alerta_japanese.m4r */; }; @@ -64,10 +61,8 @@ 8CBD3DD82149B9AD0070C963 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CBD3DD72149B9AD0070C963 /* main.m */; }; 8CC1B15A217CB09100F22178 /* DettagliMappaViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CC1B159217CB09100F22178 /* DettagliMappaViewController.m */; }; 8CC2B44F214AC7F8002ED1B2 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8CC2B44E214AC7F8002ED1B2 /* CoreMotion.framework */; }; - 8CCE164421E67F1300173CD9 /* EQNImpostazioniNotifiche.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CCE164321E67F1300173CD9 /* EQNImpostazioniNotifiche.m */; }; - 8CCE164B21E7BAB200173CD9 /* EQNNotificheTempoReale.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CCE164A21E7BAB200173CD9 /* EQNNotificheTempoReale.m */; }; 8CCE164E21E7BACE00173CD9 /* EQNNotificheSegnalazioniUtente.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CCE164D21E7BACE00173CD9 /* EQNNotificheSegnalazioniUtente.m */; }; - 8CCE165121E7BAEC00173CD9 /* EQNNotificeReteSismiche.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CCE165021E7BAEC00173CD9 /* EQNNotificeReteSismiche.m */; }; + 8CCE165121E7BAEC00173CD9 /* EQNNotificheReteSismiche.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CCE165021E7BAEC00173CD9 /* EQNNotificheReteSismiche.m */; }; 8CCE165521EA378800173CD9 /* SettingsUserReportAlertsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CCE165421EA378800173CD9 /* SettingsUserReportAlertsViewController.m */; }; 8CCE165821EB1E0000173CD9 /* SettingsSeismicNetworkAlertsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CCE165721EB1E0000173CD9 /* SettingsSeismicNetworkAlertsViewController.m */; }; 8CCE166121EBA37500173CD9 /* EQNNotificheTsunami.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CCE166021EBA37500173CD9 /* EQNNotificheTsunami.m */; }; @@ -124,6 +119,7 @@ DCC23DEF24D28F58003A2404 /* EQNEdgeInsetLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCC23DEE24D28F58003A2404 /* EQNEdgeInsetLabel.swift */; }; DCD3E3C024D15576007C78D4 /* PurchaseProVersionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCD3E3BF24D15576007C78D4 /* PurchaseProVersionViewController.swift */; }; DCD4571C24F6CF0D00B58304 /* EQNGenericValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCD4571B24F6CF0D00B58304 /* EQNGenericValue.swift */; }; + DCDAB31925188BB3001AE40D /* EQNAllertaSismica.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C14113621EE502800A59729 /* EQNAllertaSismica.m */; }; DCDE0BD924E58CCE00209778 /* EQNMainTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = DCDE0BD824E58CCE00209778 /* EQNMainTabBarController.m */; }; DCEFF21324F5821E009D3FE1 /* SettingDetailTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCEFF21224F5821E009D3FE1 /* SettingDetailTableViewCell.swift */; }; DCEFF21724F58569009D3FE1 /* SettingSectionHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCEFF21624F58569009D3FE1 /* SettingSectionHeaderView.swift */; }; @@ -249,14 +245,10 @@ 8CC1B158217CB09100F22178 /* DettagliMappaViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DettagliMappaViewController.h; sourceTree = ""; }; 8CC1B159217CB09100F22178 /* DettagliMappaViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DettagliMappaViewController.m; sourceTree = ""; }; 8CC2B44E214AC7F8002ED1B2 /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = System/Library/Frameworks/CoreMotion.framework; sourceTree = SDKROOT; }; - 8CCE164221E67F1300173CD9 /* EQNImpostazioniNotifiche.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNImpostazioniNotifiche.h; sourceTree = ""; }; - 8CCE164321E67F1300173CD9 /* EQNImpostazioniNotifiche.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNImpostazioniNotifiche.m; sourceTree = ""; }; - 8CCE164921E7BAB200173CD9 /* EQNNotificheTempoReale.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNNotificheTempoReale.h; sourceTree = ""; }; - 8CCE164A21E7BAB200173CD9 /* EQNNotificheTempoReale.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNNotificheTempoReale.m; sourceTree = ""; }; 8CCE164C21E7BACE00173CD9 /* EQNNotificheSegnalazioniUtente.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNNotificheSegnalazioniUtente.h; sourceTree = ""; }; 8CCE164D21E7BACE00173CD9 /* EQNNotificheSegnalazioniUtente.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNNotificheSegnalazioniUtente.m; sourceTree = ""; }; - 8CCE164F21E7BAEC00173CD9 /* EQNNotificeReteSismiche.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNNotificeReteSismiche.h; sourceTree = ""; }; - 8CCE165021E7BAEC00173CD9 /* EQNNotificeReteSismiche.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNNotificeReteSismiche.m; sourceTree = ""; }; + 8CCE164F21E7BAEC00173CD9 /* EQNNotificheReteSismiche.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EQNNotificheReteSismiche.h; sourceTree = ""; }; + 8CCE165021E7BAEC00173CD9 /* EQNNotificheReteSismiche.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EQNNotificheReteSismiche.m; sourceTree = ""; }; 8CCE165321EA378800173CD9 /* SettingsUserReportAlertsViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SettingsUserReportAlertsViewController.h; sourceTree = ""; }; 8CCE165421EA378800173CD9 /* SettingsUserReportAlertsViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SettingsUserReportAlertsViewController.m; sourceTree = ""; }; 8CCE165621EB1E0000173CD9 /* SettingsSeismicNetworkAlertsViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SettingsSeismicNetworkAlertsViewController.h; sourceTree = ""; }; @@ -355,8 +347,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 8C483C9B21FA665C00259FD2 /* EQNAllertaSismica.h in Frameworks */, - 8C483C9C21FA665C00259FD2 /* EQNAllertaSismica.m in Frameworks */, 8C483C9721FA662900259FD2 /* alert_star_trek.wav in Frameworks */, 8C465D9B21F653CA00F04673 /* Assets.xcassets in Frameworks */, ); @@ -515,25 +505,6 @@ name = Frameworks; sourceTree = ""; }; - 8CCE165221EA370200173CD9 /* impostazioni notifiche */ = { - isa = PBXGroup; - children = ( - 8CCE164221E67F1300173CD9 /* EQNImpostazioniNotifiche.h */, - 8CCE164321E67F1300173CD9 /* EQNImpostazioniNotifiche.m */, - 8CCE164921E7BAB200173CD9 /* EQNNotificheTempoReale.h */, - 8CCE164A21E7BAB200173CD9 /* EQNNotificheTempoReale.m */, - 8CCE164C21E7BACE00173CD9 /* EQNNotificheSegnalazioniUtente.h */, - 8CCE164D21E7BACE00173CD9 /* EQNNotificheSegnalazioniUtente.m */, - 8CCE164F21E7BAEC00173CD9 /* EQNNotificeReteSismiche.h */, - 8CCE165021E7BAEC00173CD9 /* EQNNotificeReteSismiche.m */, - 8CCE165F21EBA37500173CD9 /* EQNNotificheTsunami.h */, - 8CCE166021EBA37500173CD9 /* EQNNotificheTsunami.m */, - 8C14113521EE502800A59729 /* EQNAllertaSismica.h */, - 8C14113621EE502800A59729 /* EQNAllertaSismica.m */, - ); - path = "impostazioni notifiche"; - sourceTree = ""; - }; 8CD08632218AF5C80000CB5E /* cellTableView */ = { isa = PBXGroup; children = ( @@ -572,7 +543,6 @@ 8CF66049214C09E0009F4314 /* model */ = { isa = PBXGroup; children = ( - 8CCE165221EA370200173CD9 /* impostazioni notifiche */, 8C60224B218EDBF700C799C2 /* annotation */, 8C8EBBA521540039002784BA /* EQNUser.h */, 8C8EBBA621540039002784BA /* EQNUser.m */, @@ -793,6 +763,14 @@ isa = PBXGroup; children = ( DCEFF21924F587E3009D3FE1 /* SettingItem.swift */, + 8CCE164C21E7BACE00173CD9 /* EQNNotificheSegnalazioniUtente.h */, + 8CCE164D21E7BACE00173CD9 /* EQNNotificheSegnalazioniUtente.m */, + 8CCE164F21E7BAEC00173CD9 /* EQNNotificheReteSismiche.h */, + 8CCE165021E7BAEC00173CD9 /* EQNNotificheReteSismiche.m */, + 8C14113521EE502800A59729 /* EQNAllertaSismica.h */, + 8C14113621EE502800A59729 /* EQNAllertaSismica.m */, + 8CCE165F21EBA37500173CD9 /* EQNNotificheTsunami.h */, + 8CCE166021EBA37500173CD9 /* EQNNotificheTsunami.m */, ); path = Settings; sourceTree = ""; @@ -1063,7 +1041,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 8C483C9A21FA664000259FD2 /* EQNAllertaSismica.m in Sources */, + DCDAB31925188BB3001AE40D /* EQNAllertaSismica.m in Sources */, 8C4B0B7E21CACE3F00AED489 /* NotificationService.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1075,7 +1053,7 @@ DCEFF21324F5821E009D3FE1 /* SettingDetailTableViewCell.swift in Sources */, 8CCE166121EBA37500173CD9 /* EQNNotificheTsunami.m in Sources */, DCC23DEF24D28F58003A2404 /* EQNEdgeInsetLabel.swift in Sources */, - 8CCE165121E7BAEC00173CD9 /* EQNNotificeReteSismiche.m in Sources */, + 8CCE165121E7BAEC00173CD9 /* EQNNotificheReteSismiche.m in Sources */, DC52B8A224FC145500ABEBA6 /* SettingsBaseViewController.m in Sources */, 8CF4F4DB216D44930057110B /* EQNPastquakes.m in Sources */, 8CCE165821EB1E0000173CD9 /* SettingsSeismicNetworkAlertsViewController.m in Sources */, @@ -1091,7 +1069,6 @@ 8C4E343F215012FA008B0D2A /* EQNManager.m in Sources */, DCAA913F24F68A1D00145A3D /* SettingMultivaluesTableViewCell.swift in Sources */, DCF9E14F24F6EA07002B6B1D /* EQNSeismicNetwork.swift in Sources */, - 8CCE164421E67F1300173CD9 /* EQNImpostazioniNotifiche.m in Sources */, 8C14113721EE502800A59729 /* EQNAllertaSismica.m in Sources */, 8C483CBC21FDACE500259FD2 /* VersioneProProducts.swift in Sources */, 8C483CB821FDACD300259FD2 /* IAPHelper.swift in Sources */, @@ -1129,7 +1106,6 @@ DC0E551324F8063300D54270 /* SettingSegmentedTableViewCell.swift in Sources */, DCEFF21724F58569009D3FE1 /* SettingSectionHeaderView.swift in Sources */, 8C14113121ED3E5B00A59729 /* SettingsRealTimeAlertsViewController.m in Sources */, - 8CCE164B21E7BAB200173CD9 /* EQNNotificheTempoReale.m in Sources */, DCBB267A24D1E7F500F04559 /* SubscriptionsHeaderTableViewCell.swift in Sources */, DC65B391250F243E00251693 /* SeismicSettingsNetworksViewController.swift in Sources */, 8CF4F4D2216D2C780057110B /* EQNReteSmartphone.m in Sources */, diff --git a/Sources/Earthquake Network/AppDelegate.m b/Sources/Earthquake Network/AppDelegate.m index 368acd3..ac74009 100644 --- a/Sources/Earthquake Network/AppDelegate.m +++ b/Sources/Earthquake Network/AppDelegate.m @@ -15,7 +15,7 @@ #import "EQNAllertaSismica.h" #import "EQNAllertaSismica.h" #import "EQNNotificheSegnalazioniUtente.h" -#import "EQNNotificeReteSismiche.h" +#import "EQNNotificheReteSismiche.h" #import "EQNMainTabBarController.h" @import GoogleMaps; @@ -172,7 +172,7 @@ fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)(void))completionHandler { - // response.notification.request.content.sound = [UNNotificationSound soundNamed:[EQNAllertaSismica center].tonoAllarme]; + // response.notification.request.content.sound = [UNNotificationSound soundNamed:[EQNAllertaSismica sharedInstance].tonoAllarme]; NSDictionary *userInfo = response.notification.request.content.userInfo; EQNTabBarSection section = EQNTabBarSectionAllerte; if ([userInfo[@"type"] isEqualToString:@"eqn"]) { @@ -217,22 +217,22 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response NSLog(@"fcmToken %@", fcmToken); if (![[NSUserDefaults standardUserDefaults] objectForKey:TOKEN_USER]) { - [EQNAllertaSismica center].isAbilitato = YES; - [EQNAllertaSismica center].raggioSismiLievi = @"300"; - [EQNAllertaSismica center].raggioSismiForti = @"600"; - [EQNAllertaSismica center].sismiDaNotificare = @"0"; - [[EQNAllertaSismica center] saveUserInfo]; + [EQNAllertaSismica sharedInstance].isAbilitato = YES; + [EQNAllertaSismica sharedInstance].raggioSismiLievi = @"300"; + [EQNAllertaSismica sharedInstance].raggioSismiForti = @"600"; + [EQNAllertaSismica sharedInstance].sismiDaNotificare = @"0"; + [[EQNAllertaSismica sharedInstance] saveUserInfo]; - [EQNNotificheSegnalazioniUtente center].isAbilitato = YES; - [EQNNotificheSegnalazioniUtente center].distanzaPosizione = @"300"; - [[EQNNotificheSegnalazioniUtente center] saveUserInfo]; + [EQNNotificheSegnalazioniUtente sharedInstance].isAbilitato = YES; + [EQNNotificheSegnalazioniUtente sharedInstance].distanzaPosizione = @"300"; + [[EQNNotificheSegnalazioniUtente sharedInstance] saveUserInfo]; - [EQNNotificeReteSismiche center].isAbilitato = YES; - [EQNNotificeReteSismiche center].distanzaPosizione = @"1000"; - [EQNNotificeReteSismiche center].isAbilitaVicini = NO; - [EQNNotificeReteSismiche center].energiaSisma = @"3.5"; - [EQNNotificeReteSismiche center].energiaTerremotiForti = @"7.5"; - [[EQNNotificeReteSismiche center] saveUserInfo]; + [EQNNotificheReteSismiche sharedInstance].isAbilitato = YES; + [EQNNotificheReteSismiche sharedInstance].distanzaPosizione = @"1000"; + [EQNNotificheReteSismiche sharedInstance].isAbilitaVicini = NO; + [EQNNotificheReteSismiche sharedInstance].energiaSisma = @"3.5"; + [EQNNotificheReteSismiche sharedInstance].energiaTerremotiForti = @"7.5"; + [[EQNNotificheReteSismiche sharedInstance] saveUserInfo]; } diff --git a/Sources/Earthquake Network/Controllers/Settings/SettingsRealTimeAlertsViewController.m b/Sources/Earthquake Network/Controllers/Settings/SettingsRealTimeAlertsViewController.m index e6f950c..c5e434b 100644 --- a/Sources/Earthquake Network/Controllers/Settings/SettingsRealTimeAlertsViewController.m +++ b/Sources/Earthquake Network/Controllers/Settings/SettingsRealTimeAlertsViewController.m @@ -99,29 +99,29 @@ typedef NS_ENUM(NSInteger, RowIdentifier) { - (void)updateUI { - self.notificationEnabled = [EQNAllertaSismica center].isAbilitato; - self.doNotDisturbEnabled = [EQNAllertaSismica center].isintervalloAllarme; + self.notificationEnabled = [EQNAllertaSismica sharedInstance].isAbilitato; + self.doNotDisturbEnabled = [EQNAllertaSismica sharedInstance].isintervalloAllarme; // sismi da notificare - EQNGenericValue *sismiDaNotificare = [EQNData seismicToNotifyFor:[EQNAllertaSismica center].sismiDaNotificare]; + EQNGenericValue *sismiDaNotificare = [EQNData seismicToNotifyFor:[EQNAllertaSismica sharedInstance].sismiDaNotificare]; self.currentSeismicToNotify = sismiDaNotificare; // raggio sismi lievi - EQNGenericValue *raggioSismiLievi = [EQNData raggioSismaFor:[EQNAllertaSismica center].raggioSismiLievi]; + EQNGenericValue *raggioSismiLievi = [EQNData raggioSismaFor:[EQNAllertaSismica sharedInstance].raggioSismiLievi]; self.currentLowSeismicRadius = raggioSismiLievi; // raggio sismi forti - EQNGenericValue *raggioSismiForti = [EQNData raggioSismaFor:[EQNAllertaSismica center].raggioSismiForti]; + EQNGenericValue *raggioSismiForti = [EQNData raggioSismaFor:[EQNAllertaSismica sharedInstance].raggioSismiForti]; self.currentStrongSeismicRadius = raggioSismiForti; // non disturbare, orari - NSDate *startTime = [EQNData doNotDisturbEndDateFrom:[EQNAllertaSismica center].oraioInizio]; + NSDate *startTime = [EQNData doNotDisturbEndDateFrom:[EQNAllertaSismica sharedInstance].oraioInizio]; self.currentStartTime = startTime; - NSDate *endTime = [EQNData doNotDisturbEndDateFrom:[EQNAllertaSismica center].orarioFine]; + NSDate *endTime = [EQNData doNotDisturbEndDateFrom:[EQNAllertaSismica sharedInstance].orarioFine]; self.currentEndTime = endTime; - [[EQNAllertaSismica center] saveUserInfo]; + [[EQNAllertaSismica sharedInstance] saveUserInfo]; [self.tableView reloadData]; } @@ -159,8 +159,8 @@ typedef NS_ENUM(NSInteger, RowIdentifier) { cell.toggleSwitch.on = self.notificationEnabled; cell.valueChanged = ^(BOOL enabled) { self.notificationEnabled = enabled; - [EQNAllertaSismica center].isAbilitato = self.notificationEnabled; - [[EQNAllertaSismica center] saveUserInfo]; + [EQNAllertaSismica sharedInstance].isAbilitato = self.notificationEnabled; + [[EQNAllertaSismica sharedInstance] saveUserInfo]; [self.tableView reloadData]; }; } else if (indexPath.row == RowIdentifierNonDisturbare) { @@ -168,8 +168,8 @@ typedef NS_ENUM(NSInteger, RowIdentifier) { cell.isDisabled = !self.notificationEnabled; cell.valueChanged = ^(BOOL enabled) { self.doNotDisturbEnabled = enabled; - [EQNAllertaSismica center].isintervalloAllarme = self.doNotDisturbEnabled; - [[EQNAllertaSismica center] saveUserInfo]; + [EQNAllertaSismica sharedInstance].isintervalloAllarme = self.doNotDisturbEnabled; + [[EQNAllertaSismica sharedInstance] saveUserInfo]; [self.tableView reloadData]; }; } @@ -250,36 +250,36 @@ typedef NS_ENUM(NSInteger, RowIdentifier) { - (void)updateSismicToNotify:(EQNGenericValue *)seismic { - [EQNAllertaSismica center].sismiDaNotificare = seismic.value; - [[EQNAllertaSismica center] saveUserInfo]; + [EQNAllertaSismica sharedInstance].sismiDaNotificare = seismic.value; + [[EQNAllertaSismica sharedInstance] saveUserInfo]; [self updateUI]; } - (void)updateLowSeismicRadius:(EQNGenericValue *)radius { - [EQNAllertaSismica center].raggioSismiLievi = radius.value; - [[EQNAllertaSismica center] saveUserInfo]; + [EQNAllertaSismica sharedInstance].raggioSismiLievi = radius.value; + [[EQNAllertaSismica sharedInstance] saveUserInfo]; [self updateUI]; } - (void)updateStrongSeismicRadius:(EQNGenericValue *)radius { - [EQNAllertaSismica center].raggioSismiForti = radius.value; - [[EQNAllertaSismica center] saveUserInfo]; + [EQNAllertaSismica sharedInstance].raggioSismiForti = radius.value; + [[EQNAllertaSismica sharedInstance] saveUserInfo]; [self updateUI]; } - (void)updateStartTime:(NSDate *)date { - [EQNAllertaSismica center].oraioInizio = date; - [[EQNAllertaSismica center] saveUserInfo]; + [EQNAllertaSismica sharedInstance].oraioInizio = date; + [[EQNAllertaSismica sharedInstance] saveUserInfo]; [self updateUI]; } - (void)updateEndTime:(NSDate *)date { - [EQNAllertaSismica center].orarioFine = date; - [[EQNAllertaSismica center] saveUserInfo]; + [EQNAllertaSismica sharedInstance].orarioFine = date; + [[EQNAllertaSismica sharedInstance] saveUserInfo]; [self updateUI]; } diff --git a/Sources/Earthquake Network/Controllers/Settings/SettingsSeismicNetworkAlertsViewController.m b/Sources/Earthquake Network/Controllers/Settings/SettingsSeismicNetworkAlertsViewController.m index ec8a781..4ab99e7 100644 --- a/Sources/Earthquake Network/Controllers/Settings/SettingsSeismicNetworkAlertsViewController.m +++ b/Sources/Earthquake Network/Controllers/Settings/SettingsSeismicNetworkAlertsViewController.m @@ -7,7 +7,7 @@ // #import "SettingsSeismicNetworkAlertsViewController.h" -#import "EQNNotificeReteSismiche.h" +#import "EQNNotificheReteSismiche.h" @interface SettingsSeismicNetworkAlertsViewController () @@ -88,32 +88,32 @@ typedef NS_ENUM(NSInteger, RowIdentifier) { - (void)updateUI { - self.notificationEnabled = [EQNNotificeReteSismiche center].isAbilitato; - self.notificationNearEarthquakeEnabled = [EQNNotificeReteSismiche center].isAbilitaVicini; - self.notificationStrongEarthquakeEnabled = [EQNNotificeReteSismiche center].isTerremortiForti; + self.notificationEnabled = [EQNNotificheReteSismiche sharedInstance].isAbilitato; + self.notificationNearEarthquakeEnabled = [EQNNotificheReteSismiche sharedInstance].isAbilitaVicini; + self.notificationStrongEarthquakeEnabled = [EQNNotificheReteSismiche sharedInstance].isTerremortiForti; // raggio dalla tua posizione - EQNGenericValue *raggioSisma = [EQNData raggioSismaFor:[EQNNotificeReteSismiche center].distanzaPosizione]; + EQNGenericValue *raggioSisma = [EQNData raggioSismaFor:[EQNNotificheReteSismiche sharedInstance].distanzaPosizione]; self.currentUserPositionRadius = raggioSisma; // energia sisma - EQNGenericValue *energiaSisma = [EQNData magitudoDeboleFor:[EQNNotificeReteSismiche center].energiaSisma]; + EQNGenericValue *energiaSisma = [EQNData magitudoDeboleFor:[EQNNotificheReteSismiche sharedInstance].energiaSisma]; self.currentSeismicEnergy = energiaSisma; // terremoti vicini - EQNGenericValue *terremotiVicini = [EQNData raggioSismaFor:[EQNNotificeReteSismiche center].distanzaVicini]; + EQNGenericValue *terremotiVicini = [EQNData raggioSismaFor:[EQNNotificheReteSismiche sharedInstance].distanzaVicini]; self.currentNearEarthquakeDistance = terremotiVicini; // terremoti forti - EQNGenericValue *terremotiForti = [EQNData magitudoForteFor:[EQNNotificeReteSismiche center].energiaTerremotiForti]; + EQNGenericValue *terremotiForti = [EQNData magitudoForteFor:[EQNNotificheReteSismiche sharedInstance].energiaTerremotiForti]; self.currentStrongEarthquakeDistance = terremotiForti; // enti - if (![EQNNotificeReteSismiche center].listaEnti) { - [EQNNotificeReteSismiche center].listaEnti = [EQNData.seismicNetworkAcronyms copy]; + if (![EQNNotificheReteSismiche sharedInstance].listaEnti) { + [EQNNotificheReteSismiche sharedInstance].listaEnti = [EQNData.seismicNetworkAcronyms copy]; } - [[EQNNotificeReteSismiche center] saveUserInfo]; + [[EQNNotificheReteSismiche sharedInstance] saveUserInfo]; [self.tableView reloadData]; } @@ -151,8 +151,8 @@ typedef NS_ENUM(NSInteger, RowIdentifier) { cell.toggleSwitch.on = self.notificationEnabled; cell.valueChanged = ^(BOOL enabled) { self.notificationEnabled = enabled; - [EQNNotificeReteSismiche center].isAbilitato = self.notificationEnabled; - [[EQNNotificeReteSismiche center] saveUserInfo]; + [EQNNotificheReteSismiche sharedInstance].isAbilitato = self.notificationEnabled; + [[EQNNotificheReteSismiche sharedInstance] saveUserInfo]; [self.tableView reloadData]; }; } else if (indexPath.row == RowIdentifierTerremotiVicini) { @@ -160,8 +160,8 @@ typedef NS_ENUM(NSInteger, RowIdentifier) { cell.isDisabled = !self.notificationEnabled; cell.valueChanged = ^(BOOL enabled) { self.notificationNearEarthquakeEnabled = enabled; - [EQNNotificeReteSismiche center].isAbilitaVicini = self.notificationNearEarthquakeEnabled; - [[EQNNotificeReteSismiche center] saveUserInfo]; + [EQNNotificheReteSismiche sharedInstance].isAbilitaVicini = self.notificationNearEarthquakeEnabled; + [[EQNNotificheReteSismiche sharedInstance] saveUserInfo]; [self.tableView reloadData]; }; } else if (indexPath.row == RowIdentifierTerremotiForti) { @@ -169,8 +169,8 @@ typedef NS_ENUM(NSInteger, RowIdentifier) { cell.isDisabled = !self.notificationEnabled; cell.valueChanged = ^(BOOL enabled) { self.notificationStrongEarthquakeEnabled = enabled; - [EQNNotificeReteSismiche center].isTerremortiForti = self.notificationStrongEarthquakeEnabled; - [[EQNNotificeReteSismiche center] saveUserInfo]; + [EQNNotificheReteSismiche sharedInstance].isTerremortiForti = self.notificationStrongEarthquakeEnabled; + [[EQNNotificheReteSismiche sharedInstance] saveUserInfo]; [self.tableView reloadData]; }; } @@ -230,31 +230,31 @@ typedef NS_ENUM(NSInteger, RowIdentifier) { - (void)updateUserPositionRadius:(EQNGenericValue *)radius { - [EQNNotificeReteSismiche center].distanzaPosizione = radius.value; - [[EQNNotificeReteSismiche center] saveUserInfo]; + [EQNNotificheReteSismiche sharedInstance].distanzaPosizione = radius.value; + [[EQNNotificheReteSismiche sharedInstance] saveUserInfo]; [self updateUI]; } - (void)updateSeismicEnergy:(EQNGenericValue *)energy { - [EQNNotificeReteSismiche center].energiaSisma = energy.value; - [[EQNNotificeReteSismiche center] saveUserInfo]; + [EQNNotificheReteSismiche sharedInstance].energiaSisma = energy.value; + [[EQNNotificheReteSismiche sharedInstance] saveUserInfo]; [self updateUI]; } - (void)updateStrongEarthquakeEnergy:(EQNGenericValue *)energy { - [EQNNotificeReteSismiche center].energiaTerremotiForti = energy.value; - [[EQNNotificeReteSismiche center] saveUserInfo]; + [EQNNotificheReteSismiche sharedInstance].energiaTerremotiForti = energy.value; + [[EQNNotificheReteSismiche sharedInstance] saveUserInfo]; [self updateUI]; } - (NSString *)stringOfSelectedNetworks { - NSArray *networks = [EQNNotificeReteSismiche center].listaEnti; + NSArray *networks = [EQNNotificheReteSismiche sharedInstance].listaEnti; networks = [networks sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; return [networks componentsJoinedByString:@", "]; } diff --git a/Sources/Earthquake Network/Controllers/Settings/SettingsSeismicNetworksViewController.swift b/Sources/Earthquake Network/Controllers/Settings/SettingsSeismicNetworksViewController.swift index 659a434..5c9191d 100644 --- a/Sources/Earthquake Network/Controllers/Settings/SettingsSeismicNetworksViewController.swift +++ b/Sources/Earthquake Network/Controllers/Settings/SettingsSeismicNetworksViewController.swift @@ -42,7 +42,7 @@ class SettingsSeismicNetworksViewController: UITableViewController { let cell = tableView.dequeueReusableCell(withIdentifier: SettingDetailTableViewCell.Identifier, for: indexPath) as! SettingDetailTableViewCell cell.textLabel?.text = "\(network.acronym) (\(network.country))" - if EQNNotificeReteSismiche.center().listaEnti.contains(network.acronym) { + if EQNNotificheReteSismiche.shared().listaEnti.contains(network.acronym) { cell.accessoryType = .checkmark } else { cell.accessoryType = .none @@ -56,15 +56,15 @@ class SettingsSeismicNetworksViewController: UITableViewController { let network = networks[indexPath.row] - var savedNetworks = EQNNotificeReteSismiche.center().listaEnti + var savedNetworks = EQNNotificheReteSismiche.shared().listaEnti if let index = savedNetworks.firstIndex(where: { $0 == network.acronym }) { savedNetworks.remove(at: index) } else { savedNetworks.append(network.acronym) } - EQNNotificeReteSismiche.center().listaEnti = savedNetworks - EQNNotificeReteSismiche.center().saveUserInfo() + EQNNotificheReteSismiche.shared().listaEnti = savedNetworks + EQNNotificheReteSismiche.shared().saveUserInfo() tableView.reloadData() } diff --git a/Sources/Earthquake Network/Controllers/Settings/SettingsUserReportAlertsViewController.m b/Sources/Earthquake Network/Controllers/Settings/SettingsUserReportAlertsViewController.m index 43d1275..b485a20 100644 --- a/Sources/Earthquake Network/Controllers/Settings/SettingsUserReportAlertsViewController.m +++ b/Sources/Earthquake Network/Controllers/Settings/SettingsUserReportAlertsViewController.m @@ -50,11 +50,11 @@ - (void)updateUI { - self.notificationsEnabled = [EQNNotificheSegnalazioniUtente center].isAbilitato; + self.notificationsEnabled = [EQNNotificheSegnalazioniUtente sharedInstance].isAbilitato; - EQNGenericValue *distanzaPosizione = [EQNData raggioSismaFor:[EQNNotificheSegnalazioniUtente center].distanzaPosizione]; + EQNGenericValue *distanzaPosizione = [EQNData raggioSismaFor:[EQNNotificheSegnalazioniUtente sharedInstance].distanzaPosizione]; self.currentRadius = distanzaPosizione; - [[EQNNotificheSegnalazioniUtente center] saveUserInfo]; + [[EQNNotificheSegnalazioniUtente sharedInstance] saveUserInfo]; [self.tableView reloadData]; } @@ -62,8 +62,8 @@ - (void)updateRadius:(EQNGenericValue *)radius { self.currentRadius = radius; - [EQNNotificheSegnalazioniUtente center].distanzaPosizione = radius.value; - [[EQNNotificheSegnalazioniUtente center] saveUserInfo]; + [EQNNotificheSegnalazioniUtente sharedInstance].distanzaPosizione = radius.value; + [[EQNNotificheSegnalazioniUtente sharedInstance] saveUserInfo]; [self.tableView reloadData]; } @@ -98,8 +98,8 @@ cell.descriptionLabel.text = setting.subtitle; cell.valueChanged = ^(BOOL enabled) { self.notificationsEnabled = enabled; - [EQNNotificheSegnalazioniUtente center].isAbilitato = self.notificationsEnabled; - [[EQNNotificheSegnalazioniUtente center] saveUserInfo]; + [EQNNotificheSegnalazioniUtente sharedInstance].isAbilitato = self.notificationsEnabled; + [[EQNNotificheSegnalazioniUtente sharedInstance] saveUserInfo]; [self.tableView reloadData]; }; return cell; diff --git a/Sources/Earthquake Network/Earthquake Network-Bridging-Header.h b/Sources/Earthquake Network/Earthquake Network-Bridging-Header.h index 8849e09..729623c 100644 --- a/Sources/Earthquake Network/Earthquake Network-Bridging-Header.h +++ b/Sources/Earthquake Network/Earthquake Network-Bridging-Header.h @@ -6,5 +6,5 @@ #import "Costanti.h" #import "EQNUser.h" #import "EQNManager.h" -#import "EQNNotificeReteSismiche.h" +#import "EQNNotificheReteSismiche.h" #import "EQNSisma.h" diff --git a/Sources/Earthquake Network/model/impostazioni notifiche/EQNAllertaSismica.h b/Sources/Earthquake Network/Models/Settings/EQNAllertaSismica.h similarity index 81% rename from Sources/Earthquake Network/model/impostazioni notifiche/EQNAllertaSismica.h rename to Sources/Earthquake Network/Models/Settings/EQNAllertaSismica.h index cc2484c..74d10ed 100644 --- a/Sources/Earthquake Network/model/impostazioni notifiche/EQNAllertaSismica.h +++ b/Sources/Earthquake Network/Models/Settings/EQNAllertaSismica.h @@ -2,8 +2,8 @@ // EQNAllertaSismica.h // Earthquake Network // -// Created by Luca Beretta on 15/01/2019. -// Copyright © 2019 Luca Beretta. All rights reserved. +// Refactored by Andrea Busi on 21/09/2020 +// Copyright © 2020 Earthquake Network. All rights reserved. // #import @@ -26,9 +26,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong) NSArray *listaMessaggi; @property (nonatomic, strong) NSArray *listaAreeInteresse; -+(EQNAllertaSismica *)center; --(void)saveUserInfo; --(void)removeUser; ++ (instancetype)sharedInstance NS_SWIFT_NAME(shared()); +- (void)saveUserInfo; @end diff --git a/Sources/Earthquake Network/Models/Settings/EQNAllertaSismica.m b/Sources/Earthquake Network/Models/Settings/EQNAllertaSismica.m new file mode 100644 index 0000000..219be4a --- /dev/null +++ b/Sources/Earthquake Network/Models/Settings/EQNAllertaSismica.m @@ -0,0 +1,63 @@ +// +// EQNAllertaSismica.m +// Earthquake Network +// +// Refactored by Andrea Busi on 21/09/2020 +// Copyright © 2020 Earthquake Network. All rights reserved. +// + +#import "EQNAllertaSismica.h" +#import "Costanti.h" + + +@implementation EQNAllertaSismica + +#pragma mark - Singleton + ++ (instancetype)sharedInstance +{ + static EQNAllertaSismica *instance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [[self alloc] init]; + }); + return instance; +} + +#pragma mark - Init + +- (instancetype)init +{ + self = [super init]; + if (self) { + self.isAbilitato = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_ALLERA_SISMICA_ABILITATO]; + self.isSimiSenzaIntensita = NO; // parametro rimosso dalle impostazioni, manteniamo l'invio al server come false + self.sismiDaNotificare = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ALLERA_SISMICA_SISMI_DA_NOTIFICARE]; + self.raggioSismiLievi = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ALLERA_SISMICA_RAGGIO_SISMI_LIEVI]; + self.tonoAllarme = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ALLERA_SISMICA_TONO_ALLARME]; + if (!self.tonoAllarme) { + self.tonoAllarme = @"alert_star_trek.wav"; + } + self.isintervalloAllarme = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_ALLERA_SISMICA_ABILITA_INTERVALLO]; + self.oraioInizio = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ALLERA_SISMICA_ORA_INIZIO]; + self.orarioFine = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ALLERA_SISMICA_ORA_FINE]; + } + return self; +} + +#pragma mark - Public + +- (void)saveUserInfo +{ + [[NSUserDefaults standardUserDefaults] setBool:self.isAbilitato forKey:NOTIFICHE_ABILITATO_TSUNAMI]; + [[NSUserDefaults standardUserDefaults] setObject:self.sismiDaNotificare forKey:NOTIFICHE_ALLERA_SISMICA_SISMI_DA_NOTIFICARE]; + [[NSUserDefaults standardUserDefaults] setObject:self.raggioSismiLievi forKey:NOTIFICHE_ALLERA_SISMICA_RAGGIO_SISMI_LIEVI]; + [[NSUserDefaults standardUserDefaults] setObject:self.tonoAllarme forKey:NOTIFICHE_ALLERA_SISMICA_TONO_ALLARME]; + [[NSUserDefaults standardUserDefaults] setBool:self.isintervalloAllarme forKey:NOTIFICHE_ALLERA_SISMICA_ABILITA_INTERVALLO]; + [[NSUserDefaults standardUserDefaults] setObject:self.oraioInizio forKey:NOTIFICHE_ALLERA_SISMICA_ORA_INIZIO]; + [[NSUserDefaults standardUserDefaults] setObject:self.orarioFine forKey:NOTIFICHE_ALLERA_SISMICA_ORA_FINE]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + + +@end diff --git a/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificeReteSismiche.h b/Sources/Earthquake Network/Models/Settings/EQNNotificheReteSismiche.h similarity index 68% rename from Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificeReteSismiche.h rename to Sources/Earthquake Network/Models/Settings/EQNNotificheReteSismiche.h index f8b6ffb..6efe80a 100644 --- a/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificeReteSismiche.h +++ b/Sources/Earthquake Network/Models/Settings/EQNNotificheReteSismiche.h @@ -1,16 +1,16 @@ // -// EQNNotificeReteSismiche.h +// EQNNotificheReteSismiche.h // Earthquake Network // -// Created by Luca Beretta on 10/01/2019. -// Copyright © 2019 Luca Beretta. All rights reserved. +// Refactored by Andrea Busi on 21/09/2020 +// Copyright © 2020 Earthquake Network. All rights reserved. // #import NS_ASSUME_NONNULL_BEGIN -@interface EQNNotificeReteSismiche : NSObject +@interface EQNNotificheReteSismiche : NSObject @property (nonatomic, assign) BOOL isAbilitato; @property (nonatomic, assign) BOOL isAbilitaVicini; @@ -21,9 +21,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong) NSString *distanzaVicini; @property (nonatomic, strong) NSString *energiaTerremotiForti; -+(EQNNotificeReteSismiche *)center; --(void)saveUserInfo; --(void)removeUser; ++ (instancetype)sharedInstance NS_SWIFT_NAME(shared()); +- (void)saveUserInfo; @end diff --git a/Sources/Earthquake Network/Models/Settings/EQNNotificheReteSismiche.m b/Sources/Earthquake Network/Models/Settings/EQNNotificheReteSismiche.m new file mode 100644 index 0000000..dc2ee8f --- /dev/null +++ b/Sources/Earthquake Network/Models/Settings/EQNNotificheReteSismiche.m @@ -0,0 +1,60 @@ +// +// EQNNotificheReteSismiche.m +// Earthquake Network +// +// Refactored by Andrea Busi on 21/09/2020 +// Copyright © 2020 Earthquake Network. All rights reserved. +// + +#import "EQNNotificheReteSismiche.h" +#import "Costanti.h" +#import "EQNUtility.h" + + +@implementation EQNNotificheReteSismiche + +#pragma mark - Singleton + ++ (instancetype)sharedInstance +{ + static EQNNotificheReteSismiche *instance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [[self alloc] init]; + }); + return instance; +} + +#pragma mark - Init + +- (instancetype)init +{ + self = [super init]; + if (self) { + self.isAbilitato = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_ATTIVA_RETI_SISMICHE]; + self.isAbilitaVicini = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_ATTIVA_RETI_SISMICHE_VICINE]; + self.isTerremortiForti = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_ATTIVA_RETI_TERREMOTI_FORTI]; + self.distanzaPosizione = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_DISTANZA_POSIZIONE_RETI_SISMICHE]; + self.energiaSisma = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ATTIVA_RETI_ENERGIA_SISMI]; + self.distanzaVicini = @"50"; // parametro rimosso dalle impostazioni, valore fisso inviato al server + self.energiaTerremotiForti = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ATTIVA_RETI_ENERGIA_FORTI]; + self.listaEnti = (NSArray *)[EQNUtility loadCustomObjectWithKey:NOTIFICHE_ATTIVA_RETI_LISTA_ENTI]; + } + return self; +} + +#pragma mark - Public + +- (void)saveUserInfo +{ + [[NSUserDefaults standardUserDefaults] setObject:self.distanzaPosizione forKey:NOTIFICHE_DISTANZA_POSIZIONE_RETI_SISMICHE]; + [[NSUserDefaults standardUserDefaults] setObject:self.energiaSisma forKey:NOTIFICHE_ATTIVA_RETI_ENERGIA_SISMI]; + [[NSUserDefaults standardUserDefaults] setObject:self.energiaTerremotiForti forKey:NOTIFICHE_ATTIVA_RETI_ENERGIA_FORTI]; + [[NSUserDefaults standardUserDefaults] setBool:self.isAbilitato forKey:NOTIFICHE_ATTIVA_RETI_SISMICHE]; + [[NSUserDefaults standardUserDefaults] setBool:self.isAbilitaVicini forKey:NOTIFICHE_ATTIVA_RETI_SISMICHE_VICINE]; + [[NSUserDefaults standardUserDefaults] setBool:self.isTerremortiForti forKey:NOTIFICHE_ATTIVA_RETI_TERREMOTI_FORTI]; + [EQNUtility saveCustomObject:self.listaEnti key:NOTIFICHE_ATTIVA_RETI_LISTA_ENTI]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} + +@end diff --git a/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheSegnalazioniUtente.h b/Sources/Earthquake Network/Models/Settings/EQNNotificheSegnalazioniUtente.h similarity index 63% rename from Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheSegnalazioniUtente.h rename to Sources/Earthquake Network/Models/Settings/EQNNotificheSegnalazioniUtente.h index 214dcc8..483a145 100644 --- a/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheSegnalazioniUtente.h +++ b/Sources/Earthquake Network/Models/Settings/EQNNotificheSegnalazioniUtente.h @@ -2,8 +2,8 @@ // EQNNotificheSegnalazioniUtente.h // Earthquake Network // -// Created by Luca Beretta on 10/01/2019. -// Copyright © 2019 Luca Beretta. All rights reserved. +// Refactored by Andrea Busi on 21/09/2020 +// Copyright © 2020 Earthquake Network. All rights reserved. // #import @@ -16,9 +16,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong) NSString *distanzaPosizione; -+(EQNNotificheSegnalazioniUtente *)center; --(void)saveUserInfo; --(void)removeUser; ++ (instancetype)sharedInstance NS_SWIFT_NAME(shared()); +- (void)saveUserInfo; @end diff --git a/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheSegnalazioniUtente.m b/Sources/Earthquake Network/Models/Settings/EQNNotificheSegnalazioniUtente.m similarity index 52% rename from Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheSegnalazioniUtente.m rename to Sources/Earthquake Network/Models/Settings/EQNNotificheSegnalazioniUtente.m index 8a7f7a1..9a9a758 100644 --- a/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheSegnalazioniUtente.m +++ b/Sources/Earthquake Network/Models/Settings/EQNNotificheSegnalazioniUtente.m @@ -2,8 +2,8 @@ // EQNNotificheSegnalazioniUtente.m // Earthquake Network // -// Created by Luca Beretta on 10/01/2019. -// Copyright © 2019 Luca Beretta. All rights reserved. +// Refactored by Andrea Busi on 21/09/2020 +// Copyright © 2020 Earthquake Network. All rights reserved. // #import "EQNNotificheSegnalazioniUtente.h" @@ -11,37 +11,37 @@ @implementation EQNNotificheSegnalazioniUtente -+(EQNNotificheSegnalazioniUtente *)center{ - +#pragma mark - Singleton + ++ (instancetype)sharedInstance +{ static EQNNotificheSegnalazioniUtente *instance = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - instance = [[self alloc]init]; - [instance initSingleton]; + instance = [[self alloc] init]; }); return instance; } --(void)initSingleton{ - - self.isAbilitato = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_SU_ATTIVA_SEGNALAZIONE_UTENTE]; - self.distanzaPosizione = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_SU_DISTANZA_POSIZIONE]; - +#pragma mark - Init + +- (instancetype)init +{ + self = [super init]; + if (self) { + self.isAbilitato = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_SU_ATTIVA_SEGNALAZIONE_UTENTE]; + self.distanzaPosizione = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_SU_DISTANZA_POSIZIONE]; + } + return self; } --(void)saveUserInfo{ - +#pragma mark - Public + +- (void)saveUserInfo +{ [[NSUserDefaults standardUserDefaults] setObject:self.distanzaPosizione forKey:NOTIFICHE_SU_DISTANZA_POSIZIONE]; [[NSUserDefaults standardUserDefaults] setBool:self.isAbilitato forKey:NOTIFICHE_SU_ATTIVA_SEGNALAZIONE_UTENTE]; [[NSUserDefaults standardUserDefaults] synchronize]; - } --(void)removeUser{ - - - -} - - @end diff --git a/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheTsunami.h b/Sources/Earthquake Network/Models/Settings/EQNNotificheTsunami.h similarity index 100% rename from Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheTsunami.h rename to Sources/Earthquake Network/Models/Settings/EQNNotificheTsunami.h diff --git a/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheTsunami.m b/Sources/Earthquake Network/Models/Settings/EQNNotificheTsunami.m similarity index 100% rename from Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheTsunami.m rename to Sources/Earthquake Network/Models/Settings/EQNNotificheTsunami.m diff --git a/Sources/Earthquake Network/model/EQNGeneratoreURLServer.m b/Sources/Earthquake Network/model/EQNGeneratoreURLServer.m index 66afc42..974b7ae 100644 --- a/Sources/Earthquake Network/model/EQNGeneratoreURLServer.m +++ b/Sources/Earthquake Network/model/EQNGeneratoreURLServer.m @@ -11,13 +11,11 @@ #import "EQNUser.h" #import "EQNCalibrazione.h" #import "EQNRilevamento.h" -#import -#import "EQNImpostazioniNotifiche.h" -#import "EQNNotificheTempoReale.h" #import "EQNNotificheSegnalazioniUtente.h" -#import "EQNNotificeReteSismiche.h" +#import "EQNNotificheReteSismiche.h" #import "EQNNotificheTsunami.h" #import "EQNAllertaSismica.h" +#import @implementation EQNGeneratoreURLServer @@ -140,12 +138,12 @@ +(NSURL *)urlInvioImpostazioniNotifiche{ - NSString *n_e = [NSString stringWithFormat:@"&n_e=%i",[EQNAllertaSismica center].isAbilitato]; + NSString *n_e = [NSString stringWithFormat:@"&n_e=%i",[EQNAllertaSismica sharedInstance].isAbilitato]; - NSString *n_m = [NSString stringWithFormat:@"&n_m=%i",[EQNNotificheSegnalazioniUtente center].isAbilitato]; - NSString *n_o = [NSString stringWithFormat:@"&n_o=%i",[EQNNotificeReteSismiche center].isAbilitato]; - NSString *n_o_near = [NSString stringWithFormat:@"&n_o_near=%i",[EQNNotificeReteSismiche center].isAbilitaVicini]; - NSString *n_o_mag = [NSString stringWithFormat:@"&n_o_mag=%@",[EQNNotificeReteSismiche center].energiaSisma]; + NSString *n_m = [NSString stringWithFormat:@"&n_m=%i",[EQNNotificheSegnalazioniUtente sharedInstance].isAbilitato]; + NSString *n_o = [NSString stringWithFormat:@"&n_o=%i",[EQNNotificheReteSismiche sharedInstance].isAbilitato]; + NSString *n_o_near = [NSString stringWithFormat:@"&n_o_near=%i",[EQNNotificheReteSismiche sharedInstance].isAbilitaVicini]; + NSString *n_o_mag = [NSString stringWithFormat:@"&n_o_mag=%@",[EQNNotificheReteSismiche sharedInstance].energiaSisma]; NSString *n_tsu = [NSString stringWithFormat:@"&n_tsu=%i",[EQNNotificheTsunami center].isAbilitato]; NSString *n_o_usgs = @"&n_o_usgs=0"; @@ -167,7 +165,7 @@ NSString *n_o_igp = @"&n_o_igp=0"; NSString *n_o_uasd = @"&n_o_uasd=0"; - for (NSString *ente in [EQNNotificeReteSismiche center].listaEnti) { + for (NSString *ente in [EQNNotificheReteSismiche sharedInstance].listaEnti) { if ([ente isEqualToString:@"USGS"]) n_o_usgs = @"&n_o_usgs=1"; @@ -208,7 +206,7 @@ } NSString *enti = [NSString stringWithFormat:@"%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@%@", n_o_usgs, n_o_emsc, n_o_ingv, n_o_ign, n_o_csi, n_o_jma, n_o_ineter, n_o_ssn, n_o_sgc, n_o_rsn, n_o_csn, n_o_funvisis, n_o_geonet, n_o_inpres, n_o_igepn, n_o_phivolcs, n_o_igp, n_o_uasd]; - NSString *n_o_strong = [NSString stringWithFormat:@"n_o_strong=%i",[EQNNotificeReteSismiche center].isTerremortiForti]; + NSString *n_o_strong = [NSString stringWithFormat:@"n_o_strong=%i",[EQNNotificheReteSismiche sharedInstance].isTerremortiForti]; NSString *n_tsu_car = @"&n_tsu_car=1"; NSString *n_tsu_pac = @"&n_tsu_pac=1"; @@ -229,38 +227,38 @@ } NSString *n_tsu_aree = [NSString stringWithFormat:@"%@%@%@",n_tsu_car, n_tsu_pac, n_tsu_haw]; - NSString *n_e_unk = [NSString stringWithFormat:@"&n_e_unk=%i", [EQNAllertaSismica center].isSimiSenzaIntensita]; + NSString *n_e_unk = [NSString stringWithFormat:@"&n_e_unk=%i", [EQNAllertaSismica sharedInstance].isSimiSenzaIntensita]; - NSString *n_o_strmag = [NSString stringWithFormat:@"&n_o_strmag=%@", [EQNNotificeReteSismiche center].energiaTerremotiForti]; - if ([[EQNAllertaSismica center].sismiDaNotificare isEqualToString:NSLocalizedString(@"Qualsiasi intensità", @"")]) + NSString *n_o_strmag = [NSString stringWithFormat:@"&n_o_strmag=%@", [EQNNotificheReteSismiche sharedInstance].energiaTerremotiForti]; + if ([[EQNAllertaSismica sharedInstance].sismiDaNotificare isEqualToString:NSLocalizedString(@"Qualsiasi intensità", @"")]) n_o_strmag = @"&n_o_strmag=0"; - NSString *r_e_mild = [NSString stringWithFormat:@"&r_e_mild=%@", [EQNAllertaSismica center].raggioSismiLievi]; + NSString *r_e_mild = [NSString stringWithFormat:@"&r_e_mild=%@", [EQNAllertaSismica sharedInstance].raggioSismiLievi]; - if ([[EQNAllertaSismica center].raggioSismiLievi isEqualToString:NSLocalizedString(@"Qualsiasi distanza", @"")]) + if ([[EQNAllertaSismica sharedInstance].raggioSismiLievi isEqualToString:NSLocalizedString(@"Qualsiasi distanza", @"")]) r_e_mild = @"&r_e_mild=100000"; - NSString *r_e_strong = [NSString stringWithFormat:@"&r_e_strong=%@", [EQNAllertaSismica center].raggioSismiForti]; + NSString *r_e_strong = [NSString stringWithFormat:@"&r_e_strong=%@", [EQNAllertaSismica sharedInstance].raggioSismiForti]; - if ([[EQNAllertaSismica center].raggioSismiForti isEqualToString:NSLocalizedString(@"Qualsiasi distanza", @"")]) + if ([[EQNAllertaSismica sharedInstance].raggioSismiForti isEqualToString:NSLocalizedString(@"Qualsiasi distanza", @"")]) r_e_strong = @"&r_e_strong=100000"; - NSString *r_m = [NSString stringWithFormat:@"&r_m=%@", [EQNNotificheSegnalazioniUtente center].distanzaPosizione]; - if ([[EQNNotificheSegnalazioniUtente center].distanzaPosizione isEqualToString:NSLocalizedString(@"Qualsiasi distanza", @"")]) + NSString *r_m = [NSString stringWithFormat:@"&r_m=%@", [EQNNotificheSegnalazioniUtente sharedInstance].distanzaPosizione]; + if ([[EQNNotificheSegnalazioniUtente sharedInstance].distanzaPosizione isEqualToString:NSLocalizedString(@"Qualsiasi distanza", @"")]) r_m = @"&r_m=100000"; - NSString *r_o = [NSString stringWithFormat:@"&r_o=%@", [EQNNotificeReteSismiche center].distanzaPosizione]; - if ([[EQNNotificeReteSismiche center].distanzaPosizione isEqualToString:NSLocalizedString(@"Qualsiasi distanza", @"")]) + NSString *r_o = [NSString stringWithFormat:@"&r_o=%@", [EQNNotificheReteSismiche sharedInstance].distanzaPosizione]; + if ([[EQNNotificheReteSismiche sharedInstance].distanzaPosizione isEqualToString:NSLocalizedString(@"Qualsiasi distanza", @"")]) r_o = @"&r_o=100000"; - NSString *r_o_near = [NSString stringWithFormat:@"&r_o_near=%@", [EQNNotificeReteSismiche center].distanzaVicini]; - if ([[EQNNotificeReteSismiche center].distanzaPosizione isEqualToString:NSLocalizedString(@"Qualsiasi distanza", @"")]) + NSString *r_o_near = [NSString stringWithFormat:@"&r_o_near=%@", [EQNNotificheReteSismiche sharedInstance].distanzaVicini]; + if ([[EQNNotificheReteSismiche sharedInstance].distanzaPosizione isEqualToString:NSLocalizedString(@"Qualsiasi distanza", @"")]) r_o_near = @"&r_o_near=100000"; // da sistemare - NSString *n_e_type = [NSString stringWithFormat:@"&n_e_type=%@", [EQNAllertaSismica center].sismiDaNotificare]; + NSString *n_e_type = [NSString stringWithFormat:@"&n_e_type=%@", [EQNAllertaSismica sharedInstance].sismiDaNotificare]; NSString *stringUrl = [NSString stringWithFormat:@"%@?u_id=%@&lat=%f&lon=%f%@%@%@%@%@%@%@&ios=1&%@%@%@%@%@%@%@%@%@%@",URL_SERVER_UPLOAD_IMPOSTAZIONI, [EQNUser defaultUser].user_ID, [EQNUser defaultUser].lastPosition.coordinate.latitude, [EQNUser defaultUser].lastPosition.coordinate.longitude, n_e, n_m, n_o, n_o_near,n_o_mag, enti, n_tsu, n_o_strong,n_tsu_aree, n_e_type, n_e_unk, n_o_strmag, r_e_mild, r_e_strong, r_m, r_o, r_o_near]; diff --git a/Sources/Earthquake Network/model/impostazioni notifiche/EQNAllertaSismica.m b/Sources/Earthquake Network/model/impostazioni notifiche/EQNAllertaSismica.m deleted file mode 100644 index 7b2a433..0000000 --- a/Sources/Earthquake Network/model/impostazioni notifiche/EQNAllertaSismica.m +++ /dev/null @@ -1,61 +0,0 @@ -// -// EQNAllertaSismica.m -// Earthquake Network -// -// Created by Luca Beretta on 15/01/2019. -// Copyright © 2019 Luca Beretta. All rights reserved. -// - -#import "EQNAllertaSismica.h" -#import "Costanti.h" -@implementation EQNAllertaSismica - -+(EQNAllertaSismica *)center{ - - static EQNAllertaSismica *instance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - instance = [[self alloc]init]; - [instance initSingleton]; - }); - return instance; -} - --(void)initSingleton{ - - self.isAbilitato = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_ALLERA_SISMICA_ABILITATO]; - self.isSimiSenzaIntensita = NO; // parametro rimosso dalle impostazioni, manteniamo l'invio al server come false - self.sismiDaNotificare = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ALLERA_SISMICA_SISMI_DA_NOTIFICARE]; - self.raggioSismiLievi = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ALLERA_SISMICA_RAGGIO_SISMI_LIEVI]; - self.tonoAllarme = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ALLERA_SISMICA_TONO_ALLARME]; - if (!self.tonoAllarme) - self.tonoAllarme = @"alert_star_trek.wav"; - - self.isintervalloAllarme = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_ALLERA_SISMICA_ABILITA_INTERVALLO]; - self.oraioInizio = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ALLERA_SISMICA_ORA_INIZIO]; - self.orarioFine = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ALLERA_SISMICA_ORA_FINE]; - - -} - --(void)saveUserInfo{ - - [[NSUserDefaults standardUserDefaults] setBool:self.isAbilitato forKey:NOTIFICHE_ABILITATO_TSUNAMI]; - [[NSUserDefaults standardUserDefaults] setObject:self.sismiDaNotificare forKey:NOTIFICHE_ALLERA_SISMICA_SISMI_DA_NOTIFICARE]; - [[NSUserDefaults standardUserDefaults] setObject:self.raggioSismiLievi forKey:NOTIFICHE_ALLERA_SISMICA_RAGGIO_SISMI_LIEVI]; - [[NSUserDefaults standardUserDefaults] setObject:self.tonoAllarme forKey:NOTIFICHE_ALLERA_SISMICA_TONO_ALLARME]; - [[NSUserDefaults standardUserDefaults] setBool:self.isintervalloAllarme forKey:NOTIFICHE_ALLERA_SISMICA_ABILITA_INTERVALLO]; - [[NSUserDefaults standardUserDefaults] setObject:self.oraioInizio forKey:NOTIFICHE_ALLERA_SISMICA_ORA_INIZIO]; - [[NSUserDefaults standardUserDefaults] setObject:self.orarioFine forKey:NOTIFICHE_ALLERA_SISMICA_ORA_FINE]; - [[NSUserDefaults standardUserDefaults] synchronize]; - - -} - --(void)removeUser{ - - - -} - -@end diff --git a/Sources/Earthquake Network/model/impostazioni notifiche/EQNImpostazioniNotifiche.h b/Sources/Earthquake Network/model/impostazioni notifiche/EQNImpostazioniNotifiche.h deleted file mode 100644 index f4e7498..0000000 --- a/Sources/Earthquake Network/model/impostazioni notifiche/EQNImpostazioniNotifiche.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// EQNImpostazioniNotifiche.h -// Earthquake Network -// -// Created by Luca Beretta on 09/01/2019. -// Copyright © 2019 Luca Beretta. All rights reserved. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface EQNImpostazioniNotifiche : NSObject - -@property (nonatomic, assign) BOOL attivaIntervalloNotifica; - -@property (nonatomic, strong) NSDate *oraioInizio; -@property (nonatomic, strong) NSDate *orarioFine; - -@property (nonatomic, strong) NSString *distanzaRetiSismiche; - -+(EQNImpostazioniNotifiche *)center; --(void)saveUserInfo; --(void)removeUser; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Sources/Earthquake Network/model/impostazioni notifiche/EQNImpostazioniNotifiche.m b/Sources/Earthquake Network/model/impostazioni notifiche/EQNImpostazioniNotifiche.m deleted file mode 100644 index a13479c..0000000 --- a/Sources/Earthquake Network/model/impostazioni notifiche/EQNImpostazioniNotifiche.m +++ /dev/null @@ -1,51 +0,0 @@ -// -// EQNImpostazioniNotifiche.m -// Earthquake Network -// -// Created by Luca Beretta on 09/01/2019. -// Copyright © 2019 Luca Beretta. All rights reserved. -// - -#import "EQNImpostazioniNotifiche.h" -#import "Costanti.h" - -@implementation EQNImpostazioniNotifiche - -+(EQNImpostazioniNotifiche *)center{ - - static EQNImpostazioniNotifiche *instance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - instance = [[self alloc]init]; - [instance initSingleton]; - }); - return instance; -} - --(void)initSingleton{ - - self.oraioInizio = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ORA_INIZIO]; - self.orarioFine = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ORA_FINE]; - self.attivaIntervalloNotifica = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_ATTIVA_ORARIO]; - -} - --(void)saveUserInfo{ - - [[NSUserDefaults standardUserDefaults] setObject:self.oraioInizio forKey:NOTIFICHE_ORA_INIZIO]; - [[NSUserDefaults standardUserDefaults] setObject:self.orarioFine forKey:NOTIFICHE_ORA_FINE]; - [[NSUserDefaults standardUserDefaults] setBool:self.attivaIntervalloNotifica forKey:NOTIFICHE_ATTIVA_ORARIO]; - [[NSUserDefaults standardUserDefaults] synchronize]; - -} - --(void)removeUser{ - - [[NSUserDefaults standardUserDefaults] removeObjectForKey:NOTIFICHE_ORA_INIZIO]; - [[NSUserDefaults standardUserDefaults] removeObjectForKey:NOTIFICHE_ORA_FINE]; - [[NSUserDefaults standardUserDefaults] removeObjectForKey:NOTIFICHE_ATTIVA_ORARIO]; - [[NSUserDefaults standardUserDefaults] synchronize]; - -} - -@end diff --git a/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificeReteSismiche.m b/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificeReteSismiche.m deleted file mode 100644 index 81f9f3a..0000000 --- a/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificeReteSismiche.m +++ /dev/null @@ -1,71 +0,0 @@ -// -// EQNNotificeReteSismiche.m -// Earthquake Network -// -// Created by Luca Beretta on 10/01/2019. -// Copyright © 2019 Luca Beretta. All rights reserved. -// - -#import "EQNNotificeReteSismiche.h" -#import "Costanti.h" -#import "EQNUtility.h" -@implementation EQNNotificeReteSismiche - -+(EQNNotificeReteSismiche *)center{ - - static EQNNotificeReteSismiche *instance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - instance = [[self alloc]init]; - [instance initSingleton]; - }); - return instance; -} - --(void)initSingleton{ - - self.isAbilitato = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_ATTIVA_RETI_SISMICHE]; - self.isAbilitaVicini = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_ATTIVA_RETI_SISMICHE_VICINE]; - self.isTerremortiForti = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_ATTIVA_RETI_TERREMOTI_FORTI]; - - self.distanzaPosizione = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_DISTANZA_POSIZIONE_RETI_SISMICHE]; - - self.energiaSisma = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ATTIVA_RETI_ENERGIA_SISMI]; - - self.distanzaVicini = @"50"; // parametro rimosso dalle impostazioni, valore fisso inviato al server - - self.energiaTerremotiForti = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_ATTIVA_RETI_ENERGIA_FORTI]; - - self.listaEnti = (NSArray *)[EQNUtility loadCustomObjectWithKey:NOTIFICHE_ATTIVA_RETI_LISTA_ENTI]; - - -} - --(void)saveUserInfo{ - - [[NSUserDefaults standardUserDefaults] setObject:self.distanzaPosizione forKey:NOTIFICHE_DISTANZA_POSIZIONE_RETI_SISMICHE]; - - [[NSUserDefaults standardUserDefaults] setObject:self.energiaSisma forKey:NOTIFICHE_ATTIVA_RETI_ENERGIA_SISMI]; - - [[NSUserDefaults standardUserDefaults] setObject:self.energiaTerremotiForti forKey:NOTIFICHE_ATTIVA_RETI_ENERGIA_FORTI]; - - [[NSUserDefaults standardUserDefaults] setBool:self.isAbilitato forKey:NOTIFICHE_ATTIVA_RETI_SISMICHE]; - - [[NSUserDefaults standardUserDefaults] setBool:self.isAbilitaVicini forKey:NOTIFICHE_ATTIVA_RETI_SISMICHE_VICINE]; - - [[NSUserDefaults standardUserDefaults] setBool:self.isTerremortiForti forKey:NOTIFICHE_ATTIVA_RETI_TERREMOTI_FORTI]; - - [EQNUtility saveCustomObject:self.listaEnti key:NOTIFICHE_ATTIVA_RETI_LISTA_ENTI]; - - [[NSUserDefaults standardUserDefaults] synchronize]; - -} - --(void)removeUser{ - - - -} - - -@end diff --git a/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheTempoReale.h b/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheTempoReale.h deleted file mode 100644 index 588bd48..0000000 --- a/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheTempoReale.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// EQNNotificheTempoReale.h -// Earthquake Network -// -// Created by Luca Beretta on 10/01/2019. -// Copyright © 2019 Luca Beretta. All rights reserved. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface EQNNotificheTempoReale : NSObject - -@property (nonatomic, strong) NSString *distanzaTempoRealeLievi; -@property (nonatomic, strong) NSString *distanzaTempoRealeForti; - -@property (nonatomic, assign) BOOL attivaTempoReale; -@property (nonatomic, assign) BOOL attivaSismiSenzaIntensita; -@property (nonatomic, assign) BOOL isSismiForti; - -+(EQNNotificheTempoReale *)center; --(void)saveUserInfo; --(void)removeUser; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheTempoReale.m b/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheTempoReale.m deleted file mode 100644 index dcbb988..0000000 --- a/Sources/Earthquake Network/model/impostazioni notifiche/EQNNotificheTempoReale.m +++ /dev/null @@ -1,55 +0,0 @@ -// -// EQNNotificheTempoReale.m -// Earthquake Network -// -// Created by Luca Beretta on 10/01/2019. -// Copyright © 2019 Luca Beretta. All rights reserved. -// - -#import "EQNNotificheTempoReale.h" -#import "Costanti.h" -@implementation EQNNotificheTempoReale - - -+(EQNNotificheTempoReale *)center{ - - static EQNNotificheTempoReale *instance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - instance = [[self alloc]init]; - [instance initSingleton]; - }); - return instance; -} - --(void)initSingleton{ - - self.distanzaTempoRealeLievi = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_TR_DISTANZA_TEMPO_REALE_LIEVE]; - self.distanzaTempoRealeForti = [[NSUserDefaults standardUserDefaults] objectForKey:NOTIFICHE_TR_DISTANZA_TEMPO_REALE_FORTE]; - - self.attivaTempoReale = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_TR_ATTIVA_TEMPO_REALE]; - self.attivaSismiSenzaIntensita = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_TR_ATTIVA_SISMI_SENZA_INTENSITA]; - self.isSismiForti = [[NSUserDefaults standardUserDefaults] boolForKey:NOTIFICHE_TR_ATTIVA_SISMI_FORTI]; - -} - --(void)saveUserInfo{ - - [[NSUserDefaults standardUserDefaults] setObject:self.distanzaTempoRealeLievi forKey:NOTIFICHE_TR_DISTANZA_TEMPO_REALE_LIEVE]; - [[NSUserDefaults standardUserDefaults] setObject:self.distanzaTempoRealeForti forKey:NOTIFICHE_TR_DISTANZA_TEMPO_REALE_FORTE]; - - [[NSUserDefaults standardUserDefaults] setBool:self.attivaTempoReale forKey:NOTIFICHE_TR_ATTIVA_TEMPO_REALE]; - [[NSUserDefaults standardUserDefaults] setBool:self.attivaSismiSenzaIntensita forKey:NOTIFICHE_TR_ATTIVA_SISMI_SENZA_INTENSITA]; - [[NSUserDefaults standardUserDefaults] setBool:self.isSismiForti forKey:NOTIFICHE_TR_ATTIVA_SISMI_FORTI]; - [[NSUserDefaults standardUserDefaults] synchronize]; - -} - --(void)removeUser{ - - - -} - - -@end