Compare commits

..

50 Commits

Author SHA1 Message Date
Andrea Busi 122cf497b3 release: Increase version for release 2020-10-16 18:28:51 +02:00
Andrea Busi 361b51a5a2 fix: Use proper value when creating url for test alert 2020-10-16 18:28:51 +02:00
Andrea Busi bbfd28c5d2 dependency: Update Pods 2020-10-15 11:51:46 +02:00
Andrea Busi e399c53de1 feat: Add countdown inside notification content
Resolves: https://gitlab.steamware.net/eqn/eqn.ios/-/issues/28
2020-10-15 11:47:54 +02:00
Andrea Busi d8c0d48ad2 refactor: Improve notification content layout and cleanup code 2020-10-15 08:40:03 +02:00
Andrea Busi a474d5782f refactor: Improve style and comments for EQNUtility class 2020-10-15 08:40:03 +02:00
Andrea Busi c538ca7dcb refactor: Move ads utility in a dedicated class 2020-10-15 08:40:03 +02:00
Andrea Busi b11af3d138 fix: Explicit import StoreKit 2020-10-15 08:40:02 +02:00
Andrea Busi 8e1b1bd5a7 refactor: Remove not yet used sounds 2020-10-13 11:23:38 +02:00
Andrea Busi 67546801ac release: Increase version for release 2020-10-13 08:08:48 +02:00
Andrea Busi 6135e2d38c refactor: Rename some constants 2020-10-13 08:08:48 +02:00
Andrea Busi e46fa0417d refactor: Update notification sound and remove not yet used setting parameter 2020-10-13 08:08:48 +02:00
Andrea Busi dc6bb13960 refactor: Load notification icons from current bundle, instead of download every time from the server 2020-10-13 08:08:48 +02:00
Andrea Busi 6aecff1415 fix: Play notification sound also with app in foreground 2020-10-12 21:10:07 +02:00
Andrea Busi 6fcf58608f refactor: Remove notification logic related to tsunami 2020-10-12 21:10:07 +02:00
Andrea Busi 65ed82445b fix: Solve issue that cause 30 seconds delay to display push notifications
Also apply some refactor to improve code style
2020-10-12 21:10:07 +02:00
Andrea Busi ab727b119b fix: Disable zoom in map 2020-10-12 21:10:07 +02:00
Andrea Busi 1bd833093b refactor: Hide "Simulator" button in home 2020-10-12 21:10:07 +02:00
Andrea Busi 904d4c5de8 refactor: Change text when seismic table is empty 2020-10-12 21:10:07 +02:00
Andrea Busi 720d0fcd2a fix: Disable selection for "location data" cell 2020-10-11 16:28:13 +02:00
Andrea Busi 8f50ed0a25 fix: Use M0_0 endpoint to retrieve data if show near earthquake is enabled 2020-10-11 16:28:13 +02:00
Andrea Busi 4f3bd9aa95 refactor: Align seismic cards style to new app layout 2020-10-08 22:18:51 +02:00
Andrea Busi cb30995a07 feat: Add location data card in Allerte section 2020-10-08 22:18:51 +02:00
Andrea Busi faeb9c0788 dependency: Add Solar library 2020-10-08 22:18:51 +02:00
Andrea Busi d286909a8d refactor: Move method to get string from coordinate in EQNUtility class 2020-10-08 22:18:51 +02:00
Andrea Busi 499d689943 refactor: Minor layout fixes 2020-10-08 21:36:28 +02:00
Andrea Busi 89e7989abc feat: Add shadow and rounded corner to cards 2020-10-08 21:36:28 +02:00
Andrea Busi bf4a5e7728 feat: Add test push alert feature 2020-10-08 21:36:28 +02:00
Andrea Busi e1bd26db48 refactor: Use proper method to store/load also dictionary 2020-10-08 21:36:28 +02:00
Andrea Busi 509b75e7b5 refactor: Use a shared method to handle push notification 2020-10-08 21:36:28 +02:00
Andrea Busi 5e16909f12 refactor: Remove old strings for storyboard 2020-10-08 21:36:28 +02:00
Andrea Busi 53817ac52a refactor: Remove unused images 2020-10-08 21:36:28 +02:00
Andrea Busi 54c6297637 refactor: Use new method to get formatted time difference 2020-10-08 21:36:28 +02:00
Andrea Busi 0374a0a1bd refactor: Improve notification management 2020-10-08 21:36:28 +02:00
Andrea Busi cf7ae31eb1 refactor: Better model PastquakesAnnotation 2020-10-08 21:36:28 +02:00
Andrea Busi 92e75913ab refactor: Recreate layout for "Allerte" section 2020-10-08 21:36:28 +02:00
Andrea Busi 061c321c2b refactor: Rename ReteSmartphone controller to AllerteViewController 2020-10-08 21:36:28 +02:00
Andrea Busi d50104a2f9 refactor: Improve layout in tab Segnalazioni 2020-10-08 21:36:28 +02:00
Andrea Busi 81d554cc78 refactor: Remove grafico utenti call and model
Resolves: https://gitlab.steamware.net/eqn/eqn.ios/-/issues/26
2020-10-08 21:36:28 +02:00
Andrea Busi bda81d01ba refactor: Handle refresh for common notifications in base controller 2020-10-08 21:36:28 +02:00
Andrea Busi 708e6dd92f feat: Add cache mechanism for seismic data
- download data only after 2 minutes after the previous download
- download data when app returns from the background
- user can force data download

