144 Commits
Author SHA1 Message Date
handte 4bff009cfc Release 1.0.13.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-14 18:50:58 +01:00
handte ba1b5ab29a Fix path names in route servlet.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-14 18:07:36 +01:00
handte 8bfce31f2e Properly compute regular grid coordinates.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-14 17:48:10 +01:00
handte bca818e734 Replace COSMO D2 nwp with ICON D2 nwp.
LocationBasedServices/mowesta/pipeline/head This commit looks good
Remove cosmo d2 since it is no longer computed by DWD.
Add new icon d2 as drop-in replacement for cosmo.
Extend grip decoder to properly handle bitmap section.
Switch icon eu to use icosahedral coordinate system.
Rename inconsistent state boundary endpoint.
2021-02-14 17:23:32 +01:00
handte c95015c234 Update to 1.0.13-SNAPSHOT.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-14 00:14:25 +01:00
handte 3eced06154 Release 1.0.12.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-14 00:12:05 +01:00
handte 894b24a4ff Properly handle predictions that are not updated.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-13 23:51:49 +01:00
boese 5a3b0a62f6 fix bug in weather warning
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-08 21:10:57 +01:00
boese d34a88943a fix speechtext for weather warning
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-08 21:00:08 +01:00
boese 6a611d57d3 add weather warning in LocationWeatherService
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-08 20:48:41 +01:00
handte a3e213eea2 Add script to prepare test database that can be distributed.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-05 19:02:03 +01:00
Tobias Stottrop 9849d7c51e added feat/auth branch to jenkins
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-04 22:59:17 +01:00
boese e3d0122fb0 fix WeatherForecastIntentHandler
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-04 19:24:30 +01:00
boese 549c4b559b fix speechtext in ClothingRecommendationIntentHandler
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-01 19:14:56 +01:00
boese c4b92b734c fix speechtext in WeatherForecastIntentHandler
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-01 19:01:12 +01:00
boese ff763ec44c add Geolocation to ClothingRecommendationIntentHandler, delete logs, fix speechtext
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-01 18:48:09 +01:00
boese 912151ef2d add logs for test
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-01 18:18:01 +01:00
boese f341e8eb10 fix nullpointer
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-01 18:07:37 +01:00
boese 64af6ae5aa fix nullpointer (uppercasecity), add Geolocation to CurrentWeatherIntentHandler
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-01 17:48:47 +01:00
boese 1d64d0bd23 fix nullpointer (uppercasecity)
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-01 17:29:23 +01:00
boese bc19ba5fd0 add Geolocation of the User
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-02-01 16:47:16 +01:00
handte aea6edd08b Adapt dns names to separate production and development.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-30 02:06:36 +01:00
boese 9b62b46e0e Merge remote-tracking branch 'origin/master'
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-28 17:02:41 +01:00
boese dcad963c7c prioritize the weather type for ClothingRecommendationIntentHandler, add comments 2021-01-28 17:02:22 +01:00
handte f66a6e8a49 Change font structure, fix baseHref in angular setup.
LocationBasedServices/mowesta/pipeline/head This commit looks good
Move fonts out of assets since it is not possible to stop angular from hashing it.
Fix wrong baseHref defintion (hopefully).
2021-01-26 15:55:55 +01:00
handte 51931b979f Add baseHref to production build.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-26 10:22:04 +01:00
handte d863b0927e Replace artifactory with nexus, remove string interpolation in Jenkinsfile.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-26 00:19:14 +01:00
boese bfaf634148 fix bugs in ClothingRecommendationIntentHandler, WeatherForecastIntentHandler
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-25 19:26:02 +01:00
boese e8760938af add ClothingRecommendationIntentHandler,ClothingWeatherToStringConverter, LocationWeatherService
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-25 18:41:36 +01:00
boese 5bb3275a54 add time slot to WeatherForecastIntentHandler
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-25 17:19:19 +01:00
handte d5362ff41d Suppress deprecation and fix test warnings in SDK.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-24 20:38:32 +01:00
handte 949a0d2770 Fix type in Android app, downgrade jackson on Android.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-24 20:08:06 +01:00
handte 8af818ffbe Reduce gradle warnings when building android code from command line.
LocationBasedServices/mowesta/pipeline/head This commit looks good
Add workaround to handle Google's broken oss-license-plugin implementation.
Update robolectric to 4.5 to get rid of illegal reflective access warnings.
2021-01-24 19:19:52 +01:00
handte ac8b771ecf Cleanup Angular elements and improve nodejs build scripts to support incremental builds.
LocationBasedServices/mowesta/pipeline/head This commit looks good
Change project structure to get rid of copied assets and configuration files.
Import fonts in css using absolute paths to avoid duplication by webpack pipeline.
Stage output of ng build executions in build directory to separate ng app and elements.
Change concat scripts to assemble final output in dist folder without modifying build directory.
Add video.js files to supported modules (https://github.com/videojs/video.js/issues/6978).
Move baseRef option in angular file to new location to get rid of deprecation warning.
Change name and location of scripts to avoid copying assets.
Change name of custom element to include mowesta brand name as prefix.
2021-01-24 16:25:11 +01:00
handte 3f25520284 Backup with tools to generate traces.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-21 22:38:20 +01:00
boese 2ef558894f fix bug in WeatherForecastIntentHandler
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-21 19:32:21 +01:00
boese b68b63a110 add Region/Land to WeatherForecastIntentHandler
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-21 19:13:52 +01:00
boese 9f2ec5fb38 test WeatherForecastIntentHandler
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-21 18:52:29 +01:00
boese 9564586f97 fix location search
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-21 18:21:07 +01:00
boese 4fdfeec9a5 fix speechtext for country/state to check location search
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-21 17:30:00 +01:00
boese ffb4b56073 fix speechtext in WeatherForecastIntentHandler
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-21 17:13:15 +01:00
boese b0d71102f3 fix WeatherForecastIntentHandler
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-21 16:51:26 +01:00
boese c784c85909 add ForecastWeatherToStringConverter
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-21 16:15:32 +01:00
boese b977a80ecc format temperature
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-21 09:38:21 +01:00
boese f3251a4139 fix location test4, fix WeatherForecastIntentHandler
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-18 21:40:47 +01:00
boese d5b82cddc8 fix location test3
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-18 20:42:29 +01:00
boese 7ad855a4aa fix location test WeatherForecastIntentHandler
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-18 19:47:04 +01:00
boese 9826392819 fix location test2
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-18 19:20:27 +01:00
boese 9e8a519bc7 fix location test1
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-18 18:55:40 +01:00
boese 2029d47b29 Merge remote-tracking branch 'remotes/origin/master' into feature/alexa
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-18 17:56:27 +01:00
boese 0622b4cbc5 fix nullpointer
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-18 17:56:06 +01:00
boese 474432d2a7 add country/state search in CurrentWeatherIntentHandler,
LocationBasedServices/mowesta/pipeline/head This commit looks good
add WeatherForecastIntentHandler
2021-01-18 17:53:59 +01:00
handte 135afc064b Upgrade to 1.0.12-SNAPSHOT.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-18 17:02:32 +01:00
handte 17006aafe3 Release 1.0.11.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-18 16:58:05 +01:00
handte e5aa030857 Disable deployment.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-15 22:54:42 +01:00
handte c8e0a7f16e Fix bugs in wind color scale and deploy to production.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-15 22:52:11 +01:00
boese 35d8f06e5d fix speechtext
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-14 21:09:41 +01:00
boese b967f318c7 add WeatherConditionType,
LocationBasedServices/mowesta/pipeline/head This commit looks good
add WeatherTypeToStringConverter,
fix String output
2021-01-14 20:06:34 +01:00
boese e1f28ffd23 Merge remote-tracking branch 'remotes/origin/master' into feature/alexa
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-13 18:45:37 +01:00
boese 6d5ce170bd add error message
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-13 18:45:02 +01:00
handte 4d1d87d8ef Improve splash screen logos and animation.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-12 10:54:18 +01:00
handte d032e2e577 Workaround to support injection.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-12 09:50:08 +01:00
handte 0a7e33503f Disable deployment again.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-11 22:23:49 +01:00
handte f62c5b41cf Use MHz instead of Hz on Android, deploy to production.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-11 22:22:43 +01:00
boese cdfc018c33 add CurrentWeatherIntentHandler
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-11 21:36:33 +01:00
handte 9a773ca13f Reduce ciss logo size in android app.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-11 19:55:31 +01:00
handte 1b80e9415f Add wind video rendering and app integration.
LocationBasedServices/mowesta/pipeline/head This commit looks good
Extend api with additional weather video type for wind.
Add support for rendering wind videos to backend.
Add support for displaying wind videos to android and web app.
Upgrade android libraries to make lint happy.
Fix linting bugs and warnings related to android layouts.
Fix integer division bug in color scale renderer.
Extend scale generator tool to generate wind scale.
Add BFT wind speed scale to Android app.
Increase temperature resolution in android and web app.
2021-01-11 18:42:25 +01:00
handte 706f24f104 Add ciss and mfund logos to webapp.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-08 23:21:07 +01:00
boese 4029c15eb9 fix problems
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-08 08:50:54 +01:00
handte 6fd3209304 Change ear structure to allow multiple clients for ejb module.
LocationBasedServices/mowesta/pipeline/head This commit looks good
Extract ejb module from war and deploy it individually so that it can be used from multiple jars.
Remove lucene and hibernate jars from ear to ensure that they are loaded from wildfly installation.
Add alexa web module to ear.
Remove swagger ui from alexa context root and replace index html with a simple test message.
Remove .dat files generated during test execution.
Change package name to keep the com.mowesta.service prefix for server-side code.
Remove dead/commented code from build.gralde and web.xml.
2021-01-07 09:10:15 +01:00
boese ffa3ff7d46 change web.xml, HelloWorldSkillServlet
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-06 19:46:53 +01:00
boese 83530a9a41 change Servlet
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-04 19:30:48 +01:00
boese 7ed7d8cfcf add module alexa
LocationBasedServices/mowesta/pipeline/head This commit looks good
2021-01-03 19:47:43 +01:00
boese aff152543c add alexa hello world 2021-01-03 19:37:20 +01:00
handte bb92acc66a Update webapp to Angular 11.
LocationBasedServices/mowesta/pipeline/head This commit looks good
Update web application to use latest Angular version.
Replace 3rd party date range picker with new material implementation.
2020-12-20 22:52:44 +01:00
handte bfad0d8716 Added tool to compute distance to buildings.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-12-18 14:04:17 +01:00
handte a8028ff446 Minimal change to demo jenkins.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-12-15 09:47:21 +01:00
handte 32bcbf3647 Rename projects in Eclipse to avoid collisions, fix warnings and documentation.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-12-11 19:43:08 +01:00
handte 52ff3d660c Omit cities without proper country during import
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-12-02 15:43:45 +01:00
Marcus Handte e794d83ec5 Fix minor typo.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-11-24 21:30:00 +01:00
handte 95b82b133a Add JDNI setting to reduce data volume during testing, update jenkinsfile for beta system.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-11-24 19:48:01 +01:00
handte a66cc3bb0c Replace entity manager customization with custom persistence provider.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-11-24 16:55:11 +01:00
handte 87abaf05c1 Add more debug output to entity manager producer.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-11-24 12:16:16 +01:00
handte 3e575f96e6 Make all filesystem paths configurable via JNDI.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-11-23 14:55:36 +01:00
Marcus Handte a318d10f79 Fix dependency issues.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-11-12 21:40:46 +01:00
Marcus Handte 969d59c4c3 Add missing reactivestreams dependency.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-11-12 19:05:01 +01:00
Marcus Handte 66ba4e0d09 Switch to redhat version. 2020-11-12 18:39:47 +01:00
Marcus Handte e87199c024 Replace infinispan query with embedded.
LocationBasedServices/mowesta/pipeline/head There was a failure building this commit
2020-11-12 18:28:25 +01:00
Marcus Handte 7a6b7084ac Fix build for wildfly 20, upgrade android.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-11-12 17:36:04 +01:00
handte 42ed5a03e1 Upgrade Gradle/Android/Wildfly.
LocationBasedServices/mowesta/pipeline/head There was a failure building this commit
2020-11-09 18:45:37 +01:00
Adriano Markovic 8a564df34f Enhanced progress bar logic on admin's measurements export view.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-08-31 14:41:42 +02:00
handte 746faf92b1 Disable deployment.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-08-17 18:56:49 +02:00
handte de74b222af Increase video compression.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-08-17 18:56:19 +02:00
handte 66daf0c7b7 Disable deployment.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-08-16 13:03:18 +02:00
handte 7e0b4d88d5 Update Android plugin, fix deprecation warnings, enable deployment.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-08-16 12:45:15 +02:00
Adriano Markovic 543b3587eb Added CanDeactivatGuard to /measurements view, added popup dialog on already loaded time period, added cancel function to progress bar.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-08-13 15:10:47 +02:00
handte aa6d0cfab5 Update to 1.0.11-SNAPSHOT.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-08-13 12:34:05 +02:00
handte 84fd69dfdb Release 1.0.10.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-08-13 12:32:11 +02:00
handte 8c174f8581 Change carta urls, change border color on temperature video.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-08-13 12:22:43 +02:00
Adriano Markovic 6bd040272b Modified MeasurementSessionTest.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-08-10 13:02:22 +02:00
Adriano Markovic 2d2caaed09 Stopped initializing test devices and measurements.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-08-08 22:15:11 +02:00
Adriano Markovic cf99d87a66 Added admin measurement map feature to inspect and export measurements from all devices. 2020-08-08 21:55:39 +02:00
Adriano Markovic 778677ec40 DataTestBean modified to setup measurements with different coordinates. 2020-08-08 21:48:59 +02:00
Adriano Markovic 485f56e547 Merge branch 'master' of https://project.nes.uni-due.de/gitea/lbs/mowesta 2020-07-29 11:15:38 +02:00
handte 13080b113b Update device timestamp with new measurement.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-27 17:48:02 +02:00
Adriano Markovic d1fc3bee96 Added ETag caching to the admin endpoint for fetching all measurements. 2020-07-27 16:32:09 +02:00
Adriano Markovic 8bd0cf7bc2 Adjusted the AbstractCanDeactivate class to handle more generic use cases.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-23 01:45:57 +02:00
Adriano Markovic c306987b63 Added can-deactivate.guard for user confirmation on aborting the measurements export.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-23 00:54:30 +02:00
Adriano Markovic 84beb97a73 Implemented frontend export functionality for admin users. 2020-07-22 23:12:55 +02:00
Adriano Markovic 82b7b5544d Added endpoint for admin users for fetching measurements from all devices within a specified time range. 2020-07-22 22:22:29 +02:00
Adriano Markovic 942e42ae76 CorsResponseFilter NullPointerException fixed. 2020-07-22 22:08:18 +02:00
Adriano Markovic ed8846d950 Changed import statement due to build failure caused by circular dependencies between service <-> pipes packages.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-16 21:01:37 +02:00
Adriano Markovic 6bd27b2eff Merge branch 'master' of https://project.nes.uni-due.de/gitea/lbs/mowesta
LocationBasedServices/mowesta/pipeline/head There was a failure building this commit
2020-07-15 21:54:20 +02:00
Adriano Markovic ef86399ba3 Added non-admin user export functionality to user settings. 2020-07-15 21:54:00 +02:00
handte 6b5f85fe5f Disable deployments.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-15 20:22:14 +02:00
handte 822f4044f7 Improve video rendering performance, change ordering, deploy.
LocationBasedServices/mowesta/pipeline/head This commit looks good
Improve video rendering performance by optimizing drawing operations.
Change video rendering order from high detail to low detail.
Redeploy to production to test rendering tomorrow morning.
2020-07-15 20:20:24 +02:00
handte 7414860ace Update to 1.0.10-SNAPSHOT.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-15 00:33:56 +02:00
handte 582c1c6468 Release 1.0.9
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-15 00:00:00 +02:00
handte 192836a763 Disable deployments.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-14 23:08:10 +02:00
handte 5539048c54 Fix edge cases in algorithms, precompute projections, continue analyzer (wip), deploy.
LocationBasedServices/mowesta/pipeline/head This commit looks good
Add workaround for edge cases in marching squares when edges lie on image borders.
Improve video rendering performance (5x faster) by precomputing projections.
Cleanup scale renderer code and continue work on analyzer (incomplete).
Enable deployement to test performance optimizations.
2020-07-14 23:05:42 +02:00
Adriano Markovic 61bb009959 Added saturn-datepicker package to the web-angular module. 2020-07-14 22:38:30 +02:00
handte 843b52b468 Disable deployment.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-13 20:02:19 +02:00
handte 1487957ea4 Finish video generation, modify video filter in backend, deploy.
LocationBasedServices/mowesta/pipeline/head This commit looks good
Finish integration of isotherms and isobars.
Change filtering of videos to always return latest by category.
Temporarily enable deployment.
2020-07-13 19:58:21 +02:00
handte daf517bc6a Refactored video generation, added isolines.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-13 09:08:50 +02:00
handte c45b14d35a Improve video quality using variable bitrate encoding.
LocationBasedServices/mowesta/pipeline/head This commit looks good
Switch constant bitrate encoding to variable bitrate encoding.
Adjust constant rate factor to balance bitrate and output quality.
2020-07-09 20:19:01 +02:00
handte 4734c0f7b7 Disable deployments.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-07 21:03:31 +02:00
handte 0272fb770e Deploy to server.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-07 21:02:53 +02:00
Adriano Markovic 0b357be701 Added LocationAutocompleteComponent to the weather-search web component project.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-07 17:49:28 +02:00
Adriano Markovic de8a4b8360 Small modification on the condition-map.
LocationBasedServices/mowesta/pipeline/head There was a failure building this commit
2020-07-07 17:28:53 +02:00
Adriano Markovic 83dc34fb53 Added location-autocomplete component.
LocationBasedServices/mowesta/pipeline/head There was a failure building this commit
2020-07-07 17:03:52 +02:00
Adriano Markovic 8a306727a7 Added a search box to the conditions map and refactored the component search-field.
LocationBasedServices/mowesta/pipeline/head There was a failure building this commit
2020-07-07 17:02:52 +02:00
handte 3a2eadad70 Disable deployment.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-06 23:10:22 +02:00
handte 6017db7599 Enable deployment, extend nominatim exporter.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-06 23:09:13 +02:00
Marcus Handte bc29648790 Fix build errors due to api update.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-06 18:27:05 +02:00
handte 0ba90a0bb2 Disable deployments.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-04 11:29:08 +02:00
handte 3ec70113e6 Change search ranking and labels in ui.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-04 09:32:29 +02:00
handte 0c3b968aee Update to 1.0.9-SNAPSHOT
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-03 11:23:10 +02:00
handte b7514953a6 Release 1.0.8
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-03 11:09:34 +02:00
handte 0483420af2 Reduce threshold from 75 to 10 percent.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-03 11:06:28 +02:00
handte a72613aa58 Finalize android-app for next release.
LocationBasedServices/mowesta/pipeline/head This commit looks good
Cleanup landscape view.
Fix linting warning.
Fix depcreation warnings.
Avoid object allocation during drawing.
2020-07-03 11:01:31 +02:00
handte b45311404c Finish visualization (finger animation needs updating).
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-07-03 01:02:01 +02:00
handte df19ff4b14 Started with forecast visualization.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-29 09:10:41 +02:00
handte fa6f76ba7d Add workaround to improve ux when dragging.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-26 21:44:39 +02:00
Marcus Handte 5aee1eb084 Update to 1.0.8-SNAPSHOT.
LocationBasedServices/mowesta/pipeline/head This commit looks good
2020-06-26 17:22:49 +02:00
523 changed files with 20080 additions and 92913 deletions
Vendored
+22 -31
View File
@@ -3,18 +3,10 @@
// this groovy script is executed by jenkins
node {
def gradleInfo
def server = Artifactory.server 'project.nes.uni-due.de'
def gradleBuild = Artifactory.newGradleBuild()
gradleBuild.usesPlugin = true
gradleBuild.useWrapper = true
environment {
ANDROID_SDK_ROOT = '/var/lib/android-sdk'
}
// checkout code from scm
stage('Checkout') {
checkout scm
@@ -26,34 +18,27 @@ node {
// configure the deployer based on the version
stage('Configure') {
version = sh(returnStdout: true, script: "./gradlew properties -q | grep \"version:\" | awk '{print \$2}'", label: "Detecting project version.").trim()
println "Version is: '${version}'"
if (version.endsWith("-SNAPSHOT")) {
println "Using internal-snapshots for publication."
gradleBuild.deployer server: server, repo: 'internal-snapshots'
} else {
println "Using internal-releases for publication."
gradleBuild.deployer server: server, repo: 'internal-releases'
release = true;
}
println "Version is: '${version}'"
release = (! version.endsWith("-SNAPSHOT"))
}
// build the source code with gradle
stage('Build') {
withCredentials([string(credentialsId: 'mowesta-keystore-password', variable: 'PASSWD')]) {
def switches = "-Djenkins.build.number=${env.BUILD_NUMBER} -Dandroid.keystore.password=${PASSWD}".toString()
gradleInfo = gradleBuild.run buildFile: 'build.gradle', tasks: 'clean build', switches: switches
sh(script: './gradlew -Djenkins.build.number=' + env.BUILD_NUMBER + ' -Dandroid.keystore.password=$PASSWD clean build', label: "Building project.")
}
}
// deploy the maven publications to artifactory
// deploy the maven publications to nexus
stage ('Publish') {
if (env.BRANCH_NAME == "master" && release) {
withCredentials([string(credentialsId: 'mowesta-keystore-password', variable: 'PASSWD')]) {
def switches = "-Djenkins.build.number=${env.BUILD_NUMBER} -Dandroid.keystore.password=${PASSWD}".toString()
gradleInfo = gradleBuild.run buildFile: 'build.gradle', tasks: 'artifactoryPublish', switches: switches
}
if (env.BRANCH_NAME == "master") {
withCredentials([string(credentialsId: 'jenkins-nexus-password', variable: 'NEXUS')]) {
withCredentials([string(credentialsId: 'mowesta-keystore-password', variable: 'PASSWD')]) {
sh(script: './gradlew -Djenkins.build.number=' + env.BUILD_NUMBER + ' -Dandroid.keystore.password=$PASSWD -Djenkins.nexus.password=$NEXUS publishAllPublicationsToMavenRepository', label: "Publishing project.")
}
}
} else {
echo "Skipping deployment for non-release version or non-master branch."
echo "Skipping publication for non-release version or non-master branch."
}
}
@@ -61,12 +46,18 @@ node {
stage ('Deploy') {
// release = true; // uncomment to temporary enable snapshot deployments
if (env.BRANCH_NAME == "master" && release) {
withCredentials([sshUserPrivateKey(credentialsId: "mowesta-server-key", keyFileVariable: "keyfile")]) {
sh "scp -i ${keyfile} site-ear/build/libs/site-ear-${version}.ear wildfly@apps.nes.uni-due.de:/opt/wildfly-17-mowesta/standalone/deployments/mowesta.ear"
sh "scp -i ${keyfile} android-app/build/outputs/apk/release/*.apk wildfly@apps.nes.uni-due.de:/opt/android/mowesta/"
}
echo "Deploying to production server ..."
withCredentials([sshUserPrivateKey(credentialsId: "mowesta-server-key", keyFileVariable: "KEYFILE")]) {
sh 'scp -i $KEYFILE site-ear/build/libs/site-ear-' + version + '.ear wildfly@apps-pro.nes.uni-due.de:/opt/wildfly-21-mowesta/standalone/deployments/mowesta.ear'
sh 'scp -i $KEYFILE android-app/build/outputs/apk/release/*.apk wildfly@apps-pro.nes.uni-due.de:/opt/android/mowesta/'
}
} else if (env.BRANCH_NAME == "master" || env.BRANCH_NAME == "feat/auth") {
echo "Deploying to beta server ..."
withCredentials([sshUserPrivateKey(credentialsId: "mowesta-server-key", keyFileVariable: "KEYFILE")]) {
sh 'scp -i $KEYFILE site-ear/build/libs/site-ear-' + version + '.ear wildfly@apps-dev.nes.uni-due.de:/opt/wildfly-21-beta/standalone/deployments/mowesta.ear'
}
} else {
echo "Skipping deployment for non-release version or non-master branch."
echo "Skipping deployment for non-master branch."
}
}
+1
View File
@@ -13,3 +13,4 @@ To build the project, you will have to install [Java](http://www.oracle.com/tech
# Jenkins CI
Pull requests and new commits to any branch are automatically built by a Jenkins service. A Gitea webhook informs the service about changes to the repository. In addition, the service will automatically scan the lbs Gitea organization for new repositories every hour. Successful builds of new commits are indicated by a green tick on the commit page. The build status of pull requests is currently not shown in Gitea. However, you can go to the [Jenkins](https://project.nes.uni-due.de/jenkins/job/LocationBasedServices/job/mowesta/) service to view the result of builds including the console output. To modify the build process, you can change the Jenkinsfile groovy script in the root of the repository, if necessary.
+7 -5
View File
@@ -13,12 +13,12 @@ ext {
versionAndroidXPaging = '2.1.2'
versionAndroidXCard = '1.0.0'
versionAndroidXCoordinator = '1.1.0'
versionAndroidXConstraint = '1.1.3'
versionAndroidXNavigation = '2.3.0'
versionAndroidXConstraint = '2.0.4'
versionAndroidXNavigation = '2.3.2'
versionAndroidXLifecycle = '2.2.0'
versionAndroidXSecurity = '1.1.0-alpha01'
versionAndroidXSecurity = '1.1.0-alpha03'
versionAndroidXViewpager = '1.0.0'
versionGoogleMaterial = '1.1.0'
versionGoogleMaterial = '1.2.1'
versionAndroidXSwipeRefresh = '1.1.0'
versionExoPlayer = '2.11.5'
}
@@ -82,13 +82,14 @@ configurations {
}
}
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.mowesta.android.app"
minSdkVersion 19
targetSdkVersion 29
versionCode 7
versionCode 13
versionName "${version}"
buildConfigField "long", "BUILD_TIME", System.currentTimeMillis() + "L"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -148,6 +149,7 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
@@ -6,8 +6,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.NetworkInfo;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.util.Log;
@@ -55,7 +53,7 @@ public class WifiTask extends NetworkTask {
if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(intent.getAction())) {
Log.d(TAG, "Received network state changed.");
if (intent.hasExtra(WifiManager.EXTRA_NETWORK_INFO)) {
NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
android.net.NetworkInfo info = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
if (info != null) {
Log.d(TAG, "Received network info: " + info);
if (info.isConnected() && isWifiConnected()) {
@@ -119,7 +117,7 @@ public class WifiTask extends NetworkTask {
Log.d(TAG, "Wifi was disabled, turning it on.");
didEnableWifi = manager.setWifiEnabled(true);
}
WifiConfiguration existing = findConfiguration();
android.net.wifi.WifiConfiguration existing = findConfiguration();
if (existing == null) {
networkId = manager.addNetwork(createConfiguration());
manager.saveConfiguration();
@@ -171,8 +169,8 @@ public class WifiTask extends NetworkTask {
*/
private int getMaximumPriority() throws SecurityException {
int result = 1;
List<WifiConfiguration> configurations = manager.getConfiguredNetworks();
for (WifiConfiguration configuration: configurations) {
List<android.net.wifi.WifiConfiguration> configurations = manager.getConfiguredNetworks();
for (android.net.wifi.WifiConfiguration configuration: configurations) {
result = Math.max(result, configuration.priority);
}
return result;
@@ -184,10 +182,10 @@ public class WifiTask extends NetworkTask {
* @return The network configuration, if present already.
* @throws SecurityException Thrown if we are missing a permission.
*/
private WifiConfiguration findConfiguration() throws SecurityException {
private android.net.wifi.WifiConfiguration findConfiguration() throws SecurityException {
String ssid = getSsid();
List<WifiConfiguration> configurations = manager.getConfiguredNetworks();
for (WifiConfiguration configuration: configurations) {
List<android.net.wifi.WifiConfiguration> configurations = manager.getConfiguredNetworks();
for (android.net.wifi.WifiConfiguration configuration: configurations) {
if (ssid.equals(configuration.SSID)) {
return configuration;
}
@@ -200,19 +198,19 @@ public class WifiTask extends NetworkTask {
*
* @return The network configuration.
*/
private WifiConfiguration createConfiguration() {
WifiConfiguration result = new WifiConfiguration();
private android.net.wifi.WifiConfiguration createConfiguration() {
android.net.wifi.WifiConfiguration result = new android.net.wifi.WifiConfiguration();
result.SSID = getSsid();
result.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
result.allowedProtocols.set(WifiConfiguration.Protocol.RSN); // For WPA2
result.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
result.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
result.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
result.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
result.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
result.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
result.allowedAuthAlgorithms.set(android.net.wifi.WifiConfiguration.AuthAlgorithm.OPEN);
result.allowedProtocols.set(android.net.wifi.WifiConfiguration.Protocol.RSN); // For WPA2
result.allowedKeyManagement.set(android.net.wifi.WifiConfiguration.KeyMgmt.WPA_PSK);
result.allowedKeyManagement.set(android.net.wifi.WifiConfiguration.KeyMgmt.WPA_EAP);
result.allowedPairwiseCiphers.set(android.net.wifi.WifiConfiguration.PairwiseCipher.TKIP);
result.allowedPairwiseCiphers.set(android.net.wifi.WifiConfiguration.PairwiseCipher.CCMP);
result.allowedGroupCiphers.set(android.net.wifi.WifiConfiguration.GroupCipher.TKIP);
result.allowedGroupCiphers.set(android.net.wifi.WifiConfiguration.GroupCipher.CCMP);
result.preSharedKey = String.format("\"%s\"", ArduinoConfig.ARDUINO_PWD);
result.status = WifiConfiguration.Status.ENABLED;
result.status = android.net.wifi.WifiConfiguration.Status.ENABLED;
try {
int priority = getMaximumPriority() + 400;
Log.d(TAG, "Setting maximum priority to " + priority + ".");
@@ -71,18 +71,17 @@ public abstract class AbstractDiagramFragment extends AbstractNetworkFragment {
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.action_unit_system:
UnitSystemDialogFragment system = new UnitSystemDialogFragment();
system.show(getChildFragmentManager(), "system");
return true;
case R.id.action_temperature_unit:
TemperatureUnitDialogFragment unit = new TemperatureUnitDialogFragment();
unit.show(getChildFragmentManager(), "unit");
return true;
default:
return super.onOptionsItemSelected(item);
int itemId = item.getItemId();
if (itemId == R.id.action_unit_system) {
UnitSystemDialogFragment system = new UnitSystemDialogFragment();
system.show(getChildFragmentManager(), "system");
return true;
} else if (itemId == R.id.action_temperature_unit) {
TemperatureUnitDialogFragment unit = new TemperatureUnitDialogFragment();
unit.show(getChildFragmentManager(), "unit");
return true;
}
return super.onOptionsItemSelected(item);
}
@@ -82,19 +82,19 @@ public abstract class AbstractPlaceFragment extends AbstractNetworkFragment {
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.action_favorite_add:
getPlaceViewModel().addFavorite();
return true;
case R.id.action_favorite_remove:
getPlaceViewModel().removeFavorite();
return true;
case R.id.action_wikipedia:
openWikipedia();
return true;
case R.id.action_google_maps:
openGoogleMaps();
return true;
int itemId = item.getItemId();
if (itemId == R.id.action_favorite_add) {
getPlaceViewModel().addFavorite();
return true;
} else if (itemId == R.id.action_favorite_remove) {
getPlaceViewModel().removeFavorite();
return true;
} else if (itemId == R.id.action_wikipedia) {
openWikipedia();
return true;
} else if (itemId == R.id.action_google_maps) {
openGoogleMaps();
return true;
}
return false;
}
@@ -58,24 +58,27 @@ public class CityForecastFragment extends CityFragment.ChildFragment {
if (request != null) {
switch (request.getType()) {
case DAY:
pager.setCurrentItem(0, true);
break;
case TIME:
pager.setCurrentItem(1, true);
break;
case HOUR:
case TIME:
pager.setCurrentItem(2, true);
break;
case HOUR:
pager.setCurrentItem(3, true);
break;
}
}
});
TabLayout tabs = view.findViewById(R.id.tabs);
TabLayout tabs = getActivity().findViewById(R.id.tabs);
new TabLayoutMediator(tabs, pager, (tab, position) -> {
switch (position) {
case 0:
tab.setText(R.string.city_info_day);
tab.setText(R.string.city_info_gradient);
break;
case 1:
tab.setText(R.string.city_info_day);
break;
case 2:
tab.setText(R.string.city_info_time);
break;
default:
@@ -100,16 +103,20 @@ public class CityForecastFragment extends CityFragment.ChildFragment {
@NonNull
@Override
public Fragment createFragment(int position) {
ForecastRecyclerFragment fragment = new ForecastRecyclerFragment();
Bundle bundle = new Bundle();
bundle.putInt("page", position);
fragment.setArguments(bundle);
return fragment;
if (position == 0) {
return new CityGradientFragment();
} else {
ForecastRecyclerFragment fragment = new ForecastRecyclerFragment();
Bundle bundle = new Bundle();
bundle.putInt("page", position - 1);
fragment.setArguments(bundle);
return fragment;
}
}
@Override
public int getItemCount() {
return 3;
return 4;
}
}
@@ -426,5 +433,4 @@ public class CityForecastFragment extends CityFragment.ChildFragment {
}
}
@@ -85,16 +85,14 @@ public class CityFragment extends AbstractPlaceFragment {
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.action_customize:
getChildFragmentManager()
.beginTransaction()
.add(new CustomizeDialogFragment(), "customize")
.commit();
return true;
default:
return super.onOptionsItemSelected(item);
if (item.getItemId() == R.id.action_customize) {
getChildFragmentManager()
.beginTransaction()
.add(new CustomizeDialogFragment(), "customize")
.commit();
return true;
}
return super.onOptionsItemSelected(item);
}
@Nullable
@@ -0,0 +1,283 @@
package com.mowesta.android.app.fragment;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;
import androidx.viewpager2.widget.ViewPager2;
import com.google.android.material.appbar.AppBarLayout;
import com.mowesta.android.app.R;
import com.mowesta.android.app.databinding.FragmentGradientBinding;
import com.mowesta.android.app.model.CustomizeViewModel;
import com.mowesta.android.app.util.DateFormatter;
import com.mowesta.android.app.util.TimeUtils;
import com.mowesta.android.app.view.DataView;
import com.mowesta.android.app.view.TimeView;
import com.mowesta.android.app.view.color.CloudDepthColorScheme;
import com.mowesta.android.app.view.color.HumidityColorScheme;
import com.mowesta.android.app.view.color.PrecipitationColorScheme;
import com.mowesta.android.app.view.color.PressureColorScheme;
import com.mowesta.android.app.view.color.ScientificTemperatureColorScheme;
import com.mowesta.android.app.view.color.WhiteCloudColorScheme;
import com.mowesta.android.feign.model.WeatherCondition;
/**
* The fragment to show the overview as a bunch of gradients.
*
* @author Marcus
*/
public class CityGradientFragment extends CityFragment.ChildFragment {
/**
* The timeout after which we reset the view.
*/
private static final int TIMEOUT_REMOVER = 10000;
/**
* The view binding.
*/
private FragmentGradientBinding binding;
/**
* The time utilities.
*/
private TimeUtils timeUtils = new TimeUtils(System.currentTimeMillis(), null);
/**
* The view pager of the parent.
*/
private ViewPager2 pager;
/**
* The date formatter.
*/
private DateFormatter dateFormatter;
/**
* The handler to post the removal of
*/
private Handler handler = new Handler();
/**
* The animator for the progress bar.
*/
private ValueAnimator animator;
/**
* The weather condition to display as text.
*/
private WeatherCondition condition = new WeatherCondition();
private boolean closed = false;
private Runnable remover = () -> {
updateSelection(null);
animator.cancel();
binding.gradientText.setVisibility(View.GONE);
};
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
dateFormatter = new DateFormatter(getContext());
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_gradient, container, false);
// this is quite ugly, but we need to disable the view pager and collapse the toolbar
pager = getActivity().findViewById(R.id.pager);
AppBarLayout layout = getActivity().findViewById(R.id.layout_appbar);
binding.gradientProgress1.setMax(TIMEOUT_REMOVER);
binding.gradientProgress2.setMax(TIMEOUT_REMOVER);
animator = ValueAnimator.ofInt(TIMEOUT_REMOVER, 0);
animator.setInterpolator(new LinearInterpolator());
animator.setDuration(TIMEOUT_REMOVER);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation){
int value = (Integer)animation.getAnimatedValue();
binding.gradientProgress1.setProgress(value);
binding.gradientProgress2.setProgress(value);
binding.gradientText.setAlpha(Math.min(1, Math.max(0, value / 1000f)));
}
});
binding.gradientScroll.setOnTouchListener(binding.gradientTouch.createOnTouchListener(new TimeView.OnSlideListener() {
@Override
public void onSlide(float relative) {
if (!hasData()) return;
animator.cancel();
binding.gradientProgress1.setProgress(TIMEOUT_REMOVER);
binding.gradientProgress2.setProgress(TIMEOUT_REMOVER);
binding.gradientText.setAlpha(1);
handler.removeCallbacks(remover);
if (!closed) {
layout.setExpanded(false, true);
closed = true;
}
pager.setUserInputEnabled(false);
updateSelection(relative);
updateCondition(relative);
binding.gradientText.setVisibility(View.VISIBLE);
updateGuide(relative);
}
@Override
public void onSlideEnd() {
pager.setUserInputEnabled(true);
closed = false;
animator.start();
handler.postDelayed(remover, TIMEOUT_REMOVER);
}
}));
binding.setLifecycleOwner(getViewLifecycleOwner());
binding.gradientText.setVisibility(View.GONE);
binding.gradientTemperature.setColorScheme(new ScientificTemperatureColorScheme());
binding.gradientCloud.setColorScheme(new WhiteCloudColorScheme());
binding.gradientCloud.setSecondaryColorScheme(new CloudDepthColorScheme());
binding.gradientPreciptiation.setColorScheme(new PrecipitationColorScheme());
binding.gradientHumidity.setColorScheme(new HumidityColorScheme());
getCityViewModel().getHour().observe(getViewLifecycleOwner(), (list) -> {
if (list == null) return;
int housrs = 0;
for (int i = 0; i < list.size(); i++) {
housrs += list.get(i).getCondition().getValue().getDuration();
}
Double[] temp = new Double[housrs];
Double[] cloud = new Double[housrs];
Double[] depth = new Double[housrs];
Double[] prec = new Double[housrs];
Double[] pres = new Double[housrs];
Double[] wind = new Double[housrs];
Double[] hum = new Double[housrs];
Long[] hours = new Long[housrs];
int index = 0;
for (int i = 0; i < list.size(); i++) {
WeatherCondition wc = list.get(i).getCondition().getValue();
for (int j = 0; j < wc.getDuration(); j++) {
temp[index] = wc.getTemperature();
cloud[index] = wc.getCloudCoverage();
prec[index] = wc.getPrecipitation();
pres[index] = wc.getPressure();
depth[index] = wc.getCloudDepth();
wind[index] = wc.getWindSpeed();
hum[index] = wc.getHumidity();
hours[index] = wc.getTime() + j * 3600000;
index += 1;
}
}
binding.gradientCloud.setSecondaryData(depth);
binding.gradientTemperature.setData(temp);
binding.gradientPressure.setData(pres);
binding.gradientCloud.setData(cloud);
binding.gradientPreciptiation.setData(prec);
binding.gradientWindSpeed.setData(wind);
binding.gradientHumidity.setData(hum);
binding.gradientTouch.setData(hours);
});
getCityViewModel().getForecast().observe(getViewLifecycleOwner(), (forecast) -> {
if (forecast != null) {
// 1013,25 hPa * [ 1 − 6,5 * Höhe / (288150 m) ]5,255
double avg = 1013.25 * Math.pow(1 - 6.5 * forecast.getSurfaceHeight() / 288150.0, 5.255);
binding.gradientPressure.setColorScheme(new PressureColorScheme(avg, avg - 20, avg + 10));
}
});
getCityViewModel().getCity().observe(getViewLifecycleOwner(), (city) -> {
if (city != null) {
binding.gradientTouch.setTimezone(city.getTimezone());
timeUtils = new TimeUtils(System.currentTimeMillis(), city.getTimezone());
}
});
// observe changes to the settings that affect us
CustomizeViewModel customizeViewModel = new ViewModelProvider(this).get(CustomizeViewModel.class);
customizeViewModel.getTemperatureUnit().observe(getViewLifecycleOwner(), (u)-> {
Float selection = binding.gradientTouch.getSelection();
if (selection != null) updateCondition(selection);
});
customizeViewModel.getUnitSystem().observe(getViewLifecycleOwner(), (s) -> {
Float selection = binding.gradientTouch.getSelection();
if (selection != null) updateCondition(selection);
});
return binding.getRoot();
}
private boolean hasData() {
return binding.gradientTouch.getData() != null && binding.gradientTouch.getData().length > 0;
}
private void updateSelection(Float selection) {
binding.gradientTemperature.setSelection(selection);
binding.gradientWindSpeed.setSelection(selection);
binding.gradientPreciptiation.setSelection(selection);
binding.gradientHumidity.setSelection(selection);
binding.gradientPressure.setSelection(selection);
binding.gradientCloud.setSelection(selection);
binding.gradientTouch.setSelection(selection);
}
private void updateCondition(float selection) {
long time = binding.gradientTouch.getDataAt(selection);
condition.setTime(time);
condition.setWindSpeed(binding.gradientWindSpeed.getDataAt(selection));
condition.setPrecipitation(binding.gradientPreciptiation.getDataAt(selection));
condition.setHumidity(binding.gradientHumidity.getDataAt(selection));
condition.setPressure(binding.gradientPressure.getDataAt(selection));
condition.setCloudCoverage(binding.gradientCloud.getDataAt(selection));
condition.setTemperature(binding.gradientTemperature.getDataAt(selection));
String day = timeUtils.getDayName(getContext(), time);
String hour = dateFormatter.asTime(time, binding.gradientTouch.getTimezone());
binding.gradientTime.setText(getString(R.string.format_two_parts, day, hour));
binding.setModel(condition);
}
private void updateGuide(float relative) {
float px = 64 * getResources().getDisplayMetrics().density;
float max = 128 * getResources().getDisplayMetrics().density;
int size = binding.gradientTouch.getDirection() == DataView.Direction.HORIZONTAL ?
binding.gradientConstraint.getWidth():binding.gradientConstraint.getHeight();
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams)binding.gradientText.getLayoutParams();
float percent = size == 0 ? 0 : px / size;
float delta = size == 0 ? 0 : max / size;
if (binding.gradientTouch.getDirection() == DataView.Direction.VERTICAL) {
if (relative - delta < 0) {
binding.guideGradient.setGuidelinePercent(relative + 2 * percent);
params.bottomToTop = -1;
params.topToBottom = R.id.guide_gradient;
} else {
binding.guideGradient.setGuidelinePercent(relative - percent);
params.topToBottom = -1;
params.bottomToTop = R.id.guide_gradient;
}
} else {
if (relative > 0.5) {
binding.guideGradient.setGuidelinePercent(relative - percent);
params.leftToLeft = -1;
params.rightToRight = R.id.guide_gradient;
} else {
binding.guideGradient.setGuidelinePercent(relative + percent);
params.leftToLeft = R.id.guide_gradient;
params.rightToRight = -1;
}
}
binding.gradientText.setLayoutParams(params);
}
@Override
public void onPause() {
handler.removeCallbacks(remover);
remover.run();
super.onPause();
}
}
@@ -45,13 +45,7 @@ public class CityInfoFragment extends CityFragment.ChildFragment {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
FragmentCityInfoBinding binding = DataBindingUtil.inflate(inflater, R.layout.fragment_city_info, container, false);
MapView mapView = binding.getRoot().findViewById(R.id.map_detail);
MapViewUtil.setupInteractiveMap(mapView);
// reduce brightness of map (technically, we should generate a night mode in leafless but this needs to be fixed in the library)
if (getResources().getBoolean(R.bool.dark_mode)) {
mapView.setAlpha(0.5f);
} else {
mapView.setAlpha(1f);
}
MapViewUtil.setupInteractiveMap(mapView, getResources().getBoolean(R.bool.dark_mode));
CityViewModel model = new ViewModelProvider(getParentFragment().getParentFragment()).get(CityViewModel.class);
ConditionViewModel condition = new ViewModelProvider(this).get(ConditionViewModel.class);
Runnable updateCondition = () -> {
@@ -88,9 +88,11 @@ public class CollectionFragment extends Fragment {
// add a funky animation
if (savedInstanceState == null) {
List<View> views = new ArrayList<>();
views.add(binding.collectionNotePermission);
views.add(binding.collectionNoteLocation);
views.add(binding.collectionNoteData);
views.add(binding.collectionNoteEnable);
views.add(binding.privacyMeasureSwitch);
views.add(binding.collectionNotePermission);
views.add(binding.buttonContinue);
AnimatorSet set = new AnimatorSet();
ObjectAnimator first = ObjectAnimator.ofFloat(binding.logoSun, "translationY", DisplayUtils.dpToPixels(getContext(), 90), 0f);
@@ -109,7 +109,7 @@ public class CountryFragment extends AbstractPlaceFragment {
model.getCities().observe(getViewLifecycleOwner(), (list) -> adapter.submitList(list));
recyclerView.setAdapter(adapter);
MapView mapView = view.findViewById(R.id.map_detail);
MapViewUtil.setupInteractiveMap(mapView);
MapViewUtil.setupInteractiveMap(mapView, getResources().getBoolean(R.bool.dark_mode));
Runnable updateMap = () -> {
MapViewUtil.removePolylines(mapView, polylines);
polylines.clear();
@@ -52,7 +52,16 @@ public class LoginFragment extends Fragment {
Navigation.findNavController(binding.getRoot()).navigate(R.id.destination_devices, null, b.build());
break;
case COLLECTION:
Navigation.findNavController(binding.getRoot()).navigate(R.id.action_login_collection);
try {
Navigation.findNavController(binding.getRoot()).navigate(R.id.action_login_collection);
} catch (IllegalArgumentException e) {
// this is most likely bug in the navigation library, since it cannot find the
// node in the xml file which is technically impossible (probably a race during loading)
NavOptions.Builder builder = new NavOptions.Builder().setPopUpTo(R.id.destination_login, true);
builder.setEnterAnim(R.anim.slide_in_right);
builder.setExitAnim(R.anim.slide_out_left);
Navigation.findNavController(binding.getRoot()).navigate(R.id.destination_collection, null, builder.build());
}
break;
}
@@ -78,6 +78,7 @@ public class SplashFragment extends Fragment {
View title = root.findViewById(R.id.splash_title);
View subtitle = root.findViewById(R.id.splash_subtitle);
View world = root.findViewById(R.id.splash_world);
View logos = root.findViewById(R.id.logo_panel);
AnimatorSet set = new AnimatorSet();
ValueAnimator gradientAnimator = ValueAnimator.ofFloat(0, 1);
gradientAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
@@ -93,6 +94,10 @@ public class SplashFragment extends Fragment {
ObjectAnimator worldAnimator = ObjectAnimator.ofFloat(world, "alpha", 0, 1);
worldAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
worldAnimator.setDuration(750);
logos.setAlpha(0);
ObjectAnimator logoAnimator = ObjectAnimator.ofFloat(logos, "alpha", 0, 1);
logoAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
logoAnimator.setDuration(750);
ObjectAnimator sunAnimator = ObjectAnimator.ofFloat(sun, "alpha", 0, 1);
sunAnimator.setInterpolator(new LinearInterpolator());
sunAnimator.setDuration(150);
@@ -105,6 +110,7 @@ public class SplashFragment extends Fragment {
set.playTogether(sunAnimator, titleAnimator, subtitleAnimator);
set.play(worldAnimator).after(sunAnimator);
set.play(logoAnimator).after(sunAnimator);
set.play(gradientAnimator).after(sunAnimator);
set.start();
return root;
@@ -108,7 +108,7 @@ public class StateFragment extends AbstractPlaceFragment {
model.getCities().observe(getViewLifecycleOwner(), (list) -> adapter.submitList(list));
recyclerView.setAdapter(adapter);
MapView mapView = view.findViewById(R.id.map_detail);
MapViewUtil.setupInteractiveMap(mapView);
MapViewUtil.setupInteractiveMap(mapView, getResources().getBoolean(R.bool.dark_mode));
Runnable updateMap = () -> {
MapViewUtil.removePolylines(mapView, polylines);
polylines.clear();
@@ -122,7 +122,7 @@ public class StationFragment extends AbstractDiagramFragment {
model.getReports().observe(getViewLifecycleOwner(), (list) -> adapter.submitList(list));
recyclerView.setAdapter(adapter);
MapView mapView = view.findViewById(R.id.map_detail);
MapViewUtil.setupInteractiveMap(mapView);
MapViewUtil.setupInteractiveMap(mapView, getResources().getBoolean(R.bool.dark_mode));
Runnable updateMap = () -> {
if (model.getStation().getValue() != null) {
WeatherStation s = model.getStation().getValue();
@@ -832,7 +832,7 @@ public class BindingAdapters {
} else if (o instanceof Double) {
switch (value.getType()) {
case CPU_FREQUENCY:
valueText = r.getString(R.string.format_frequency, ((Double)o).floatValue());
valueText = r.getString(R.string.format_frequency, ((Double)o).floatValue() / 1000000);
break;
case SOLAR_VOLTAGE:
case BATTERY_VOLTAGE:
@@ -218,6 +218,8 @@ public class BindingTransforms {
return R.string.video_type_pressure;
case PRECIPITATION:
return R.string.video_type_precipitation;
case WIND:
return R.string.video_type_wind;
default:
return R.string.video_type_temperature;
}
@@ -146,6 +146,7 @@ public class SetupViewModel extends AndroidViewModel {
}
}
@Override
@SuppressWarnings("deprecation")
public void onStatusChanged(String provider, int status, Bundle extras) { }
@Override
public void onProviderEnabled(String provider) { }
@@ -1,6 +1,7 @@
package com.mowesta.android.app.util;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
@@ -38,8 +39,8 @@ public class DateFormatter {
* @return The formatted date with time.
*/
public String asDateTime(long time, @Nullable String timezone) {
Date date = getDate(time, timezone);
return getDateFormat().format(date) + " " + getTimeFormat().format(date);
Calendar date = getDate(time, timezone);
return format(getDateFormat(), date) + " " + format(getTimeFormat(), date);
}
/**
@@ -50,7 +51,7 @@ public class DateFormatter {
* @return The formatted date.
*/
public String asDate(long time, @Nullable String timezone) {
return getDateFormat().format(getDate(time, timezone));
return format(getDateFormat(), getDate(time, timezone));
}
/**
@@ -61,7 +62,7 @@ public class DateFormatter {
* @return The formatted time.
*/
public String asTime(long time, @Nullable String timezone) {
return getTimeFormat().format(getDate(time, timezone));
return format(getTimeFormat(), getDate(time, timezone));
}
/**
@@ -71,13 +72,26 @@ public class DateFormatter {
* @param timezone The timezone or null to use the host timezone.
* @return The date.
*/
private Date getDate(long time, @Nullable String timezone) {
private Calendar getDate(long time, @Nullable String timezone) {
Calendar c = Calendar.getInstance();
if (timezone != null) {
c.setTimeZone(TimeZone.getTimeZone(timezone));
}
c.setTimeInMillis(time);
return c.getTime();
return c;
}
/**
* Formats the time in the calendar using the format.
*
* @param format The format.
* @param c The calendar.
* @return The string.
*/
private String format(DateFormat format, Calendar c) {
format.setCalendar(c);
return format.format(c.getTime());
}
/**
@@ -34,9 +34,14 @@ import java.util.List;
public class MapViewUtil {
/**
* The url.
* The url for a light mode tile map.
*/
private static final String URL = "https://cloud.locoslab.com/carta/get/{z}/{x}/{y}.png";
private static final String URL_LIGHT = "https://www.mowesta.com/carta/tile/{z}/{x}/{y}.png";
/**
* The url for a dark mode tile map.
*/
private static final String URL_DARK = "https://www.mowesta.com/carta/tile/dark/{z}/{x}/{y}.png";
/**
@@ -153,7 +158,7 @@ public class MapViewUtil {
*/
public static void setupNonInteractiveMap(MapView mapView) {
setupInteraction(mapView, false);
setupTileLayer(mapView);
setupTileLayer(mapView, false);
}
/**
@@ -176,19 +181,21 @@ public class MapViewUtil {
* Configures an interactive map view.
*
* @param mapView The map view.
* @param darkMode True to enable dark mode, false otherwise
*/
public static void setupInteractiveMap(MapView mapView) {
public static void setupInteractiveMap(MapView mapView, boolean darkMode) {
setupInteraction(mapView, true);
setupTileLayer(mapView);
setupTileLayer(mapView, darkMode);
}
/**
* Adds a tile layer to the map.
*
* @param mapView The map view.
* @param darkMode True to use dark mode.
*/
private static void setupTileLayer(MapView mapView) {
TileLayerOptions options = new TileLayerOptions(URL);
private static void setupTileLayer(MapView mapView, boolean darkMode) {
TileLayerOptions options = new TileLayerOptions(darkMode?URL_DARK:URL_LIGHT);
options.minZoom = 4;
options.maxZoom = 18;
TileLayer layer = new TileLayer(options);
@@ -52,6 +52,42 @@ public class UnitUtils {
return speed * 3.6;
}
/**
* Returns the class on the Beaufort scale for a wind speed
* given in meter per second.
*
* @param value The wind speed.
* @return The beaufort scale (0-12).
*/
public static int mpsToBFT(double value) {
if (value < 0.5d)
return 0;
else if (value < 1.6d)
return 1;
else if (value < 3.4d)
return 2;
else if (value < 5.6d)
return 3;
else if (value < 8.0d)
return 4;
else if (value < 10.8d)
return 5;
else if (value < 13.9d)
return 6;
else if (value < 17.2d)
return 7;
else if (value < 20.8d)
return 8;
else if (value < 24.5d)
return 9;
else if (value < 28.5d)
return 10;
else if (value < 32.7d)
return 11;
else
return 12;
}
/**
* Converts the pressure given in hpa into
* psi.
@@ -125,13 +161,13 @@ public class UnitUtils {
public static String getTemperature(@NonNull Context context, double celsisus) {
MowestaSettings.TemperatureUnit unit = getSettings(context).getTemperatureUnit();
if (unit == MowestaSettings.TemperatureUnit.CELSIUS) {
return context.getString(R.string.format_temperature_celsius, round(celsisus));
return context.getString(R.string.format_temperature_celsius, celsisus);
} else {
int fahrenheit = round(celsiusToFahrenheit(celsisus));
double fahrenheit = celsiusToFahrenheit(celsisus);
if (unit == MowestaSettings.TemperatureUnit.FAHRENHEIT) {
return context.getString(R.string.format_temperature_fahrenheit, fahrenheit);
} else {
return context.getString(R.string.format_temperature_both, round(celsisus), fahrenheit);
return context.getString(R.string.format_temperature_both, celsisus, fahrenheit);
}
}
}
@@ -152,12 +188,13 @@ public class UnitUtils {
public static String getWindSpeed(@NonNull Context context, double mps) {
MowestaSettings.UnitSystem system = getSettings(context).getUnitSystem();
mps = Math.abs(mps); // make sure this is a positive value
if (system == MowestaSettings.UnitSystem.STANDARD) {
return context.getString(R.string.format_wind_speed_si, round(mpsToKmph(mps)));
return context.getString(R.string.format_wind_speed_si, round(mpsToKmph(mps)), mpsToBFT(mps));
} else {
double mph = mpsToMph(mps);
if (system == MowestaSettings.UnitSystem.IMPERIAL) {
return context.getString(R.string.format_wind_speed_im, round(mph));
return context.getString(R.string.format_wind_speed_im, round(mph), mpsToBFT(mps));
} else {
return context.getString(R.string.format_wind_speed_both, round(mpsToKmph(mps)), round(mph));
}
@@ -166,6 +203,7 @@ public class UnitUtils {
public static String getPrecipitation(@NonNull Context context, double mm) {
MowestaSettings.UnitSystem system = getSettings(context).getUnitSystem();
mm = Math.max(0, mm); // make sure this is positive
if (system == MowestaSettings.UnitSystem.STANDARD) {
return context.getString(R.string.format_precipitation_si, mm);
} else {
@@ -180,6 +218,7 @@ public class UnitUtils {
public static String getSnowDepth(@NonNull Context context, double m) {
MowestaSettings.UnitSystem system = getSettings(context).getUnitSystem();
m = Math.max(0, m); // make sure this is positive
if (system == MowestaSettings.UnitSystem.STANDARD) {
return context.getString(R.string.format_snow_si, m);
} else {
@@ -0,0 +1,275 @@
package com.mowesta.android.app.view;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.res.ResourcesCompat;
import com.mowesta.android.app.R;
/**
* A base class for views that show data. Besides from storing the
* values this view also contains some funky logic to create a
* magnifier effect.
*
* @param <T> The type of data to display.
*/
public abstract class DataView<T> extends View {
/** The drawing direction of the gradient. */
public enum Direction {
/** Draw from left to right. */
HORIZONTAL,
/** Draw from top to bottom. */
VERTICAL;
};
/**
* The drawing direction.
*/
@NonNull
protected Direction direction = Direction.VERTICAL;
/**
* A bitmap to draw the magnifier effect.
*/
protected Bitmap bitmap;
/**
* The bitmap size in dp.
*/
protected int bitmapSize;
/**
* The data of the view.
*/
@Nullable
protected T[] data;
/**
* The current selection or null.
*/
@Nullable
protected Float selection;
@NonNull
protected Paint bitmapBorderPaint = new Paint();
/**
* The color for the background.
*/
private int colorNormal;
/**
* The canvas to draw on the bitmap.
*/
private Canvas bitmapCanvas;
/**
* Creates a new view.
*
* @param context The context.
*/
public DataView(Context context) {
super(context);
init(context, null);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attributes.
*/
public DataView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context, attrs);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attributes.
* @param defStyleAttr The style attrs.
*/
public DataView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context, attrs);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attributes.
* @param defStyleAttr The style attrs.
* @param defStyleRes The style res.
*/
@TargetApi(21)
public DataView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context, attrs);
}
/**
* Initializes the view.
*
* @param context The context.
* @param attrs The attribute set.
*/
private void init(Context context, @Nullable AttributeSet attrs) {
colorNormal = ResourcesCompat.getColor(context.getResources(), R.color.normal, null);
DisplayMetrics m = getResources().getDisplayMetrics();
bitmapSize = (int)(m.density * 48 + 0.5);
bitmapBorderPaint.setColor(ResourcesCompat.getColor(context.getResources(), R.color.inverse, null));
bitmapBorderPaint.setStyle(Paint.Style.STROKE);
bitmapBorderPaint.setStrokeWidth(4);
if (attrs != null) {
TypedArray ta = getContext().obtainStyledAttributes(attrs, R.styleable.DataView);
int type = ta.getInt(R.styleable.DataView_direction,-1);
if (type >= 0 && type < Direction.values().length) {
this.direction = Direction.values()[type];
}
ta.recycle();
}
}
/**
* Sets the drawing direction.
*
* @param direction The drawing direction.
*/
public void setDirection(@NonNull Direction direction) {
this.direction = direction;
updateBitmap();
}
/**
* Returns the drawing direction.
*
* @return The drawing direction.
*/
@NonNull
public Direction getDirection() {
return direction;
}
/**
* Sets the current data.
*
* @param data The data.
*/
public void setData(@Nullable T[] data) {
this.data = data;
}
/**
* Returns the current data.
*
* @return The current data.
*/
@Nullable
public T[] getData() {
return data;
}
/**
* Returns the data at the relative position.
*
* @param pos The relative position.
* @return The data.
*/
@Nullable
public T getDataAt(float pos) {
if (data == null || data.length == 0) return null;
int idx = (int)((data.length - 1) * pos);
idx = Math.min(Math.max(0, idx), data.length - 1);
return data[idx];
}
@Override
protected void onDraw(Canvas canvas) {
long now = System.currentTimeMillis();
super.onDraw(canvas);
onDrawData(now, canvas);
if (selection != null) {
bitmap.eraseColor(colorNormal);
if (getBackground() != null) {
getBackground().draw(bitmapCanvas);
}
bitmapCanvas.save();
if (direction == Direction.VERTICAL) {
bitmapCanvas.scale(1, 3);
bitmapCanvas.translate(0, -selection * getHeight() + bitmapSize / 6f);
} else {
bitmapCanvas.scale(3, 1);
bitmapCanvas.translate(-selection * getWidth() + bitmapSize / 6f, 0);
}
onDrawData(now, bitmapCanvas);
bitmapCanvas.restore();
if (direction == Direction.VERTICAL) {
bitmapCanvas.drawLine(0, 1, bitmap.getWidth(), 1, bitmapBorderPaint);
bitmapCanvas.drawLine(0, bitmap.getHeight() - 2, bitmap.getWidth(), bitmap.getHeight() - 2, bitmapBorderPaint);
canvas.drawBitmap(bitmap, 0, selection * getHeight() - bitmapSize / 2, null);
} else {
bitmapCanvas.drawLine( 1, 0, 1, bitmap.getHeight(), bitmapBorderPaint);
bitmapCanvas.drawLine(bitmap.getWidth() - 2, 0, bitmap.getWidth() - 2, bitmap.getHeight(), bitmapBorderPaint);
canvas.drawBitmap(bitmap, selection * getWidth() - bitmapSize / 2, 0, null);
}
}
}
public void setSelection(@Nullable Float selection) {
this.selection = selection;
invalidate();
}
@Nullable
public Float getSelection() {
return selection;
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
updateBitmap();
}
protected abstract void onDrawData(long time, Canvas canvas);
/**
* Recomputes the bitmap based on the size.
*/
private void updateBitmap() {
if (bitmap != null) {
bitmap.recycle();
bitmap = null;
bitmapCanvas = null;
}
if (direction == Direction.VERTICAL) {
if (getWidth() > 0) {
bitmap = Bitmap.createBitmap(getWidth(), bitmapSize, Bitmap.Config.ARGB_8888);
bitmapCanvas = new Canvas(bitmap);
}
} else {
if (getHeight() > 0) {
bitmap = Bitmap.createBitmap(bitmapSize, getHeight(), Bitmap.Config.ARGB_8888);
bitmapCanvas = new Canvas(bitmap);
}
}
}
}
@@ -0,0 +1,323 @@
package com.mowesta.android.app.view;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.res.ResourcesCompat;
import com.mowesta.android.app.R;
import java.util.Random;
/**
* A gradient view that shows rain drops. This is used for the
* precipitation.
*
* @author Marcus
*/
public class DropView extends GradientView {
/**
* The threshold for rain.
*/
private static final double DROP_THRESHOLD = 0.1;
/**
* The maximum number of water drops to simulate.
*/
private static final int MAXIMUM_DROPS = 45;
/**
* The speed of the drops in dp.
*/
private static final int DROP_SPEED = 20;
/**
* The random number generator for drops.
*/
private Random random = new Random();
/**
* The drawable for a water drop.
*/
private Drawable drawable;
/**
* The sum of all rain used to skew the random
* number generator.
*/
private double sqrtSum;
/**
* The square roots of the data.
*/
private double[] sqrts;
/**
* The water drops.
*/
private WaterDrop[] drops = null;
/**
* Creates a new view.
*
* @param context The context.
*/
public DropView(Context context) {
super(context);
init(context);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attributes.
*/
public DropView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attributes.
* @param defStyleAttr The style.
*/
public DropView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attributes.
* @param defStyleAttr The style.
* @param defStyleRes The style res.
*/
public DropView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context);
}
/**
* Initializes the view.
*
* @param context The context.
*/
private void init(Context context) {
drawable = AppCompatResources.getDrawable(context, R.drawable.fg_water_drop);
}
@Override
public void setData(Double[] data) {
super.setData(data);
sqrtSum = 0;
if (data != null) {
sqrts = new double[data.length];
for (int i = 0; i < data.length; i++) {
if (data[i] > DROP_THRESHOLD) {
sqrts[i] = Math.sqrt(data[i]);
sqrtSum += sqrts[i];
}
}
} else {
sqrts = null;
}
updateDrops();
}
@Override
public void setDirection(@NonNull Direction direction) {
super.setDirection(direction);
updateDrops();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
updateDrops();
}
/**
* Updates the drops after the data or size has changed.
*/
private void updateDrops() {
if (data != null && data.length > 0 && sqrtSum > 0) {
int count = Math.min((int) sqrtSum + 5, MAXIMUM_DROPS);
drops = new WaterDrop[count];
float density = getResources().getDisplayMetrics().density;
for (int i = 0; i < drops.length; i++) {
drops[i] = new WaterDrop(density);
}
postInvalidateOnAnimation();
}
}
@Override
protected void onDrawData(long time, Canvas canvas) {
super.onDrawData(time, canvas);
if (drops != null) {
for (int i = 0; i < drops.length; i++) {
drops[i].animate(time);
drops[i].draw(canvas);
}
postInvalidateOnAnimation();
}
}
/**
* A class to emulate a single water drop.
*/
private class WaterDrop {
/**
* The current time.
*/
private long time;
/**
* The left corner.
*/
private float x;
/**
* The top corner.
*/
private float y;
/**
* The remaining distance that this drop will
* travel (in y direction) before it fades out.
*/
private float distance;
/**
* The speed at which the drop moves down in
* pixels per second.
*/
private int speed;
/**
* The size of the current drop in pixels.
*/
private float size;
/**
* The alpha value used for drawing.
*/
private float alpha;
/**
* The screen density to compute random sizes
* in dp.
*/
private float density;
/**
* Creates a new drop.
*
* @param density The screen density.
*/
private WaterDrop(float density) {
this.density = density;
}
/**
* Computes a new random starting location for the water drop
* as well as the size, movement speed (larger drops are faster)
* and the distance to travel.
*/
private void reset() {
int value = random.nextInt(5);
size = this.density * (value + 3);
float speedFactor = 0.5f + (value + 1) / 10f;
speed = (int)(speedFactor * density * DROP_SPEED);
float percent = random.nextFloat();
double position = percent * sqrtSum;
double current = 0;
for (int i = 0; i < data.length; i++) {
if (data[i] > DROP_THRESHOLD) current += sqrts[i];
if (current >= position) {
int start = i;
int end = i;
for (int j = start - 1; j >= Math.max(0, i - 8); j--) {
if (data[j] > data[i]) start = j;
else break;
}
for (int j = end + i; j < Math.min(data.length, i + 8); j++) {
if (data[j] > data[i]) end = j;
else break;
}
if (direction == Direction.VERTICAL) {
float dh = getHeight() / (float)data.length;
y = dh * (start - random.nextFloat());
x = (getWidth() - size) * random.nextFloat();
distance = dh * (end + random.nextFloat()) - y;
} else {
float dw = getWidth() / (float)data.length;
y = getHeight() * random.nextFloat();
x = dw * (i + random.nextFloat());
distance = (getHeight() - y) * random.nextFloat();
}
break;
}
}
alpha = 0.5f;
}
/**
* Animates the drop for the current time.
*
* @param time The current time.
*/
public void animate(long time) {
if (this.time == 0) {
reset();
} else {
moveBy(time - this.time);
if (alpha <= 0) {
reset();
}
}
this.time = time;
}
/**
* Moves the animation forward by a delta t in millis.
*
* @param delta The delta t in millis.
*/
private void moveBy(long delta) {
int shift = (int)(size * (random.nextFloat() - .5f));
float dx = delta / 1000f;
float newy = y + dx * speed;
x = x + dx * shift;
distance -= newy - y;
alpha = (float)Math.min(1, Math.max(0, 1 + distance / (size / 2)));
y = newy;
}
/**
* Draws the drop in its current state.
*
* @param canvas The canvas to draw onto.
*/
public void draw(Canvas canvas) {
int a = (int)Math.max(0, Math.min(255, alpha * 255));
drawable.setAlpha(a);
int ix = (int)x;
int iy = (int)y;
int s = (int)(size * alpha);
drawable.setBounds(ix, iy, ix + s, iy + s);
drawable.draw(canvas);
}
}
}
@@ -0,0 +1,106 @@
package com.mowesta.android.app.view;
import android.content.Context;
import android.util.AttributeSet;
import androidx.annotation.Nullable;
import com.google.android.gms.common.SignInButton;
import com.mowesta.android.app.view.color.IColorScheme;
/**
* A gradient view that joins two data items to get a color.
* This is required to join the cloud depth and coverage.
*
* @author Marcus
*/
public class DualGradientView extends GradientView {
/**
* The secondary data.
*/
@Nullable
private Double[] secondaryData;
/**
* The secondary color scheme.
*/
@Nullable
private IColorScheme secondaryColorScheme;
/**
* Creates a new view.
*
* @param context The context.
*/
public DualGradientView(Context context) {
super(context);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attributes.
*/
public DualGradientView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attributes.
* @param defStyleAttr The default attributes.
*/
public DualGradientView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attributes.
* @param defStyleAttr The default attributes.
* @param defStyleRes The default res.
*/
public DualGradientView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
/**
* Sets the secondary color scheme.
*
* @param secondaryColorScheme The secondary color scheme.
*/
public void setSecondaryColorScheme(@Nullable IColorScheme secondaryColorScheme) {
this.secondaryColorScheme = secondaryColorScheme;
updateColors();
updateGradient();
}
/**
* Sets the secondary data.
*
* @param secondaryData The secondary data.
*/
public void setSecondaryData(@Nullable Double[] secondaryData) {
this.secondaryData = secondaryData;
updateColors();
updateGradient();
}
@Override
protected void updateColors() {
super.updateColors();
if (colors != null && secondaryData != null && secondaryColorScheme != null && secondaryData.length == colors.length) {
for (int i = 0; i < colors.length; i++) {
int cover = colors[i];
int other = secondaryColorScheme.getColor(secondaryData[i]);
colors[i] = (cover & 0xFF000000) | (other & 0x00FFFFFF);
}
}
}
}
@@ -0,0 +1,199 @@
package com.mowesta.android.app.view;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.mowesta.android.app.view.color.IColorScheme;
/**
* A view to display weather information as a gradient that is
* drawn efficiently using the graphics card of the device.
*
* @author Marcus
*/
public class GradientView extends DataView<Double> {
/**
* The color scheme.
*/
@Nullable
protected IColorScheme colorScheme;
/**
* The colors for the data.
*/
@Nullable
protected int[] colors;
/**
* The positions for the data.
*/
@Nullable
protected float[] positions;
/**
* The gradient for the data.
*/
@Nullable
protected LinearGradient gradient;
/**
* The paint to draw the gradient.
*/
protected Paint paint = new Paint();
/**
* Creates a new view.
*
* @param context The context.
*/
public GradientView(Context context) {
super(context);
init(context);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attrs.
*/
public GradientView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attrs.
* @param defStyleAttr The default style.
*/
public GradientView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attrs.
* @param defStyleAttr The default style.
* @param defStyleRes The default res.
*/
@TargetApi(21)
public GradientView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context);
}
/**
* Initializes the view.
*
* @param context The context.
*/
private void init(Context context) {
paint.setStyle(Paint.Style.FILL);
}
@Override
public void setData(Double[] data) {
this.data = data;
updatePositions();
updateColors();
updateGradient();
}
/**
* Returns the color scheme to render the data.
*
* @return The color scheme.
*/
@Nullable
public IColorScheme getColorScheme() {
return colorScheme;
}
/**
* Sets the color scheme to render the data.
*
* @param colorScheme The color scheme.
*/
public void setColorScheme(@Nullable IColorScheme colorScheme) {
this.colorScheme = colorScheme;
updateColors();
updateGradient();
}
@Override
public void setDirection(@NonNull Direction direction) {
this.direction = direction;
updateGradient();
}
@Override
protected void onDrawData(long time, Canvas canvas) {
if (gradient != null) {
paint.setShader(gradient);
canvas.drawRect(0, 0, getWidth(), getHeight(), paint);
}
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
updateGradient();
}
/**
* Computes the gradient to draw the data.
*/
protected void updateGradient() {
if (colors == null || positions == null) {
gradient = null;
} else {
float x = direction == Direction.HORIZONTAL ? getWidth(): 0;
float y = direction == Direction.HORIZONTAL ? 0 : getHeight();
gradient = new LinearGradient(0, 0, x, y, colors, positions, Shader.TileMode.CLAMP);
}
}
/**
* Updates the positions of the gradient.
*/
protected void updatePositions() {
if (data == null) {
positions = null;
} else {
positions = new float[data.length];
for (int i = 0; i < positions.length; i++) {
positions[i] = 0.5f/data.length + i/(float)data.length;
}
}
}
/**
* Updates the colors of the gradient.
*/
protected void updateColors() {
if (data == null || colorScheme == null) {
colors = null;
} else {
colors = new int[data.length];
for (int i = 0; i < colors.length; i++) {
colors[i] = colorScheme.getColor(data[i]);
}
}
}
}
@@ -0,0 +1,330 @@
package com.mowesta.android.app.view;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
import android.util.AttributeSet;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.res.ResourcesCompat;
import com.locoslab.library.geometry.util.clipper.Clipper;
import com.mowesta.android.app.R;
import java.util.Random;
/**
* This data view generates particles moving at a data-dependent
* speed. The particles are drawn as a linear gradient. The size
* of the gradient also depends on the speed. This view is used
* to draw the wind speed.
*
* @author Marcus
*/
public class ParticleView extends DataView<Double> {
/**
* A random number generator to share across all
* particles.
*/
@NonNull
private Random random = new Random();
/**
* The particles that store their current position.
*/
@Nullable
private Particle[] particles;
/**
* The paint to draw the particles.
*/
@NonNull
private Paint paint = new Paint();
/**
* A factor to speed up or slow down the motion. This
* factor is multiplied by the speed in meter per second
* to get the motion in pixels per second.
*/
private float speedFactor = 10;
/**
* The relative length of the particle tails. This
* is used to derive the maximum length.
*/
private float relativeLength = .5f;
/**
* The relative height of the particle tails. This
* is used to derive the stroke width.
*/
private float relativeHeight = .5f;
/**
* The randomized start time.
*/
private int randomizeTime = 2000;
/**
* Creates a new view.
*
* @param context The context.
*/
public ParticleView(Context context) {
super(context);
init(context);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attrs.
*/
public ParticleView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attrs.
* @param defStyleAttr The default style attrs.
*/
public ParticleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attrs.
* @param defStyleAttr The default style attrs.
* @param defStyleRes The default style res.
*/
@TargetApi(21)
public ParticleView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context);
}
/**
* Initializes the view.
*
* @param context The context.
*/
private void init(Context context) {
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeCap(Paint.Cap.ROUND);
}
@Override
protected void onDrawData(long time, Canvas canvas) {
if (particles != null) {
for (int i = particles.length - 1; i >= 0; i--) {
particles[i].animate(time);
particles[i].draw(canvas, paint);
}
postInvalidateOnAnimation();
}
}
@Override
public void setData(@Nullable Double[] data) {
super.setData(data);
updateParticles();
}
@Override
public void setDirection(@NonNull Direction direction) {
super.setDirection(direction);
updateParticles();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
updateParticles();
}
/**
* Re-computes the particle's based on the data and the direction.
*/
private void updateParticles() {
int width = getWidth();
int height = getHeight();
if (data == null || data.length == 0 || width == 0 || height == 0) {
particles = null;
} else {
Direction dir = direction==Direction.VERTICAL?Direction.HORIZONTAL:Direction.VERTICAL;
int color = ResourcesCompat.getColor(getResources(), R.color.particle, null);
double max = 0;
for (int i = 0; i < data.length; i++)
max = Math.max(max, data[i]);
particles = new Particle[data.length];
float cell = (direction == Direction.VERTICAL?height:width) / (float)data.length;
float length = (direction == Direction.VERTICAL?width:height) * relativeLength;
float size = direction == Direction.VERTICAL?width:height;
paint.setStrokeWidth(cell * relativeHeight);
for (int i = 0; i < data.length; i++) {
RectF rect = direction == Direction.VERTICAL ? new RectF(0, cell * i, size, cell * (i + 1)) :
new RectF(cell * i, 0, cell * (i + 1), size);
float speed = (float)(speedFactor * data[i]);
float tail = (float)(max == 0 ? 0 : (data[i] / max)) * length;
particles[i] = new Particle(random, rect, dir, color, speed, tail, randomizeTime);
}
}
}
/**
* A single particle that moves into horizontal or vertical direction.
*
* @author Marcus
*/
private static class Particle {
/** A random number generator to make the particle less predictable. */
@NonNull
private Random random;
/** The movement direction (horizontal: left to right, vertical: top to bottom). */
@NonNull
private Direction direction;
/** The rectangle in which we draw. */
@NonNull
private RectF rect;
/** The current x-position of the particle (head). */
private float x;
/** The current y-position of the particle (head). */
private float y;
/** The length of the particle's tail. */
private float length;
/** The movement speed in pixels per second. */
private float speed;
/** The time used to randomize restarts. */
private int randomize;
/** The time when the particle's position was last computed. */
private long time;
/** A gradient to quickly draw the particle. */
@NonNull
private LinearGradient gradient;
/** The translation matrix to avoid object allocations. */
@NonNull
private Matrix matrix = new Matrix();
/**
* A single particle that moves either vertically or horizontally.
*
* @param random A random number generator.
* @param rect The rectangle in which the particle moves.
* @param direction The direction to move (left to right or top to bottom).
* @param speed The movement speed in pixels per second.
* @param length The length of the tail of the particle.
* @param randomize The time used to randomize the restart when the particle moved off the screen.
*/
public Particle(@NonNull Random random, @NonNull RectF rect, @NonNull Direction direction, int color, float speed, float length, int randomize) {
this.random = random;
this.direction = direction;
this.rect = rect;
this.speed = speed;
this.length = length;
this.randomize = randomize;
gradient = new LinearGradient(0, 0,
direction == Direction.HORIZONTAL?length:0,
direction == Direction.HORIZONTAL?0:length,
new int[] { 0x00ffffff, color },
new float[] { 0f, 1f}, Shader.TileMode.CLAMP);
}
/**
* Draws the particle onto the canvas.
*
* @param c The canvas.
* @param paint The paint to draw with.
*/
public void draw(Canvas c, Paint paint) {
float xs = (direction == Direction.HORIZONTAL)? x - length: x;
float ys = (direction == Direction.HORIZONTAL)? y : y - length;
matrix.setTranslate(xs, ys);
gradient.setLocalMatrix(matrix);
paint.setShader(gradient);
c.drawLine(xs , ys, x, y, paint);
}
/**
* Computes the animation state based on the time.
*
* @param time The time.
*/
public void animate(long time) {
if (this.time == 0 || isFinished()) {
reset(this.time == 0);
} else {
moveBy(time - this.time);
}
this.time = time;
}
/**
* Determines whether the particle has moved out of sight.
*
* @return True if it has moved out of sight. False otherwise.
*/
private boolean isFinished() {
if (direction == Direction.HORIZONTAL) {
return x - length > rect.right;
} else {
return y - length > rect.bottom;
}
}
/**
* Resets the particle to a new initial position.
*
* @param init True, if the positions shall be randomly distributed.
*/
private void reset(boolean init) {
float movement = random.nextInt(randomize) / 1000f * speed;
if (direction == Direction.HORIZONTAL) {
x = rect.left - movement + (init?rect.width() * random.nextFloat():0);
y = rect.top + (rect.bottom - rect.top) * 0.5f;
} else {
x = rect.left + (rect.right - rect.left) * 0.5f;
y = rect.top - movement + (init?rect.height() * random.nextFloat():0);
}
}
/**
* Moves the particle depending on the time passed.
*
* @param delta The time passed in milliseconds.
*/
private void moveBy(long delta) {
float movement = delta / 1000f * speed;
if (direction == Direction.HORIZONTAL) {
x += movement;
} else {
y += movement;
}
}
}
}
@@ -0,0 +1,429 @@
package com.mowesta.android.app.view;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.MotionEvent;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.res.ResourcesCompat;
import com.mowesta.android.app.R;
import com.mowesta.android.app.util.TimeUtils;
/**
* The view to display the time and to handle touch events.
*
* @author Marcus
*/
public class TimeView extends DataView<Long> {
/**
* An interface for listeners that want to be
* informed about touch events.
*
* @author Marcus
*/
public interface OnSlideListener {
/**
* Called when there is a slide event on the view at
* the specified relative position.
*
* @param relative The relative position (0 to 1).
*/
void onSlide(float relative);
void onSlideEnd();
}
/**
* A listener to handle the touch events on the view.
*
*/
private static class TouchListener implements View.OnTouchListener {
/** The epsilon to ignore duplicate events. */
private float EPSILON = 0.0001f;
/** The time view that is observed by this listener. */
private TimeView view;
/** A cache for the view position.*/
private int[] viewPosition = new int[2];
/**
* If down, the id of the pointer that we are tracking.
*/
private int id = 0;
/**
* A boolean to memorize whether we already saw a finger going down.
*/
private boolean down = false;
/**
* The last relative position that we saw.
*/
private float position = 0;
@NonNull
private OnSlideListener listener;
public TouchListener(@NonNull TimeView view, @NonNull OnSlideListener listener) {
this.view = view;
this.listener = listener;
}
@Override
public boolean onTouch(View v, MotionEvent event) {
updateViewPosition();
int index = event.getActionIndex();
int mask = event.getActionMasked();
boolean onView = isOnView(event);
switch (mask) {
case MotionEvent.ACTION_DOWN:
if (! down && onView) {
down = true;
id = event.getPointerId(index);
position = getPosition(event);
listener.onSlide(position);
};
break;
case MotionEvent.ACTION_MOVE:
if (down && id == event.getPointerId(index)) {
float np = getPosition(event);
if (Math.abs(np - position) > EPSILON) {
position = np;
listener.onSlide(position);
}
}
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
if (down && id == event.getPointerId(index)) {
down = false;
listener.onSlideEnd();
return true;
}
break;
}
return down;
}
private void updateViewPosition() {
view.getLocationOnScreen(viewPosition);
}
private float getPosition(MotionEvent event) {
if (view.getDirection() == Direction.HORIZONTAL) {
if (view.getWidth() == 0) return 0;
float x = event.getRawX();
return Math.min(1, Math.max(0, (x - viewPosition[0]) / view.getWidth()));
} else {
if (view.getHeight() == 0) return 0;
float y = event.getRawY();
return Math.min(1, Math.max(0, (y - viewPosition[1]) / view.getHeight()));
}
}
private boolean isOnView(MotionEvent event) {
float x = event.getRawX();
float y = event.getRawY();
return x >= viewPosition[0] && x < viewPosition[0] + view.getWidth()
&& y >= viewPosition[1] && y < viewPosition[1] + view.getHeight();
}
}
/**
* The timezone.
*/
private String timezone;
/**
* The positions to draw lines.
*/
private float[] positions;
/**
* The lengths of the lines at the positions.
*/
private float[] lengths;
/**
* The paint to draw the lines.
*/
private Paint paint = new Paint();
/**
* The paint to draw the current time.
*/
private Paint paintNow = new Paint();
/**
* The circle animation.
*/
private TouchCircleAnimation animation = new TouchCircleAnimation(this);
/**
* Creates a new view.
*
* @param context The context.
*/
public TimeView(Context context) {
super(context);
init(context);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attributes.
*/
public TimeView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init(context);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attributes.
* @param defStyleAttr The default attributes.
*/
public TimeView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
/**
* Creates a new view.
*
* @param context The context.
* @param attrs The attributes.
* @param defStyleAttr The default attributes.
* @param defStyleRes The default style.
*/
@TargetApi(21)
public TimeView(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
init(context);
}
/**
* Initializes the view.
*
* @param context The context.
*/
private void init(Context context) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
paint.setStrokeWidth((int)(1f * displayMetrics.density + .5f));
paint.setColor(ResourcesCompat.getColor(context.getResources(), R.color.inverse, null));
paint.setAntiAlias(true);
paintNow.setStrokeWidth((int)(2f * displayMetrics.density + .5f));
paintNow.setColor(ResourcesCompat.getColor(context.getResources(), R.color.primary, null));
paintNow.setAntiAlias(true);
}
/**
* Creates an touch listener for this view.
*
* @param listener The listener to keep track of events.
* @return The touch listener.
*/
public View.OnTouchListener createOnTouchListener(@NonNull OnSlideListener listener) {
return new TouchListener(this, listener);
}
/**
* Sets the timezone to draw the hours.
*
* @param timezone The timezone.
*/
public void setTimezone(String timezone) {
this.timezone = timezone;
updateTimes();
}
/**
* Returns the time zone.
*
* @return The timezone.
*/
public String getTimezone() {
return timezone;
}
@Override
public void setData(@Nullable Long[] data) {
super.setData(data);
updateTimes();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
updateTimes();
}
@Override
protected void onDrawData(long time, Canvas canvas) {
animation.animate(time);
animation.draw(canvas);
if (positions != null) {
// draw now
for (int i = 1; i < data.length; i++) {
if (time > data[i - 1] && time <= data[i]) {
float fraction = (data[i] - time) / (data[i] - data[i - 1]);
float pos = (direction == Direction.VERTICAL?getHeight():getWidth()) * (i + fraction) / data.length;
float end = direction == Direction.VERTICAL?getWidth():getHeight();
if (direction == Direction.VERTICAL) {
canvas.drawLine(0, pos, end, pos, paintNow);
} else {
canvas.drawLine(pos, 0, pos, end, paintNow);
}
}
}
// draw grid
float center = (direction == Direction.VERTICAL?getWidth():getHeight()) / 2f;
for (int i = 0; i < positions.length; i++) {
float xs = direction == Direction.VERTICAL?center - .5f * lengths[i]:positions[i];
float xe = direction == Direction.VERTICAL?center + .5f * lengths[i]:positions[i];
float ys = direction == Direction.HORIZONTAL?center - .5f * lengths[i]:positions[i];
float ye = direction == Direction.HORIZONTAL?center + .5f * lengths[i]:positions[i];
canvas.drawLine(xs, ys, xe, ye, paint);
}
}
}
public void updateTimes() {
if (data == null || data.length == 0) {
lengths = null;
positions = null;
} else {
int[] hours = new int[data.length];
TimeUtils time = new TimeUtils(System.currentTimeMillis(), timezone);
int ranges = 0;
for (int i = 0; i < data.length; i++) {
hours[i] = time.getHour(data[i]);
if (hours[i] % 6 == 0) {
ranges += 1;
}
}
positions = new float[ranges];
lengths = new float[ranges];
int index = 0;
int total = direction == Direction.VERTICAL?getHeight():getWidth();
int max = direction == Direction.VERTICAL?getWidth():getHeight();
for (int i = 0; i < data.length; i++) {
if (hours[i] % 6 == 0) {
positions[index] = ((float)total / data.length) * (i + .5f);
lengths[index] = hours[i] == 0 ? (max * .75f): (max * 0.25f);
index += 1;
}
}
}
}
private class TouchCircleAnimation {
/** The center of the click. */
float cx, cy;
/** The animated radius. */
float radius;
/** The animated alpha value. */
float alpha;
/** The speed at which the circle expands. */
float expand = 500;
/**
* The speed at which the alpha value decays.
*/
float fade = 2f;
/** The Animation time. */
long time = 0;
/** The number of repeatitions. */
int repeat = 0;
/** A boolean to indicate when done. */
boolean done = false;
/** The paint to draw. */
Paint paint = new Paint();
/** The view. */
DataView<?> view;
/** The finger drawable. */
Drawable touch;
public TouchCircleAnimation(DataView<?> view) {
this.view = view;
this.touch = AppCompatResources.getDrawable(view.getContext(), R.drawable.ic_touch_app_normal_24);
paint.setColor(ResourcesCompat.getColor(view.getResources(), R.color.accent, null));
paint.setStyle(Paint.Style.FILL);
}
public void animate(long now) {
if (time == 0) {
reset();
} else {
updateBy(now - time);
if (alpha < 0) {
reset();
}
}
time = now;
done = repeat > 3;
}
private void updateBy(long delta) {
float dx = delta / 1000f;
alpha -= dx * fade;
radius += dx * expand;
}
public void draw(Canvas c) {
if (!done) {
if (repeat > 1) {
int a = (int)Math.min(255, Math.max(0, 255 * alpha));
paint.setAlpha(Math.min(255, a + 128));
c.drawCircle(cx, cy, radius, paint);
touch.setAlpha(a);
touch.draw(c);
}
postInvalidateOnAnimation();
}
}
public void reset() {
cx = getWidth() / 2;
cy = getHeight() / 2;
if (view.direction == Direction.VERTICAL) {
cy = cy / 2f;
}
int padding = (int)(Math.min(getWidth(), getHeight()) * 0.1f);
int size = Math.min(getWidth(), getHeight()) / 2 - padding;
touch.setBounds((int)cx - size, (int)cy - size, (int)cx + size, (int) cy + size);
radius = 1;
alpha = 1;
repeat += 1;
}
}
}
@@ -0,0 +1,32 @@
package com.mowesta.android.app.view.color;
import com.mowesta.android.app.view.interpolation.LinearInterpolation;
import java.util.ArrayList;
import java.util.List;
/**
* A color scheme for the cloud depth.
*
* @author Marcus
*/
public class CloudDepthColorScheme extends InterpolatedColorScheme {
/**
* The list of supports.
*/
private static List<ColorSupport> SUPPORT = new ArrayList<>();
static {
SUPPORT.add(new ColorSupport(0, 0x00FFFFFF));
SUPPORT.add(new ColorSupport(1, 0xFF999999));
}
/**
* Creates a new color scheme to render the cloud depth.
*/
public CloudDepthColorScheme() {
super(SUPPORT, new LinearInterpolation());
}
}
@@ -0,0 +1,32 @@
package com.mowesta.android.app.view.color;
import com.mowesta.android.app.view.interpolation.LinearInterpolation;
import java.util.ArrayList;
import java.util.List;
/**
* The color scheme for relative humidity.
*
* @author Marcus
*/
public class HumidityColorScheme extends InterpolatedColorScheme {
/**
* The support vector with the temperature to color mapping.
*/
private static List<ColorSupport> SUPPORT = new ArrayList<>();
static {
SUPPORT.add(new ColorSupport(0, 0x0042BAD0));
SUPPORT.add(new ColorSupport(100, 0xFF42BAD0));
}
/**
* Creates a color scheme.
*/
public HumidityColorScheme() {
super(SUPPORT, new LinearInterpolation());
}
}
@@ -0,0 +1,19 @@
package com.mowesta.android.app.view.color;
/**
* A color scheme is responsible for mapping a data
* value to an ARGB color.
*
* @author Marcus
*/
public interface IColorScheme {
/**
* Returns the color for the data value.
*
* @param value The data value.
* @return The ARGB value with 8 bit resolution.
*/
int getColor(double value);
}
@@ -0,0 +1,202 @@
package com.mowesta.android.app.view.color;
import com.mowesta.android.app.view.interpolation.IDataInterpolation;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* A color scheme for temperature given in degrees Kelvin.
*
* @author Marcus
*/
public class InterpolatedColorScheme implements IColorScheme {
/**
* A support point that defines the color for a particular value.
*
* @author Marcus
*/
public static class ColorSupport implements Comparable<ColorSupport> {
/**
* The value.
*/
protected double value;
/**
* The red component.
*/
protected int red;
/**
* The green component (0 - 255).
*/
protected int green;
/**
* The blue component.
*/
protected int blue;
/**
* The alpha component.
*/
protected int alpha;
/**
* Creates the support for the specified color.
*
* @param value The value that should exhibit the color.
* @param argb The color value.
*/
public ColorSupport(double value, int argb) {
this(value, (argb >> 24) & 0xff, (argb >> 16) & 0xff, (argb >> 8) & 0xff, argb & 0xff);
}
/**
* Creates a new support at a particular value.
*
* @param value The data value that should exhibit the color.
* @param a The alpha value.
* @param r The red value.
* @param g The green value.
* @param b The blue value.
*/
public ColorSupport(double value, int a, int r, int g, int b) {
this.value = value;
this.alpha = a & 0xff;
this.red = r & 0xff;
this.green = g & 0xff;
this.blue = b & 0xff;
}
/**
* Returns the value.
*
* @return The value.
*/
public double getValue() {
return value;
}
/**
* Returns the color as ARGB int.
*
* @return The color as ARGB int.
*/
public int getColor() {
return alpha << 24 | red << 16 | green << 8 | blue;
}
/**
* Returns the blue component (0-255).
*
* @return The blue component.
*/
public int getRed() {
return red;
}
/**
* Returns the blue component (0-255).
*
* @return The blue component.
*/
public int getGreen() {
return green;
}
/**
* Returns the blue component (0-255).
*
* @return The blue component.
*/
public int getAlpha() {
return alpha;
}
/**
* Returns the blue component (0-255).
*
* @return The blue component.
*/
public int getBlue() {
return blue;
}
@Override
public int compareTo(ColorSupport o) {
return Double.compare(value, o.value);
}
}
/**
* The supporting points.
*/
protected List<ColorSupport> supports;
/**
* The interpolation strategy.
*/
protected IDataInterpolation interpolation;
/**
* Creates an interpolated color scheme.
*
* @param supports The supports.
* @param interpolation The interpolation strategy.
*/
public InterpolatedColorScheme(List<ColorSupport> supports, IDataInterpolation interpolation) {
if (supports.isEmpty()) throw new IllegalArgumentException("At least one color support point must be specified.");
this.supports = new ArrayList<>(supports);
this.interpolation = interpolation;
Collections.sort(supports);
}
@Override
public int getColor(double data) {
// data is smaller than any support, return lowest support color
if (data < supports.get(0).getValue()) return supports.get(0).getColor();
for (int i = 1; i < supports.size(); i++) {
if (supports.get(i).getValue() > data) {
return getColor(supports.get(i - 1), supports.get(i), data);
}
}
// data is larger than any support, return highest support color
return supports.get(supports.size() - 1).getColor();
}
/**
* Computes the interpolated color for the value.
*
* @param from The lower support.
* @param to The higher support.
* @param value The data value.
* @return The interpolated color.
*/
private int getColor(ColorSupport from, ColorSupport to, double value) {
double fraction = (value - from.getValue()) / (double)(to.getValue() - from.getValue());
int alpha = getColor(from.getAlpha(), to.getAlpha(), fraction);
int red = getColor(from.getRed(), to.getRed(), fraction);
int green = getColor(from.getGreen(), to.getGreen(), fraction);
int blue = getColor(from.getBlue(), to.getBlue(), fraction);
return alpha << 24 | red << 16 | green << 8 | blue;
}
/**
* Computes the interpolated color value and ensures that it
* lies within the target bounds.
*
* @param from The start color value.
* @param to The to color value.
* @param fraction The fraction between from and to.
* @return The color value.
*/
private int getColor(int from, int to, double fraction) {
double r = interpolation.interpolate(from, to, fraction);
return Math.min(255, Math.max(0, (int)Math.round(r)));
}
}
@@ -0,0 +1,37 @@
package com.mowesta.android.app.view.color;
import com.mowesta.android.app.view.interpolation.LinearInterpolation;
import java.util.ArrayList;
import java.util.List;
/**
* The color scheme for precipitation (rain, snow, etc.).
* @author Marcus
*
*/
public class PrecipitationColorScheme extends InterpolatedColorScheme {
/**
* The support vector with the temperature to color mapping.
*/
private static List<ColorSupport> SUPPORT = new ArrayList<>();
static {
SUPPORT.add(new ColorSupport(0, 0x0000000));
SUPPORT.add(new ColorSupport(0.1, 0x88008800));
SUPPORT.add(new ColorSupport(1, 0xFF00FF00)); // Nieselregen (<1)
SUPPORT.add(new ColorSupport(10, 0xFF00FFFF));
SUPPORT.add(new ColorSupport(20, 0xFF0000FF)); // Starkregen (>20)
SUPPORT.add(new ColorSupport(20, 0xFF880000));
SUPPORT.add(new ColorSupport(35, 0xFFFF0000)); // Unwetter (>35)
}
/**
* Creates a color scheme.
*/
public PrecipitationColorScheme() {
super(SUPPORT, new LinearInterpolation());
}
}
@@ -0,0 +1,46 @@
package com.mowesta.android.app.view.color;
import com.mowesta.android.app.view.interpolation.LinearInterpolation;
import java.util.ArrayList;
import java.util.List;
/**
* A color scheme that makes low pressure zones blue and high
* pressure zones red.
*
* @author Marcus
*
*/
public class PressureColorScheme extends InterpolatedColorScheme {
/**
* Creates a pressure color scheme.
*
* @param avg The average value.
* @param min The minimum value.
* @param max The maximum value.
*/
public PressureColorScheme(double avg, double min, double max) {
super(createSupport(avg, min, max), new LinearInterpolation());
}
/**
* Creates the support for the color scheme based on the average,
* minimum and maximum values.
*
* @param avg The average.
* @param min The minimum.
* @param max The maximum.
* @return The support for the scheme.
*/
private static List<ColorSupport> createSupport(double avg, double min, double max) {
List<ColorSupport> result = new ArrayList<>();
result.add(new ColorSupport(min, 255, 0, 0, 0));
result.add(new ColorSupport(avg, 255, 0, 0, 255));
result.add(new ColorSupport(max, 255, 255, 0, 255));
return result;
}
}
@@ -0,0 +1,66 @@
package com.mowesta.android.app.view.color;
import com.mowesta.android.app.view.interpolation.IDataInterpolation;
import com.mowesta.android.app.view.interpolation.LinearInterpolation;
import com.mowesta.android.app.view.interpolation.StepInterpolation;
import java.util.ArrayList;
import java.util.List;
/**
* A color scheme that is extracted from the climate charts of DWD.
*
* @author Marcus
*/
public class ScientificTemperatureColorScheme extends InterpolatedColorScheme {
/**
* The support vector with the temperature to color mapping.
*/
private static List<ColorSupport> SUPPORT = new ArrayList<>();
static {
SUPPORT.add(new ColorSupport(-35, 0xFF0000FB));
SUPPORT.add(new ColorSupport(-30, 0xFF2E46FF));
SUPPORT.add(new ColorSupport(-25, 0xFF3974FF));
SUPPORT.add(new ColorSupport(-20, 0xFF39A9FF));
SUPPORT.add(new ColorSupport(-15, 0xFF29DBFF));
SUPPORT.add(new ColorSupport(-10, 0xFF30FFEF));
SUPPORT.add(new ColorSupport(-5, 0xFF88FFBE));
SUPPORT.add(new ColorSupport(0, 0xFFB6FE8E));
SUPPORT.add(new ColorSupport(0, 0xFFFFFF00));
SUPPORT.add(new ColorSupport(5, 0xFFDAFF61));
SUPPORT.add(new ColorSupport(10, 0xFFF8FF26));
SUPPORT.add(new ColorSupport(15, 0xFFFEE100));
SUPPORT.add(new ColorSupport(20, 0xFFFFB200));
SUPPORT.add(new ColorSupport(25, 0xFFFE8500));
SUPPORT.add(new ColorSupport(30, 0xFFFF5100));
SUPPORT.add(new ColorSupport(35, 0xFFB30000));
}
/**
* Creates a color scheme with linear interpolation.
*/
public ScientificTemperatureColorScheme() {
this(true);
}
/**
* Creates a color scheme with linear or step-wise interpolation.
*
* @param linearInterpolation If set to true, enables linear interpolation.
*/
public ScientificTemperatureColorScheme(boolean linearInterpolation) {
super(SUPPORT, linearInterpolation?new LinearInterpolation():new StepInterpolation(1f));
}
/**
* Creates a colors scheme with the specified interpolation.
*
* @param interpolation The interpolation function.
*/
public ScientificTemperatureColorScheme(IDataInterpolation interpolation) {
super(SUPPORT, interpolation);
}
}
@@ -0,0 +1,32 @@
package com.mowesta.android.app.view.color;
import com.mowesta.android.app.view.interpolation.LinearInterpolation;
import java.util.ArrayList;
import java.util.List;
/**
* A color scheme for the cloud coverage provided as a value between 0 and 1.
*
* @author Marcus
*/
public class WhiteCloudColorScheme extends InterpolatedColorScheme {
/**
* The support vector with the temperature to color mapping.
*/
private static List<ColorSupport> SUPPORT = new ArrayList<>();
static {
SUPPORT.add(new ColorSupport(0, 0x00FFFFFF));
SUPPORT.add(new ColorSupport(1, 0xFFFFFFFF));
}
/**
* Creates a color scheme with linear interpolation.
*/
public WhiteCloudColorScheme() {
super(SUPPORT, new LinearInterpolation());
}
}
@@ -0,0 +1,21 @@
package com.mowesta.android.app.view.interpolation;
/**
* An interface to interpolate data.
*
* @author Marcus
*/
public interface IDataInterpolation {
/**
* Computes an interpolated value between x and y that
* resides at the specified fraction.
*
* @param x The x value.
* @param y The y value.
* @param fraction The fraction (between 0 = x and 1 = y).
* @return The interpolated value.
*/
double interpolate(double x, double y, double fraction);
}
@@ -0,0 +1,15 @@
package com.mowesta.android.app.view.interpolation;
/**
* A simple linear interpolation.
*
* @author Marcus
*/
public class LinearInterpolation implements IDataInterpolation {
@Override
public double interpolate(double x, double y, double fraction) {
return x + (y - x) * fraction;
}
}
@@ -0,0 +1,46 @@
package com.mowesta.android.app.view.interpolation;
/**
* An interpolation that does not compute intermediate values but
* instead bases its decision on which value to return on the fraction,
* creating a step function.
*
* @author Marcus
*/
public class StepInterpolation implements IDataInterpolation {
/**
* The default threshold value that results in financial rounding.
*/
public static final double DEFAULT_THRESHOLD = 0.5;
/**
* The threshold at which to switch.
*/
private double threshold;
/**
* Creates an interpolation function with the default threshold.
*/
public StepInterpolation() {
this(DEFAULT_THRESHOLD);
}
/**
* Creates a new step interpolation with the specified
* threshold.
*
* @param threshold The threshold that defines which
* value to return.
*/
public StepInterpolation(double threshold) {
this.threshold = threshold;
}
@Override
public double interpolate(double x, double y, double fraction) {
if (fraction < threshold) return x;
else return y;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

@@ -2,10 +2,10 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:gradientRadius="150%p"
android:centerX="0.8"
android:centerY="1"
android:centerX="0.2"
android:centerY="0.5"
android:endColor="#00695C"
android:startColor="#CBCDD1"
android:type="radial" />
android:startColor="#CBCDD1"
android:type="radial" />
</shape>
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:centerX="0.5"
android:angle="270"
android:endColor="#A0ffffff"
android:centerColor="#40ffffff"
android:startColor="#00ffffff"
android:type="linear" />
</shape>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="0"
android:endColor="#f8e9cf"
android:centerColor="#ffffff"
android:startColor="#f8e9cf"
android:type="linear" />
</shape>
@@ -0,0 +1,18 @@
<vector android:height="24dp" android:viewportHeight="1576.68"
android:viewportWidth="1576.68" android:width="24dp"
xmlns:aapt="http://schemas.android.com/aapt" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:pathData="M788.34,788.34m-784.54,0a784.54,784.54 0,1 1,1569.08 0a784.54,784.54 0,1 1,-1569.08 0">
<aapt:attr name="android:fillColor">
<gradient
android:startX="1577"
android:startY="0"
android:endX="0"
android:endY="1577"
android:startColor="#aaaaaaaa"
android:endColor="#00ffffff"
android:type="linear">
</gradient>
</aapt:attr>
</path>
<path android:fillColor="#eeFFFFFF" android:pathData="M932.1,185.17c135.76,82 339.41,251.63 439.96,406.9 100.54,155.27 97.98,296.16 78.45,397.05 -19.53,100.88 -56.04,161.74 -83.9,133.57 -27.86,-28.18 -47.07,-145.4 -112.07,-279.53 -65,-134.13 -175.78,-285.17 -282.41,-409.44 -106.63,-124.27 -209.09,-221.77 -226.38,-273.33 -17.3,-51.57 50.59,-57.2 186.36,24.8z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="30"
android:tint="?attr/colorControlNormal"
android:viewportWidth="30" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M4.61,16.88c0,-1.15 0.36,-2.17 1.08,-3.07c0.72,-0.9 1.63,-1.48 2.74,-1.73c0.31,-1.37 1.02,-2.49 2.11,-3.37s2.35,-1.32 3.76,-1.32c1.38,0 2.61,0.43 3.69,1.28s1.78,1.95 2.1,3.29h0.33c0.9,0 1.73,0.22 2.49,0.65s1.37,1.03 1.81,1.79c0.44,0.76 0.67,1.58 0.67,2.48c0,0.88 -0.21,1.7 -0.63,2.45s-1,1.35 -1.73,1.8c-0.73,0.45 -1.54,0.69 -2.41,0.72H9.41c-1.34,-0.06 -2.47,-0.57 -3.4,-1.53C5.08,19.37 4.61,18.22 4.61,16.88zM6.32,16.88c0,0.87 0.3,1.62 0.9,2.26s1.33,0.98 2.19,1.03h11.19c0.86,-0.04 1.59,-0.39 2.19,-1.03c0.61,-0.64 0.91,-1.4 0.91,-2.26c0,-0.88 -0.33,-1.63 -0.98,-2.27c-0.65,-0.64 -1.42,-0.96 -2.32,-0.96H18.8c-0.11,0 -0.17,-0.06 -0.17,-0.18l-0.07,-0.57c-0.11,-1.08 -0.58,-1.99 -1.4,-2.72c-0.82,-0.73 -1.77,-1.1 -2.86,-1.1c-1.09,0 -2.05,0.37 -2.85,1.1c-0.81,0.73 -1.27,1.64 -1.37,2.72l-0.08,0.57c0,0.12 -0.07,0.18 -0.2,0.18H9.27c-0.84,0.1 -1.54,0.46 -2.1,1.07S6.32,16.05 6.32,16.88z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="30"
android:tint="?attr/colorControlNormal"
android:viewportWidth="30" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M7.56,17.19c0,-0.88 0.24,-1.89 0.72,-3.03s1.1,-2.25 1.86,-3.31c1.56,-2.06 2.92,-3.62 4.06,-4.67l0.75,-0.72c0.25,0.26 0.53,0.5 0.83,0.72c0.41,0.42 1.04,1.11 1.88,2.09s1.57,1.85 2.17,2.65c0.71,1.01 1.32,2.1 1.81,3.25s0.74,2.16 0.74,3.03c0,1 -0.19,1.95 -0.58,2.86c-0.39,0.91 -0.91,1.7 -1.57,2.36c-0.66,0.66 -1.45,1.19 -2.37,1.58c-0.92,0.39 -1.89,0.59 -2.91,0.59c-1,0 -1.95,-0.19 -2.86,-0.57c-0.91,-0.38 -1.7,-0.89 -2.36,-1.55c-0.66,-0.65 -1.19,-1.44 -1.58,-2.35S7.56,18.23 7.56,17.19zM9.82,14.26c0,0.83 0.17,1.49 0.52,1.99c0.35,0.49 0.88,0.74 1.59,0.74c0.72,0 1.25,-0.25 1.61,-0.74c0.35,-0.49 0.53,-1.15 0.54,-1.99c-0.01,-0.84 -0.19,-1.5 -0.54,-2c-0.35,-0.49 -0.89,-0.74 -1.61,-0.74c-0.71,0 -1.24,0.25 -1.59,0.74C9.99,12.76 9.82,13.42 9.82,14.26zM11.39,14.26c0,-0.15 0,-0.27 0,-0.35s0.01,-0.19 0.02,-0.33c0.01,-0.14 0.02,-0.25 0.05,-0.32s0.05,-0.16 0.09,-0.24c0.04,-0.08 0.09,-0.15 0.15,-0.18c0.07,-0.04 0.14,-0.06 0.23,-0.06c0.14,0 0.25,0.04 0.33,0.12s0.14,0.21 0.17,0.38c0.03,0.18 0.05,0.32 0.06,0.45s0.01,0.3 0.01,0.52c0,0.23 0,0.4 -0.01,0.52c-0.01,0.12 -0.03,0.27 -0.06,0.45c-0.03,0.17 -0.09,0.3 -0.17,0.38s-0.19,0.12 -0.33,0.12c-0.09,0 -0.16,-0.02 -0.23,-0.06c-0.07,-0.04 -0.12,-0.1 -0.15,-0.18c-0.04,-0.08 -0.07,-0.17 -0.09,-0.24c-0.02,-0.08 -0.04,-0.19 -0.05,-0.32c-0.01,-0.14 -0.02,-0.25 -0.02,-0.32S11.39,14.41 11.39,14.26zM11.98,22.01h1.32l4.99,-10.74h-1.35L11.98,22.01zM16.28,19.02c0.01,0.84 0.2,1.5 0.55,2c0.35,0.49 0.89,0.74 1.6,0.74c0.72,0 1.25,-0.25 1.6,-0.74c0.35,-0.49 0.52,-1.16 0.53,-2c-0.01,-0.84 -0.18,-1.5 -0.53,-1.99c-0.35,-0.49 -0.88,-0.74 -1.6,-0.74c-0.71,0 -1.25,0.25 -1.6,0.74C16.47,17.52 16.29,18.18 16.28,19.02zM17.85,19.02c0,-0.23 0,-0.4 0.01,-0.52c0.01,-0.12 0.03,-0.27 0.06,-0.45s0.09,-0.3 0.17,-0.38s0.19,-0.12 0.33,-0.12c0.09,0 0.17,0.02 0.24,0.06c0.07,0.04 0.12,0.1 0.16,0.19c0.04,0.09 0.07,0.17 0.1,0.24s0.04,0.18 0.05,0.32l0.01,0.32l0,0.34c0,0.16 0,0.28 0,0.35l-0.01,0.32l-0.05,0.32l-0.1,0.24l-0.16,0.19l-0.24,0.06c-0.14,0 -0.25,-0.04 -0.33,-0.12s-0.14,-0.21 -0.17,-0.38c-0.03,-0.18 -0.05,-0.33 -0.06,-0.45S17.85,19.25 17.85,19.02z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="30"
android:tint="?attr/colorControlNormal"
android:viewportWidth="30" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M11.01,12.23c0,-0.26 0.13,-0.59 0.38,-1.01c0.25,-0.42 0.5,-0.77 0.73,-1.04c0.06,-0.07 0.14,-0.17 0.23,-0.28s0.15,-0.17 0.16,-0.18l0.37,0.43c0.28,0.31 0.53,0.66 0.76,1.07c0.23,0.41 0.35,0.74 0.35,1.01c0,0.41 -0.14,0.77 -0.43,1.06c-0.28,0.29 -0.63,0.44 -1.05,0.44c-0.41,0 -0.77,-0.15 -1.06,-0.44C11.16,12.99 11.01,12.64 11.01,12.23zM14.13,16.38c0,-0.29 0.08,-0.62 0.24,-1.01c0.16,-0.38 0.36,-0.74 0.6,-1.06c0.46,-0.61 0.89,-1.12 1.31,-1.53c0.04,-0.03 0.13,-0.11 0.26,-0.24l0.25,0.24c0.39,0.37 0.83,0.88 1.32,1.52c0.26,0.34 0.46,0.7 0.62,1.08s0.24,0.71 0.24,1c0,0.69 -0.23,1.26 -0.7,1.73c-0.47,0.47 -1.05,0.7 -1.73,0.7c-0.68,0 -1.25,-0.24 -1.72,-0.71S14.13,17.05 14.13,16.38zM15.65,9.48c0,-0.43 0.33,-1 1,-1.7l0.25,0.28c0.19,0.22 0.36,0.46 0.51,0.74c0.15,0.27 0.23,0.5 0.23,0.68c0,0.28 -0.1,0.5 -0.29,0.69c-0.19,0.18 -0.42,0.28 -0.7,0.28c-0.29,0 -0.53,-0.09 -0.72,-0.28C15.75,9.98 15.65,9.75 15.65,9.48z"/>
</vector>
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="@color/primary">
<path
android:fillColor="@android:color/white"
android:pathData="M9,11.24V7.5C9,6.12 10.12,5 11.5,5S14,6.12 14,7.5v3.74c1.21,-0.81 2,-2.18 2,-3.74C16,5.01 13.99,3 11.5,3S7,5.01 7,7.5C7,9.06 7.79,10.43 9,11.24zM18.84,15.87l-4.54,-2.26c-0.17,-0.07 -0.35,-0.11 -0.54,-0.11H13v-6C13,6.67 12.33,6 11.5,6S10,6.67 10,7.5v10.74c-3.6,-0.76 -3.54,-0.75 -3.67,-0.75c-0.31,0 -0.59,0.13 -0.79,0.33l-0.79,0.8l4.94,4.94C9.96,23.83 10.34,24 10.75,24h6.79c0.75,0 1.33,-0.55 1.44,-1.28l0.75,-5.27c0.01,-0.07 0.02,-0.14 0.02,-0.2C19.75,16.63 19.37,16.09 18.84,15.87z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:viewportHeight="30"
android:tint="?attr/colorControlNormal"
android:viewportWidth="30" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M3.1,16.97c0,0.24 0.09,0.45 0.28,0.62c0.16,0.19 0.37,0.28 0.63,0.28H18.7c0.29,0 0.53,0.1 0.73,0.3c0.2,0.2 0.3,0.45 0.3,0.74c0,0.29 -0.1,0.53 -0.3,0.72c-0.2,0.19 -0.44,0.29 -0.74,0.29c-0.29,0 -0.54,-0.1 -0.73,-0.29c-0.16,-0.18 -0.36,-0.26 -0.6,-0.26c-0.25,0 -0.46,0.09 -0.64,0.26s-0.27,0.38 -0.27,0.61c0,0.25 0.09,0.46 0.28,0.63c0.56,0.55 1.22,0.83 1.96,0.83c0.78,0 1.45,-0.27 2.01,-0.81c0.56,-0.54 0.83,-1.19 0.83,-1.97s-0.28,-1.44 -0.84,-2c-0.56,-0.56 -1.23,-0.84 -2,-0.84H4.01c-0.25,0 -0.46,0.09 -0.64,0.26C3.19,16.51 3.1,16.72 3.1,16.97zM3.1,13.69c0,0.23 0.09,0.43 0.28,0.61c0.17,0.18 0.38,0.26 0.63,0.26h20.04c0.78,0 1.45,-0.27 2.01,-0.82c0.56,-0.54 0.84,-1.2 0.84,-1.97c0,-0.77 -0.28,-1.44 -0.84,-1.99s-1.23,-0.83 -2.01,-0.83c-0.77,0 -1.42,0.27 -1.95,0.8c-0.18,0.16 -0.27,0.38 -0.27,0.67c0,0.26 0.09,0.47 0.26,0.63c0.17,0.16 0.38,0.24 0.63,0.24c0.24,0 0.45,-0.08 0.63,-0.24c0.19,-0.21 0.42,-0.31 0.7,-0.31c0.29,0 0.53,0.1 0.73,0.3c0.2,0.2 0.3,0.44 0.3,0.73c0,0.29 -0.1,0.53 -0.3,0.72c-0.2,0.19 -0.44,0.29 -0.73,0.29H4.01c-0.25,0 -0.46,0.09 -0.64,0.26C3.19,13.23 3.1,13.44 3.1,13.69z"/>
</vector>
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@android:id/background">
<color android:color="#33363636" />
</item>
<item android:id="@android:id/progress">
<clip
android:clipOrientation="vertical"
android:gravity="bottom">
<shape>
<gradient
android:startColor="#f9a825"
android:centerColor="#f9a825"
android:endColor="#f9a825"
android:angle="90" />
</shape>
</clip>
</item>
</layer-list>
@@ -0,0 +1,285 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="model"
type="com.mowesta.android.feign.model.WeatherCondition" />
</data>
<androidx.core.widget.NestedScrollView
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:fillViewport="true"
android:id="@+id/gradient_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:baselineAligned="false"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:layout_weight="1"
android:layout_width="24dp"
android:layout_height="0dp"
android:scaleType="fitCenter"
android:contentDescription="@string/label_temperature"
app:srcCompat="@drawable/ic_thermometer_normal_24"/>
<ImageView
android:layout_weight="1"
android:layout_width="22dp"
android:layout_height="0dp"
android:scaleType="fitCenter"
android:contentDescription="@string/label_precipitation"
app:srcCompat="@drawable/ic_raindrops_normal_24"/>
<ImageView
android:layout_weight="1"
android:layout_width="24dp"
android:layout_height="0dp"
android:scaleType="fitCenter"
android:contentDescription="@string/label_cloud_coverage"
app:srcCompat="@drawable/ic_cloud_normal_24"/>
<ImageView
android:layout_weight="1"
android:layout_width="24dp"
android:layout_height="0dp"
android:scaleType="fitCenter"
android:padding="4dp"
android:contentDescription="@string/label_local_time"
app:srcCompat="@drawable/ic_alarm_normal_24"/>
<ImageView
android:layout_weight="1"
android:layout_width="24dp"
android:layout_height="0dp"
android:scaleType="fitCenter"
android:padding="2dp"
android:contentDescription="@string/label_humidity"
app:srcCompat="@drawable/ic_humidity_normal_24"/>
<ImageView
android:layout_weight="1"
android:layout_width="24dp"
android:layout_height="0dp"
android:scaleType="fitCenter"
android:contentDescription="@string/label_wind_speed"
app:srcCompat="@drawable/ic_wind_normal_24"/>
<ImageView
android:layout_weight="1"
android:layout_width="24dp"
android:layout_height="0dp"
android:scaleType="fitCenter"
android:contentDescription="@string/label_pressure"
app:srcCompat="@drawable/ic_barometer_normal_24"/>
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/gradient_constraint"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mowesta.android.app.view.GradientView
app:direction="HORIZONTAL"
android:id="@+id/gradient_temperature"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"/>
<com.mowesta.android.app.view.DropView
app:direction="HORIZONTAL"
android:id="@+id/gradient_preciptiation"
android:background="@drawable/bg_precipitation"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"/>
<com.mowesta.android.app.view.DualGradientView
app:direction="HORIZONTAL"
android:id="@+id/gradient_cloud"
android:background="@color/bg_cloud"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"/>
<com.mowesta.android.app.view.TimeView
app:direction="HORIZONTAL"
android:id="@+id/gradient_touch"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"/>
<com.mowesta.android.app.view.GradientView
app:direction="HORIZONTAL"
android:id="@+id/gradient_humidity"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"/>
<com.mowesta.android.app.view.ParticleView
app:direction="HORIZONTAL"
android:id="@+id/gradient_wind_speed"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"/>
<com.mowesta.android.app.view.GradientView
app:direction="HORIZONTAL"
android:id="@+id/gradient_pressure"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="0dp"/>
</LinearLayout>
<androidx.constraintlayout.widget.Guideline
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/guide_gradient"
app:layout_constraintGuide_percent="0.5"
android:orientation="vertical"/>
<LinearLayout
android:id="@+id/gradient_text"
app:layout_constraintLeft_toLeftOf="@id/guide_gradient"
android:background="@color/normal"
android:orientation="horizontal"
android:layout_width="160dp"
android:layout_height="match_parent">
<ProgressBar
android:id="@+id/gradient_progress_1"
android:layout_width="2dp"
android:background="@color/normal"
android:layout_height="match_parent"
android:progressDrawable="@drawable/progress_vertical"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminate="false" />
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:paddingStart="@dimen/space_medium"
android:paddingEnd="@dimen/space_medium"
android:orientation="vertical">
<com.google.android.material.textview.MaterialTextView
tools:text="7°C"
temperature="@{model}"
android:textStyle="bold"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:gravity="center"
android:layout_gravity="center"
android:maxLines="1"
android:ellipsize="end"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dp"/>
<com.google.android.material.textview.MaterialTextView
tools:text="11mm/h"
precipitation="@{model}"
android:maxLines="1"
android:ellipsize="end"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:gravity="center"
android:layout_gravity="center"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dp"/>
<com.google.android.material.textview.MaterialTextView
tools:text="99%"
cloudCoverage="@{model}"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:gravity="center"
android:layout_gravity="center"
android:maxLines="1"
android:ellipsize="end"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dp"/>
<com.google.android.material.textview.MaterialTextView
tools:text="1.1.2000 11:00"
android:id="@+id/gradient_time"
android:maxLines="1"
android:ellipsize="end"
android:gravity="center"
android:layout_gravity="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dp"/>
<com.google.android.material.textview.MaterialTextView
tools:text="99%"
humidity="@{model}"
android:gravity="center"
android:layout_gravity="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:maxLines="1"
android:ellipsize="end"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dp"/>
<com.google.android.material.textview.MaterialTextView
tools:text="4km/h"
windSpeed="@{model}"
android:maxLines="1"
android:ellipsize="end"
android:gravity="center"
android:layout_gravity="center"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dp"/>
<com.google.android.material.textview.MaterialTextView
tools:text="1000.3hPa"
pressure="@{model}"
android:gravity="center"
android:layout_gravity="center"
android:maxLines="1"
android:ellipsize="end"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="0dp"/>
</LinearLayout>
<ProgressBar
android:id="@+id/gradient_progress_2"
android:layout_width="2dp"
android:background="@color/normal"
android:layout_height="match_parent"
android:scaleY="-1"
android:progressDrawable="@drawable/progress_vertical"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminate="false" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</layout>
@@ -29,7 +29,7 @@
android:layout_width="48dp"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content"
android:tint="@color/fg_accent"
app:tint="@color/fg_accent"
app:srcCompat="@drawable/ic_view_headline_normal_24"/>
<TextView
android:layout_weight="1"
@@ -125,7 +125,7 @@
android:textSize="24dp"
android:gravity="center"
app:weather="RAINDROPS" />
<Switch
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_gravity="center"
style="@style/TextAppearance.MaterialComponents.Body1"
android:singleLine="true"
@@ -146,7 +146,7 @@
android:textSize="24dp"
android:gravity="center"
app:weather="WIND_DIRECTION" />
<Switch
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_gravity="center"
style="@style/TextAppearance.MaterialComponents.Body1"
android:singleLine="true"
@@ -167,7 +167,7 @@
android:textSize="24dp"
android:gravity="center"
app:weather="CLOUD" />
<Switch
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_gravity="center"
style="@style/TextAppearance.MaterialComponents.Body1"
android:singleLine="true"
@@ -188,7 +188,7 @@
android:textSize="24dp"
android:gravity="center"
app:weather="HUMIDITY" />
<Switch
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_gravity="center"
style="@style/TextAppearance.MaterialComponents.Body1"
android:singleLine="true"
@@ -209,7 +209,7 @@
android:textSize="24dp"
android:gravity="center"
app:weather="SNOWFLAKE_COLD" />
<Switch
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_gravity="center"
style="@style/TextAppearance.MaterialComponents.Body1"
android:singleLine="true"
@@ -230,7 +230,7 @@
android:textSize="24dp"
android:gravity="center"
app:weather="BAROMETER" />
<Switch
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_gravity="center"
style="@style/TextAppearance.MaterialComponents.Body1"
android:singleLine="true"
@@ -38,7 +38,7 @@
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="48dp"
android:layout_gravity="bottom"
android:background="@color/primary"
app:itemIconTint="@drawable/selector_navigation"
@@ -60,21 +60,12 @@
android:text="@string/collection_explain"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1" />
<Switch
android:id="@+id/privacy_measure_switch"
android:layout_margin="@dimen/space_large"
android:layout_width="match_parent"
android:textAppearance="@style/TextAppearance.MaterialComponents.Button"
android:textColor="@color/primary"
android:layout_height="wrap_content"
android:text="@string/collection_on_off" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/collection_note_permission"
android:id="@+id/collection_note_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_medium"
android:text="@string/collection_note_permission"
android:text="@string/collection_note_location"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2" />
@@ -97,6 +88,24 @@
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/privacy_measure_switch"
android:layout_margin="@dimen/space_medium"
android:layout_width="match_parent"
android:textAppearance="@style/TextAppearance.MaterialComponents.Button"
android:textColor="@color/primary"
android:layout_height="wrap_content"
android:text="@string/collection_on_off" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/collection_note_permission"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/space_medium"
android:text="@string/collection_note_permission"
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2" />
<com.google.android.material.button.MaterialButton
android:id="@+id/button_continue"
@@ -0,0 +1,295 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="model"
type="com.mowesta.android.feign.model.WeatherCondition" />
</data>
<androidx.core.widget.NestedScrollView
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:fillViewport="true"
android:id="@+id/gradient_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="24dp"
android:contentDescription="@string/label_temperature"
app:srcCompat="@drawable/ic_thermometer_normal_24"/>
<ImageView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="24dp"
android:contentDescription="@string/label_precipitation"
app:srcCompat="@drawable/ic_raindrops_normal_24"/>
<ImageView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="24dp"
android:contentDescription="@string/label_cloud_coverage"
app:srcCompat="@drawable/ic_cloud_normal_24"/>
<ImageView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="24dp"
android:scaleType="fitCenter"
android:padding="4dp"
android:contentDescription="@string/label_local_time"
app:srcCompat="@drawable/ic_alarm_normal_24"/>
<ImageView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="24dp"
android:padding="2dp"
android:contentDescription="@string/label_humidity"
app:srcCompat="@drawable/ic_humidity_normal_24"/>
<ImageView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="24dp"
android:contentDescription="@string/label_wind_speed"
app:srcCompat="@drawable/ic_wind_normal_24"/>
<ImageView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="24dp"
android:contentDescription="@string/label_pressure"
app:srcCompat="@drawable/ic_barometer_normal_24"/>
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/gradient_constraint"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mowesta.android.app.view.GradientView
android:id="@+id/gradient_temperature"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"/>
<com.mowesta.android.app.view.DropView
android:id="@+id/gradient_preciptiation"
android:background="@drawable/bg_precipitation"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"/>
<com.mowesta.android.app.view.DualGradientView
android:id="@+id/gradient_cloud"
android:background="@color/bg_cloud"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"/>
<com.mowesta.android.app.view.TimeView
android:id="@+id/gradient_touch"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"/>
<com.mowesta.android.app.view.GradientView
android:id="@+id/gradient_humidity"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"/>
<com.mowesta.android.app.view.ParticleView
android:id="@+id/gradient_wind_speed"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"/>
<com.mowesta.android.app.view.GradientView
android:id="@+id/gradient_pressure"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"/>
</LinearLayout>
<androidx.constraintlayout.widget.Guideline
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/guide_gradient"
app:layout_constraintGuide_percent="0.5"
android:orientation="horizontal"/>
<LinearLayout
android:id="@+id/gradient_text"
app:layout_constraintBottom_toTopOf="@id/guide_gradient"
android:background="@color/normal"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ProgressBar
android:id="@+id/gradient_progress_1"
android:layout_width="match_parent"
android:background="@color/normal"
android:foregroundGravity="center_vertical"
android:layout_height="2dp"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminate="false" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Space
android:layout_width="24dp"
android:layout_height="0dp"/>
<com.google.android.material.textview.MaterialTextView
tools:text="11mm/h"
precipitation="@{model}"
android:maxLines="1"
android:ellipsize="end"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:gravity="center_horizontal|bottom"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<com.google.android.material.textview.MaterialTextView
tools:text="Donnerstag | 11:00"
android:id="@+id/gradient_time"
android:singleLine="true"
android:ellipsize="middle"
android:gravity="center_horizontal|bottom"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<com.google.android.material.textview.MaterialTextView
tools:text="4km/h"
windSpeed="@{model}"
android:maxLines="1"
android:ellipsize="end"
android:gravity="center_horizontal|bottom"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<Space
android:layout_width="24dp"
android:layout_height="0dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
<com.google.android.material.textview.MaterialTextView
tools:text="7°C"
temperature="@{model}"
android:textStyle="bold"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:gravity="start|bottom"
android:maxLines="1"
android:ellipsize="end"
android:layout_weight="1.5"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<com.google.android.material.textview.MaterialTextView
tools:text="99%"
cloudCoverage="@{model}"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:gravity="end|bottom"
android:maxLines="1"
android:ellipsize="end"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<Space
android:layout_width="64dp"
android:layout_height="0dp"/>
<com.google.android.material.textview.MaterialTextView
tools:text="99%"
humidity="@{model}"
android:gravity="start|bottom"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:maxLines="1"
android:ellipsize="end"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<com.google.android.material.textview.MaterialTextView
tools:text="1000.3hPa"
pressure="@{model}"
android:gravity="end|bottom"
android:maxLines="1"
android:ellipsize="end"
android:textAppearance="@style/TextAppearance.MaterialComponents.Caption"
android:layout_weight="1.5"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
<Space
android:layout_width="8dp"
android:layout_height="0dp"/>
</LinearLayout>
<ProgressBar
android:id="@+id/gradient_progress_2"
android:layout_width="match_parent"
android:background="@color/normal"
android:foregroundGravity="center_vertical"
android:layout_height="2dp"
android:scaleX="-1"
style="?android:attr/progressBarStyleHorizontal"
android:indeterminate="false" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</layout>
@@ -2,6 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@@ -11,6 +12,7 @@
app:tabMaxWidth="0dp"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabTextAppearance="@style/TextAppearance.Mowesta.TabLayout"
tools:targetApi="21"
android:elevation="4dp"
android:layout_width="match_parent"
@@ -38,10 +38,7 @@
android:padding="@dimen/space_medium"
android:contentDescription="@null"
app:srcCompat="@drawable/ic_toys_normal_24"
android:tint="@color/accent" />
app:tint="@color/accent" />
<LinearLayout
android:layout_width="match_parent"
@@ -106,7 +103,7 @@
android:layout_width="@dimen/space_medium"
android:layout_height="0dp"/>
<Switch
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/setup_switch_manual"
android:checked="@={ model.manualPosition }"
android:gravity="center"
@@ -10,6 +10,17 @@
tools:context=".MowestaActivity"
android:orientation="vertical">
<LinearLayout
android:id="@+id/logo_panel"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:background="@drawable/bg_launch_logo"
android:layout_width="match_parent"
android:layout_height="96dp">
</LinearLayout>
<ImageView
android:id="@+id/splash_world"
android:layout_width="match_parent"
@@ -78,17 +89,44 @@
</LinearLayout>
<ImageView
android:id="@+id/logo_locoslab"
android:layout_width="wrap_content"
android:layout_height="48dp"
<LinearLayout
android:orientation="horizontal"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:padding="8dp"
android:adjustViewBounds="true"
android:contentDescription="@null"
android:scaleType="fitEnd"
app:srcCompat="@drawable/logo_locoslab" />
android:layout_width="match_parent"
android:layout_height="48dp">
<ImageView
android:id="@+id/logo_ciss"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:adjustViewBounds="false"
android:contentDescription="@null"
android:scaleType="fitStart"
app:srcCompat="@drawable/logo_ciss" />
<Space
android:layout_width="32dp"
android:layout_height="0dp"/>
<ImageView
android:id="@+id/logo_locoslab"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingBottom="3dp"
android:adjustViewBounds="false"
android:contentDescription="@null"
android:scaleType="fitEnd"
app:srcCompat="@drawable/logo_locoslab" />
</LinearLayout>
</RelativeLayout>
</layout>
@@ -30,7 +30,6 @@
android:layout_height="match_parent"
android:padding="8dp"
app:srcCompat="@drawable/icon_launch_sun"
android:fitsSystemWindows="true"
android:scaleType="fitEnd"
app:layout_collapseMode="parallax" />
@@ -2,7 +2,9 @@
<com.google.android.material.appbar.AppBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:theme="@style/ThemeOverlay.MaterialComponents.Dark"
android:id="@+id/layout_appbar"
android:layout_width="match_parent"
android:layout_height="128dp">
@@ -44,5 +46,8 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
@@ -26,7 +26,7 @@
android:layout_height="48dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:tint="@color/fg_accent"
app:tint="@color/fg_accent"
android:contentDescription="@null"
android:gravity="center"
android:layout_gravity="center_vertical" />
@@ -26,7 +26,7 @@
android:layout_height="48dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:tint="@color/fg_accent"
app:tint="@color/fg_accent"
android:contentDescription="@null"
android:gravity="center"
android:layout_gravity="center_vertical" />
@@ -27,7 +27,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:contentDescription="@null"
android:tint="@color/fg_accent"
app:tint="@color/fg_accent"
android:gravity="center"
android:layout_gravity="center_vertical" />
<LinearLayout
@@ -67,7 +67,7 @@
android:layout_gravity="bottom"
android:gravity="bottom"
android:contentDescription="@string/label_altitude"
android:tint="@color/fg_accent"
app:tint="@color/fg_accent"
tools:targetApi="O"
android:tooltipText="@string/label_altitude"
app:srcCompat="@drawable/ic_landscape_normal_24" />
@@ -10,15 +10,10 @@
type="com.mowesta.android.app.model.VideoViewModel.OnVideoSelectedListener" />
</data>
<LinearLayout
android:layout_margin="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_margin="8dp"
android:layout_gravity="center_horizontal"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -41,7 +36,6 @@
android:ellipsize="end"
android:singleLine="true"
android:textAppearance="?attr/textAppearanceCaption" />
</LinearLayout>
</LinearLayout>
</layout>
@@ -85,9 +85,10 @@
<string name="collection_logo_fair">FAIR Forschungsprojekt</string>
<string name="collection_title">Hilf MoWeSta</string>
<string name="collection_explain">Verwandle Dein Gerät in eine Mobile Wetter Station* und hilf uns dabei herauszufinden, ob wir Wettervorhersagen mit Hilfe von mobilen Messungen durch Freiwillige wie Dich verbessern können!</string>
<string name="collection_note_permission">* Die Datenerfassung benötigt die Erlaubnis Deinen Standort im Hintergrund zu bestimmen.</string>
<string name="collection_note_data">* Die Übertragung der Messdaten an MoWeSta nutzt Deine mobile Datenverbindung, was sehr teuer sein kann.</string>
<string name="collection_note_enable">* Du kannst die Datenerfassung und -übertragung jederzeit über die Einstellungen der Anwendung ein- und ausschalten.</string>
<string name="collection_note_location">* Falls Du mitmachst, erhebt MoWeSta Standortdaten, um den Ort der Messungen zu bestimmen, auch wenn die App geschlossen ist oder nicht verwendet wird. </string>
<string name="collection_note_data">* Falls Du mitmachst, überträgt MoWeSta Standort und Messdaten im Hintergrund über Deine mobile Datenverbindung, was sehr teuer sein kann.</string>
<string name="collection_note_enable">* Die Datenerfassung und -übertragung im Hintergrund erfolgt nur mit Deiner Zustimmung und Du kannst sie jederzeit über die Einstellungen der Anwendung ein- und ausschalten.</string>
<string name="collection_note_permission">Zum Mitmachen benötigen wir die Erlaubnis Deinen Standort im Hintergrund zu bestimmen.</string>
<string name="collection_on_off">Jetzt mitmachen</string>
<string name="collection_button_continue">Lass uns loslegen</string>
@@ -100,7 +101,7 @@
<!-- Settings -->
<string name="setting_category_privacy">Datenschutz</string>
<string name="setting_privacy_measure_title">Datenerfassung</string>
<string name="setting_privacy_measure_summary">Aktiviert die Erfassung von Messungen im Hintergrund. Deaktivierung beendet die Messung und Übertragung von Daten.</string>
<string name="setting_privacy_measure_summary">Aktiviert die Erfassung von Messungen im Hintergrund. Falls aktiviert, erhebt MoWeSta Standortdaten, auch wenn die App geschlossen ist oder nicht verwendet wird..</string>
<string name="setting_privacy_reset_title">Zurücksetzen</string>
<string name="setting_privacy_reset_summary">Entfernt alle auf dem Gerät gespeicherten Daten und setzt die Geräteregistierung zurück. Nach der Ausführung muss das Gerät erneut registriert werden.</string>
<string name="setting_privacy_reset_message">Möchtest Du wirklich ALLE Daten löschen? Das kannst Du nicht mehr rückgängig machen!</string>
@@ -177,6 +178,7 @@
<string name="video_source_icon_europe">Europa</string>
<string name="video_source_cosmo_europe">D-A-CH</string>
<string name="video_type_temperature">Temperatur</string>
<string name="video_type_wind">Wind</string>
<string name="video_type_pressure">Luftdruck</string>
<string name="video_type_cloud">Bewölkung</string>
<string name="video_type_precipitation">Niederschlag</string>
@@ -228,8 +230,9 @@
<string name="city_video">Videos</string>
<string name="city_info">Informationen</string>
<string name="city_info_title">Aktuelles Wetter</string>
<string name="city_info_gradient">Visuell</string>
<string name="city_info_day">Tag</string>
<string name="city_info_time">Tageszeit</string>
<string name="city_info_time">Zeitraum</string>
<string name="city_info_hour">Stunde</string>
<string name="label_station">Wetterstation</string>
<string name="label_full_day">Gesamter Tag</string>
@@ -3,4 +3,7 @@
<color name="separator">#555555</color>
<color name="bg_search">#333333</color>
<color name="inverse">#a0ffffff</color>
<color name="normal">#ff000000</color>
<color name="particle">#ff4444ff</color>
</resources>
@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<declare-styleable name="DataView">
<attr name="direction" format="enum">
<enum name="HORIZONTAL" value="0" />
<enum name="VERTICAL" value="1" />
</attr>
</declare-styleable>
<declare-styleable name="WeatherView">
<attr name="weather" format="enum">
<enum name="DAY_SUNNY" value="0"/>
@@ -10,5 +10,21 @@
<color name="separator">#eeeeee</color>
<color name="bg_search">#fefefe</color>
<color name="inverse">#a0000000</color>
<color name="normal">#ffffffff</color>
<color name="particle">#ff0000ff</color>
<color name="fg_accent">#c0000000</color>
<color name="bg_cloud">#5c99e9</color>
<!--
0xFFEFF8FD, // 1 ice
0xFF989278, // 2 rock
0xFFD1B281, // 3 sand
0xFFE3CCAB, // 4 sandyloam
0xFFCD9160, // 5 loam
0xFFB65941, // 6 clayloam
0xFFAC753B, // 7 clay
0xFF987E6F, // 8 peat
0xFF47859c, // 9 sea water
-->
</resources>
+6 -7
View File
@@ -8,16 +8,15 @@
<string tools:ignore="UnusedResources" name="mowesta_sdk_notification_activity_class_name" translatable="false">com.mowesta.android.app.MowestaActivity</string>
<string name="format_temperature_both" translatable="false">%d&lt;small>\u00A0°C&lt;/small> / %d&lt;small>\u00A0°F&lt;/small></string>
<string name="format_temperature_celsius" translatable="false">%d&lt;small> °C&lt;/small></string>
<string name="format_temperature_fahrenheit" translatable="false">%d&lt;small> °F&lt;/small></string>
<string name="format_temperature_both" translatable="false">%.1f&lt;small>\u00A0°C&lt;/small> / %.1f&lt;small>\u00A0°F&lt;/small></string>
<string name="format_temperature_celsius" translatable="false">%.1f&lt;small> °C&lt;/small></string>
<string name="format_temperature_fahrenheit" translatable="false">%.1f&lt;small> °F&lt;/small></string>
<string name="format_pressure_both" translatable="false">&lt;span>%.1f&lt;small>\u00A0hPa&lt;/small>&lt;/span> / &lt;span>%.3f&lt;small>\u00A0psi&lt;/small>&lt;/span></string>
<string name="format_pressure_si" translatable="false">%.1f&lt;small> hPa&lt;/small></string>
<string name="format_pressure_im" translatable="false">%.3f&lt;small> psi&lt;/small></string>
<string name="format_wind_speed_both" translatable="false">%d&lt;small>\u00A0km\u2215h&lt;/small> / %d&lt;small>\u00A0mph&lt;/small></string>
<string name="format_wind_speed_si" translatable="false">%d&lt;small> km\u2215h&lt;/small></string>
<string name="format_wind_speed_im" translatable="false">%d&lt;small> mph&lt;/small></string>
<string name="format_wind_speed_si" translatable="false">%d&lt;small> km\u2215h&lt;/small> (&lt;small>BFT&lt;/small> %d)</string>
<string name="format_wind_speed_im" translatable="false">%d&lt;small> mph&lt;/small> (&lt;small>BFT&lt;/small> %d)</string>
<string name="format_precipitation_both" translatable="false">%.1f&lt;small>\u00A0mm\u2215h&lt;/small> / %.2f&lt;small>\u00A0in\u2215h&lt;/small></string>
<string name="format_precipitation_si" translatable="false">%.1f&lt;small> mm\u2215h&lt;/small></string>
<string name="format_precipitation_im" translatable="false">%.2f&lt;small> in\u2215h&lt;/small></string>
@@ -30,7 +29,7 @@
<string name="format_humidity" translatable="false">%.2f&lt;small> %%&lt;/small></string>
<string name="format_cloud_coverage" translatable="false">%.2f&lt;small> %%&lt;/small></string>
<string name="format_frequency" translatable="false">%.0f&lt;small> Hz&lt;/small></string>
<string name="format_frequency" translatable="false">%.0f&lt;small> MHz&lt;/small></string>
<string name="format_voltage" translatable="false">%.2f&lt;small> V&lt;/small></string>
<string name="format_compact" translatable="false">%.0f</string>
<string name="format_integer" translatable="false">%d</string>
+7 -4
View File
@@ -87,9 +87,10 @@
<string name="collection_logo_fair">FAIR Research Project</string>
<string name="collection_title">Help MoWeSta</string>
<string name="collection_explain">Transform your device into a Mobile Weather Station* and help us to determine whether we can improve weather forecasts using crowd-sourced weather information provided by people like you!</string>
<string name="collection_note_permission">* Data collection requires the permission to determine your location in the background.</string>
<string name="collection_note_data">* The transmission of measurements to MoWeSta uses your mobile data which can be very expensive.</string>
<string name="collection_note_enable">* You can activate or deactivate the measurements and transmission at any time through the app settings.</string>
<string name="collection_note_location">* If you participate, MoWeSta collects location data to determine the location of temperature readings even when the app is closed or not in use.</string>
<string name="collection_note_data">* If you participate, MoWeSta collects and transmits the location and measurement data in the background via your mobile data connection which can be very expensive.</string>
<string name="collection_note_enable">* Data collection is opt-in only, you can activate or deactivate the data collection and transmission in the background at any time through the app settings.</string>
<string name="collection_note_permission">Participation requires you to grant the permission for background localization.</string>
<string name="collection_on_off">Participate now</string>
<string name="collection_button_continue">Let\'s get started</string>
@@ -102,7 +103,7 @@
<!-- Settings -->
<string name="setting_category_privacy">Privacy</string>
<string name="setting_privacy_measure_title">Measurements</string>
<string name="setting_privacy_measure_summary">Enables the service to perform measurements in the background. If disabled, the application will no longer perform and upload measurements.</string>
<string name="setting_privacy_measure_summary">Enables the service to perform measurements in the background. If enabled, MoWeSta collects location data even when the app is closed or not in use.</string>
<string name="setting_privacy_reset_title">Reset</string>
<string name="setting_privacy_reset_summary">Removes all app data stored on your device and unregisters the device. After deletion, you will have to re-register your device.</string>
<string name="setting_privacy_reset_message">Do you really want remove ALL data? You cannot undo this later!</string>
@@ -180,6 +181,7 @@
<string name="video_source_icon_europe">Europe</string>
<string name="video_source_cosmo_europe">D-A-CH</string>
<string name="video_type_temperature">Temperature</string>
<string name="video_type_wind">Wind</string>
<string name="video_type_pressure">Pressure</string>
<string name="video_type_cloud">Cloudiness</string>
<string name="video_type_precipitation">Precipitation</string>
@@ -231,6 +233,7 @@
<string name="city_video">Video</string>
<string name="city_info">Information</string>
<string name="city_info_title">Current Weather</string>
<string name="city_info_gradient">Visual</string>
<string name="city_info_day">Day</string>
<string name="city_info_time">Time</string>
<string name="city_info_hour">Hour</string>
@@ -29,4 +29,9 @@
<style name="ThemeOverlay.Mowesta.MaterialComponents" parent="Theme.MaterialComponents.Light" />
<style name="TextAppearance.Mowesta.TabLayout" parent="TextAppearance.MaterialComponents.Button">
<item name="android:letterSpacing" tools:targetApi="21">0</item>
</style>
</resources>
+5
View File
@@ -4,6 +4,11 @@ plugins {
description = "Mowesta Android Feign"
// downgrade jackson for Android, since versions > 2.9
// will contain module-info.class files that will result
// in a large number of android lint warnings
versionJackson = "2.9.10"
dependencies {
compile "de.grundid.opendatalab:geojson-jackson:${versionGeojson}"
compile "io.swagger:swagger-annotations:${versionSwagger}"
+13
View File
@@ -2,6 +2,13 @@ apply plugin: 'com.android.library'
description = "Mowesta Android SDK"
// remove project version to workaround bugs in
// oss-license-plugin that detects local libraries
// by checking for a version called "unspecified"
// see DependencyTask.groovy on GitHub at
// https://github.com/google/play-services-plugins
project.version = "unspecified"
android {
compileSdkVersion 29
@@ -23,6 +30,12 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
lintOptions {
quiet true
}
}
dependencies {
@@ -104,6 +104,7 @@ public abstract class SdkService extends Service {
}
@Override
@SuppressWarnings("deprecation")
public void onStatusChanged(String provider, int status, Bundle extras) {
}
@@ -217,14 +218,15 @@ public abstract class SdkService extends Service {
private Handler handler = new Handler();
@Override
@SuppressWarnings("deprecation")
public void onCreate() {
Log.d(TAG, "Creating sdk service.");
super.onCreate();
repository = SdkRepository.getInstance(this.getApplication());
capabilityManager = new CapabilityManager(getApplication());
channelManager = new ChannelManager(getApplication());
channelManager.createChannel();
startForeground(channelManager.getNotificationId(), channelManager.createNotification(R.string.mowesta_sdk_notification_content_idle));
repository = SdkRepository.getInstance(this.getApplication());
capabilityManager = new CapabilityManager(getApplication());
repository.getUploading().observeForever(uploadListener);
locationManager = (LocationManager)getApplicationContext().getSystemService(LOCATION_SERVICE);
wifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
@@ -635,6 +637,10 @@ public abstract class SdkService extends Service {
// cleanup based on type
if (currentState == State.GPS) cleanupGps();
if (currentState == State.NET) cleanupNet();
// workaround locations that might be buffered already
// in the location listeners buffer which can cause
// two locations to be sent despite deactivation
if (measurement == null) return;
Coordinate c = new Coordinate();
c.setLatitude(location.getLatitude());
c.setLongitude(location.getLongitude());
@@ -74,7 +74,7 @@ public class BufferDatabaseTest {
Assert.assertEquals(2, b3.get(0).getCoordinate().getLatitude(), 0.0001);
Assert.assertEquals(2, b3.get(0).getCoordinate().getLongitude(), 0.0001);
Assert.assertEquals(2, b3.get(0).getData().size());
database.close();
}
@@ -79,6 +79,7 @@ public class CacheDatabaseTest {
accessor.clearAll();
Assert.assertEquals(0, accessor.countLocations());
Assert.assertEquals(0, accessor.countNetworks());
database.close();
}
/**
+32 -38
View File
@@ -2,34 +2,26 @@ apply plugin: 'maven-publish'
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:4.10.0'
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.2'
classpath 'org.handte.gradle:gradle-android-eclipse:1.0.0'
classpath "org.openbakery:xcode-plugin:0.19.1"
}
repositories {
maven {
url = 'https://project.nes.uni-due.de/artifactory/releases';
url = 'https://project.nes.uni-due.de/nexus/repository/maven-public';
credentials { username = 'public'; password = 'public' }
authentication { basic(BasicAuthentication) }
}
maven {
url = 'https://project.nes.uni-due.de/artifactory/snapshots';
credentials { username = 'public'; password = 'public' }
authentication { basic(BasicAuthentication) }
}
google()
}
}
allprojects {
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
// set version for our project
group = 'com.mowesta'
version = '1.0.7'
version = '1.0.13'
// set versions for our libraries
ext {
@@ -40,12 +32,14 @@ allprojects {
versionSwagger = '1.5.22'
versionGeojson = '1.8.1'
// wildfly dependencies, keep in sync
versionJackson = '2.9.9'
versionResteasy = '3.7.0.Final'
versionWildfly = '17.0.1.Final'
versionJackson = '2.10.5'
versionResteasy = '3.13.2.Final'
versionWildfly = '21.0.0.Final'
versionPicketbox = '5.0.3.Final'
versionHibernateSearch = '5.10.5.Final'
versionInfinispan = '9.4.14.Final'
versionHibernate = '5.3.18.Final'
versionHibernateSearch = '5.10.7.Final'
// built-in infinispan dependency
versionInfinispan = '9.4.20.Final'
// testing dependencies
versionJunit = '4.12'
versionArquillianContainer = '2.2.0.Final'
@@ -56,11 +50,11 @@ allprojects {
// other frameworks
mapstructVersion = '1.3.1.Final'
// shared android dependencies
versionAndroidXTest = '1.2.0'
versionAndroidXAppcompat = '1.1.0'
versionAndroidXRoom = '2.2.5'
versionAndroidXTest = '1.3.0'
versionAndroidXAppcompat = '1.2.0'
versionAndroidXRoom = '2.2.6'
versionAndroidXPreference = '1.1.1'
versionRobolectric = '4.3.1'
versionRobolectric = '4.5'
}
@@ -85,6 +79,7 @@ subprojects {
publications {
maven(MavenPublication) {
artifact file('build/outputs/aar/android-sdk-release.aar')
version = project.version
}
}
}
@@ -122,32 +117,31 @@ subprojects {
}
artifactoryPublish.dependsOn('build')
artifactoryPublish {
publications(publishing.publications.maven);
}
repositories {
repositories {
maven {
url = 'https://project.nes.uni-due.de/artifactory/releases';
credentials { username = 'public'; password = 'public' }
authentication { basic(BasicAuthentication) }
}
maven {
url = 'https://project.nes.uni-due.de/artifactory/snapshots';
url = 'https://project.nes.uni-due.de/nexus/repository/maven-public';
credentials { username = 'public'; password = 'public' }
authentication { basic(BasicAuthentication) }
}
}
}
publishing {
repositories {
maven {
url = version.endsWith('SNAPSHOT') ?
"https://project.nes.uni-due.de/nexus/repository/maven-snapshots" :
"https://project.nes.uni-due.de/nexus/repository/maven-releases"
credentials { username = 'jenkins'; password = System.properties['jenkins.nexus.password'] }
authentication { basic(BasicAuthentication) }
}
}
}
tasks.register("generatePomFileForMavenPublication") {
// rename subprojects in eclipse to avoid collisions with other projects
eclipse.project.name = 'mowesta-' + project.name
}
tasks.register("build") {
tasks.register("generatePomFileForMavenPublication") { }
}
tasks.register("build") { }
@@ -42,7 +42,7 @@ import io.swagger.annotations.Authorization;
public interface IDeviceService {
// device functions (for the mobile app)
/**
* Creates and returns a new device.
*
@@ -66,6 +66,7 @@ public interface IDeviceService {
/**
* Sets the user account for a previously registered device.
*
* @param device The device to associate with the user.
* @return A response.
*/
@POST
@@ -100,7 +101,7 @@ public interface IDeviceService {
/**
* Deletes the current device.
*
*
* @return A response code to indicate the success.
*/
@DELETE
@@ -29,7 +29,7 @@ import io.swagger.annotations.ApiResponses;
/**
* The api to query and fetch locations.
*
*
* @author Marcus
*/
@Api
@@ -40,7 +40,7 @@ public interface ILocationService {
/**
* Returns a page of locations that match the query.
*
*
* @param pageConfig The page configuration.
* @param context The search context.
* @param term The search term.
@@ -53,16 +53,16 @@ public interface ILocationService {
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="Location hierarchy page retrieved successfully.", response=LocationHierarchyPage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
})
@PermitAll
Response searchLocations(@BeanParam @Valid PageConfig pageConfig, @BeanParam @Valid SearchContext context,
@ApiParam(value="The search term.", required=true) @QueryParam("term") @NotNull @Valid String term);
/**
* Returns a page of cities that are inside a particular area defined by two coordinates.
*
*
* @param pageConfig The page configuration.
* @param longitude1 The longitude of the first coordinate.
* @param latitude1 The latitude of the first coordinate.
@@ -76,18 +76,18 @@ public interface ILocationService {
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="The pages.", response=CityPage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
})
@PermitAll
Response searchCities(@BeanParam @Valid PageConfig pageConfig,
@ApiParam(value = "The longitude of the first coordinate.", required = true) @QueryParam("longitude1") double longitude1,
Response searchCities(@BeanParam @Valid PageConfig pageConfig,
@ApiParam(value = "The longitude of the first coordinate.", required = true) @QueryParam("longitude1") double longitude1,
@ApiParam(value = "The latitude of the first coordinate.", required = true) @QueryParam("latitude1") double latitude1,
@ApiParam(value = "The longitude of the second coordinate.", required = true) @QueryParam("longitude2") double longitude2,
@ApiParam(value = "The longitude of the second coordinate.", required = true) @QueryParam("longitude2") double longitude2,
@ApiParam(value = "The latitude of the second coordinate.", required = true) @QueryParam("latitude2") double latitude2);
/**
* Returns a page of cities.
*
*
* @param pageConfig The page configuration.
* @return A page of cities.
*/
@@ -97,10 +97,10 @@ public interface ILocationService {
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="City page retrieved successfully.", response=CityPage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
})
@PermitAll
Response getCities(@BeanParam @Valid PageConfig pageConfig);
/**
* Returns a particular city.
*
@@ -119,8 +119,8 @@ public interface ILocationService {
/**
* Returns a geojson representation of the city boundaries.
*
* @param id The id of the city.
*
* @param id The id of the city.
* @return The boundaries of geojson or an error code.
*/
@GET
@@ -134,8 +134,8 @@ public interface ILocationService {
@PermitAll
@Produces({MediaType.APPLICATION_JSON})
Response getCityBoundary(@ApiParam(value = "The city id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
* Returns a page of states.
*
@@ -151,7 +151,7 @@ public interface ILocationService {
})
@PermitAll
Response getStates(@BeanParam @Valid PageConfig pageConfig);
/**
* Returns a particular state.
*
@@ -167,15 +167,15 @@ public interface ILocationService {
})
@PermitAll
Response getState(@ApiParam(value = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
* Returns a geojson representation of the state boundaries.
*
* @param id The id of the state.
* @return The boundaries of geojson or an error code.
* @return The boundaries as geojson or an error code.
*/
@GET
@Path("state/{id: [0-9]+}/boundary")
@Path("states/{id: [0-9]+}/boundary")
@ApiOperation(value = "Gets the state boundary for a state with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "State boundary retrieved successfully.", response=Geometry.class),
@@ -185,7 +185,28 @@ public interface ILocationService {
@PermitAll
@Produces({MediaType.APPLICATION_JSON})
Response getStateBoundary(@ApiParam(value = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
* The deprecated version of the method that has a typo in the path name (state instead of states).
* To be removed, if Android Apps < V14 are no longer present.
*
* @param id The id of the state.
* @return The boundaries as geojson or an error code.
*/
@GET
@Path("state/{id: [0-9]+}/boundary")
@ApiOperation(value = "Deprecated: Gets the state boundary for a state with a particular id.", tags = {Tags.DEFAULT, Tags.LOCATION})
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "State boundary retrieved successfully.", response=Geometry.class),
@ApiResponse(code = HttpServletResponse.SC_NO_CONTENT, message = "The state boundary are not available."),
@ApiResponse(code = HttpServletResponse.SC_NOT_FOUND, message = "The state does not exist."),
})
@PermitAll
@Produces({MediaType.APPLICATION_JSON})
@Deprecated
Response getStateBoundaryDeprecated(@ApiParam(value = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
* Returns a page of cities for a state ordered by importance.
*
@@ -202,10 +223,10 @@ public interface ILocationService {
})
@PermitAll
Response getStateCities(@ApiParam(value = "The state id.", required = true) @PathParam("id") @Valid @Min(0) long id, @BeanParam @Valid PageConfig pageConfig);
/**
* Returns a page of countries.
*
*
* @param pageConfig The page configuration.
* @return A page of countries.
*/
@@ -215,10 +236,10 @@ public interface ILocationService {
@ApiResponses({
@ApiResponse(code=HttpServletResponse.SC_OK, message="Country page retrieved successfully.", response=CountryPage.class),
@ApiResponse(code=HttpServletResponse.SC_BAD_REQUEST, message="Invalid request parameter.")
})
})
@PermitAll
Response getCountries(@BeanParam @Valid PageConfig pageConfig);
/**
* Returns a particular country.
*
@@ -237,8 +258,8 @@ public interface ILocationService {
/**
* Returns a geojson representation of the country boundaries.
*
* @param id The id of the country.
*
* @param id The id of the country.
* @return The boundaries of geojson or an error code.
*/
@GET
@@ -252,7 +273,7 @@ public interface ILocationService {
@PermitAll
@Produces({MediaType.APPLICATION_JSON})
Response getCountryBoundary(@ApiParam(value = "The country id.", required = true) @PathParam("id") @Valid @Min(0) long id);
/**
* Returns a page of cities for a country ordered by importance.
*
@@ -270,5 +291,5 @@ public interface ILocationService {
@PermitAll
Response getCountryCities(@ApiParam(value = "The country id.", required = true) @PathParam("id") @Valid @Min(0) long id, @BeanParam @Valid PageConfig pageConfig);
}
@@ -104,7 +104,7 @@ public interface IMeasurementService {
*/
@GET
@Path("devices/{id: ([0-9])+}/measurements")
@ApiOperation(value = "Returns a page of measurements of a specific device from a certain time range.", authorizations = {
@ApiOperation(value = "Returns a page of measurements of a specific device from a certain time range.",authorizations = {
@Authorization(Authorizations.USER), @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.DEVICE })
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Measurements retrieved successfully.", response = MeasurementPage.class),
@@ -113,4 +113,21 @@ public interface IMeasurementService {
@RolesAllowed({ Roles.USER, Roles.ADMIN })
Response getDeviceMeasurements(@ApiParam(value = "The device id.", required = true) @PathParam("id") long id, @BeanParam @Valid TimeRange timeRange, @BeanParam @Valid PageConfig pageConfig);
/**
* Returns a page of measurements of all devices within a certain time range.
*
* @param timeRange The time range.
* @param pageConfig The page config.
* @return The page of measurements.
*/
@GET
@Path("devices/measurements")
@ApiOperation(value = "Returns a page of measurements of all devices within a certain time range.",
authorizations = { @Authorization(Authorizations.ADMIN) }, tags = { Tags.DEFAULT, Tags.DEVICE })
@ApiResponses({
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Measurements retrieved successfully.", response = MeasurementPage.class),
@ApiResponse(code = HttpServletResponse.SC_FORBIDDEN, message = "Insufficient privileges to retrieve the measurements.") })
@RolesAllowed({ Roles.ADMIN })
Response getAllMeasurementsByRange(@BeanParam @Valid TimeRange timeRange, @BeanParam @Valid PageConfig pageConfig);
}
@@ -3,7 +3,7 @@ package com.mowesta.api.weather;
/**
* An enumeration with different video types that
* we generate from our dataset.
*
*
* @author Marcus
*/
public enum VideoType {
@@ -23,6 +23,10 @@ public enum VideoType {
/**
* The temperature video.
*/
TEMPERATURE;
TEMPERATURE,
/**
* The wind video.
*/
WIND;
}
+2 -2
View File
@@ -1,6 +1,6 @@
#Sat May 30 11:33:41 CEST 2020
#Sat Nov 07 15:10:18 CET 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
+17
View File
@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
2C2CA271237304E200529274 /* MowestaApi in Frameworks */ = {isa = PBXBuildFile; productRef = 2C2CA270237304E200529274 /* MowestaApi */; };
2C32C47524B355A500B69113 /* SwiftUICharts in Frameworks */ = {isa = PBXBuildFile; productRef = 2C32C47424B355A500B69113 /* SwiftUICharts */; };
2C7846D52372F44300766694 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C7846D42372F44300766694 /* AppDelegate.swift */; };
2C7846D72372F44300766694 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C7846D62372F44300766694 /* SceneDelegate.swift */; };
2C7846D92372F44300766694 /* MainTabView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C7846D82372F44300766694 /* MainTabView.swift */; };
@@ -303,6 +304,7 @@
9E6D641223CCC2600002CBCF /* Socket in Frameworks */,
9E0D267223AD2E7D00BE14F5 /* AuthenticationServices.framework in Frameworks */,
9E6D640623CC73320002CBCF /* NetworkExtension.framework in Frameworks */,
2C32C47524B355A500B69113 /* SwiftUICharts in Frameworks */,
9E3BCD3623ACED50002F2D8F /* KeychainSwift in Frameworks */,
2C2CA271237304E200529274 /* MowestaApi in Frameworks */,
);
@@ -695,6 +697,7 @@
2C2CA270237304E200529274 /* MowestaApi */,
9E3BCD3523ACED50002F2D8F /* KeychainSwift */,
9E6D641123CCC2600002CBCF /* Socket */,
2C32C47424B355A500B69113 /* SwiftUICharts */,
);
productName = app;
productReference = 2C7846D12372F44300766694 /* MoWeSta.app */;
@@ -772,6 +775,7 @@
packageReferences = (
9E3BCD3423ACED50002F2D8F /* XCRemoteSwiftPackageReference "keychain-swift" */,
9E6D641023CCC2600002CBCF /* XCRemoteSwiftPackageReference "BlueSocket" */,
2C32C47324B355A500B69113 /* XCRemoteSwiftPackageReference "ChartView" */,
);
productRefGroup = 2C7846D22372F44300766694 /* Products */;
projectDirPath = "";
@@ -1294,6 +1298,14 @@
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
2C32C47324B355A500B69113 /* XCRemoteSwiftPackageReference "ChartView" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/AppPear/ChartView";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.5.3;
};
};
9E3BCD3423ACED50002F2D8F /* XCRemoteSwiftPackageReference "keychain-swift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/evgenyneu/keychain-swift.git";
@@ -1321,6 +1333,11 @@
isa = XCSwiftPackageProductDependency;
productName = MowestaApi;
};
2C32C47424B355A500B69113 /* SwiftUICharts */ = {
isa = XCSwiftPackageProductDependency;
package = 2C32C47324B355A500B69113 /* XCRemoteSwiftPackageReference "ChartView" */;
productName = SwiftUICharts;
};
9E3BCD3523ACED50002F2D8F /* KeychainSwift */ = {
isa = XCSwiftPackageProductDependency;
package = 9E3BCD3423ACED50002F2D8F /* XCRemoteSwiftPackageReference "keychain-swift" */;
@@ -9,6 +9,7 @@
import os
import Foundation
import KeychainSwift
import UIKit
import MowestaApi
/*
@@ -83,7 +84,8 @@ class UserData: ObservableObject {
if !DeviceData.shared.created {
resetDeviceForPairing()
} else {
DeviceAPI.setCurrentDeviceUser(completion: { d, err in
let d = Device(_id: DeviceData.shared.idInt64, creationTime: 0, modificationTime: 0, deleted: false, user: nil, os: .ios, manufacturer: "Apple Inc.", device: UIDevice.current.modelName, model: UIDevice.current.model)
DeviceAPI.setCurrentDeviceUser(body: d, completion: { d, err in
if let error = err {
switch(error as! ErrorResponse) {
case .error(let statusCode, _, _):
@@ -47,7 +47,7 @@ class MeasurementService {
if let c = coordinate {
let measurement = MowestaApi.Measurement(coordinate: c, time: timestamp, measurements: measurementData, deviceId: DeviceData.shared.idInt64)
DeviceAPI.addCurrentDeviceMeasurements(body: MeasurementBatch(elements: [measurement]), completion: { _,err in
DeviceAPI.addCurrentDeviceMeasurements(body: [measurement], completion: { _,err in
if let error = err {
NSLog("\(error)")
} else {
+23
View File
@@ -0,0 +1,23 @@
plugins {
id 'war'
}
description = 'Mowesta Alexa Service'
dependencies {
providedCompile project(':service-ejb')
compile "com.amazon.alexa:ask-sdk:2.37.1"
testCompile project(':service-ejb')
testCompile "junit:junit:${versionJunit}"
testCompile "org.jboss.arquillian.junit:arquillian-junit-container:${versionArquillianJunit}"
testCompile "org.wildfly.arquillian:wildfly-arquillian-container-managed:${versionArquillianContainer}"
providedCompile "jakarta.platform:jakarta.jakartaee-api:${versionJavaee}"
providedCompile "com.fasterxml.jackson.core:jackson-databind:${versionJackson}"
}
jar {
enabled = true
}
@@ -0,0 +1,72 @@
package com.mowesta.service.alexa;
import com.amazon.ask.Skills;
import com.amazon.ask.servlet.SkillServlet;
import com.mowesta.service.alexa.impl.CancelandStopIntentHandler;
import com.mowesta.service.alexa.impl.ClothingRecommendationIntentHandler;
import com.mowesta.service.alexa.impl.CurrentWeatherIntentHandler;
import com.mowesta.service.alexa.impl.HelpIntentHandler;
import com.mowesta.service.alexa.impl.LaunchRequestHandler;
import com.mowesta.service.alexa.impl.SessionEndedRequestHandler;
import com.mowesta.service.alexa.impl.WeatherForecastIntentHandler;
import com.mowesta.service.session.LocationSessionBean;
import com.mowesta.service.session.WeatherSessionBean;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServlet;
@RequestScoped
public class AlexaServlet extends HttpServlet {
private HttpServlet servlet;
@Inject
LocationSessionBean locationSessionBean;
@Inject
WeatherSessionBean weatherSessionBean;
Logger log = Logger.getLogger(getClass().getName());
@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
getServlet().service(req, res);
}
public HttpServlet getServlet() {
if (servlet == null) {
servlet = createServlet();
try {
servlet.init(getServletConfig());
} catch (ServletException e) {
throw new RuntimeException("Failed to initialize skill servlet.", e);
}
}
return servlet;
}
public SkillServlet createServlet() {
log.log(Level.INFO,"Servlet created " + locationSessionBean + " " + weatherSessionBean);
return new SkillServlet(Skills.standard()
.addRequestHandlers(
new CancelandStopIntentHandler(),
new HelpIntentHandler(),
new LaunchRequestHandler(),
new SessionEndedRequestHandler(),
new CurrentWeatherIntentHandler(locationSessionBean, weatherSessionBean),
new WeatherForecastIntentHandler(locationSessionBean, weatherSessionBean),
new ClothingRecommendationIntentHandler(locationSessionBean, weatherSessionBean))
.withSkillId("amzn1.ask.skill.208278db-dd0c-477e-9946-5ebe634831aa")
.build());
}
}
@@ -0,0 +1,38 @@
/*
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/apache2.0/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the License.
*/
package com.mowesta.service.alexa.impl;
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
import com.amazon.ask.model.Response;
import java.util.Optional;
import static com.amazon.ask.request.Predicates.intentName;
public class CancelandStopIntentHandler implements RequestHandler {
@Override
public boolean canHandle(HandlerInput input) {
return input.matches(intentName("AMAZON.StopIntent").or(intentName("AMAZON.CancelIntent")));
}
@Override
public Optional<Response> handle(HandlerInput input) {
String speechText = "Goodbye";
return input.getResponseBuilder()
.withSpeech(speechText)
.withSimpleCard("HelloWorld", speechText)
.build();
}
}
@@ -0,0 +1,182 @@
package com.mowesta.service.alexa.impl;
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
import com.amazon.ask.dispatcher.request.handler.impl.IntentRequestHandler;
import com.amazon.ask.model.IntentRequest;
import com.amazon.ask.model.Response;
import com.mowesta.api.Language;
import com.mowesta.api.PageConfig;
import com.mowesta.api.SearchContext;
import com.mowesta.api.location.Location;
import com.mowesta.api.location.LocationHierarchyPage;
import com.mowesta.api.weather.WeatherCondition;
import com.mowesta.api.weather.WeatherForecast;
import com.mowesta.api.weather.WeatherType;
import com.mowesta.service.session.LocationSessionBean;
import com.mowesta.service.session.WeatherSessionBean;
import org.apache.logging.log4j.util.Strings;
import org.joda.time.LocalDateTime;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import static com.amazon.ask.request.Predicates.intentName;
/**
* Recommends clothing to the user for today / tomorrow / the day after for a location.
*
* @author Katharina
*/
public class ClothingRecommendationIntentHandler implements IntentRequestHandler {
LocationSessionBean locationSessionBean;
WeatherSessionBean weatherSessionBean;
LocationWeatherService locationWeatherService;
ClothingWeatherToStringConverter clothingWeatherToStringConverter = new ClothingWeatherToStringConverter();
public ClothingRecommendationIntentHandler(LocationSessionBean locationSessionBean, WeatherSessionBean weatherSessionBean) {
this.locationSessionBean = locationSessionBean;
this.weatherSessionBean = weatherSessionBean;
locationWeatherService = new LocationWeatherService(this.locationSessionBean, this.weatherSessionBean);
}
@Override
public boolean canHandle(HandlerInput input, IntentRequest intentRequest) {
return input.matches(intentName("ClothingRecommendationIntent"));
}
@Override
public Optional<Response> handle(HandlerInput input, IntentRequest intentRequest) {
String speechText = "";
String city = intentRequest.getIntent().getSlots().get("Stadt").getValue();
String uppercaseCity ="";
if(city!=null) uppercaseCity= city.substring(0, 1).toUpperCase() + city.substring(1);
String timeslot = intentRequest.getIntent().getSlots().get("Zeitpunkt").getValue();
int timebegin = getTime(timeslot);
int timeend;
if(timebegin>=24) {
timeend = timebegin+24;
} else {
timeend = 24;
}
Location location = null;
if(city ==null){
location = locationWeatherService.getGeoLocation(input);
}else{
LocationHierarchyPage locationHierarchyPage = locationSessionBean.findLocations(new PageConfig(0, 60), new SearchContext(Language.GERMAN), city);
location = locationWeatherService.getLocation(intentRequest, locationHierarchyPage);
}
if (location == null && city!=null) {
String errorText = "Die Stadt " + uppercaseCity + " wurde nicht gefunden.";
return input.getResponseBuilder()
.withSpeech(errorText)
.withSimpleCard("Error", errorText)
.build();
} else if (location == null && city == null){
String errorText = "Dein aktueller Ort konnte nicht gefunden werden.";
return input.getResponseBuilder()
.withSpeech(errorText)
.withSimpleCard("Error", errorText)
.build();
}
WeatherForecast weatherForecast = weatherSessionBean.getForecast(location.getCoordinate());
if (weatherForecast != null) {
Double maxTemperature = null;
Double maxWindspeed = null;
Map<WeatherType, Integer> weatherTypeMap = new HashMap<WeatherType, Integer>();
for (int i = 0; i < weatherForecast.getConditions().size(); i++) {
WeatherCondition condition = weatherForecast.getConditions().get(i);
if (timebegin!=-1 && condition.getHour() >= timebegin && condition.getHour() < timeend) {
if (maxTemperature == null || condition.getTemperature() > maxTemperature) {
maxTemperature = weatherForecast.getConditions().get(i).getTemperature();
}
if (weatherTypeMap.isEmpty() || !weatherTypeMap.containsKey(condition.getType())) {
weatherTypeMap.put(condition.getType(), clothingWeatherToStringConverter.setPriorityOfWeather(condition.getType()));
}
if(maxWindspeed == null || condition.getWindSpeed() > maxWindspeed ){
maxWindspeed = weatherForecast.getConditions().get(i).getWindSpeed();
}
}
}
if(city!=null){
speechText += "In " + uppercaseCity + " empfehle ich dir "+timeslot;
} else {
speechText += "Ich empfehle dir " + timeslot;
}
if(maxTemperature != null) {
if(maxTemperature<=10){
speechText+= " warme Kleidung";
}else if(maxTemperature <= 20){
speechText+= " eine Jacke oder Weste";
}else if(maxTemperature <= 30){
speechText+= " eine leichte Jacke";
}else if(maxTemperature >30){
speechText += " leichte Kleidung";
}
}
if(!weatherTypeMap.isEmpty()) {
Map.Entry<WeatherType, Integer> maxWeather = Collections.max(weatherTypeMap.entrySet(), Comparator.comparingInt(Map.Entry::getValue));
speechText += clothingWeatherToStringConverter.convertToString(maxWeather.getKey()) + ".";
}
if(maxWindspeed!= null && maxTemperature!= null) {
String warning = locationWeatherService.checkForWeatherWarning(maxWindspeed, maxTemperature, maxTemperature);
if (!Strings.isBlank(warning)) speechText += " Vorsicht! " + warning;
}
if(maxTemperature == null) {
speechText = "Es wurde zurzeit keine Kleidungsempfehlung gefunden.";
}
}else {
speechText += "Es wurde zurzeit keine Kleidungsempfehlung gefunden.";
}
return input.getResponseBuilder()
.withSpeech(speechText)
.withSimpleCard("ClothingRecommendationIntent", speechText)
.build();
}
private int getTime(String timeslot){
LocalDateTime localDateTime = LocalDateTime.now();
switch (timeslot) {
case "heute":
return localDateTime.getHourOfDay();
case "morgen":
return 24;
case "übermorgen":
return 48;
}
return -1;
}
}
@@ -0,0 +1,101 @@
package com.mowesta.service.alexa.impl;
import com.mowesta.api.weather.WeatherType;
/**
* Converts each weather type to a specific string or gives it a specific priority.
*
* @author Katharina
*/
public class ClothingWeatherToStringConverter {
public String convertToString(WeatherType weatherType) {
String weathercondition = "";
switch (weatherType) {
case UNKNOWN:
break;
case FOG:
case FOG_DEPOSITING_RIME:
case CLOUDY:
case PARTLY_CLOUDY:
weathercondition = "";
break;
case CLEAR_SKY:
case MAINLY_CLEAR:
weathercondition = " und einen Schutz gegen die Sonne";
break;
case SNOW_GRAINS:
case HEAVY_DRIZZLE:
case SLIGHT_DRIZZLE:
case MODERATE_DRIZZLE:
case RAIN_SHOWER_SLIGHT:
case SLIGHT_RAIN_NOT_FREEZING:
case SNOW_SHOWER_SLIGHT:
case SLIGHT_FALL_OF_SNOWFLAKES:
case RAIN_SHOWER_MODERATE_HEAVY:
case RAIN_SHOWER_VIOLENT:
case HEAVY_RAIN_NOT_FREEZING:
case RAIN_FREEZING_SLIGHT:
case DRIZZLE_FREEZING_SLIGHT:
case THUNDERSTORM_HAIL_HEAVY:
case HEAVY_FALL_OF_SNOWFLAKES:
case SNOW_SHOWER_MODERATE_HEAVY:
case MODERATE_RAIN_NOT_FREEZING:
case MODERATE_FALL_OF_SNOWFLAKES:
case RAIN_FREEZING_MODERATE_HEAVY:
case THUNDERSTORM_SLIGHT_MODERATE:
case DRIZZLE_FREEZING_MODERATE_HEAVY:
weathercondition = " und einen Regenschirm oder wasserfeste Kleidung";
break;
}
return weathercondition;
}
public int setPriorityOfWeather(WeatherType weatherType){
int priority = 0;
switch (weatherType) {
case UNKNOWN:
break;
case FOG:
case FOG_DEPOSITING_RIME:
case CLOUDY:
case PARTLY_CLOUDY:
priority = 1;
break;
case CLEAR_SKY:
case MAINLY_CLEAR:
priority = 2;
break;
case SNOW_GRAINS:
case HEAVY_DRIZZLE:
case SLIGHT_DRIZZLE:
case MODERATE_DRIZZLE:
case RAIN_SHOWER_SLIGHT:
case SLIGHT_RAIN_NOT_FREEZING:
case SNOW_SHOWER_SLIGHT:
case SLIGHT_FALL_OF_SNOWFLAKES:
case RAIN_SHOWER_MODERATE_HEAVY:
case RAIN_SHOWER_VIOLENT:
case HEAVY_RAIN_NOT_FREEZING:
case RAIN_FREEZING_SLIGHT:
case DRIZZLE_FREEZING_SLIGHT:
case THUNDERSTORM_HAIL_HEAVY:
case HEAVY_FALL_OF_SNOWFLAKES:
case SNOW_SHOWER_MODERATE_HEAVY:
case MODERATE_RAIN_NOT_FREEZING:
case MODERATE_FALL_OF_SNOWFLAKES:
case RAIN_FREEZING_MODERATE_HEAVY:
case THUNDERSTORM_SLIGHT_MODERATE:
case DRIZZLE_FREEZING_MODERATE_HEAVY:
priority = 3;
break;
}
return priority;
}
}
@@ -0,0 +1,118 @@
package com.mowesta.service.alexa.impl;
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
import com.amazon.ask.dispatcher.request.handler.impl.IntentRequestHandler;
import com.amazon.ask.model.IntentRequest;
import com.amazon.ask.model.Response;
import com.mowesta.api.Language;
import com.mowesta.api.PageConfig;
import com.mowesta.api.SearchContext;
import com.mowesta.api.location.City;
import com.mowesta.api.location.Country;
import com.mowesta.api.location.Location;
import com.mowesta.api.location.LocationHierarchy;
import com.mowesta.api.location.LocationHierarchyPage;
import com.mowesta.api.location.State;
import com.mowesta.api.weather.WeatherCondition;
import com.mowesta.service.entity.EntityNotFoundException;
import com.mowesta.service.session.LocationSessionBean;
import com.mowesta.service.session.WeatherSessionBean;
import org.apache.logging.log4j.util.Strings;
import java.text.DecimalFormat;
import java.util.Optional;
import static com.amazon.ask.request.Predicates.intentName;
/**
* Tells the user the current weather for a location.
*
* @author Katharina
*/
public class CurrentWeatherIntentHandler implements IntentRequestHandler {
LocationSessionBean locationSessionBean;
WeatherSessionBean weatherSessionBean;
WeatherTypeToStringConverter weatherTypeToStringConverter = new WeatherTypeToStringConverter();
LocationWeatherService locationWeatherService;
public CurrentWeatherIntentHandler(LocationSessionBean locationSessionBean, WeatherSessionBean weatherSessionBean) {
this.locationSessionBean = locationSessionBean;
this.weatherSessionBean = weatherSessionBean;
locationWeatherService = new LocationWeatherService(this.locationSessionBean, this.weatherSessionBean);
}
@Override
public boolean canHandle(HandlerInput input, IntentRequest intentRequest) {
return input.matches(intentName("CurrentWeatherIntent"));
}
@Override
public Optional<Response> handle(HandlerInput input, IntentRequest intentRequest) {
String speechText = "";
String city = intentRequest.getIntent().getSlots().get("Stadt").getValue();
String uppercaseCity ="";
if(city!=null) uppercaseCity= city.substring(0, 1).toUpperCase() + city.substring(1);
Location location = null;
if(city ==null){
location = locationWeatherService.getGeoLocation(input);
}else {
LocationHierarchyPage locationHierarchyPage = locationSessionBean.findLocations(new PageConfig(0, 60), new SearchContext(Language.GERMAN), city);
location = locationWeatherService.getLocation(intentRequest, locationHierarchyPage);
}
if (location == null && city!=null) {
String errorText = "Die Stadt " + uppercaseCity + " wurde nicht gefunden.";
return input.getResponseBuilder()
.withSpeech(errorText)
.withSimpleCard("Error", errorText)
.build();
} else if (location == null && city == null){
String errorText = "Dein aktueller Ort konnte nicht gefunden werden.";
return input.getResponseBuilder()
.withSpeech(errorText)
.withSimpleCard("Error", errorText)
.build();
}
WeatherCondition currentWeatherOfLocation = weatherSessionBean.getCondition(location.getCoordinate());
if (currentWeatherOfLocation != null) {
DecimalFormat decimalFormat = new DecimalFormat("#.#");
String temperature = String.valueOf(decimalFormat.format(currentWeatherOfLocation.getTemperature())).replaceAll("\\.", ",");
String[] splitTemperature = temperature.split(",");
if (splitTemperature.length > 1 && splitTemperature[1].equals("0")) temperature = splitTemperature[0];
String weatherType = weatherTypeToStringConverter.convertToString(currentWeatherOfLocation.getType());
if(city!=null){
speechText += "In " + uppercaseCity + " sind zurzeit " + temperature + " Grad" + weatherType + ".";
} else {
speechText += "Es sind zurzeit " + temperature + " Grad" + weatherType + ".";
}
String warning =locationWeatherService.checkForWeatherWarning(currentWeatherOfLocation.getWindSpeed(), currentWeatherOfLocation.getTemperature(), currentWeatherOfLocation.getTemperature());
if(!Strings.isBlank(warning)) speechText += " Vorsicht! " + warning;
} else {
speechText += "Es wurde zurzeit kein aktuelles Wetter gefunden.";
}
return input.getResponseBuilder()
.withSpeech(speechText)
.withSimpleCard("CurrentWeather", speechText)
.build();
}
}
@@ -0,0 +1,31 @@
package com.mowesta.service.alexa.impl;
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
import com.amazon.ask.model.Response;
import java.util.Optional;
import static com.amazon.ask.request.Predicates.intentName;
// 2018-July-09: AMAZON.FallackIntent is only currently available in en-US locale.
// This handler will not be triggered except in that locale, so it can be
// safely deployed for any locale.
public class FallbackIntentHandler implements RequestHandler {
@Override
public boolean canHandle(HandlerInput input) {
return input.matches(intentName("AMAZON.FallbackIntent"));
}
@Override
public Optional<Response> handle(HandlerInput input) {
String speechText = "Sorry, I don't know that. You can say try saying help!";
return input.getResponseBuilder()
.withSpeech(speechText)
.withSimpleCard("HelloWorld", speechText)
.withReprompt(speechText)
.build();
}
}
@@ -0,0 +1,90 @@
package com.mowesta.service.alexa.impl;
import com.mowesta.api.weather.WeatherType;
/**
* Converts each weather type to a specific string for the weather forecast.
*
* @author Katharina
*/
public class ForecastWeatherToStringConverter {
public String convertToString(WeatherType weatherType) {
String weathercondition = "";
switch (weatherType) {
case UNKNOWN:
break;
case FOG:
case FOG_DEPOSITING_RIME:
weathercondition = " nebelig";
break;
case CLOUDY:
case PARTLY_CLOUDY:
weathercondition = " bewölkt";
break;
case CLEAR_SKY:
case MAINLY_CLEAR:
weathercondition = " klar am Himmel";
break;
case SNOW_GRAINS:
weathercondition = " Graupelschauer geben";
break;
case HEAVY_DRIZZLE:
weathercondition = " starken Nieselregen geben";
break;
case SLIGHT_DRIZZLE:
weathercondition = " leichten Nieselregen geben";
break;
case MODERATE_DRIZZLE:
weathercondition = " Nieselregen geben";
break;
case RAIN_SHOWER_SLIGHT:
case SLIGHT_RAIN_NOT_FREEZING:
weathercondition = " leicht regnen";
break;
case SNOW_SHOWER_SLIGHT:
case SLIGHT_FALL_OF_SNOWFLAKES:
weathercondition = " leichten Schneefall geben";
break;
case RAIN_SHOWER_MODERATE_HEAVY:
case RAIN_SHOWER_VIOLENT:
case HEAVY_RAIN_NOT_FREEZING:
weathercondition = " Starkregen geben";
break;
case RAIN_FREEZING_SLIGHT:
weathercondition = " gefrierenden leichten Regen geben";
break;
case DRIZZLE_FREEZING_SLIGHT:
weathercondition = " gefrierenden leichten Nieselregen geben";
break;
case THUNDERSTORM_HAIL_HEAVY:
weathercondition = " Hagelschauern und Gewitter geben";
break;
case HEAVY_FALL_OF_SNOWFLAKES:
case SNOW_SHOWER_MODERATE_HEAVY:
weathercondition = " starken Schneefall geben";
break;
case MODERATE_RAIN_NOT_FREEZING:
weathercondition = " regnen";
break;
case MODERATE_FALL_OF_SNOWFLAKES:
weathercondition = " schneien";
break;
case RAIN_FREEZING_MODERATE_HEAVY:
weathercondition = " gefrierenden Regen geben";
break;
case THUNDERSTORM_SLIGHT_MODERATE:
weathercondition = " mitunter gewittern";
break;
case DRIZZLE_FREEZING_MODERATE_HEAVY:
weathercondition = " gefrierenden Sprühregen geben";
break;
}
return weathercondition;
}
}
@@ -0,0 +1,40 @@
/*
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/apache2.0/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the License.
*/
package com.mowesta.service.alexa.impl;
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
import com.amazon.ask.model.Response;
import java.util.Optional;
import static com.amazon.ask.request.Predicates.intentName;
public class HelpIntentHandler implements RequestHandler {
@Override
public boolean canHandle(HandlerInput input) {
return input.matches(intentName("AMAZON.HelpIntent"));
}
@Override
public Optional<Response> handle(HandlerInput input) {
String speechText = "You can say hello to me!";
return input.getResponseBuilder()
.withSpeech(speechText)
.withSimpleCard("HelloWorld", speechText)
.withReprompt(speechText)
.build();
}
}
@@ -0,0 +1,42 @@
/*
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/apache2.0/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the License.
*/
package com.mowesta.service.alexa.impl;
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
import com.amazon.ask.model.LaunchRequest;
import com.amazon.ask.model.Response;
import java.util.Optional;
import static com.amazon.ask.request.Predicates.requestType;
public class LaunchRequestHandler implements RequestHandler {
@Override
public boolean canHandle(HandlerInput input) {
return input.matches(requestType(LaunchRequest.class));
}
@Override
public Optional<Response> handle(HandlerInput input) {
String speechText = "Welcome to the Alexa Skills Kit, you can say hello";
return input.getResponseBuilder()
.withSpeech(speechText)
.withSimpleCard("HelloWorld", speechText)
.withReprompt(speechText)
.build();
}
}
@@ -0,0 +1,167 @@
package com.mowesta.service.alexa.impl;
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
import com.amazon.ask.model.IntentRequest;
import com.amazon.ask.model.PermissionStatus;
import com.amazon.ask.model.Permissions;
import com.amazon.ask.model.interfaces.geolocation.GeolocationState;
import com.mowesta.api.Coordinate;
import com.mowesta.api.PageConfig;
import com.mowesta.api.location.CityPage;
import com.mowesta.api.location.Country;
import com.mowesta.api.location.Location;
import com.mowesta.api.location.LocationHierarchy;
import com.mowesta.api.location.LocationHierarchyPage;
import com.mowesta.api.location.State;
import com.mowesta.api.weather.WeatherCondition;
import com.mowesta.service.entity.EntityNotFoundException;
import com.mowesta.service.session.LocationSessionBean;
import com.mowesta.service.session.WeatherSessionBean;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Service that provides an intent with the location the user is looking for.
*
* @author Katharina
*/
public class LocationWeatherService {
LocationSessionBean locationSessionBean;
WeatherSessionBean weatherSessionBean;
private static final String GEO_PERMISSION = "alexa::devices:all:geolocation:read";
public LocationWeatherService(LocationSessionBean locationSessionBean, WeatherSessionBean weatherSessionBean) {
this.locationSessionBean = locationSessionBean;
this.weatherSessionBean = weatherSessionBean;
}
public Location getGeoLocation(HandlerInput input){
Location geoLocation = null;
Permissions permissions = input.getRequestEnvelope().getSession().getUser().getPermissions();
if(input.getRequestEnvelope().getContext().getSystem().getDevice().getSupportedInterfaces()
.getGeolocation() != null && permissions != null && permissions.getScopes() != null
&& permissions.getScopes().get(GEO_PERMISSION).getStatus() == PermissionStatus.GRANTED){
GeolocationState geo = input.getRequestEnvelope().getContext().getGeolocation();
Coordinate userPosition = new Coordinate(geo.getCoordinate().getLongitudeInDegrees(),geo.getCoordinate().getLatitudeInDegrees());
Coordinate secondUserPosition = new Coordinate(geo.getCoordinate().getLongitudeInDegrees()+0.01, geo.getCoordinate().getLatitudeInDegrees()+0.01);
CityPage cities = locationSessionBean.findCities(new PageConfig(0, 1), userPosition , secondUserPosition );
geoLocation = cities.getElements().get(0);
return geoLocation;
} else return null;
}
public Location getLocation(IntentRequest intentRequest, LocationHierarchyPage locationHierarchyPage) {
if (locationHierarchyPage.getElements().isEmpty()) {
return null;
}
if (intentRequest.getIntent().getSlots().get("Region").getValue() != null) {
return getByRegion(intentRequest.getIntent().getSlots().get("Region").getValue(), intentRequest.getIntent().getSlots().get("Stadt").getValue(), locationHierarchyPage);
} else if (intentRequest.getIntent().getSlots().get("Land").getValue() != null) {
return getByCountry(intentRequest.getIntent().getSlots().get("Land").getValue(), intentRequest.getIntent().getSlots().get("Stadt").getValue(), locationHierarchyPage);
} else return locationHierarchyPage.getElements().get(0);
}
private Location getByRegion(String regionName, String cityName, LocationHierarchyPage locationHierarchyPage) {
for (LocationHierarchy element : locationHierarchyPage.getElements()) {
if(!locationContainsName(cityName, element)) {
continue;
}
State state = null;
try {
state = locationSessionBean.getCity(element.getId(), true).getState();
} catch (EntityNotFoundException e) {
e.printStackTrace();
}
if (state == null) continue;
if (locationContainsName(regionName, state)) {
return element;
}
}
return null;
}
private Location getByCountry(String name, String cityName, LocationHierarchyPage locationHierarchyPage) {
for (LocationHierarchy element : locationHierarchyPage.getElements()) {
if(!locationContainsName(cityName, element)) {
continue;
}
Country country = null;
try {
country = locationSessionBean.getCity(element.getId(), true).getCountry();
} catch (EntityNotFoundException e) {
e.printStackTrace();
}
if (country == null) continue;
if (locationContainsName(name, country)) {
return element;
}
}
return null;
}
private boolean locationContainsName(String name, Location location) {
return location.getNames().values().stream()
.map(locationName -> locationName.toLowerCase().replaceAll("-", " "))
.anyMatch(locationName -> locationName.equals(name));
}
public String checkForWeatherWarning(double windspeed, double minTemperature, double maxTemperature) {
String warning = "";
if(windspeed>=14 && windspeed<18){
warning += "Warnung vor starken Windböen. ";
}else if(windspeed>=18 && windspeed <=20){
warning += "Warnung vor stürmischem Wind. ";
}else if(windspeed>=21 && windspeed <=24){
warning += "Warnung vor Sturm. ";
}else if(windspeed>=25 && windspeed >=28) {
warning += "Warnung vor schwerem Sturm. ";
}else if(windspeed>=29 && windspeed >=33){
warning += "Warnung vor orkanartigen Sturm. ";
}else if(windspeed>33){
warning += "Warnung vor einem Orkan. ";
}
if(maxTemperature >= 32) {
warning += "Warnung vor Hitze. ";
}else if(minTemperature< 0 && minTemperature>=-2){
warning += "Warnung vor geringem Frost. ";
}else if(minTemperature<-2 && minTemperature>=-5){
warning += "Warnung vor mäßigen Frost. ";
}else if(minTemperature<-5 && minTemperature>=-10){
warning += "Warnung vor mäßigen Frost. ";
}else if(minTemperature<-10 && minTemperature>=-15){
warning += "Warnung vor strengem Frost. ";
}else if(minTemperature<-15){
warning += "Warnung vor sehr strengem Frost. ";
}
return warning;
}
}
@@ -0,0 +1,38 @@
/*
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/apache2.0/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the License.
*/
package com.mowesta.service.alexa.impl;
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
import com.amazon.ask.model.Response;
import com.amazon.ask.model.SessionEndedRequest;
import java.util.Optional;
import static com.amazon.ask.request.Predicates.requestType;
public class SessionEndedRequestHandler implements RequestHandler {
@Override
public boolean canHandle(HandlerInput input) {
return input.matches(requestType(SessionEndedRequest.class));
}
@Override
public Optional<Response> handle(HandlerInput input) {
// any cleanup logic goes here
return input.getResponseBuilder().build();
}
}
@@ -0,0 +1,219 @@
package com.mowesta.service.alexa.impl;
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
import com.amazon.ask.dispatcher.request.handler.impl.IntentRequestHandler;
import com.amazon.ask.model.IntentRequest;
import com.amazon.ask.model.Response;
import com.mowesta.api.Coordinate;
import com.mowesta.api.Language;
import com.mowesta.api.PageConfig;
import com.mowesta.api.SearchContext;
import com.mowesta.api.location.Country;
import com.mowesta.api.location.Location;
import com.mowesta.api.location.LocationHierarchy;
import com.mowesta.api.location.LocationHierarchyPage;
import com.mowesta.api.location.State;
import com.mowesta.api.weather.WeatherCondition;
import com.mowesta.api.weather.WeatherForecast;
import com.mowesta.api.weather.WeatherType;
import com.mowesta.service.entity.EntityNotFoundException;
import com.mowesta.service.session.LocationSessionBean;
import com.mowesta.service.session.WeatherSessionBean;
import org.apache.logging.log4j.util.Strings;
import org.joda.time.DateTime;
import org.joda.time.LocalDateTime;
import java.text.DecimalFormat;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.logging.Logger;
import static com.amazon.ask.request.Predicates.intentName;
/**
* Tells the user the weather for today / tomorrow / the day after for a location.
*
* @author Katharina
*/
public class WeatherForecastIntentHandler implements IntentRequestHandler {
LocationSessionBean locationSessionBean;
WeatherSessionBean weatherSessionBean;
LocationWeatherService locationWeatherService;
ForecastWeatherToStringConverter forecastWeatherToStringConverter = new ForecastWeatherToStringConverter();
public WeatherForecastIntentHandler(LocationSessionBean locationSessionBean, WeatherSessionBean weatherSessionBean) {
this.locationSessionBean = locationSessionBean;
this.weatherSessionBean = weatherSessionBean;
locationWeatherService = new LocationWeatherService(this.locationSessionBean, this.weatherSessionBean);
}
@Override
public boolean canHandle(HandlerInput input, IntentRequest intentRequest) {
return input.matches(intentName("WeatherForecastIntent"));
}
@Override
public Optional<Response> handle(HandlerInput input, IntentRequest intentRequest) {
String speechText = "";
String city = intentRequest.getIntent().getSlots().get("Stadt").getValue();
String uppercaseCity ="";
if(city!=null) uppercaseCity= city.substring(0, 1).toUpperCase() + city.substring(1);
String timeslot = intentRequest.getIntent().getSlots().get("Zeitpunkt").getValue();
int timebegin = getTime(timeslot);
int timeend;
if(timebegin>=24) {
timeend = timebegin+24;
} else {
timeend = 24;
}
Location location = null;
if(city ==null){
location = locationWeatherService.getGeoLocation(input);
}else{
LocationHierarchyPage locationHierarchyPage = locationSessionBean.findLocations(new PageConfig(0, 60), new SearchContext(Language.GERMAN), city);
location = locationWeatherService.getLocation(intentRequest, locationHierarchyPage);
}
if (location == null && city!=null) {
String errorText = "Die Stadt " + uppercaseCity + " wurde nicht gefunden.";
return input.getResponseBuilder()
.withSpeech(errorText)
.withSimpleCard("Error", errorText)
.build();
} else if (location == null && city == null){
String errorText = "Dein aktueller Ort konnte nicht gefunden werden.";
return input.getResponseBuilder()
.withSpeech(errorText)
.withSimpleCard("Error", errorText)
.build();
}
WeatherForecast weatherForecast = weatherSessionBean.getForecast(location.getCoordinate());
if (weatherForecast != null) {
Double minTemperature = null;
Double maxTemperature = null;
Double maxWindspeed = null;
Map<WeatherType, Integer> weatherTypeMap = new HashMap<WeatherType, Integer>();
for (int i = 0; i < weatherForecast.getConditions().size(); i++) {
WeatherCondition condition = weatherForecast.getConditions().get(i);
if (timebegin!=-1 && condition.getHour() >= timebegin && condition.getHour() < timeend) {
if (minTemperature == null || condition.getTemperature() < minTemperature) {
minTemperature = weatherForecast.getConditions().get(i).getTemperature();
}
if (maxTemperature == null || condition.getTemperature() > maxTemperature) {
maxTemperature = weatherForecast.getConditions().get(i).getTemperature();
}
if(maxWindspeed == null || condition.getWindSpeed() > maxWindspeed){
maxWindspeed = weatherForecast.getConditions().get(i).getWindSpeed();
}
if (weatherTypeMap.isEmpty()) {
weatherTypeMap.put(condition.getType(), 1);
} else if (weatherTypeMap.containsKey(condition.getType())) {
weatherTypeMap.put(condition.getType(), weatherTypeMap.get(condition.getType()) + 1);
} else {
weatherTypeMap.put(condition.getType(), 1);
}
}
}
if(city!=null) {
speechText += "In " + uppercaseCity + " beträgt " + timeslot + " die ";
} else speechText += timeslot.substring(0, 1).toUpperCase() + timeslot.substring(1) + " beträgt die ";
if(maxTemperature != null) {
String maxTemp = getTemperature(maxTemperature);
speechText += "Maximaltemperatur " + maxTemp + " Grad";
}
if(maxTemperature != null && minTemperature != null) {
speechText += " und die ";
}
if(minTemperature != null) {
String minTemp = getTemperature(minTemperature);
speechText += "Minimaltemperatur " + minTemp + " Grad";
}
speechText += ".";
if(!weatherTypeMap.isEmpty()) {
Map.Entry<WeatherType, Integer> maxWeather = Collections.max(weatherTypeMap.entrySet(), Comparator.comparingInt(Map.Entry::getValue));
weatherTypeMap.remove(maxWeather.getKey());
String maxWeatherString = forecastWeatherToStringConverter.convertToString(maxWeather.getKey());
String secMaxWeatherString = "";
if(!weatherTypeMap.isEmpty()){
Map.Entry<WeatherType, Integer> secMaxWeather = Collections.max(weatherTypeMap.entrySet(), Comparator.comparingInt(Map.Entry::getValue));
secMaxWeatherString = forecastWeatherToStringConverter.convertToString(secMaxWeather.getKey());
}
speechText += " Zudem wird es " + maxWeatherString;
if(!Strings.isBlank(secMaxWeatherString) && !maxWeatherString.equals(secMaxWeatherString)) speechText+= " und teilweise wird es" + secMaxWeatherString;
speechText += ".";
if(maxWindspeed!= null && minTemperature!=null && maxTemperature!= null){
String warning =locationWeatherService.checkForWeatherWarning(maxWindspeed, minTemperature, maxTemperature);
if(!Strings.isBlank(warning)) speechText += " Vorsicht! " + warning;
}
}
if(maxTemperature == null && minTemperature == null) {
speechText = "Es wurde zurzeit keine Wettervorhersage gefunden.";
}
} else {
speechText += "Es wurde zurzeit keine Wettervorhersage gefunden.";
}
return input.getResponseBuilder()
.withSpeech(speechText)
.withSimpleCard("CurrentWeather", speechText)
.build();
}
private String getTemperature(Double temperature) {
DecimalFormat decimalFormat = new DecimalFormat("#.#");
String maxTemp = String.valueOf(decimalFormat.format(temperature)).replaceAll("\\.", ",");
String[] splitMaxTemp = maxTemp.split(",");
if (splitMaxTemp.length > 1 && splitMaxTemp[1].equals("0")) maxTemp = splitMaxTemp[0];
return maxTemp;
}
private int getTime(String timeslot){
LocalDateTime localDateTime = LocalDateTime.now();
switch (timeslot) {
case "heute":
return localDateTime.getHourOfDay();
case "morgen":
return 24;
case "übermorgen":
return 48;
}
return -1;
}
}
@@ -0,0 +1,101 @@
package com.mowesta.service.alexa.impl;
import com.mowesta.api.weather.WeatherType;
/**
* Converts each weather type to a specific string for the current weather.
*
* @author Katharina
*/
public class WeatherTypeToStringConverter {
public String convertToString(WeatherType weatherType){
String weathercondition = "";
switch (weatherType){
case UNKNOWN:
break;
case FOG:
weathercondition = " und es ist nebelig";
break;
case CLOUDY:
weathercondition = " und es ist bewölkt";
break;
case CLEAR_SKY:
weathercondition = " und der Himmel ist klar";
break;
case SNOW_GRAINS:
weathercondition = " und es gibt Graupelschauer";
break;
case MAINLY_CLEAR:
weathercondition = " und der Himmel ist hauptsächlich klar";
break;
case HEAVY_DRIZZLE:
weathercondition = " und es gibt einen starken Nieselregen";
break;
case PARTLY_CLOUDY:
weathercondition = " und es ist teilweise bewölkt";
break;
case SLIGHT_DRIZZLE:
weathercondition = " und es gibt leichten Nieselregen";
break;
case MODERATE_DRIZZLE:
weathercondition = " und es gibt Nieselregen";
break;
case RAIN_SHOWER_SLIGHT:
case SLIGHT_RAIN_NOT_FREEZING:
weathercondition = " und es regnet leicht";
break;
case SNOW_SHOWER_SLIGHT:
case SLIGHT_FALL_OF_SNOWFLAKES:
weathercondition = " und es gibt leichten Schneefall";
break;
case FOG_DEPOSITING_RIME:
weathercondition = " und es gibt Nebel";
break;
case RAIN_SHOWER_VIOLENT:
case HEAVY_RAIN_NOT_FREEZING:
weathercondition = " und es gibt Starkregen";
break;
case RAIN_FREEZING_SLIGHT:
weathercondition = " und es gibt gefrierenden leichten Regen";
break;
case DRIZZLE_FREEZING_SLIGHT:
weathercondition = " und es gibt gefrierenden leichten Nieselregen";
break;
case THUNDERSTORM_HAIL_HEAVY:
weathercondition = " und es kann zu Hagelschauern und Gewitter kommen";
break;
case HEAVY_FALL_OF_SNOWFLAKES:
weathercondition = " und es gibt starken Schneefall";
break;
case MODERATE_RAIN_NOT_FREEZING:
weathercondition = " und es regnet";
break;
case RAIN_SHOWER_MODERATE_HEAVY:
weathercondition = " und es regnet teilweise schwer";
break;
case SNOW_SHOWER_MODERATE_HEAVY:
weathercondition = " und es schneit teilweise stark";
break;
case MODERATE_FALL_OF_SNOWFLAKES:
weathercondition = " und es schneit";
break;
case RAIN_FREEZING_MODERATE_HEAVY:
weathercondition = " und es gibt gefrierenden Regen";
break;
case THUNDERSTORM_SLIGHT_MODERATE:
weathercondition = " und es gewittert teilweise";
break;
case DRIZZLE_FREEZING_MODERATE_HEAVY:
weathercondition = " und es kommt zu gefrierenden Sprühregen";
break;
}
return weathercondition;
}
}
@@ -0,0 +1,41 @@
package com.mowesta.service.alexa.impl;
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
import com.amazon.ask.dispatcher.request.handler.impl.IntentRequestHandler;
import com.amazon.ask.model.IntentRequest;
import com.amazon.ask.model.Response;
import com.mowesta.service.entity.UserEntity;
import java.util.Optional;
import static com.amazon.ask.request.Predicates.intentName;
public class WeatherstationIntentHandler implements IntentRequestHandler {
@Override
public boolean canHandle(HandlerInput input, IntentRequest intentRequest) {
return input.matches(intentName("WeatherstationIntent"));
}
@Override
public Optional<Response> handle(HandlerInput input, IntentRequest intentRequest) {
String accessToken = input.getRequestEnvelope().getContext().getSystem().getUser().getAccessToken();
if (accessToken!=null) {
String errorText = "Du musst mit angemeldet sein, um diesen Service nutzen zu können. " +
"Bitte gehe in die Alexa App und melde dich an.";
return input.getResponseBuilder()
.withSpeech(errorText)
.withLinkAccountCard()
.build();
} else {
String errorText = "Herzlichen Glückwunsch";
return input.getResponseBuilder()
.withSpeech(errorText)
.withSimpleCard("Glückwunsch", errorText)
.build();
}
}
}

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