Example #1
0
  public void onHandleMessage(Message msg) {

    if (msg.sendingUid == 1) // TODO replace 1 with enum
    {
      if (dialogManager.getPrintCamera() == dialogManager.PRINT_CAMERA)
        appendComment(BotAdapter.Type.Camera, msg.getData().getString("message"));
      else // do all this only if no camera demo
      {
        if (lastpicture != null) // relevant on every second picture asumess 2 pictures per round!!
        {
          if (lastpicture.equals(msg.getData().getString("message"))) // no change
          {
            appendComment(BotAdapter.Type.Camera, msg.getData().getString("message") + "no change");
          } else // this one reflects emergency - so switch to help
          {
            appendComment(BotAdapter.Type.Camera, "change -> help");
            tts.speak("Please say help if help is needed", TextToSpeech.QUEUE_FLUSH, null, "1");
            dialogManager.setHelpFromCamera();
          }

          lastpicture = null; // for next round of two TODO handle reset event
        } else // first picture in round
        {
          lastpicture = msg.getData().getString("message");
        }
      }
    }
    if (msg.sendingUid == 2) // TODO replace 2
    {
      // place holder
    }
    if (msg.sendingUid == 3) // TODO replace 3
    lastpicture = null;
  }
Example #2
0
  public void onRadioButtonClicked(View view) {
    // Is the button now checked?
    boolean checked = ((RadioButton) view).isChecked();

    // Check which radio button was clicked
    switch (view.getId()) {
      case R.id.CynicradioButton:
        if (checked) dialogManager.setAttitudeCynic();
        break;
      case R.id.DistantradioButton:
        if (checked) dialogManager.setAttitudeDistant();
        break;
    }
  }
Example #3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_bot);
    setupComments();
    setupSpeakButton();
    setupCameraButton();
    setupSendCommentButton();
    setupImageDemoButton();

    surfaceView = (SurfaceView) findViewById(R.id.surfaceView);

    cameraControl = new CameraControl(messageHandler);
    cameraControl.init(getApplicationContext(), surfaceView);
    lastpicture = null;

    dialogManager = new DialogManager(this, this, messageHandler);

    dialogManager.setAttitudeCynic(); // happy

    drawingStartLocation = getIntent().getIntExtra(ARG_DRAWING_START_LOCATION, 0);
    if (savedInstanceState == null) {
      contentRoot
          .getViewTreeObserver()
          .addOnPreDrawListener(
              new ViewTreeObserver.OnPreDrawListener() {
                @Override
                public boolean onPreDraw() {
                  contentRoot.getViewTreeObserver().removeOnPreDrawListener(this);
                  startIntroAnimation();
                  return true;
                }
              });
    }

    tts =
        new TextToSpeech(
            getApplicationContext(),
            new TextToSpeech.OnInitListener() {
              @Override
              public void onInit(int status) {
                if (status != TextToSpeech.ERROR) {
                  tts.setLanguage(Locale.US);
                }
              }
            });

    dialogManager.skypeControl.setTts(tts);

    sr = SpeechRecognizer.createSpeechRecognizer(this);
    sr.setRecognitionListener(new STTListener());

    final AIConfiguration config =
        new AIConfiguration(
            "CLIENT_ACCESS_TOKEN_FAIL",
            "SUBSCRIPTION_KEY_FAIL",
            AIConfiguration.SupportedLanguages.English,
            AIConfiguration.RecognitionEngine.System);
  }
Example #4
0
  private String getComment() {

    String comment = etComment.getText().toString();
    if (TextUtils.isEmpty(comment)) {
      btnSendComment.startAnimation(AnimationUtils.loadAnimation(this, R.anim.shake_error));
      return null;
    }

    comment = dialogManager.sendRequest(comment);

    if (TextUtils.isEmpty(comment)) {
      btnSendComment.startAnimation(AnimationUtils.loadAnimation(this, R.anim.shake_error));
      return null;
    }

    return comment;
  }
Example #5
0
 public void onImageButtonClicked(View view) {
   boolean checked = ((ToggleButton) view).isChecked();
   if (checked) dialogManager.setPrintCamera();
   else dialogManager.UnsetPrintCamera();
 }