Ejemplo n.º 1
0
  private static void activityStarted() {
    Logger.D(TAG, "activityStarted (1): sActivitiesActive=" + sActivitiesActive);
    if (sActivitiesActive == 0) {
      Logger.D(TAG, "first activity started");

      RhodesService r = RhodesService.getInstance();
      if (r != null) r.handleAppActivation();
    }
    ++sActivitiesActive;
    Logger.D(TAG, "activityStarted (2): sActivitiesActive=" + sActivitiesActive);
  }
Ejemplo n.º 2
0
  public static void activityStopped() {
    Logger.D(TAG, "activityStopped (1): sActivitiesActive=" + sActivitiesActive);

    --sActivitiesActive;
    if (sActivitiesActive == 0) {
      Logger.D(TAG, "last activity stopped");

      RhodesService r = RhodesService.getInstance();
      if (r != null) r.handleAppDeactivation();
    }
    Logger.D(TAG, "activityStopped (2): sActivitiesActive=" + sActivitiesActive);
  }
Ejemplo n.º 3
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
      case KeyEvent.KEYCODE_BACK:
        RhodesService r = RhodesService.getInstance();
        if (DEBUG) Log.d(TAG, "onKeyDown: r=" + r);
        if (r == null) return false;

        MainView v = r.getMainView();
        v.back(v.activeTab());
        return true;
    }

    return super.onKeyDown(keyCode, event);
  }
Ejemplo n.º 4
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.º 5
0
    public void run() {
      try {
        RhodesService r = RhodesService.getInstance();

        MainView mainView = r.getMainView();
        MainView v = null;

        SimpleMainView smv = null;
        if (mainView instanceof SimpleMainView) {
          smv = (SimpleMainView) mainView;
        }

        switch (type) {
          case NOBAR_TYPE:
            if (smv == null) v = new SimpleMainView(mainView);
            else smv.removeToolbar();
            started = false;
            break;
          case TOOLBAR_TYPE:
            if (smv == null) v = new SimpleMainView(mainView, params);
            else smv.setToolbar(params);
            started = true;
            break;
          case TABBAR_TYPE:
            v = new TabbedMainView(params);
            started = true;
            break;
          default:
            Logger.E(TAG, "Unknown bar type passed: " + type);
        }

        if (v != null) {
          r.setMainView(v);
          if (v instanceof TabbedMainView) {
            // loading of default opened tab should be after TabView insert to real Views tree
            TabbedMainView tmv = (TabbedMainView) v;
            tmv.loadFirstPage();
          }
        }
      } catch (Exception e) {
        reportFail("CreateTask", e);
      }
    }
Ejemplo n.º 6
0
 private boolean isValidSecurityToken() {
   boolean valid = true;
   String security_token = RhodesService.getBuildConfig("security_token");
   if (security_token != null) {
     if (security_token.length() > 0) {
       valid = false;
       Object params = getIntent().getExtras();
       if (params != null && params instanceof Bundle) {
         Bundle startParams = (Bundle) params;
         String rho_start_params = startParams.getString(RHO_START_PARAMS_KEY);
         if (rho_start_params != null) {
           String security_token_key = "sequrity_token=";
           int sec_index = rho_start_params.indexOf(security_token_key);
           if (sec_index >= 0) {
             String tmp =
                 rho_start_params.substring(
                     sec_index + security_token_key.length(),
                     rho_start_params.length() - sec_index - security_token_key.length());
             int end_of_token = tmp.indexOf(",");
             if (end_of_token >= 0) {
               tmp = tmp.substring(0, end_of_token);
             }
             end_of_token = tmp.indexOf(" ");
             if (end_of_token >= 0) {
               tmp = tmp.substring(0, end_of_token);
             }
             if (tmp.equals(security_token)) {
               valid = true;
             }
           }
         }
       }
     }
   }
   return valid;
 }
Ejemplo n.º 7
0
 public void run() {
   RhodesService.getInstance().getMainView().switchTab(index);
 }
Ejemplo n.º 8
0
 @Override
 public void onConfigurationChanged(Configuration newConfig) {
   Logger.T(TAG, "+++ onConfigurationChanged");
   super.onConfigurationChanged(newConfig);
   RhodesService.getInstance().rereadScreenProperties();
 }
Ejemplo n.º 9
0
 @Override
 protected void onStop() {
   RhodesService.activityStopped();
   super.onStop();
 }
Ejemplo n.º 10
0
 @Override
 protected void onStart() {
   super.onStart();
   RhodesService.activityStarted();
 }