Compare commits
50 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 122cf497b3 | |||
| 361b51a5a2 | |||
| bbfd28c5d2 | |||
| e399c53de1 | |||
| d8c0d48ad2 | |||
| a474d5782f | |||
| c538ca7dcb | |||
| b11af3d138 | |||
| 8e1b1bd5a7 | |||
| 67546801ac | |||
| 6135e2d38c | |||
| e46fa0417d | |||
| dc6bb13960 | |||
| 6aecff1415 | |||
| 6fcf58608f | |||
| 65ed82445b | |||
| ab727b119b | |||
| 1bd833093b | |||
| 904d4c5de8 | |||
| 720d0fcd2a | |||
| 8f50ed0a25 | |||
| 4f3bd9aa95 | |||
| cb30995a07 | |||
| faeb9c0788 | |||
| d286909a8d | |||
| 499d689943 | |||
| 89e7989abc | |||
| bf4a5e7728 | |||
| e1bd26db48 | |||
| 509b75e7b5 | |||
| 5e16909f12 | |||
| 53817ac52a | |||
| 54c6297637 | |||
| 0374a0a1bd | |||
| cf7ae31eb1 | |||
| 92e75913ab | |||
| 061c321c2b | |||
| d50104a2f9 | |||
| 81d554cc78 | |||
| bda81d01ba | |||
| 708e6dd92f | |||
| 74d7c71ed4 | |||
| 27503c1643 | |||
| 95935dd377 | |||
| b357039901 | |||
| df8c154848 | |||
| 882e0ba4b6 | |||
| 88572c2829 | |||
| bad1ce5879 | |||
| ce387912f8 |
@@ -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
|
||||
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 752 B |
|
After Width: | Height: | Size: 775 B |
|
After Width: | Height: | Size: 749 B |
|
After Width: | Height: | Size: 811 B |
|
After Width: | Height: | Size: 846 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.5 KiB |