// Path: app/src/main/java/io/rapidpro/surveyor/Logger.java
// public class Logger {
// 
//     private static final String TAG = "Surveyor";
// 
//     public static void e(String message, Throwable t) {
//         Log.e(TAG, message, t);
//     }
// 
//     public static void w(String message) {
//         Log.w(TAG, message);
//     }
// 
//     public static void d(String message) {
//         Log.d(TAG, message);
//     }
// }
// 
// Path: app/src/main/java/io/rapidpro/surveyor/SurveyorIntent.java
// public interface SurveyorIntent {
//     String EXTRA_ORG_UUID = "surveyor.extra.org_uuid";
//     String EXTRA_FLOW_UUID = "surveyor.extra.flow_uuid";
// 
//     String EXTRA_SUBMISSION_FILE = "surveyor.extra.submission_file";
// 
//     // where media files are to be stored
//     String EXTRA_MEDIA_FILE = "surveyor.extra.media_file";
// 
//     String EXTRA_ERROR = "surveyor.extra.error";
//     String EXTRA_CAMERA_DIRECTION = "surveyor.extra.camera_direction";
// }
// 
// Path: app/src/main/java/io/rapidpro/surveyor/ui/IconTextView.java
// public class IconTextView extends TextView {
//     public IconTextView(Context context, AttributeSet attrs) {
//         super(context, attrs);
//         setTypeface(Typefaces.get(getContext(), "material.ttf"));
//     }
// 
//     public void setIconColor(int color) {
//         setTextColor(getResources().getColor(color));
//     }
// }


import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import io.rapidpro.surveyor.Logger;
import io.rapidpro.surveyor.R;
import io.rapidpro.surveyor.SurveyorIntent;
import io.rapidpro.surveyor.ui.IconTextView;
            mediaRecorder = new MediaRecorder();
            mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
            mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
            mediaRecorder.setOutputFile(output);
            mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
            mediaRecorder.prepare();

        } catch (Exception e) {
            Logger.e("Unable to create media recorder", e);
        }

        mediaRecorder.start();
    }

    private void releaseMediaRecorder() {
        if (mediaRecorder != null) {
            mediaRecorder.reset();
            mediaRecorder.release();
            mediaRecorder = null;
        }
    }

    private void stopRecording() {
        if (mediaRecorder != null) {
            mediaRecorder.stop();
        }
        releaseMediaRecorder();
        isRecording = false;

        Intent returnIntent = new Intent();
// Path: app/src/main/java/io/rapidpro/surveyor/Logger.java
// public class Logger {
// 
//     private static final String TAG = "Surveyor";
// 
//     public static void e(String message, Throwable t) {
//         Log.e(TAG, message, t);
//     }
// 
//     public static void w(String message) {
//         Log.w(TAG, message);
//     }
// 
//     public static void d(String message) {
//         Log.d(TAG, message);
//     }
// }
// 
// Path: app/src/main/java/io/rapidpro/surveyor/SurveyorIntent.java
// public interface SurveyorIntent {
//     String EXTRA_ORG_UUID = "surveyor.extra.org_uuid";
//     String EXTRA_FLOW_UUID = "surveyor.extra.flow_uuid";
// 
//     String EXTRA_SUBMISSION_FILE = "surveyor.extra.submission_file";
// 
//     // where media files are to be stored
//     String EXTRA_MEDIA_FILE = "surveyor.extra.media_file";
// 
//     String EXTRA_ERROR = "surveyor.extra.error";
//     String EXTRA_CAMERA_DIRECTION = "surveyor.extra.camera_direction";
// }
// 
// Path: app/src/main/java/io/rapidpro/surveyor/ui/IconTextView.java
// public class IconTextView extends TextView {
//     public IconTextView(Context context, AttributeSet attrs) {
//         super(context, attrs);
//         setTypeface(Typefaces.get(getContext(), "material.ttf"));
//     }
// 
//     public void setIconColor(int color) {
//         setTextColor(getResources().getColor(color));
//     }
// }


// Path: app/src/main/java/io/rapidpro/surveyor/activity/CaptureAudioActivity.java
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import io.rapidpro.surveyor.Logger;
import io.rapidpro.surveyor.R;
import io.rapidpro.surveyor.SurveyorIntent;
import io.rapidpro.surveyor.ui.IconTextView;

            mediaRecorder = new MediaRecorder();
            mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
            mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
            mediaRecorder.setOutputFile(output);
            mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
            mediaRecorder.prepare();

        } catch (Exception e) {
            Logger.e("Unable to create media recorder", e);
        }

        mediaRecorder.start();
    }

    private void releaseMediaRecorder() {
        if (mediaRecorder != null) {
            mediaRecorder.reset();
            mediaRecorder.release();
            mediaRecorder = null;
        }
    }

    private void stopRecording() {
        if (mediaRecorder != null) {
            mediaRecorder.stop();
        }
        releaseMediaRecorder();
        isRecording = false;

        Intent returnIntent = new Intent();
        returnIntent.putExtra(SurveyorIntent.EXTRA_MEDIA_FILE, getIntent().getStringExtra(SurveyorIntent.EXTRA_MEDIA_FILE));