Hi everyone,
Recently, I found issue #2482 to be interesting. So, I spent some time playing with Android Studio to solve it. Here is a simple demo of my solution:
I added a new button "Timepicker Mode" to the Business Hours Editor Page (android/res/layout/item_timetable.xml). And I also created a new pop-up dialog (SelectTimepickerModeFragment) to let the users select their preferred timepicker mode. Please check the details in my commit to branch [rq-select-timepicker] of my forked repository.
One of the challenges I encountered was that the TimePicker Class does not have a set method for its attribute "android:timePickerMode" and after a couple of searches I found it difficult to dynamically manipulate the attribute of the xml element. So, my solution this is to add a alternative version of "android/res/layout/fragment_timetable_picker.xml", which is called "fragment_timetable_picker_spinner.xml." Their only differences are the ids and the values of timePickerMode. In addition, I added some if statements to "android/src/com/mapswithme/maps/editor/HoursMinutesPickerFragment.java," which directly inflates the timepicker dialog. As a result, HoursMinutesPickerFragment will inflate different XMLs based on the users' choices.
Another problem I had was how the data communications between fragments should be done, i.e. how I can pass the timepicker's mode info from my new dialog to the actual timepicker dialog. My solution to this is to mimic the existing interaction logic between "HoursMinutesPickerFragment" and "SimpleTimetableAdapter." I made an listener interface for the new pop-up dialog (SelectTimepickerModeFragment) and then let SimpleTimetableAdapter to implement the listener. Then after the users choose the timepicker's mode, SimpleTimetableAdapter will pass its listened information to HoursMinutesPickerFragment through an existing method HoursMinutesPickerFragment.pick().
The two paragraphs above provide a brief explanation of how I solve the issue. I have not created a pull request yet because I really need your opinions on my changes. I am kind of new to this project so I just want to make sure these changes will not create unexpected errors. I have tested this manually on my Android Emulators (API31 x86_64). And by far I have not seen any apparent issues. But actually there's a couple of holes I can think of: 1. The button for selecting modes is just a casual copy of the elements in the same layout, which needs to be designed more carefully to fit the app's style requirements. 2. The style of the pop-up dialog also needs some extra work, e.g. the dark theme is not supported.
Please let me know if you have any problems or suggestions!
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too