Beispiel #1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // ////// ******** Initializing and assigning memory to UI Items ********** /////////
    editVoiceDetails = (RelativeLayout) findViewById(R.id.edit_voice_details);
    editTimeDetailsChronometer = (Chronometer) findViewById(R.id.edit_time_details_chronometer);
    editStopButton = (Button) findViewById(R.id.edit_stop_button);
    editPlayButton = (Button) findViewById(R.id.edit_play_button);
    editRerecordButton = (Button) findViewById(R.id.edit_rerecord_button);
    typeOfEntry = R.string.voice;
    typeOfEntryFinished = R.string.finished_voiceentry;
    typeOfEntryUnfinished = R.string.unfinished_voiceentry;
    editHelper();
    // ////// ******** Starts Recording each time activity starts ****** ///////
    if (android.os.Environment.getExternalStorageState()
        .equals(android.os.Environment.MEDIA_MOUNTED)) {
      setGraphicsVoice();

      if (intentExtras.containsKey(Constants.KEY_ENTRY_LIST_EXTRA) && !setUnknown) {
        File tempFile;
        if (isFromFavorite) {
          tempFile = fileHelper.getAudioFileFavorite(mFavoriteList.id);
        } else {
          tempFile = fileHelper.getAudioFileEntry(entry.id);
        }

        if (tempFile.canRead()) {
          if (isFromFavorite) {
            mAudioPlay = new AudioPlay(mFavoriteList.id, this, isFromFavorite);
          } else {
            mAudioPlay = new AudioPlay(entry.id, this, isFromFavorite);
          }
          editStopButton.setVisibility(View.GONE);
          editPlayButton.setVisibility(View.VISIBLE);
          editRerecordButton.setVisibility(View.VISIBLE);
          editTimeDetailsChronometer.setText(
              new DisplayTimeForChronometer().getDisplayTime(mAudioPlay.getPlayBackTime()));
        } else {
          editTimeDetailsChronometer.setText("Audio File Missing");
          editTimeDetailsChronometer.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
          editRerecordButton.setVisibility(View.VISIBLE);
          editStopButton.setVisibility(View.GONE);
          editPlayButton.setVisibility(View.GONE);
        }
      } else {
        if (!isFromFavorite) {
          mRecordingHelper = new RecordingHelper(fileHelper.getAudioFileEntry(entry.id), this);
          mRecordingHelper.startRecording();
          controlVoiceChronometer();
        }
      }
    } else {
      Toast.makeText(this, "sdcard not available", Toast.LENGTH_LONG).show();
    }
    setClickListeners();
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   typeOfEntry = R.string.text;
   typeOfEntryFinished = R.string.unfinished_textentry;
   typeOfEntryUnfinished = R.string.unfinished_textentry;
   editHelper();
   createDatabaseEntry();
   setFavoriteHelper();
 }
Beispiel #3
0
 @Override
 protected void onPause() {
   ////// ****** stop recording & audio playback  ***** ///////
   stopRecordingAndPlayback();
   super.onPause();
 }
Beispiel #4
0
 @Override
 public void onBackPressed() {
   stopRecordingAndPlayback();
   super.onBackPressed();
 }
Beispiel #5
0
  @Override
  public void onClick(View v) {
    super.onClick(v);
    // ///// ******** Adding On Click Actions to click listeners ********* //////////

    switch (v.getId()) {

        // // ***** if stop button pressed ****** //////
      case R.id.edit_stop_button:
        stopRecording(true);
        break;
        // // ***** if play button pressed ****** //////
      case R.id.edit_play_button:
        // //// ******** to handle playback of recorded file ********* ////////
        if (isFromFavorite) {
          mAudioPlay = new AudioPlay(mFavoriteList.id, this, isFromFavorite);
        } else {
          mAudioPlay = new AudioPlay(entry.id, this, isFromFavorite);
        }

        // ///// ******* Chronometer Starts Countdown ****** ///////
        countDownTimer =
            new MyCountDownTimer(
                mAudioPlay.getPlayBackTime(),
                1000,
                editTimeDetailsChronometer,
                editStopButton,
                editPlayButton,
                mAudioPlay);

        // //// ****** Handles UI items on button click ****** ///////
        editPlayButton.setVisibility(View.GONE);
        editStopButton.setVisibility(View.VISIBLE);
        editRerecordButton.setVisibility(View.VISIBLE);

        // /// ******** Start Audio Playback and counter to play audio
        // ****** ///////
        if (!mAudioPlay.isAudioPlaying()) {
          mAudioPlay.startPlayBack();
        } else {
          mAudioPlay.stopPlayBack();
          mAudioPlay.startPlayBack();
        }
        countDownTimer.start();
        break;

        // // ***** if rerecord button pressed ****** //////
      case R.id.edit_rerecord_button:
        isChanged = true;
        if (countDownTimer != null) {
          countDownTimer.cancel();
        }

        // /// ******* If Audio PlayBack is there stop playing audio *******//////
        if (mAudioPlay != null && mAudioPlay.isAudioPlaying()) {
          mAudioPlay.stopPlayBack();
        }

        // //// ****** Handles UI items on button click ****** ///////
        editPlayButton.setVisibility(View.GONE);
        editStopButton.setVisibility(View.VISIBLE);
        editRerecordButton.setVisibility(View.GONE);

        // //// ****** Restarts chronometer and recording ******* ////////
        if (mRecordingHelper != null && mRecordingHelper.isRecording()) {
          mRecordingHelper.stopRecording();
        }
        File mPath;
        mDatabaseAdapter.open();
        if (isFromFavorite) {
          mPath = fileHelper.getAudioFileFavorite(mFavoriteList.id);
          mDatabaseAdapter.updateFileUploadedFavoriteTable(mFavoriteList.id);
        } else {
          mPath = fileHelper.getAudioFileEntry(entry.id);
          mDatabaseAdapter.updateFileUploadedEntryTable(entry.id);
        }
        mDatabaseAdapter.close();
        mRecordingHelper = new RecordingHelper(mPath, this);
        mRecordingHelper.startRecording();
        editTimeDetailsChronometer.setTextSize(TypedValue.COMPLEX_UNIT_SP, 36);
        editTimeDetailsChronometer.setBase(SystemClock.elapsedRealtime());
        editTimeDetailsChronometer.start();
        break;

      default:
        break;
    }
  }