Ejemplo n.º 1
0
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    Logger.T(TAG, "onConfigurationChanged");
    super.onConfigurationChanged(newConfig);
    if (!sScreenAutoRotate) {
      Logger.D(
          TAG,
          "Screen rotation is disabled. Force old orientation: "
              + getScreenProperties().getOrientation());
      setRequestedOrientation(getScreenProperties().getOrientation());
    } else {
      ScreenProperties props = getScreenProperties();
      props.reread(this);

      int rotation = 0;
      switch (props.getOrientation()) {
        case ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE:
          rotation = 90;
          break;
        case ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT:
          rotation = 180;
          break;
        case ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE:
          rotation = 270;
          break;
        case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
        default:
          rotation = 0;
          break;
      }

      RhodesService.onScreenOrientationChanged(props.getWidth(), props.getHeight(), rotation);
    }
  }
Ejemplo n.º 2
0
    public void reread(Context context) {
      Logger.T(TAG, "Updating screen properties");

      WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);

      Display d = wm.getDefaultDisplay();

      mScreenWidth = d.getWidth();
      mScreenHeight = d.getHeight();

      DisplayMetrics metrics = new DisplayMetrics();
      d.getMetrics(metrics);

      mScreenPpiX = metrics.xdpi;
      mScreenPpiY = metrics.ydpi;

      mScreenOrientation =
          AndroidFunctionalityManager.getAndroidFunctionality().getScreenOrientation(context);

      Logger.D(
          TAG,
          "New screen properties - width: "
              + mScreenWidth
              + ", height: "
              + mScreenHeight
              + ", orientation: "
              + mScreenOrientation);
    }
Ejemplo n.º 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Logger.T(TAG, "onCreate");

    Intent intent = new Intent(this, RhodesService.class);
    intent.putExtra(RhodesService.INTENT_SOURCE, INTENT_SOURCE);
    ComponentName serviceName = startService(intent);
    if (serviceName == null) throw new RuntimeException("Can not start Rhodes service");
    bindService(intent, this, Context.BIND_AUTO_CREATE);
    mBoundToService = true;

    if (RhoConf.isExist("disable_screen_rotation")) {
      sScreenAutoRotate = !RhoConf.getBool("disable_screen_rotation");
    }

    if (sScreenProp == null) {
      sScreenProp = new ScreenProperties(this);
    } else {
      if (!sScreenAutoRotate) {
        Logger.D(
            TAG,
            "Screen rotation is disabled. Force orientation: "
                + getScreenProperties().getOrientation());
        setRequestedOrientation(getScreenProperties().getOrientation());
      }
    }
  }
Ejemplo n.º 4
0
 @Override
 public void onConfigurationChanged(Configuration newConfig) {
   Logger.T(TAG, "+++ onConfigurationChanged");
   super.onConfigurationChanged(newConfig);
   RhodesService.getInstance().rereadScreenProperties();
 }