Skip to content

Commit

Permalink
[android] Support full-screen on cobalt_apk and fix URL logic on launch
Browse files Browse the repository at this point in the history
1. Set URL filed to GONE to support full-screen video on ATV.
2. Refactor setting URL logic on launching Cobalt.apk.

b/362837382
b/376148547
  • Loading branch information
borongc committed Oct 31, 2024
1 parent b634436 commit 66d68b5
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import android.view.ViewGroup.LayoutParams;
import android.view.ViewParent;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import dev.cobalt.media.MediaCodecCapabilitiesLogger;
import dev.cobalt.media.VideoSurfaceView;
import dev.cobalt.util.DisplayUtil;
Expand Down Expand Up @@ -143,10 +144,7 @@ protected void createContent(final Bundle savedInstanceState) {
mWindowAndroid.setAnimationPlaceholderView(
mShellManager.getContentViewRenderView().getSurfaceView());

// TODO(cobalt, b/376148547): set Chrobalt initial url and remove this function.
if (mStartupUrl.isEmpty()) {
mStartupUrl = getUrlFromIntent(getIntent());
}
mStartupUrl = getUrlFromIntent(getIntent());
if (!TextUtils.isEmpty(mStartupUrl)) {
mShellManager.setStartupUrl(Shell.sanitizeUrl(mStartupUrl));
}
Expand All @@ -160,7 +158,7 @@ protected void createContent(final Bundle savedInstanceState) {
new BrowserStartupController.StartupCallback() {
@Override
public void onSuccess() {
finishInitialization(savedInstanceState);
finishCobaltInitialization();
}

@Override
Expand Down Expand Up @@ -240,9 +238,15 @@ protected void shellHandleIntent(Intent intent) {
}
}

// TODO(cobalt, b/376148547): set Chrobalt initial url and remove this function.
protected void setStartupUrl(String url) {
mStartupUrl = url;
private void finishCobaltInitialization() {
mShellManager.launchShell("https://www.youtube.com/tv");

toggleFullscreenMode(true);
}

protected void toggleFullscreenMode(boolean enterFullscreen) {
LinearLayout toolBar = (LinearLayout) findViewById(R.id.toolbar);
toolBar.setVisibility(enterFullscreen ? View.GONE : View.VISIBLE);
}

// Initially copied from ContentShellActiviy.java
Expand Down Expand Up @@ -322,7 +326,6 @@ protected void onCreate(Bundle savedInstanceState) {
getStarboardBridge().handleDeepLink(startDeepLink);
}

setStartupUrl("https://www.youtube.com/tv");
super.onCreate(savedInstanceState);
createContent(savedInstanceState);

Expand Down

0 comments on commit 66d68b5

Please sign in to comment.