-
Notifications
You must be signed in to change notification settings - Fork 0
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
Dining redesign: open until subtitle, updated day chips, availability card redesign, improved chart and menus #48
Conversation
[diff-counting] Significant lines: 766. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good so far! I'm thinking we could probably optimize how many requests we make, since we're getting the operating hours with the historical data already.
fun facilityHours(facilityId: String, startDate: String, endDate: String, facilityHoursOnResponse: (List<Pair<Long, Long>>) -> Unit) { | ||
val facilityHoursRequest = getRequest( | ||
url = "$OPERATING_HOURS_ENDPOINT?id=$facilityId&startDate=$startDate&endDate=$endDate", | ||
onResponse = { response -> | ||
facilityHoursOnResponse(JsonParser.parseOperatingHoursToTimestampList(response)) | ||
}, | ||
onError = { | ||
error -> Log.d("Error fetching hours", error.networkResponse.toString()); | ||
} | ||
) | ||
queue.add(facilityHoursRequest) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think since fetchHistoricalJSON()
also does a request to get the operating hours, it would make sense to combine the two in some way. Right now, I think you end up fetching it twice in FacilityInfoPage.kt
.
*/ | ||
fun getCurrentDate(): String { | ||
fun getCurrentDate(yearBeginning: Boolean): String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should get backend to update to use ISO format with year at beginning LOL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, there's another function called getDate()
that we should probably combine
fun parseTime(timestamp: Long): String { | ||
val timeZone = Calendar.getInstance().timeZone | ||
var format = SimpleDateFormat("h:mma", Locale.US) | ||
if (DateFormat.is24HourFormat(DensityApplication.getAppContext())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
love me some 24h time 😍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the improvements to the API calls - it makes a lot of sense to pair the timestamps + interval strings together and have the view determine what to use.
fun facilityHours(facilityId: String, startDate: String, endDate: String, facilityHoursTimeStampsOnResponse: (List<Pair<Long, Long>>) -> Unit, | ||
facilityHoursStringsOnResponse: (List<String>) -> Unit) { | ||
val facilityHoursRequest = getRequest( | ||
url = "$OPERATING_HOURS_ENDPOINT?id=$facilityId&startDate=$startDate&endDate=$endDate", | ||
onResponse = { response -> | ||
facilityHoursOnResponse(JsonParser.parseOperatingHoursToTimestampList(response)) | ||
facilityHoursTimeStampsOnResponse(JsonParser.parseOperatingHoursToTimestampList(response)) | ||
facilityHoursStringsOnResponse(JsonParser.parseOperatingHours(response)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good, makes sense to pair these together
facilityHoursStringsOnResponse = { | ||
hoursStringsList -> | ||
opHoursStrings = hoursStringsList | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will things get messed up if opHoursStrings
is not set in time for the UI updates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it won't throw an error since it's just an empty list...
/** | ||
* getDate(day) provides the date for historical endpoint request. | ||
* getDateString(day) provides the date in string format for historical endpoint request. | ||
*/ | ||
fun getDate(day: String): String { | ||
fun getDateObject(day: String): Date { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did the documentation get mixed up?
…king if closed/open and one that shows operating hours for selected day
- move `fun initializeView` into `onCreate` - add helper for getting integer of day (0 = sun ... 6 = sat)
- no data, just some hardcoded strings + approx. layout
- increase font size - marginStart 8dp
…us-density-android into dining_redesign
- left-align chips - move chips out of card - update font color/styles - remove accessibility icon when closed
…us-density-android into dining_redesign had to add last updated text
…lowered width of day chips
- change FluxUtil.convertDateObjectToString to use ISO format (yyyy-MM-dd) - now works with new backend changes
- flatten relative layout
- made the bars only rounded on the top - updated label and axis colors - updated some code style - TODO: improve performance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably get another pair of eyes on this, but I think it's ready to merge.
Merging for now, but there is still a related issue #49. |
Summary
This pull request adds a toolbar that utilizes the api endpoint facilityHours in order to fetch the operating hours of a facility. Using this info, the user sees in the subtitle of the toolbar whether it's open or closed and exactly when it is open until or when it is closed until. Right Now, entire subtitle is red or green depending on whether it is closed or open. Will work on implementing it such that it matches the design on Figma, where only the word open or closed is colored in.
This pull request is the first step towards the dining redesign effort.
Test Plan
I created a list inside the facilityHoursOnResponse function definition inside of the checkFacilityIsOpen() function inside the FacilityInfoPage Kotlin activity. This list had a bunch of sample unix timestamps for a day's operating hour time slots. The last element was the first time slot of the next day. This hardcoded list allows us to test our onResponse handler, since right now any request to the operatingHours endpoint will return an empty list. Then, we should also hardcode the currentTime variable within this function and play around with its value ensuring the results are as expected.
The cases we must test are as follows. The case that the currentTime is lower than the first time slots open time. Next case, is that the currentTime falls into one of the time slots in the day meaning that the facility is open. Another case is that the currentTime falls between two time slots so the facility is closed and will open when it is the second of the two time slots' open time. Finally, the last case is that the time is past the last time slot of the day's close time. After ensuring that all these edge cases are met, we should be good to go.
We must also make sure to test that the JSON parsing of the API response works as expected! In order to do this, we should actually mock the API response, so that we are testing the JSON parsing of the API response body.
Updated screenshot (2020-06-27)

Notes
In building this feature, I had to make a few minor changes in other parts of the code.