コード例 #1
0
  public void onClick(View v) {
    int viewId = v.getId();

    // if the button is recognized
    if (mDisplayMap.containsKey(viewId)) {
      appendDigit(mDisplayMap.get(viewId));
    }
  }
コード例 #2
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
      case KeyEvent.KEYCODE_MENU:
        if (Receiver.call_state == UserAgent.UA_STATE_INCOMING_CALL
            && mSlidingCardManager == null) {
          answer();
          return true;
        }
        break;

      case KeyEvent.KEYCODE_CALL:
        switch (Receiver.call_state) {
          case UserAgent.UA_STATE_INCOMING_CALL:
            answer();
            break;
          case UserAgent.UA_STATE_INCALL:
          case UserAgent.UA_STATE_HOLD:
            Receiver.engine(this).togglehold();
            break;
        }
        // consume KEYCODE_CALL so PhoneWindow doesn't do anything with it
        return true;

      case KeyEvent.KEYCODE_BACK:
        if (mDialerDrawer.isOpened()) mDialerDrawer.animateClose();
        else if (Receiver.call_state == UserAgent.UA_STATE_INCOMING_CALL) reject();
        return true;

      case KeyEvent.KEYCODE_CAMERA:
        // Disable the CAMERA button while in-call since it's too
        // easy to press accidentally.
        return true;

      case KeyEvent.KEYCODE_VOLUME_DOWN:
      case KeyEvent.KEYCODE_VOLUME_UP:
        if (Receiver.call_state == UserAgent.UA_STATE_INCOMING_CALL) {
          Receiver.stopRingtone();
          return true;
        }
        RtpStreamReceiver.adjust(keyCode, true);
        return true;
    }
    if (Receiver.call_state == UserAgent.UA_STATE_INCALL) {
      char number = event.getNumber();
      if (Character.isDigit(number) || number == '*' || number == '#') {
        appendDigit(number);
        return true;
      }
    }
    return super.onKeyDown(keyCode, event);
  }