| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.chrome.browser; | |
| 6 | |
| 7 import android.graphics.PixelFormat; | |
| 8 import android.view.View; | |
| 9 import android.view.Window; | |
| 10 import android.view.WindowManager; | |
| 11 | |
| 12 import org.chromium.chrome.browser.init.AsyncInitializationActivity; | |
| 13 import org.chromium.chrome.browser.vr_shell.VrShell; | |
| 14 | |
| 15 /** | |
| 16 * A subclass of AsyncInitializationActivity, used in Daydream VR mode. | |
| 17 * TODO(bshe): This activity needs to access the same set of tabs as ChromeTabbe
dActivity. | |
| 18 * See more detail in crbug.com/641038. | |
| 19 * | |
| 20 */ | |
| 21 public class VrActivity extends AsyncInitializationActivity { | |
| 22 private VrShell mVrShellView; | |
| 23 | |
| 24 @Override | |
| 25 public void onResume() { | |
| 26 super.onResume(); | |
| 27 mVrShellView.onResume(); | |
| 28 } | |
| 29 | |
| 30 @Override | |
| 31 public void onPause() { | |
| 32 super.onPause(); | |
| 33 mVrShellView.onPause(); | |
| 34 } | |
| 35 | |
| 36 @Override | |
| 37 public void onDestroy() { | |
| 38 super.onDestroy(); | |
| 39 if (mVrShellView != null) { | |
| 40 mVrShellView.shutdown(); | |
| 41 mVrShellView = null; | |
| 42 } | |
| 43 } | |
| 44 | |
| 45 @Override | |
| 46 public void initializeCompositor() { | |
| 47 super.initializeCompositor(); | |
| 48 mVrShellView.onNativeLibraryReady(); | |
| 49 } | |
| 50 | |
| 51 @Override | |
| 52 public void setContentView() { | |
| 53 setupVrModeWindowFlags(); | |
| 54 addVrViews(); | |
| 55 } | |
| 56 | |
| 57 private void addVrViews() { | |
| 58 mVrShellView = new VrShell(this); | |
| 59 WindowManager.LayoutParams params = new WindowManager.LayoutParams( | |
| 60 WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutPar
ams.MATCH_PARENT, | |
| 61 WindowManager.LayoutParams.TYPE_APPLICATION, 0, PixelFormat.OPAQ
UE); | |
| 62 setContentView(mVrShellView, params); | |
| 63 } | |
| 64 | |
| 65 private void setupVrModeWindowFlags() { | |
| 66 Window window = getWindow(); | |
| 67 window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); | |
| 68 window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_S
TABLE | |
| 69 | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FL
AG_LAYOUT_FULLSCREEN | |
| 70 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULL
SCREEN | |
| 71 | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); | |
| 72 } | |
| 73 } | |
| OLD | NEW |