diff --git a/android/app/build.gradle b/android/app/build.gradle index ddd7e38..070fb6f 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -30,8 +30,8 @@ android { applicationId "org.comunes.fires" minSdkVersion 16 targetSdkVersion 27 - versionCode 7 - versionName "1.7" + versionCode 8 + versionName "1.8" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } diff --git a/android/app/src/main/AndroidManifest-Sample.xml b/android/app/src/main/AndroidManifest-Sample.xml index 9db35fe..aafa1ca 100644 --- a/android/app/src/main/AndroidManifest-Sample.xml +++ b/android/app/src/main/AndroidManifest-Sample.xml @@ -16,7 +16,7 @@ FlutterApplication and put your custom class here. --> + android:value="true" /> diff --git a/android/app/src/main/res/values-es/strings.xml b/android/app/src/main/res/values-es/strings.xml new file mode 100644 index 0000000..18a4518 --- /dev/null +++ b/android/app/src/main/res/values-es/strings.xml @@ -0,0 +1,4 @@ + + + ¡Tod@s contra el Fuego! + diff --git a/android/app/src/main/res/values-gl/strings.xml b/android/app/src/main/res/values-gl/strings.xml new file mode 100644 index 0000000..b509cd1 --- /dev/null +++ b/android/app/src/main/res/values-gl/strings.xml @@ -0,0 +1,4 @@ + + + Tod@s contra o Lume! + diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..65089d9 --- /dev/null +++ b/android/app/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + + All Against The Fire! + diff --git a/lib/activeFires.dart b/lib/activeFires.dart index 11884ea..04a4641 100644 --- a/lib/activeFires.dart +++ b/lib/activeFires.dart @@ -5,10 +5,10 @@ import 'package:fires_flutter/models/yourLocation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_fab_dialer/flutter_fab_dialer.dart'; import 'package:flutter_redux/flutter_redux.dart'; -import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:redux/src/store.dart'; import 'colors.dart'; +import 'firesSpinner.dart'; import 'generated/i18n.dart'; import 'genericMap.dart'; import 'globalFiresBottomStats.dart'; @@ -17,7 +17,6 @@ import 'mainDrawer.dart'; import 'models/appState.dart'; import 'placesAutocompleteUtils.dart'; import 'redux/actions.dart'; -import 'firesSpinner.dart'; @immutable class _ViewModel { @@ -95,6 +94,10 @@ class _ActiveFiresPageState extends State { onPressed: () { loc.subscribed = !loc.subscribed; onToggle(loc); + setState(() {}); + showSnackMsg(loc.subscribed + ? S.of(context).subscribedToFires + : S.of(context).unsubscribedToFires); }), title: new Text(loc.description, style: new TextStyle(fontSize: 16.0)), subtitle: loc.currentNumFires == YourLocation.withoutStats @@ -102,12 +105,16 @@ class _ActiveFiresPageState extends State { : loc.currentNumFires == 0 ? new Text(S.of(context).noFiresAround) : loc.currentNumFires == 1 - ? new Text(S - .of(context) - .fireAroundThisArea(loc.distance.toString()), style: fireStatsStyle) - : new Text(S.of(context).firesAroundThisArea( - loc.currentNumFires.toString(), - loc.distance.toString()), style: fireStatsStyle), + ? new Text( + S + .of(context) + .fireAroundThisArea(loc.distance.toString()), + style: fireStatsStyle) + : new Text( + S.of(context).firesAroundThisArea( + loc.currentNumFires.toString(), + loc.distance.toString()), + style: fireStatsStyle), onLongPress: () { showSnackMsg(S.of(context).toDeleteThisPlace); }, diff --git a/lib/fireAlert.dart b/lib/fireAlert.dart index 80e78c7..3fd2322 100644 --- a/lib/fireAlert.dart +++ b/lib/fireAlert.dart @@ -33,6 +33,22 @@ class _FireAlertState extends State { ); } + Widget buildNotifyNeighboursButton() { + return new Align( + alignment: const Alignment(0.0, -0.2), + child: new FloatingActionButton( + heroTag: 'neighAction', + child: const Icon(CommunityMaterialIcons.bullhorn), + onPressed: () { + _scaffoldKey.currentState.showSnackBar(new SnackBar( + content: new Text(S.of(context).inDevelopment), + )); + }, + ), + ); + } + + Widget buildTweetButton() { return new Align( alignment: const Alignment(0.0, -0.2), @@ -46,7 +62,7 @@ class _FireAlertState extends State { String where = yourLocation.description.replaceAll(' ', '').split(',')[0]; print(where); - Share.share('#IF${where} FIXME'); + Share.share(S.of(context).tweetAboutSelf(yourLocation.description, '#IF${where}')); }).catchError((onError) { _scaffoldKey.currentState.showSnackBar(new SnackBar( content: new Text( @@ -65,12 +81,19 @@ class _FireAlertState extends State { List fireSteps = listWithoutNulls([ new CustomStep( title: new Text(S.of(context).callEmergencyServicesTitle), - // subtitle: content: new Column(children: [ new Text(S.of(context).callEmergencyServicesDescription), new SizedBox(height: 20.0), buildCallButton() ])), + new CustomStep( + title: new Text(S.of(context).notifyNeighbours), + // state: CustomStepState.disabled, + content: new Column(children: [ + new Text(S.of(context).notifyNeighboursDescription), + new SizedBox(height: 20.0), + buildNotifyNeighboursButton() + ])), // TODO conditional: this only in Spain new CustomStep( title: new Text(S.of(context).tweetAboutAFireTitle), diff --git a/lib/generated/i18n.dart b/lib/generated/i18n.dart index 9555e5a..b43f6e0 100644 --- a/lib/generated/i18n.dart +++ b/lib/generated/i18n.dart @@ -59,6 +59,7 @@ class S implements WidgetsLocalizations { String get firesInYourPlaces => "Active fires in your places"; String get firesNearPlace => "Fires near other place"; String get getAlertsOfFiresinThatArea => "Get alerts of fires in that area"; + String get inDevelopment => "In development"; String get inGreenMonitoredAreas => "In green, the areas monitored by our users currently"; String get isYourUbicationEnabled => "I cannot get your current location. It's your ubication enabled?"; String get itSeemsAControlledBurning => "It's a controlled burning"; @@ -72,9 +73,12 @@ class S implements WidgetsLocalizations { String get notAWildfire => "Isn't that a forest fire?"; String get notPermsUbication => "We don't have permission to get your location"; String get notifyAFire => "Notify a fire"; + String get notifyNeighbours => "Notify other users"; + String get notifyNeighboursDescription => "Alert other users of the area about the fire"; String get privacyPolicy => "Privacy Policy"; String get shareAppBtn => "Share our app"; String get starAppBtn => "Rate our app"; + String get subscribedToFires => "Subscribed to fires notifications"; String get supportPageDescription => "You can support this initiative, spreading the word, helping us to develop our software, translating this app to your language, suggesting other public data sources of fires to use, etc."; String get supportThisInitiative => "Support this initiative"; String get thanksForParticipating => "Thanks for participating"; @@ -85,6 +89,7 @@ class S implements WidgetsLocalizations { String get tweetAboutAFireTitle => "Tweet about"; String get typeTheNameOfAPlace => "Type the name of a place, region, etc"; String get unsubscribe => "Unsubscribe"; + String get unsubscribedToFires => "Unsubscribed to fires notifications"; String get warningThisIsAVeryLargeArea => "Warning: this is a very large area"; String get youDeletedThisNotification => "You deleted this notification"; String get youDeletedThisPlace => "You deleted this place"; @@ -101,6 +106,7 @@ class S implements WidgetsLocalizations { String noFiresAroundThisArea(String kmAround) => "There is no fires at $kmAround км around this area"; String somethingAgo(String something) => "$something ago"; String subscribeToValueAroundThisArea(String sliderValue) => "Subscribe to $sliderValue км around this area"; + String tweetAboutSelf(String location, String hash) => "Fire in $location $hash"; String updatedLastCheck(String lastCheck) => "Updated $lastCheck"; } @@ -177,10 +183,16 @@ class es extends S { @override String get aYear => "un año"; @override + String get unsubscribedToFires => "Desuscrito a notificaciones de fuegos"; + @override String get itSeemsNotAtForesFire => "Parece que este fuego no es un fuego forestal."; @override String get UNDO => "DESHACER"; @override + String get notifyNeighbours => "Notifica a otros usuarios/as"; + @override + String get inDevelopment => "En desarrollo"; + @override String get tweetAboutAFireTitle => "Twittea"; @override String get supportPageDescription => "Puedes apoyar esta iniciativa, dando difusión, ayudándonos a desarrollar nuestro software, traduciendo esta aplicación a tu idioma, sugeriendo otras fuentes de datos públicas de fuegos para usar, etc."; @@ -193,6 +205,8 @@ class es extends S { @override String get NASAAck => "Reconocemos el uso de datos e imágenes de LANCE FIRMS operadas por NASA/GSFC/Earth Science Data and Information System (ESDIS) con fondos proporcionados por NASA/HQ."; @override + String get subscribedToFires => "Suscrito a notificaciones de fuegos"; + @override String get isYourUbicationEnabled => "No podemos saber tu ubicación actual. ¿Están los servicios de ubicación en tu móvil activados?"; @override String get thanksForParticipating => "Gracias por Participar"; @@ -229,6 +243,8 @@ class es extends S { @override String get firesInTheWorld => "Fuegos en el mundo"; @override + String get notifyNeighboursDescription => "Alerta a otros usuarios de la zona sobre el fuego"; + @override String get addSomePlace => "Añade otro lugar"; @override String get confirm => "Confirmar"; @@ -261,6 +277,8 @@ class es extends S { @override String somethingAgo(String something) => "hace $something"; @override + String tweetAboutSelf(String location, String hash) => "Fuego en $location $hash"; + @override String subscribeToValueAroundThisArea(String sliderValue) => "Suscríbete a $sliderValue км a la redonda"; @override String inHours(String value) => "$value horas"; diff --git a/lib/genericMap.dart b/lib/genericMap.dart index 157a48e..018ff9f 100644 --- a/lib/genericMap.dart +++ b/lib/genericMap.dart @@ -388,19 +388,19 @@ class _genericMapState extends State { falsePosList.forEach((falsePos) { var coords = falsePos['geo']['coordinates']; // print('false pos: ${coords}'); - var loc = LatLng(coords[1], coords[0]); + var loc = LatLng(double.parse(coords[1]), double.parse(coords[0])); markers.add(FireMarker(loc, FireMarkType.falsePos)); if (calibrate) markers.add(FireMarker(loc, FireMarkType.pixel)); }); industries.forEach((industry) { // print(fire['geo']['coordinates']); var coords = industry['geo']['coordinates']; - var loc = LatLng(coords[1], coords[0]); + var loc = LatLng(double.parse(coords[1]), double.parse(coords[0])); markers.add(FireMarker(loc, FireMarkType.industry)); if (calibrate) markers.add(FireMarker(loc, FireMarkType.pixel)); }); fires.forEach((fire) { - var loc = new LatLng(fire['lat'], fire['lon']); + var loc = new LatLng(double.parse(fire['lat']), double.parse(fire['lon'])); markers.add( FireMarker(loc, FireMarkType.fire, () => print('marker pressed'))); markers.add(FireMarker(loc, FireMarkType.pixel)); diff --git a/lib/homePage.dart b/lib/homePage.dart index 5e1aaf1..f4c2544 100644 --- a/lib/homePage.dart +++ b/lib/homePage.dart @@ -84,14 +84,14 @@ class _HomePageState extends State { super.initState(); _firebaseMessaging.configure(onMessage: (Map message) { debugPrint("onMessage in fireApp (isLoaded: ${store.state.isLoaded}): $message"); - _showItemDialog(message, _notifForMessage(message)); + _showItemDialog(message, _notifForMessage(message, store.state.isLoaded)); }, onLaunch: (Map message) { debugPrint("onLaunch (isLoaded: ${store.state.isLoaded}): $message"); - _notifForMessage(message); + _notifForMessage(message, store.state.isLoaded); _navigateToItemDetail(message); }, onResume: (Map message) { debugPrint("onResume (isLoaded: ${store.state.isLoaded}): $message"); - _notifForMessage(message); + _notifForMessage(message, store.state.isLoaded); _navigateToItemDetail(message); }); _firebaseMessaging.requestNotificationPermissions( @@ -282,7 +282,7 @@ class _HomePageState extends State { // https://pub.dartlang.org/packages/firebase_messaging#-example-tab- final FirebaseMessaging _firebaseMessaging = new FirebaseMessaging(); - FireNotification _notifForMessage(Map message) { + FireNotification _notifForMessage(Map message, bool isLoaded) { FireNotification notif; try { notif = new FireNotification( @@ -299,7 +299,12 @@ class _HomePageState extends State { debugPrint(e.toString()); } if (notif != null) - newNotifications.add(notif); + // if our store is loaded, we just dispatch the notification, if not, we wait til is loaded + if (isLoaded) { + store.dispatch(new AddFireNotificationAction(notif)); + } else { + newNotifications.add(notif); + } return notif; } } diff --git a/lib/models/firesApi.dart b/lib/models/firesApi.dart index 23df2bb..a689bbc 100644 --- a/lib/models/firesApi.dart +++ b/lib/models/firesApi.dart @@ -192,7 +192,7 @@ class FiresApi { "token": state.firesApiKey, "mobileToken": mobileToken, "sealed": sealed, - "type": type.toString() + "type": type.toString().split('.')[1] }; final String url = '${state.firesApiUrl}mobile/falsepositive'; return await resty.post(url).json(params).go().then((response) { diff --git a/lib/redux/fetchDataMiddleware.dart b/lib/redux/fetchDataMiddleware.dart index a939802..4b419c6 100644 --- a/lib/redux/fetchDataMiddleware.dart +++ b/lib/redux/fetchDataMiddleware.dart @@ -58,6 +58,7 @@ void fetchDataMiddleware(Store store, action, NextDispatcher next) { store.dispatch(new AddedYourLocationAction(action.loc)); persistYourLocations(store.state.yourLocations); } + getFiresStatsInLocation(store, action.loc); } if (action is DeleteYourLocationAction) { @@ -87,13 +88,7 @@ void fetchDataMiddleware(Store store, action, NextDispatcher next) { } if (action is ShowYourLocationMapAction) { - api - .getFiresInLocation( - state: store.state, - lat: action.loc.lat, - lon: action.loc.lon, - distance: action.loc.distance) - .then((result) => store.dispatch(result)); + getFiresStatsInLocation(store, action.loc); } if (action is ShowFireNotificationMapAction) { @@ -111,9 +106,6 @@ void fetchDataMiddleware(Store store, action, NextDispatcher next) { lon: action.loc.lon, distance: action.loc.distance) .then((result) => store.dispatch(result))); - else { - // FIXME do something? - } store.dispatch(new UpdatedYourLocationAction(action.loc)); persistYourLocations(store.state.yourLocations); } @@ -150,12 +142,12 @@ void fetchDataMiddleware(Store store, action, NextDispatcher next) { if (action is FetchYourLocationsAction) { // Use the api to fetch the YourLocations loadYourLocations().then((localLocations) { - api - .fetchYourLocations(store.state) - .then((List subscribedLocations) { - // If it succeeds, dispatch a success action with the YourLocations. - // Our reducer will then update the State using these YourLocations. - // print('Subscribed to: ${subscribedLocations.length}'); + api + .fetchYourLocations(store.state) + .then((List subscribedLocations) { + // If it succeeds, dispatch a success action with the YourLocations. + // Our reducer will then update the State using these YourLocations. + // print('Subscribed to: ${subscribedLocations.length}'); if (subscribedLocations is List) { // unsubscribe all locally to sync the subs state localLocations.forEach((location) => location.subscribed = false); @@ -173,12 +165,12 @@ void fetchDataMiddleware(Store store, action, NextDispatcher next) { localLocations.forEach((yl) { api - .getFiresInLocation( - state: store.state, - lat: yl.lat, - lon: yl.lon, - distance: yl.distance) - .then((value) { + .getFiresInLocation( + state: store.state, + lat: yl.lat, + lon: yl.lon, + distance: yl.distance) + .then((value) { yl.currentNumFires = value.numFires; store.dispatch(new UpdateYourLocationAction(yl)); }); @@ -211,18 +203,21 @@ void fetchDataMiddleware(Store store, action, NextDispatcher next) { } if (action is FetchMonitoredAreasAction) { - api.getMonitoredAreas(state: store.state).then((result) { // store.dispatch() - store.dispatch( - new FetchMonitoredAreasSucceededAction(result)); - }); + api.getMonitoredAreas(state: store.state).then((result) { + // store.dispatch() + store.dispatch(new FetchMonitoredAreasSucceededAction(result)); + }); } if (action is MarkFireAsFalsePositiveAction) { - api.markFalsePositive(store.state, store.state.user.token, action.notif.sealed, action.type).then((result) { + api + .markFalsePositive(store.state, store.state.user.token, + action.notif.sealed, action.type) + .then((result) { if (result) { // Not necessary - // store.dispatch(new UpdatedFireNotificationAction(action.notif)); getFiresStatsInFire(store, action.notif); + store.dispatch(new UpdatedFireNotificationAction(action.notif)); } }); } @@ -231,6 +226,20 @@ void fetchDataMiddleware(Store store, action, NextDispatcher next) { next(action); } +void getFiresStatsInLocation(Store store, YourLocation loc) { + api + .getFiresInLocation( + state: store.state, + lat: loc.lat, + lon: loc.lon, + distance: loc.distance) + .then((result) { + store.dispatch(result); + loc.currentNumFires = result.numFires; + store.dispatch(new UpdateYourLocationAction(loc)); + }); +} + void getFiresStatsInFire(Store store, FireNotification notif) { api .getFiresInLocation( diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb index eab1be2..9e4e49f 100644 --- a/res/values/strings_en.arb +++ b/res/values/strings_en.arb @@ -53,8 +53,11 @@ "errorFirePlaceDialog": "We couldn't get the location of the fire", "callEmergencyServicesTitle": "Call 112", "callEmergencyServicesDescription": "You should call 112 if you have not already done so to notify the emergency services.", + "notifyNeighbours": "Notify other users", + "notifyNeighboursDescription": "Alert other users of the area about the fire", "tweetAboutAFireTitle": "Tweet about", "tweetAboutAFireDescription": "Additionally if you use twitter you can share additional information with the emergency services, for example, attaching photos to the tweet if you have good visibility of the fire, when you took the photos, exact location, etc. Use #hashtags type #IFMinicipalTerminal for example #IFJumilla (Forest Fire in Jumilla).", + "tweetAboutSelf": "Fire in $location $hash", "supportPageDescription": "You can support this initiative, spreading the word, helping us to develop our software, translating this app to your language, suggesting other public data sources of fires to use, etc.", "fireNotificationsTitleShort": "Notifications", "fireNotificationsTitle": "Fire Notifications", @@ -79,5 +82,8 @@ "mapPrivacy": "In order to preserve the privacy of our users, the reflected data are randomly altered and are only indicative.", "comunesSupportBtn": "Know and support our work", "shareAppBtn": "Share our app", - "starAppBtn": "Rate our app" + "starAppBtn": "Rate our app", + "unsubscribedToFires": "Unsubscribed to fires notifications", + "subscribedToFires": "Subscribed to fires notifications", + "inDevelopment": "In development" } \ No newline at end of file diff --git a/res/values/strings_es.arb b/res/values/strings_es.arb index ac01162..96e0cb9 100644 --- a/res/values/strings_es.arb +++ b/res/values/strings_es.arb @@ -53,8 +53,11 @@ "errorFirePlaceDialog": "No hemos podido obtener la ubicación del fuego", "callEmergencyServicesTitle": "Llama al 112", "callEmergencyServicesDescription": "Deberías llamar al 112 si no lo has hecho ya para avisar a los servicios de emergencia.", + "notifyNeighbours": "Notifica a otros usuarios/as", + "notifyNeighboursDescription": "Alerta a otros usuarios de la zona sobre el fuego", "tweetAboutAFireTitle": "Twittea", "tweetAboutAFireDescription": "Adicionalmente si usas twitter puedes compartir información adicional con los servicios de emergencia, por ejemplo, adjuntando fotos al tweet si tienes buena visibilidad del fuego, cuando tomaste las fotos, ubicación exacta, etc. Usa #hashtags tipo #IFTerminoMunicipal por ejemplo #IFJumilla (Incendio Forestal en Jumilla).", + "tweetAboutSelf": "Fuego en $location $hash", "supportPageDescription": "Puedes apoyar esta iniciativa, dando difusión, ayudándonos a desarrollar nuestro software, traduciendo esta aplicación a tu idioma, sugeriendo otras fuentes de datos públicas de fuegos para usar, etc.", "fireNotificationsTitle": "Notificaciones de fuegos", "fireNotificationTitle": "Notificación de fuego", @@ -79,5 +82,8 @@ "mapPrivacy": "Para preservar la privacidad de nuestros usuarios/as, los datos reflejados están aleatoriamente alterados y son solo orientativos.", "comunesSupportBtn": "Conoce y apoya nuestro trabajo", "shareAppBtn": "Comparte nuestra app", - "starAppBtn": "Puntúa nuestra app" + "starAppBtn": "Puntúa nuestra app", + "unsubscribedToFires": "Desuscrito a notificaciones de fuegos", + "subscribedToFires": "Suscrito a notificaciones de fuegos", + "inDevelopment": "En desarrollo" } \ No newline at end of file