예제 #1
0
  /**
   * Called when application is first created. <b>Set up:</b>
   *
   * <ol>
   *   <li>Create and open the main space and put the primary user (the user that started this
   *       application) into the space
   *   <li>Initialize button functionality: main button
   * </ol>
   *
   * <b>Assumptions:</b>
   *
   * <ul>
   *   <li>The main space is created by the primary user
   *   <li>XMPPConnection is established and authorized before this Activity is called
   * </ul>
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    if (D) Log.d(TAG, "onCreate - Started the MainApplication activity");
    super.onCreate(savedInstanceState);
    ContextTracker.setContext(this);

    // Open up the layout specified by the main XML
    setContentView(R.layout.main);
    // Change the parameters of the appearance according to screen size
    // adjustLayoutParams();
    // This spaceview already created for you in the XML file, so retrieve
    // it
    screen = (SpaceView) findViewById(R.id.space_view);
    // Check if the mainspace was already created
    if (Space.getMainSpace() == null) {
      // Obtain username used to log into the application
      Intent start_intent = getIntent();
      username = start_intent.getStringExtra(Network.KEY_USERNAME);
      // Create instance of primary user
      if (userPrimary == null) {
        userPrimary = new User(username, username.split("@")[0], R.drawable.question);
      }
      try {
        // create the mainspace
        SpaceController.createMainSpace(this);

        // create an empty private space
        // SpaceController.addSpace(this);

        // TODO add private space preview
      } catch (XMPPException e) {
        // Log.e(TAG, "onCreate - Error (" + e.getXMPPError().getCode()
        // + ") " + e.getXMPPError().getMessage());
        e.printStackTrace();
      }
      screen.setSpace(Space.getMainSpace());
      // screen.getSpaceViewController().changeSpace(Space.getMainSpace());
      Space.getMainSpace().setScreenOn(true);
      // Space.getMainSpace().setEntered(true);

      font = Typeface.createFromAsset(getAssets(), Values.font);
      // Button mainButtonText = (Button) findViewById(R.id.main_button);
      // mainButtonText.setTypeface(font);

    }
    // this.plusButtonSetUp(0);
    initializeButtons();

    // Initializes the onKeyListener to record keypad events
    screen.setOnKeyListener(onKeyListener);

    // DEBUG: create User object to test invitations and kickouts
    debug = new User("opencommsec@" + Network.DEFAULT_HOSTNAME, "opencommsec", 0);
    // for (Space s : Space.allSpaces) Log.v(TAG, s.getRoomID());
    debug1 = new User("mucopencomm@" + Network.DEFAULT_HOSTNAME, "mucopencomm", 0);

    // Change screen dimensions to 480x800
    Values.setValues(480, 800);
  }
예제 #2
0
 /**
  * Removes all UI traces of a privatespace/sidechat 1) Removes space from hashmap of all spaces 2)
  * Removes the corresponding privatespaceButton 3) Changes the space to the Mainspace (but only if
  * wasn't a mainspace) However, if you are leaving the mainspace, then start a new activity and go
  * ack to the dashboard
  */
 public void delPrivateSpaceUI(Space space, boolean isMainSpace) {
   if (isMainSpace) {
     Intent i = new Intent(MainApplication.screen.getSpace().getContext(), DashboardView.class);
     MainApplication.screen.getSpace().getContext().startActivity(i);
   } else {
     // 1
     Space.allSpaces.remove(space.getRoomID());
     // 2
     PrivateSpaceIconView foundIcon = null;
     for (PrivateSpaceIconView ps : PrivateSpaceIconView.allPSIcons) {
       if (ps.getSpace() == space) foundIcon = ps;
     }
     if (foundIcon != null) delPrivateSpaceButton(foundIcon);
     // 3
     screen.getSpaceViewController().changeSpace(Space.getMainSpace());
   }
 }