Resolves: https://gitlab.steamware.net/eqn/eqn.ios/-/issues/18
2020-10-08 21:36:28 +02:00
Andrea Busi 74d7c71ed4 refactor: Improve code and use new utility method 2020-10-08 21:36:28 +02:00
Andrea Busi 27503c1643 refactor: Add new method to store/retrieve an array from NSUserDefault
This method uses only supported API, in order to solve deprecated warnings. Also, remove useless method
2020-10-08 21:36:28 +02:00
Andrea Busi 95935dd377 refactor: Remove commented code 2020-10-08 21:36:28 +02:00
Andrea Busi b357039901 refactor: Remove unused constants 2020-10-08 21:36:28 +02:00
Andrea Busi df8c154848 refactor: Remove AppTransportSecurity exception, only HTTPS are made from the app 2020-10-08 21:36:27 +02:00
Andrea Busi 882e0ba4b6 refactor: Remove not yet used strings 2020-10-08 21:36:27 +02:00
Andrea Busi 88572c2829 refactor: Use HTTPS endpoint to download notification icons 2020-10-08 21:36:27 +02:00
Andrea Busi bad1ce5879 refactor: Convert from Macro to static constants and use HTTPS as default protocol
Resolves: https://gitlab.steamware.net/eqn/eqn.ios/-/issues/17
2020-10-08 21:36:27 +02:00
Andrea Busi ce387912f8 feat: Add method to get formatted time difference 2020-10-08 21:36:27 +02:00
217 changed files with 3708 additions and 3844 deletions
+53
View File
@@ -1,5 +1,58 @@
# Changelog
## Versione 3.1.0
### Build (46)
- Corretto invio parametri per test allerta
### Build (45)
- Rimossi suoni non utilizzati
- Rivista content extension notifica
## Versione 3.0
### Build (44)
- Corrette stringhe in tab Sismi
- Disabilitato zoom mappa in Allerte
- Nascosto bottone per "Simulatore"
- Corretto problema ritardo visualizzazione notifiche push
- Suono notifiche riprodotto anche con app in foreground
- Icone in notifiche caricate da locale e non scaricate dal server
- Aggiornato suono notifica
### Build (43)
- Corretto scaricamento dati sismi per gestione "qualsiasi terremoto se < 50 km"
- Corretta selezione cella "dati posizione"
### Build (42)
- Corretto filtro rete GEONET
- Completata funzione "Test allerta"
- Aggiunta card "dati posizione"
### Build (40)
- Completato flusso e alert per invio messaggio
- Correzioni layout
### Build (39)
- Ombra e angoli arrotondati in card
- Funzione test allerte (WIP)
### Build (38)
- Aggiornate icone stelle
- Aggiunto messaggio localizzazione
- Rimosso bottone invio messaggio
### Build (37)
- Correzioni varie layout
- Corretto flusso invio commento
### Build (36)
- Migrate chiamate ad HTTPS
- Rimossa eccezione AppTransportSecurity per chiamate non sicure
- Aggiunto meccanismo cache per sismi
- Rivisto layout tab Segnalazioni (WIP)
- Rivisto layout tab Allerte (WIP)
## Versione 2.3.2
### Build (41)
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="M4Y-Lb-cyx">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="M4Y-Lb-cyx">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
@@ -15,68 +13,61 @@
<objects>
<viewController id="M4Y-Lb-cyx" userLabel="Notification View Controller" customClass="NotificationViewController" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" simulatedAppContext="notificationCenter" id="S3S-Oj-5AN">
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="330"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pCT-Wh-lut">
<rect key="frame" x="30" y="28" width="274" height="33"/>
<constraints>
<constraint firstAttribute="height" constant="33" id="3nL-zP-Xy4"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<nil key="textColor"/>
<rect key="frame" x="8" y="216" width="304" height="20.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f3d-th-bgU">
<rect key="frame" x="16" y="69" width="288" height="47"/>
<constraints>
<constraint firstAttribute="height" constant="47" id="ret-xK-EBP"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label hidden="YES" opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bT3-3m-qLh">
<rect key="frame" x="16" y="124" width="288" height="29"/>
<constraints>
<constraint firstAttribute="height" constant="29" id="Uqp-c7-9jk"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="bT3-3m-qLh">
<rect key="frame" x="8" y="285" width="304" height="29"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleTitle2"/>
<color key="textColor" red="0.91764705879999997" green="0.46274509800000002" blue="0.0078431372550000003" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<mapView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" mapType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="4ID-Zb-OQF">
<rect key="frame" x="0.0" y="161" width="320" height="259"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="200"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="259" id="WpP-bs-nlm"/>
<constraint firstAttribute="height" constant="200" id="Pgl-8e-ePq"/>
</constraints>
<connections>
<outlet property="delegate" destination="M4Y-Lb-cyx" id="Cs2-OY-eT2"/>
</connections>
</mapView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f3d-th-bgU">
<rect key="frame" x="8" y="244.5" width="304" height="20.5"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<constraints>
<constraint firstItem="4ID-Zb-OQF" firstAttribute="leading" secondItem="2BE-c3-nQJ" secondAttribute="leading" id="6ml-zm-WGB"/>
<constraint firstItem="f3d-th-bgU" firstAttribute="top" secondItem="pCT-Wh-lut" secondAttribute="bottom" constant="8" id="7wZ-2G-DRJ"/>
<constraint firstItem="f3d-th-bgU" firstAttribute="leading" secondItem="2BE-c3-nQJ" secondAttribute="leading" constant="16" id="B18-89-k0p"/>
<constraint firstItem="2BE-c3-nQJ" firstAttribute="trailing" secondItem="f3d-th-bgU" secondAttribute="trailing" constant="16" id="JZ8-8S-jXR"/>
<constraint firstItem="2BE-c3-nQJ" firstAttribute="trailing" secondItem="pCT-Wh-lut" secondAttribute="trailing" constant="16" id="P48-jk-9M7"/>
<constraint firstItem="4ID-Zb-OQF" firstAttribute="top" secondItem="bT3-3m-qLh" secondAttribute="bottom" constant="8" id="beN-rS-bGS"/>
<constraint firstItem="bT3-3m-qLh" firstAttribute="leading" secondItem="2BE-c3-nQJ" secondAttribute="leading" constant="16" id="cYK-5u-EMT"/>
<constraint firstItem="4ID-Zb-OQF" firstAttribute="bottom" secondItem="2BE-c3-nQJ" secondAttribute="bottom" constant="-60" id="gfC-gJ-8KE"/>
<constraint firstItem="bT3-3m-qLh" firstAttribute="top" secondItem="f3d-th-bgU" secondAttribute="bottom" constant="8" id="ixD-Y8-JnR"/>
<constraint firstItem="4ID-Zb-OQF" firstAttribute="trailing" secondItem="2BE-c3-nQJ" secondAttribute="trailing" id="n4A-8c-Bbr"/>
<constraint firstItem="2BE-c3-nQJ" firstAttribute="trailing" secondItem="bT3-3m-qLh" secondAttribute="trailing" constant="16" id="sak-kv-U04"/>
<constraint firstItem="pCT-Wh-lut" firstAttribute="leading" secondItem="2BE-c3-nQJ" secondAttribute="leading" constant="30" id="tuy-Pe-AhL"/>
<constraint firstItem="pCT-Wh-lut" firstAttribute="top" secondItem="2BE-c3-nQJ" secondAttribute="top" constant="8" id="xC7-C5-Yju"/>
</constraints>
<viewLayoutGuide key="safeArea" id="2BE-c3-nQJ"/>
<constraints>
<constraint firstItem="pCT-Wh-lut" firstAttribute="leading" secondItem="2BE-c3-nQJ" secondAttribute="leading" constant="8" id="3cg-0U-ASJ"/>
<constraint firstItem="f3d-th-bgU" firstAttribute="leading" secondItem="pCT-Wh-lut" secondAttribute="leading" id="7qA-vV-ocI"/>
<constraint firstItem="2BE-c3-nQJ" firstAttribute="trailing" secondItem="pCT-Wh-lut" secondAttribute="trailing" constant="8" id="CAC-UM-SaJ"/>
<constraint firstItem="f3d-th-bgU" firstAttribute="trailing" secondItem="pCT-Wh-lut" secondAttribute="trailing" id="Dd7-BF-iOG"/>
<constraint firstItem="f3d-th-bgU" firstAttribute="top" secondItem="pCT-Wh-lut" secondAttribute="bottom" constant="8" id="FJ8-nn-ydU"/>
<constraint firstItem="2BE-c3-nQJ" firstAttribute="bottom" secondItem="bT3-3m-qLh" secondAttribute="bottom" constant="16" id="I71-6U-jK3"/>
<constraint firstItem="pCT-Wh-lut" firstAttribute="top" secondItem="4ID-Zb-OQF" secondAttribute="bottom" constant="16" id="It9-RA-906"/>
<constraint firstItem="bT3-3m-qLh" firstAttribute="trailing" secondItem="f3d-th-bgU" secondAttribute="trailing" id="KXf-x4-iZs"/>
<constraint firstItem="bT3-3m-qLh" firstAttribute="leading" secondItem="f3d-th-bgU" secondAttribute="leading" id="QlJ-Vh-oi4"/>
<constraint firstItem="bT3-3m-qLh" firstAttribute="top" secondItem="f3d-th-bgU" secondAttribute="bottom" constant="20" id="UUO-2F-eE7"/>
<constraint firstItem="4ID-Zb-OQF" firstAttribute="trailing" secondItem="2BE-c3-nQJ" secondAttribute="trailing" id="buf-BU-I5b"/>
<constraint firstItem="4ID-Zb-OQF" firstAttribute="leading" secondItem="2BE-c3-nQJ" secondAttribute="leading" id="e8D-ji-t64"/>
<constraint firstItem="4ID-Zb-OQF" firstAttribute="top" secondItem="2BE-c3-nQJ" secondAttribute="top" id="hL6-gc-S6i"/>
</constraints>
</view>
<extendedEdge key="edgesForExtendedLayout"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<size key="freeformSize" width="320" height="480"/>
<size key="freeformSize" width="320" height="330"/>
<connections>
<outlet property="descrizione" destination="f3d-th-bgU" id="3PP-J5-iAi"/>
<outlet property="mappa" destination="4ID-Zb-OQF" id="d2K-qy-Q7P"/>
<outlet property="onda" destination="bT3-3m-qLh" id="xoD-qM-UAF"/>
<outlet property="titolo" destination="pCT-Wh-lut" id="C0V-PC-Sai"/>
<outlet property="descriptionLabel" destination="f3d-th-bgU" id="Aym-KJ-DqY"/>
<outlet property="mapView" destination="4ID-Zb-OQF" id="x8o-nT-bL4"/>
<outlet property="titleLabel" destination="pCT-Wh-lut" id="uIg-dn-Wms"/>
<outlet property="waveLabel" destination="bT3-3m-qLh" id="AkJ-nd-d2R"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="vXp-U4-Rya" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -2,17 +2,12 @@
// NotificationViewController.h
// EQNNotificationContent
//
// Created by Luca Beretta on 03/01/2019.
// Copyright © 2019 Luca Beretta. All rights reserved.
// Refactored by Andrea Busi on 14/10/2020.
// Copyright © 2020 Earthquake Network. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface NotificationViewController : UIViewController
@property (weak, nonatomic) IBOutlet UILabel *titolo;
@property (weak, nonatomic) IBOutlet UILabel *descrizione;
@property (weak, nonatomic) IBOutlet UILabel *onda;
@property (weak, nonatomic) IBOutlet MKMapView *mappa;
@end
@@ -2,82 +2,164 @@
// NotificationViewController.m
// EQNNotificationContent
//
// Created by Luca Beretta on 03/01/2019.
// Copyright © 2019 Luca Beretta. All rights reserved.
// Refactored by Andrea Busi on 14/10/2020.
// Copyright © 2020 Earthquake Network. All rights reserved.
//
#import "NotificationViewController.h"
#import <UserNotifications/UserNotifications.h>
#import <UserNotificationsUI/UserNotificationsUI.h>
#import <MapKit/MapKit.h>
#import "PastquakesAnnotation.h"
#import "ReteSismicaAnnotation.h"
#import "EQNUtility.h"
@import UserNotifications;
@import UserNotificationsUI;
@import MapKit;
@interface NotificationViewController () <UNNotificationContentExtension, MKMapViewDelegate>
@property (nonatomic, strong) NSDictionary *info;
@property (nonatomic, strong) NSURLSession *session;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *descriptionLabel;
@property (weak, nonatomic) IBOutlet UILabel *waveLabel;
@property (weak, nonatomic) IBOutlet MKMapView *mapView;
/// This will be calculated as seismic date + warning time
@property (strong, nonatomic) NSDate *userSeismicTimestamp;
@property (strong, nonatomic) NSTimer *countdownTimer;
@end
@implementation NotificationViewController
- (void)viewDidLoad {
- (void)setMapView:(MKMapView *)mapView
{
_mapView = mapView;
_mapView.scrollEnabled = NO;
_mapView.zoomEnabled = NO;
}
#pragma mark - View Lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any required interface initialization here.
}
-(void)didReceiveNotification:(UNNotification *)notification {
- (void)didReceiveNotification:(UNNotification *)notification
{
UNNotificationContent *content = notification.request.content;
NSDictionary *userInfo = content.userInfo;
self.titolo.text = notification.request.content.title;
self.descrizione.text = notification.request.content.body;
NSDictionary *dict = notification.request.content.userInfo;
CLLocation *coordinate = [[CLLocation alloc] initWithLatitude:[dict[@"latitude"] doubleValue] longitude:[dict[@"longitude"] doubleValue]];
// set title and description
self.titleLabel.text = content.title;
self.descriptionLabel.text = content.body;
// add annotation onthe map
CLLocation *coordinate = [[CLLocation alloc] initWithLatitude:[userInfo[@"latitude"] doubleValue]
longitude:[userInfo[@"longitude"] doubleValue]];
MKCoordinateSpan span = MKCoordinateSpanMake(10.5, 10.5);
MKCoordinateRegion region = MKCoordinateRegionMake(coordinate.coordinate, span);
self.mappa.delegate = self;
[self.mappa setCenterCoordinate:coordinate.coordinate animated:NO];
[self.mappa setRegion:region animated:YES];
self.mappa.scrollEnabled = NO;
[self.mapView setCenterCoordinate:coordinate.coordinate animated:NO];
[self.mapView setRegion:region animated:YES];
if ([dict[@"type"] isEqualToString:@"eqn"]) {
PastquakesAnnotation *annotation = [[PastquakesAnnotation alloc] initWithTitle:notification.request.content.body location:coordinate.coordinate intensita:[dict[@"intensity"] intValue]];
[self.mappa addAnnotation:annotation];
}
else if ([dict[@"type"] isEqualToString:@"manual"]){
ReteSismicaAnnotation *annotation = [[ReteSismicaAnnotation alloc] initWithTitle:notification.request.content.body location:coordinate.coordinate magnitudo:[dict[@"magnitudo"] intValue]];
[self.mappa addAnnotation:annotation];
if ([userInfo[@"type"] isEqualToString:@"eqn"]) {
PastquakesAnnotation *annotation = [[PastquakesAnnotation alloc] initWithTitle:content.body
location:coordinate.coordinate
intensita:[userInfo[@"intensity"] intValue]];
[self.mapView addAnnotation:annotation];
} else if ([userInfo[@"type"] isEqualToString:@"manual"]){
ReteSismicaAnnotation *annotation = [[ReteSismicaAnnotation alloc] initWithTitle:content.body
location:coordinate.coordinate
magnitudo:[userInfo[@"magnitudo"] intValue]];
[self.mapView addAnnotation:annotation];
}
self.onda.text = [NSString stringWithFormat:@"%@ %@ %@", NSLocalizedString(@"Onda sismica in", @""), dict[@"wave_speed"], NSLocalizedString(@"secondi", @"")];
self.userSeismicTimestamp = [self calculateUserSeismicTimestampWithInfo:userInfo];
if (self.userSeismicTimestamp) {
// start the countdown
self.countdownTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(countdownFired:)
userInfo:nil
repeats:YES];
[self.countdownTimer fire];
}
}
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{
#pragma mark - Private
- (nullable NSDate *)calculateUserSeismicTimestampWithInfo:(NSDictionary *)info
{
// dobbiamo calcolare l'ora in cui il sisma arriverà nella posizione dell'utente
// per fare questo, il calcolo sarà:
// timestamp sisma + warning time
// ultima posizione nota dell'utente
CLLocationManager *manager = [[CLLocationManager alloc] init];
CLLocation *lastUserLocation = manager.location;
if (!lastUserLocation) {
return nil;
}
// posizione sisma
double latitude = [info[@"latitude"] doubleValue];
double longitude = [info[@"longitude"] doubleValue];
CLLocation *location = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
// distanza tra sisma e utente (in km)
CLLocationDistance distance = [lastUserLocation distanceFromLocation:location];
double userDistance = distance/1000;
// calcoliamo warning_time
double waveSpeed = [info[@"wave_speed"] doubleValue];
double warningTime = round(userDistance/waveSpeed - 5);
// aggiungiamo il warning time al timestamp del sisma
NSDate *seismicDate = [EQNUtility getDateFromString:info[@"datetime"]];
NSDate *userSeismicDate = [seismicDate dateByAddingTimeInterval:warningTime];
return userSeismicDate;
}
- (void)countdownFired:(id)sender
{
NSDate *now = [NSDate date];
NSTimeInterval difference = MAX([self.userSeismicTimestamp timeIntervalSinceDate:now], 0);
self.waveLabel.text = [NSString stringWithFormat:@"%@ %.0f %@", NSLocalizedString(@"alert_wave", @""), difference, NSLocalizedString(@"alert_seconds", @"")];
if (difference <= 0) {
// stop the countdown
[self.countdownTimer invalidate];
self.countdownTimer = nil;
}
}
#pragma mark - MKMapViewDelegate
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[PastquakesAnnotation class]]) {
PastquakesAnnotation *anLocation = (PastquakesAnnotation *)annotation;
MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:IDENTIFIER_ANNOTATION_PASTQUAKES];
if (annotationView == nil)
if (annotationView == nil) {
annotationView = anLocation.annotationView;
else
} else {
annotationView.annotation = anLocation;
}
return annotationView;
}
else if ([annotation isKindOfClass:[ReteSismicaAnnotation class]]) {
} else if ([annotation isKindOfClass:[ReteSismicaAnnotation class]]) {
ReteSismicaAnnotation *anLocation = (ReteSismicaAnnotation *)annotation;
MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:IDENTIFIER_ANNOTATION_RETESMARTPHONE];
if (annotationView == nil)
if (annotationView == nil) {
annotationView = anLocation.annotationView;
else
} else {
annotationView.annotation = anLocation;
}
return annotationView;
}
return nil;
return nil;
}
@end
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 775 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 749 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 811 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 846 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Some files were not shown because too many files have changed in this diff Show More