<commit_before>package cordova.plugins.microvideo;

import android.app.Activity;
import android.hardware.Camera;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import java.io.File;
import java.io.IOException;

public class MicroVideoActivity extends Activity implements SurfaceHolder.Callback {

	private int m_count = 0;
	private Camera m_camera;
	private MediaRecorder m_mediaRecorder;
	private SurfaceView m_surfaceView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		final LinearLayout layout = new LinearLayout(this);
		layout.setOrientation(LinearLayout.VERTICAL);
		setContentView(layout);

		final Button button = new Button(this);
		button.setText("Record");
		button.setOnTouchListener(new View.OnTouchListener() {

			@Override
			public boolean onTouch(View view, MotionEvent motionEvent) {
				switch (motionEvent.getActionMasked()) {
					case MotionEvent.ACTION_DOWN:
						m_camera.unlock();

						m_mediaRecorder.reset();

						m_mediaRecorder.setCamera(m_camera);

						m_mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
						m_mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

						m_mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

						m_mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
						m_mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);

						m_mediaRecorder.setAudioChannels(2);
						m_mediaRecorder.setVideoFrameRate(15);
						m_mediaRecorder.setVideoSize(480, 320);

						m_mediaRecorder.setOutputFile(new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), String.format("MediaRecorder_%d.mp4", ++m_count)).getAbsolutePath());

						try {
							m_mediaRecorder.prepare();
							m_mediaRecorder.start();
						} catch (IOException e) {
							e.printStackTrace();
						}

						return true;

					case MotionEvent.ACTION_UP:
						if (null != m_mediaRecorder) {
							m_mediaRecorder.stop();
						}

						return true;

					default:
						return false;
				}
			}

		});
		layout.addView(button);

		m_surfaceView = new SurfaceView(this);
		m_surfaceView.getHolder().addCallback(this);
		layout.addView(m_surfaceView);
	}

	@Override
	public void surfaceCreated(SurfaceHolder holder) {
		m_camera = Camera.open();

		if (null == m_camera) {
			finish();
		}

		m_mediaRecorder = new MediaRecorder();
	}

	@Override
	public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
		try {
			m_camera.setDisplayOrientation(90);
			m_camera.setPreviewDisplay(holder);
			m_camera.startPreview();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
<commit_msg>修改程序文件<commit_after>package cordova.plugins.microvideo;

import android.app.Activity;
import android.hardware.Camera;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import java.io.File;
import java.io.IOException;

public class MicroVideoActivity extends Activity implements SurfaceHolder.Callback {

	private int m_count = 0;
	private Camera m_camera;
	private MediaRecorder m_mediaRecorder;
	private SurfaceView m_surfaceView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		final LinearLayout layout = new LinearLayout(this);
		layout.setOrientation(LinearLayout.VERTICAL);
		setContentView(layout);

		final Button button = new Button(this);
		button.setText("Record");
		button.setOnTouchListener(new View.OnTouchListener() {

			@Override
			public boolean onTouch(View view, MotionEvent motionEvent) {
				switch (motionEvent.getActionMasked()) {
					case MotionEvent.ACTION_DOWN:
						m_camera.unlock();

						m_mediaRecorder.reset();

						m_mediaRecorder.setCamera(m_camera);

						m_mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
						m_mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);

						m_mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

						m_mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
						m_mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);

						m_mediaRecorder.setAudioChannels(2);
						m_mediaRecorder.setVideoFrameRate(15);
						m_mediaRecorder.setVideoSize(480, 320);

						m_mediaRecorder.setOutputFile(new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), String.format("MediaRecorder_%d.mp4", ++m_count)).getAbsolutePath());

						try {
							m_mediaRecorder.prepare();
							m_mediaRecorder.start();
						} catch (IOException e) {
							e.printStackTrace();
						}

						return true;

					case MotionEvent.ACTION_UP:
						if (null != m_mediaRecorder) {
							m_mediaRecorder.stop();
						}

						return true;

					default:
						return false;
				}
			}

		});
		layout.addView(button);

		m_surfaceView = new SurfaceView(this);
		m_surfaceView.getHolder().addCallback(this);
		layout.addView(m_surfaceView);
	}

	@Override
	public void surfaceCreated(SurfaceHolder holder) {
		if (0 < Camera.getNumberOfCameras()) {
			m_camera = Camera.open(0);
		}

		if (null == m_camera) {
			finish();
		}

		m_mediaRecorder = new MediaRecorder();
	}

	@Override
	public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
		try {
			int degrees = 0;

			switch (getWindowManager().getDefaultDisplay().getRotation()) {
				case Surface.ROTATION_0: degrees = 0; break;
				case Surface.ROTATION_90: degrees = 90; break;
				case Surface.ROTATION_180: degrees = 180; break;
				case Surface.ROTATION_270: degrees = 270; break;
			}

			Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
			Camera.getCameraInfo(0, cameraInfo);

			if (Camera.CameraInfo.CAMERA_FACING_FRONT == cameraInfo.facing) {
				degrees = (360 - (cameraInfo.orientation + degrees) % 360) % 360;
			} else {
				degrees = (cameraInfo.orientation - degrees + 360) % 360;
			}

			m_camera.setDisplayOrientation(degrees);
			m_camera.setPreviewDisplay(holder);
			m_camera.startPreview();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

{'fraction_non_alphanumeric': 0.10183918528651771, 'fraction_numerical': 0.010487916096671226, 'mean_word_length': 4.353946297803092, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2253043', 'n_tokens_mistral': 2503, 'n_tokens_neox': 1990, 'n_words': 361}