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

Add fullscreen option to in-line videos #2747

Merged
merged 17 commits into from Apr 29, 2024

Conversation

avazirna
Copy link
Contributor

@avazirna avazirna commented Mar 18, 2024

Summary

This PR adds the option to view inline videos in fullscreen mode. The initial approach was to use a third-party video app, but in order to offer a seamless user experience, an internal activity preferred.

Ticket: https://dimagi.atlassian.net/browse/SAAS-15133

Product Description

With this change, there will be an Fullscreen mode button in the media controller panel, which when pressed it transitions to fullscreen mode. And once in fullscreen mode, the same button can be used to transition back:

Inline_video_in_fullscreen_demo.mp4

Safety Assurance

  • I have confidence that this PR will not introduce a regression for the reasons below
  • Do we need to enhance manual QA test coverage ? If yes, "QA Note" label is set correctly

Safety story

@avazirna avazirna self-assigned this Mar 18, 2024
OrangeAndGreen
OrangeAndGreen previously approved these changes Mar 18, 2024
Copy link
Contributor

@OrangeAndGreen OrangeAndGreen left a comment

Choose a reason for hiding this comment

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

One little nit but otherwise all looks good.

public void setAnchorView(View view) {
super.setAnchorView(view);

CommCareVideoView videoView;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: minimize the code in the case, i.e.:
int videoId = fullScreenMode ? R.id.fullscreen_video_view : R.id.inline_video_view;
CommCareVideoView videoView = view.findViewById(videoId);

@shubham1g5 shubham1g5 self-requested a review March 19, 2024 14:13
Copy link
Contributor

@shubham1g5 shubham1g5 left a comment

Choose a reason for hiding this comment

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

Looks good overall, the PR should have a QA note and release note. We should also include a video/gif of the transition back and forth to get to know how the transition UX feels like.

@@ -293,4 +293,16 @@
<color name="login_edit_text_color">@color/cc_core_text</color>
<color name="login_edit_text_color_error">@color/cc_attention_negative_color</color>
<dimen name="map_button_min_width">120dp</dimen>

<style name="MediaButton">
Copy link
Contributor

Choose a reason for hiding this comment

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

lets call it FullScreenVideoButton instead.

Comment on lines +299 to +300
<item name="android:layout_width">71dip</item>
<item name="android:layout_height">52dip</item>
Copy link
Contributor

Choose a reason for hiding this comment

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

can we keep the sizes in multiples of 8 here (reasoning)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the same style being used by the Android's internal Media controller widgets, I kept the same dimensions to ensure consistency. But I don't think changing them will have an impact.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good in that case.

setContentView(viewBinding.root)

// Get video URI from intent, finish if no URI is available
// TODO: we should inform the user when we finish because there is no data
Copy link
Contributor

Choose a reason for hiding this comment

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

pending todo, we should actually crash if no uri is available since that obviously means a code error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

instead of crashing, I opted for canceling the activity and informing the user.

} else {
Intent intent = new Intent(getContext(), FullscreenVideoViewActivity.class);
intent.setData(FileUtil.getUriForExternalFile(getContext(),
new File(videoView.getVideoPath())));
Copy link
Contributor

Choose a reason for hiding this comment

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

we should explicitly validate videoView.getVideoPath() is not null and crash with an exception otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The validation of the of the video path happens before the instantiation of the CommCareMediaController, so this branch would only be executed if the file exists.

@avazirna
Copy link
Contributor Author

@damagatchi retest this please

1 similar comment
@avazirna
Copy link
Contributor Author

@damagatchi retest this please

@@ -332,6 +332,8 @@ public void onActivityResultSessionSafe(int requestCode, int resultCode, Intent
} else if (requestCode == FormEntryConstants.INTENT_CALLOUT) {
processIntentResponse(intent, true);
Toast.makeText(this, Localization.get("intent.callout.cancelled"), Toast.LENGTH_SHORT).show();
} else if (requestCode == FormEntryConstants.VIEW_VIDEO_FULLSCREEN) {
Toast.makeText(this, Localization.get("media.invalid.video.path"), Toast.LENGTH_SHORT).show();
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem like the ideal validation place to me, we can potentially have other code path ways that can cancel the full screen activity. I think we should not even start the FullscreenVideoViewActivity.kt if the video uri is null or invalid and crash hard if we encounter the video path to be null inside the FullscreenVideoViewActivity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. 8588645

Copy link
Contributor

Choose a reason for hiding this comment

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

we should remove the validation here now right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it has been removed already, the code there is outdated. Can you double check?

@avazirna avazirna added this to the 2.54 milestone Apr 17, 2024
@avazirna avazirna force-pushed the add-fullscreen-option-to-inline-videos branch from 123590e to 8588645 Compare April 26, 2024 12:32
@avazirna avazirna merged commit 2df7444 into master Apr 29, 2024
5 of 9 checks passed
@avazirna avazirna deleted the add-fullscreen-option-to-inline-videos branch April 29, 2024 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants