예제 #1
0
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    AndroidSystem system =
        (AndroidSystem)
            AndroidServiceLocator.GetInstance()
                .GetService(AndroidServiceLocator.SERVICE_TYPE_SYSTEM);
    boolean locked = system.IsOrientationLocked();
    if (locked) {
      int configOrientation;
      DisplayOrientation lockedOrientation = system.GetLockedOrientation();
      if (DisplayOrientation.Portrait.equals(lockedOrientation)) {
        configOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
      } else if (DisplayOrientation.Landscape.equals(lockedOrientation)) {
        configOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
      } else {
        // Portrait as default orientation
        configOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
      }
      if (newConfig.orientation != configOrientation) {
        LOG.Log(
            Module.GUI,
            "Main Activity onConfigurationChanged setting requested orientation: "
                + configOrientation);

        setRequestedOrientation(configOrientation);
      }
    } else {
      activityManager.layoutSplashscreen();
      appView.requestLayout();
    }
  }