<commit_before>package ti.modules.titanium.media;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Date;

import org.appcelerator.titanium.TiBlob;
import org.appcelerator.titanium.TiContext;
import org.appcelerator.titanium.TiDict;
import org.appcelerator.titanium.TiModule;
import org.appcelerator.titanium.io.TiBaseFile;
import org.appcelerator.titanium.io.TiFileFactory;
import org.appcelerator.titanium.kroll.KrollCallback;
import org.appcelerator.titanium.util.Log;
import org.appcelerator.titanium.util.TiActivityResultHandler;
import org.appcelerator.titanium.util.TiActivitySupport;
import org.appcelerator.titanium.util.TiConfig;
import org.appcelerator.titanium.util.TiFileHelper;
import org.appcelerator.titanium.util.TiIntentWrapper;
import org.appcelerator.titanium.util.TiUIHelper;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.Bitmap.Config;
import android.hardware.Camera;
import android.net.Uri;
import android.os.Vibrator;
import android.provider.MediaStore;
import android.provider.MediaStore.Images;
import android.view.View;
import android.view.Window;

public class MediaModule extends TiModule
{
	private static final String LCAT = "TiMedia";
	private static final boolean DBG = TiConfig.LOGD;

	private static final long[] DEFAULT_VIBRATE_PATTERN = { 100L,250L };
	private static final String PHOTO_DCIM_CAMERA = "/sdcard/dcim/Camera";

	protected static final int UNKNOWN_ERROR = 0;
	protected static final int DEVICE_BUSY = 1;
	protected static final int NO_CAMERA = 2;
	protected static final int NO_VIDEO = 3;

	protected static TiDict constants;

	public MediaModule(TiContext tiContext)
	{
		super(tiContext);
	}

	@Override
	public TiDict getConstants()
	{
		if (constants == null) {
			constants = new TiDict();

			constants.put("UNKNOWN_ERROR", UNKNOWN_ERROR);
			constants.put("DEVICE_BUSY", DEVICE_BUSY);
			constants.put("NO_CAMERA", NO_CAMERA);
			constants.put("NO_VIDEO", NO_VIDEO);
		}

		return constants;
	}

	public void vibrate(long[] pattern)
	{
		if (pattern == null) {
			pattern = DEFAULT_VIBRATE_PATTERN;
		}
		Vibrator vibrator = (Vibrator) getTiContext().getTiApp().getSystemService(Context.VIBRATOR_SERVICE);
		if (vibrator != null) {
			vibrator.vibrate(pattern, -1);
		}
	}

	public void showCamera(Object[] args)
	{
		TiDict options = (TiDict) args[0];

		KrollCallback successCallback = null;
		KrollCallback cancelCallback = null;
		KrollCallback errorCallback = null;

		if (options.containsKey("success")) {
			successCallback = (KrollCallback) options.get("success");
		}
		if (options.containsKey("cancel")) {
			cancelCallback = (KrollCallback) options.get("cancel");<commit_msg>Video constants<commit_after>package ti.modules.titanium.media;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Date;

import org.appcelerator.titanium.TiBlob;
import org.appcelerator.titanium.TiContext;
import org.appcelerator.titanium.TiDict;
import org.appcelerator.titanium.TiModule;
import org.appcelerator.titanium.io.TiBaseFile;
import org.appcelerator.titanium.io.TiFileFactory;
import org.appcelerator.titanium.kroll.KrollCallback;
import org.appcelerator.titanium.util.Log;
import org.appcelerator.titanium.util.TiActivityResultHandler;
import org.appcelerator.titanium.util.TiActivitySupport;
import org.appcelerator.titanium.util.TiConfig;
import org.appcelerator.titanium.util.TiFileHelper;
import org.appcelerator.titanium.util.TiIntentWrapper;
import org.appcelerator.titanium.util.TiUIHelper;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.hardware.Camera;
import android.net.Uri;
import android.os.Vibrator;
import android.provider.MediaStore;
import android.provider.MediaStore.Images;
import android.view.Window;

public class MediaModule extends TiModule
{
	private static final String LCAT = "TiMedia";
	private static final boolean DBG = TiConfig.LOGD;

	private static final long[] DEFAULT_VIBRATE_PATTERN = { 100L,250L };
	private static final String PHOTO_DCIM_CAMERA = "/sdcard/dcim/Camera";

	protected static final int UNKNOWN_ERROR = 0;
	protected static final int DEVICE_BUSY = 1;
	protected static final int NO_CAMERA = 2;
	protected static final int NO_VIDEO = 3;

	protected static TiDict constants;

	public MediaModule(TiContext tiContext)
	{
		super(tiContext);
	}

	@Override
	public TiDict getConstants()
	{
		if (constants == null) {
			constants = new TiDict();

			constants.put("UNKNOWN_ERROR", UNKNOWN_ERROR);
			constants.put("DEVICE_BUSY", DEVICE_BUSY);
			constants.put("NO_CAMERA", NO_CAMERA);
			constants.put("NO_VIDEO", NO_VIDEO);

			constants.put("VIDEO_SCALING_ASPECT_FILL", 0);
			constants.put("VIDEO_SCALING_MODE_FILL", 1);

			constants.put("VIDEO_CONTROL_DEFAULT", 0);
		}

		return constants;
	}

	public void vibrate(long[] pattern)
	{
		if (pattern == null) {
			pattern = DEFAULT_VIBRATE_PATTERN;
		}
		Vibrator vibrator = (Vibrator) getTiContext().getTiApp().getSystemService(Context.VIBRATOR_SERVICE);
		if (vibrator != null) {
			vibrator.vibrate(pattern, -1);
		}
	}

	public void showCamera(Object[] args)
	{
		TiDict options = (TiDict) args[0];

		KrollCallback successCallback = null;
		KrollCallback cancelCallback = null;
		KrollCallback errorCallback = null;

		if (options.containsKey("success")) {
			successCallback = (KrollCallback) options.get("success");
		}
		if (options.containsKey("cancel")) {
			cancelCallback = (KrollCallback) options.get("cancel");
{'fraction_non_alphanumeric': 0.10543989254533244, 'fraction_numerical': 0.004533243787777031, 'mean_word_length': 5.6484375, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7060088', 'n_tokens_mistral': 2100, 'n_tokens_neox': 1960, 'n_words': 392}