Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added #882 - Weather feature overlay #1174

Merged

Conversation

amrhossamdev
Copy link
Member

@amrhossamdev amrhossamdev commented Mar 14, 2024

Added #882.

Light Theme Dark Theme Options
Light Dark Option

Design

I talked to Mr. Aaron to pick out the design and icons we'd use. We focused on different weather states and I picked up the icons from https://www.amcharts.com/free-animated-svg-weather-icons/. I got 'fog' and 'wind' icons from Google Material Design. To make sure we covered everything, I checked the weather states listed here and the credit of all of the icons used added to the about.

Edge cases

  • Out of range -> hide the weather view.
  • In range then out of range -> hide the weather view.
  • In range -> show the weather view.
  • Out of range and go to the region manually -> show the weather view.
  • Click on show route on the map will make the arrival header appear -> overlay the weather view with the arrival header.
  • Expanding the slide panel -> overlay the weather view

Also, I have added an option to change the temperature unit, automatically, and by default the unit will be picked up using the user device's local country setting then he can change the unit from the setting to Celsius or Fahrenheit

Also, i have made sure that all icons are supported & suitable for the Dark mode

Logic

I have used OBA Weather API to get the weather when we are in a valid region.

But how we will know that we are in a valid region?

There was an interface in BaseMapFragment that was responsible for notifying the user about when he will be out of range, I implemented an interface onValidRegion in HomeActivity that will callback to us from BaseMapFragment and tell us if are in a valid region or not, to get the weather and manage the weather view as well.

But what if we are already in a valid region ?

There is a method called showStops in BaseMapFragment, that will work if we are in a valid region so I will also callback to HomeActivity to notify we are in a valid region to Show the weather

I observed that showStops is a real-time function that will be invoked a lot of times so I have made sure to call the OBA Weather API only when we Change the region or going from invalid region to valid region to avoid multiple calls.

Tests

I have written a IO Test test for checking that we have for each Region id a Weather Response

Video showing trying different test cases.

Video : Click here

I'm looking for your feedback and I will be happy to listen to it

  • Apply the AndroidStyle.xml style template to your code in Android Studio.

  • Run the unit tests with gradlew connectedObaGoogleDebugAndroidTest to make sure you didn't break anything

  • If you have multiple commits please combine them into one commit by squashing them for the initial submission of the pull request. When addressing comments on a pull request, please push a new commit per comment when possible (reviewers will squash and merge using GitHub merge tool)

Signed-off-by: Amr Hossam <amrhossam.dev@gmail.com>
Copy link
Member

@aaronbrethorst aaronbrethorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terrific work, Amr! I can't wait to get this into users' hands!

@aaronbrethorst aaronbrethorst merged commit 3df18c7 into OneBusAway:main Mar 22, 2024
2 checks passed
@amrhossamdev amrhossamdev mentioned this pull request Mar 22, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants