Esempio n. 1
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.desktop);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    mRemoteHostDesktop = (DesktopView) findViewById(R.id.desktop_view);
    mRemoteHostDesktop.setDesktop(this);
    mSwitchToCardboardDesktopActivity = false;

    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // For this Activity, the home button in the action bar acts as a Disconnect button, so
    // set the description for accessibility/screen readers.
    getSupportActionBar().setHomeActionContentDescription(R.string.disconnect_myself_button);

    // The action bar is already shown when the activity is started however calling the
    // function below will set our preferred system UI flags which will adjust the layout
    // size of the canvas and we can avoid an initial resize event.
    showActionBar();

    View decorView = getWindow().getDecorView();
    decorView.setOnSystemUiVisibilityChangeListener(this);

    mActivityLifecycleListener =
        CapabilityManager.getInstance()
            .onActivityAcceptingListener(this, Capabilities.CAST_CAPABILITY);
    mActivityLifecycleListener.onActivityCreated(this, savedInstanceState);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      attachKeyboardVisibilityListener();

      // Only create an Autohide task if the system supports immersive fullscreen mode.  Older
      // versions of the OS benefit less from this functionality and we don't want to change
      // the experience for them.
      mActionBarAutoHideTask =
          new Runnable() {
            public void run() {
              hideActionBar();
            }
          };
    } else {
      mRemoteHostDesktop.setFitsSystemWindows(true);
    }
  }