-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Moves media player related functionalities to Media Widget class #2817
Conversation
The purpose of this class would be to pull out all functionality related to media player
Audio, grid, grid-multi and select widgets require media player. So the plan is to extend MediaWidget in these classes and in later commits, start moving the media related methods and fields into MediaWidget
The super call is redundant as of now, but it is better than removing the method from QuestionWidget class
Additionally, a check had to be added to ODKView to check if the widget is of type MediaWidget before performing autoplay during loading of the widget
1. Adds autoplay parameter to playAllPromptText() 2. Removes separate methods for playing audio/video and uses the above parameter to distinguish between type of autoplay Since the name of method playAllPromptText() is generic, so it should behave in a generic manner as well. Until now, it was only concerned with autoplaying audio, while giving an impression that it is common method for all kinds of prompts (audio/video)
Remove unused getter. Since the member variable is only being used within the same class, so the getters can be dropped Annotate methods of GuidanceHint as @nonnull to remove nullable warning. Since it is an enum & the default value of GuidanceHint should be 'No' instread of 'null', so it is safe to return 'No' and mark method as @nonnull
I reviewed and tested your changes since I want to continue work on #2521 and it would be better to merge this pr firs. I have a problem with the it crashes:
but it's not your fault since it crashes on master branch as well and on older versions too... |
@grzesiek2010 No, I didn't. I have listed down all of the tests performed manually in the PR description. |
}); | ||
// plays the question text | ||
super.playAllPromptText(); | ||
public void playAllPromptText(String playOption) { |
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.
Hi Shobhit. Did you consider using an enum for playOption?
public MediaWidget(Context context, FormEntryPrompt prompt) { | ||
super(context, prompt); | ||
|
||
String imageURI = this instanceof SelectImageMapWidget ? null : prompt.getImageText(); |
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.
Not sure, but I think we’re using the convention that initialisms (like URI) are capitalized like uri or imageUri. I have an audio clip of Josh Bloch himself recommending this.
try { | ||
playColor = Color.parseColor(playColorString); | ||
} catch (IllegalArgumentException e) { | ||
Timber.e(e, "Argument %s is incorrect", playColorString); |
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.
Argument %s to Color.parseColor is incorrect
might be more helpful.
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 see you didn’t create, but just moved this code, so disregard the above if you like.
|
||
expanded = new AtomicBoolean(false); | ||
|
||
if (getState() != null) { | ||
if (getState().containsKey(GUIDANCE_EXPANDED_STATE + getFormEntryPrompt().getIndex())) { | ||
Boolean result = getState().getBoolean(GUIDANCE_EXPANDED_STATE + getFormEntryPrompt().getIndex()); | ||
boolean result = getState().getBoolean(GUIDANCE_EXPANDED_STATE + getFormEntryPrompt().getIndex()); | ||
expanded = new AtomicBoolean(result); |
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’m suspicious of an AtomicBoolean that’s recreated rather than set. I didn’t study this closely though.
Autoplay seems to be in use: see https://forum.opendatakit.org/search?q=autoplay%20order%3Alatest). I also think it's useful for ACASI surveys. @grzesiek2010 Can you file an issue so we can discuss what the current behavior is and how we can fix and document it? |
Tested with success Verified on Android: 4.2, 4.4, 5.1, 6.0, 7.0, 8.1 Verified cases:
@opendatakit-bot unlabel "needs testing" |
Ohhhh I feel ashamed that I didn't catch it before but of course, all widgets can have media attached to a question text... @shobhitagarwal1612 your changes brake that option what shows this form: are you able to come up with any reasonable solution because I think reverting all changes might be the best solution here? Yes since all widgets can have media files the whole issue was wrong... |
I discussed this a bit with @grzesiek2010 and wanted to document some of the gaps so we can get better.
I think one thing that we can all do going forward is to let PRs sit a little bit before going into testing. My hope here is that more time will give more people a chance to review. Another thing we can do is to aim for having two people give the go ahead on a merge. Do these two adjustments sound reasonable for preventing this kind of problem? |
Closes #1640
What has been done to verify that this works as intended?
Tested manually on Redmi Note 4 and compared the
All-Widgets
andBirds
forms before and after the changes.Tests performed:
Why is this the best possible solution? Were any other approaches considered?
This PR is aimed at moving all of the media player related functionalities into an abstract class
MediaWidget
. This also performs minor refactors such as conversion of anonymous inner classes into lambda and minor code cleanup. This reduces the size ofQuestionWidget
by 100 lines.How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
This PR changes the way layout which contains the question text and other media (audio, video, image) is initialized and the methods controlling media are moved to another class. So, all of the changes must be closely reviewed in order to prevent any regressions.
Do we need any specific form for testing your changes? If so, please attach one.
I tested using the
All-Widgets
andBirds
formDoes this change require updates to documentation? If so, please file an issue here and include the link below.
No
Before submitting this PR, please make sure you have:
./gradlew checkAll
and confirmed all checks still pass OR confirm CircleCI build passes and run./gradlew connectedDebugAndroidTest
locally.