From 81a7fbb76d121e1e60d028485b2abbac9e3882a8 Mon Sep 17 00:00:00 2001 From: Comment Date: Tue, 6 Aug 2013 23:21:14 +0100 Subject: initial commit --- AndroidManifest.xml | 31 ++++ bin/AndroidManifest.xml | 31 ++++ bin/capture.apk | Bin 0 -> 258435 bytes bin/classes.dex | Bin 0 -> 626556 bytes bin/classes/com/example/capture/BuildConfig.class | Bin 0 -> 347 bytes bin/classes/com/example/capture/MainActivity.class | Bin 0 -> 6458 bytes bin/classes/com/example/capture/R$attr.class | Bin 0 -> 343 bytes bin/classes/com/example/capture/R$dimen.class | Bin 0 -> 464 bytes bin/classes/com/example/capture/R$drawable.class | Bin 0 -> 410 bytes bin/classes/com/example/capture/R$id.class | Bin 0 -> 434 bytes bin/classes/com/example/capture/R$layout.class | Bin 0 -> 434 bytes bin/classes/com/example/capture/R$menu.class | Bin 0 -> 391 bytes bin/classes/com/example/capture/R$string.class | Bin 0 -> 475 bytes bin/classes/com/example/capture/R$style.class | Bin 0 -> 434 bytes bin/classes/com/example/capture/R.class | Bin 0 -> 683 bytes ...support-v4-96cf90bc600ae91b8934fcabf6ab47e4.jar | Bin 0 -> 211326 bytes bin/res/drawable-hdpi/ic_launcher.png | Bin 0 -> 5964 bytes bin/res/drawable-mdpi/ic_launcher.png | Bin 0 -> 3112 bytes bin/res/drawable-xhdpi/ic_launcher.png | Bin 0 -> 9355 bytes bin/res/drawable-xxhdpi/ic_launcher.png | Bin 0 -> 17889 bytes bin/resources.ap_ | Bin 0 -> 41375 bytes gen/com/example/capture/BuildConfig.java | 6 + gen/com/example/capture/R.java | 70 +++++++ ic_launcher-web.png | Bin 0 -> 51394 bytes libs/android-support-v4.jar | Bin 0 -> 556198 bytes lint.xml | 3 + proguard-project.txt | 20 ++ project.properties | 14 ++ res/drawable-hdpi/ic_launcher.png | Bin 0 -> 7658 bytes res/drawable-mdpi/ic_launcher.png | Bin 0 -> 3777 bytes res/drawable-xhdpi/ic_launcher.png | Bin 0 -> 12516 bytes res/drawable-xxhdpi/ic_launcher.png | Bin 0 -> 24777 bytes res/layout/activity_main.xml | 16 ++ res/layout/main.xml | 8 + res/menu/main.xml | 9 + res/values-sw600dp/dimens.xml | 8 + res/values-sw720dp-land/dimens.xml | 9 + res/values-v11/styles.xml | 11 ++ res/values-v14/styles.xml | 12 ++ res/values/dimens.xml | 7 + res/values/strings.xml | 8 + res/values/styles.xml | 20 ++ src/com/example/capture/MainActivity.java | 201 +++++++++++++++++++++ 43 files changed, 484 insertions(+) create mode 100644 AndroidManifest.xml create mode 100644 bin/AndroidManifest.xml create mode 100644 bin/capture.apk create mode 100644 bin/classes.dex create mode 100644 bin/classes/com/example/capture/BuildConfig.class create mode 100644 bin/classes/com/example/capture/MainActivity.class create mode 100644 bin/classes/com/example/capture/R$attr.class create mode 100644 bin/classes/com/example/capture/R$dimen.class create mode 100644 bin/classes/com/example/capture/R$drawable.class create mode 100644 bin/classes/com/example/capture/R$id.class create mode 100644 bin/classes/com/example/capture/R$layout.class create mode 100644 bin/classes/com/example/capture/R$menu.class create mode 100644 bin/classes/com/example/capture/R$string.class create mode 100644 bin/classes/com/example/capture/R$style.class create mode 100644 bin/classes/com/example/capture/R.class create mode 100644 bin/dexedLibs/android-support-v4-96cf90bc600ae91b8934fcabf6ab47e4.jar create mode 100644 bin/res/drawable-hdpi/ic_launcher.png create mode 100644 bin/res/drawable-mdpi/ic_launcher.png create mode 100644 bin/res/drawable-xhdpi/ic_launcher.png create mode 100644 bin/res/drawable-xxhdpi/ic_launcher.png create mode 100644 bin/resources.ap_ create mode 100644 gen/com/example/capture/BuildConfig.java create mode 100644 gen/com/example/capture/R.java create mode 100644 ic_launcher-web.png create mode 100644 libs/android-support-v4.jar create mode 100644 lint.xml create mode 100644 proguard-project.txt create mode 100644 project.properties create mode 100644 res/drawable-hdpi/ic_launcher.png create mode 100644 res/drawable-mdpi/ic_launcher.png create mode 100644 res/drawable-xhdpi/ic_launcher.png create mode 100644 res/drawable-xxhdpi/ic_launcher.png create mode 100644 res/layout/activity_main.xml create mode 100644 res/layout/main.xml create mode 100644 res/menu/main.xml create mode 100644 res/values-sw600dp/dimens.xml create mode 100644 res/values-sw720dp-land/dimens.xml create mode 100644 res/values-v11/styles.xml create mode 100644 res/values-v14/styles.xml create mode 100644 res/values/dimens.xml create mode 100644 res/values/strings.xml create mode 100644 res/values/styles.xml create mode 100644 src/com/example/capture/MainActivity.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml new file mode 100644 index 0000000..a49fde4 --- /dev/null +++ b/AndroidManifest.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/bin/AndroidManifest.xml b/bin/AndroidManifest.xml new file mode 100644 index 0000000..a49fde4 --- /dev/null +++ b/bin/AndroidManifest.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/bin/capture.apk b/bin/capture.apk new file mode 100644 index 0000000..142bd1f Binary files /dev/null and b/bin/capture.apk differ diff --git a/bin/classes.dex b/bin/classes.dex new file mode 100644 index 0000000..b480214 Binary files /dev/null and b/bin/classes.dex differ diff --git a/bin/classes/com/example/capture/BuildConfig.class b/bin/classes/com/example/capture/BuildConfig.class new file mode 100644 index 0000000..608ca5d Binary files /dev/null and b/bin/classes/com/example/capture/BuildConfig.class differ diff --git a/bin/classes/com/example/capture/MainActivity.class b/bin/classes/com/example/capture/MainActivity.class new file mode 100644 index 0000000..dbe56d4 Binary files /dev/null and b/bin/classes/com/example/capture/MainActivity.class differ diff --git a/bin/classes/com/example/capture/R$attr.class b/bin/classes/com/example/capture/R$attr.class new file mode 100644 index 0000000..80190fd Binary files /dev/null and b/bin/classes/com/example/capture/R$attr.class differ diff --git a/bin/classes/com/example/capture/R$dimen.class b/bin/classes/com/example/capture/R$dimen.class new file mode 100644 index 0000000..cfd9b91 Binary files /dev/null and b/bin/classes/com/example/capture/R$dimen.class differ diff --git a/bin/classes/com/example/capture/R$drawable.class b/bin/classes/com/example/capture/R$drawable.class new file mode 100644 index 0000000..64fa271 Binary files /dev/null and b/bin/classes/com/example/capture/R$drawable.class differ diff --git a/bin/classes/com/example/capture/R$id.class b/bin/classes/com/example/capture/R$id.class new file mode 100644 index 0000000..28a8a90 Binary files /dev/null and b/bin/classes/com/example/capture/R$id.class differ diff --git a/bin/classes/com/example/capture/R$layout.class b/bin/classes/com/example/capture/R$layout.class new file mode 100644 index 0000000..6d0f64d Binary files /dev/null and b/bin/classes/com/example/capture/R$layout.class differ diff --git a/bin/classes/com/example/capture/R$menu.class b/bin/classes/com/example/capture/R$menu.class new file mode 100644 index 0000000..b6e0704 Binary files /dev/null and b/bin/classes/com/example/capture/R$menu.class differ diff --git a/bin/classes/com/example/capture/R$string.class b/bin/classes/com/example/capture/R$string.class new file mode 100644 index 0000000..6274096 Binary files /dev/null and b/bin/classes/com/example/capture/R$string.class differ diff --git a/bin/classes/com/example/capture/R$style.class b/bin/classes/com/example/capture/R$style.class new file mode 100644 index 0000000..dda8175 Binary files /dev/null and b/bin/classes/com/example/capture/R$style.class differ diff --git a/bin/classes/com/example/capture/R.class b/bin/classes/com/example/capture/R.class new file mode 100644 index 0000000..c74d8b1 Binary files /dev/null and b/bin/classes/com/example/capture/R.class differ diff --git a/bin/dexedLibs/android-support-v4-96cf90bc600ae91b8934fcabf6ab47e4.jar b/bin/dexedLibs/android-support-v4-96cf90bc600ae91b8934fcabf6ab47e4.jar new file mode 100644 index 0000000..b5785b4 Binary files /dev/null and b/bin/dexedLibs/android-support-v4-96cf90bc600ae91b8934fcabf6ab47e4.jar differ diff --git a/bin/res/drawable-hdpi/ic_launcher.png b/bin/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..efa7c5f Binary files /dev/null and b/bin/res/drawable-hdpi/ic_launcher.png differ diff --git a/bin/res/drawable-mdpi/ic_launcher.png b/bin/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..ec27f2e Binary files /dev/null and b/bin/res/drawable-mdpi/ic_launcher.png differ diff --git a/bin/res/drawable-xhdpi/ic_launcher.png b/bin/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..92fc57d Binary files /dev/null and b/bin/res/drawable-xhdpi/ic_launcher.png differ diff --git a/bin/res/drawable-xxhdpi/ic_launcher.png b/bin/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..b6f8f4e Binary files /dev/null and b/bin/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/bin/resources.ap_ b/bin/resources.ap_ new file mode 100644 index 0000000..884fc04 Binary files /dev/null and b/bin/resources.ap_ differ diff --git a/gen/com/example/capture/BuildConfig.java b/gen/com/example/capture/BuildConfig.java new file mode 100644 index 0000000..63b07e4 --- /dev/null +++ b/gen/com/example/capture/BuildConfig.java @@ -0,0 +1,6 @@ +/** Automatically generated file. DO NOT MODIFY */ +package com.example.capture; + +public final class BuildConfig { + public final static boolean DEBUG = true; +} \ No newline at end of file diff --git a/gen/com/example/capture/R.java b/gen/com/example/capture/R.java new file mode 100644 index 0000000..56e9848 --- /dev/null +++ b/gen/com/example/capture/R.java @@ -0,0 +1,70 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package com.example.capture; + +public final class R { + public static final class attr { + } + public static final class dimen { + /** Default screen margins, per the Android Design guidelines. + + Customize dimensions originally defined in res/values/dimens.xml (such as + screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. + + */ + public static final int activity_horizontal_margin=0x7f040000; + public static final int activity_vertical_margin=0x7f040001; + } + public static final class drawable { + public static final int ic_launcher=0x7f020000; + } + public static final class id { + public static final int action_settings=0x7f080001; + public static final int surface_camera=0x7f080000; + } + public static final class layout { + public static final int activity_main=0x7f030000; + public static final int main=0x7f030001; + } + public static final class menu { + public static final int main=0x7f070000; + } + public static final class string { + public static final int action_settings=0x7f050001; + public static final int app_name=0x7f050000; + public static final int hello_world=0x7f050002; + } + public static final class style { + /** + Base application theme, dependent on API level. This theme is replaced + by AppBaseTheme from res/values-vXX/styles.xml on newer devices. + + + Theme customizations available in newer API levels can go in + res/values-vXX/styles.xml, while customizations related to + backward-compatibility can go here. + + + Base application theme for API 11+. This theme completely replaces + AppBaseTheme from res/values/styles.xml on API 11+ devices. + + API 11 theme customizations can go here. + + Base application theme for API 14+. This theme completely replaces + AppBaseTheme from BOTH res/values/styles.xml and + res/values-v11/styles.xml on API 14+ devices. + + API 14 theme customizations can go here. + */ + public static final int AppBaseTheme=0x7f060000; + /** Application theme. + All customizations that are NOT specific to a particular API-level can go here. + */ + public static final int AppTheme=0x7f060001; + } +} diff --git a/ic_launcher-web.png b/ic_launcher-web.png new file mode 100644 index 0000000..a18cbb4 Binary files /dev/null and b/ic_launcher-web.png differ diff --git a/libs/android-support-v4.jar b/libs/android-support-v4.jar new file mode 100644 index 0000000..cf12d28 Binary files /dev/null and b/libs/android-support-v4.jar differ diff --git a/lint.xml b/lint.xml new file mode 100644 index 0000000..ee0eead --- /dev/null +++ b/lint.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/proguard-project.txt b/proguard-project.txt new file mode 100644 index 0000000..f2fe155 --- /dev/null +++ b/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/project.properties b/project.properties new file mode 100644 index 0000000..ce39f2d --- /dev/null +++ b/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-18 diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png new file mode 100644 index 0000000..288b665 Binary files /dev/null and b/res/drawable-hdpi/ic_launcher.png differ diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png new file mode 100644 index 0000000..6ae570b Binary files /dev/null and b/res/drawable-mdpi/ic_launcher.png differ diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png new file mode 100644 index 0000000..d4fb7cd Binary files /dev/null and b/res/drawable-xhdpi/ic_launcher.png differ diff --git a/res/drawable-xxhdpi/ic_launcher.png b/res/drawable-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..85a6081 Binary files /dev/null and b/res/drawable-xxhdpi/ic_launcher.png differ diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml new file mode 100644 index 0000000..168c9b8 --- /dev/null +++ b/res/layout/activity_main.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/res/layout/main.xml b/res/layout/main.xml new file mode 100644 index 0000000..b64d0eb --- /dev/null +++ b/res/layout/main.xml @@ -0,0 +1,8 @@ + + + \ No newline at end of file diff --git a/res/menu/main.xml b/res/menu/main.xml new file mode 100644 index 0000000..c002028 --- /dev/null +++ b/res/menu/main.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml new file mode 100644 index 0000000..44f01db --- /dev/null +++ b/res/values-sw600dp/dimens.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml new file mode 100644 index 0000000..61e3fa8 --- /dev/null +++ b/res/values-sw720dp-land/dimens.xml @@ -0,0 +1,9 @@ + + + + 128dp + + diff --git a/res/values-v11/styles.xml b/res/values-v11/styles.xml new file mode 100644 index 0000000..3c02242 --- /dev/null +++ b/res/values-v11/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/res/values-v14/styles.xml b/res/values-v14/styles.xml new file mode 100644 index 0000000..a91fd03 --- /dev/null +++ b/res/values-v14/styles.xml @@ -0,0 +1,12 @@ + + + + + + diff --git a/res/values/dimens.xml b/res/values/dimens.xml new file mode 100644 index 0000000..55c1e59 --- /dev/null +++ b/res/values/dimens.xml @@ -0,0 +1,7 @@ + + + + 16dp + 16dp + + diff --git a/res/values/strings.xml b/res/values/strings.xml new file mode 100644 index 0000000..8b9e6e4 --- /dev/null +++ b/res/values/strings.xml @@ -0,0 +1,8 @@ + + + + capture + Settings + Hello world! + + diff --git a/res/values/styles.xml b/res/values/styles.xml new file mode 100644 index 0000000..6ce89c7 --- /dev/null +++ b/res/values/styles.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/src/com/example/capture/MainActivity.java b/src/com/example/capture/MainActivity.java new file mode 100644 index 0000000..b6e96de --- /dev/null +++ b/src/com/example/capture/MainActivity.java @@ -0,0 +1,201 @@ +package com.example.capture; + +import java.io.File; +import java.io.IOException; +import java.util.Date; +import android.app.Activity; +import android.content.Intent; +import android.hardware.Camera; +import android.hardware.Camera.Parameters; +import android.media.MediaRecorder; +import android.net.Uri; +import android.os.Bundle; +import android.os.Environment; +import android.util.Log; +import android.view.MenuItem; +import android.view.SurfaceHolder; +import android.view.SurfaceHolder.Callback; +import android.view.Menu; +import android.view.SurfaceView; +import android.widget.Toast; + +//http://stackoverflow.com/questions/17042308/select-a-music-file-to-play-with-mediaplayer +//http://stackoverflow.com/questions/2709087/turning-a-string-into-a-uri-android + +public class MainActivity extends Activity implements Callback { + + @Override + protected void onDestroy() { + stopRecording(); + super.onDestroy(); + } + + private SurfaceHolder surfaceHolder; + private SurfaceView surfaceView; + public MediaRecorder mrec = new MediaRecorder(); + private Camera mCamera; + private Uri uriSound; + + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.main); + + surfaceView = (SurfaceView) findViewById(R.id.surface_camera); + + mCamera = Camera.open(); + + surfaceHolder = surfaceView.getHolder(); + surfaceHolder.addCallback(this); + surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); + + uriSound=Uri.parse(""); + + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) + { + + menu.add(0, 0, 0, "Start"); + menu.add(0, 0, 0, "Pick audio track"); + return super.onCreateOptionsMenu(menu); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) + { + if(item.getTitle().equals("Start")) + { + try { + + startRecording(); + item.setTitle("Stop"); + + } catch (Exception e) { + + String message = e.getMessage(); + Log.i(null, "Problem " + message); + mrec.release(); + } + + } + else if(item.getTitle().equals("Stop")) + { + mrec.stop(); + mrec.release(); + mrec = null; + item.setTitle("Start"); + } + else if(item.getTitle().equals("Pick audio track")) + { + Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI); + startActivityForResult(intent, 10); + } + + return super.onOptionsItemSelected(item); + } + + protected void startRecording() throws IOException + { + if(mCamera==null) + mCamera = Camera.open(); + + String filename; + String path; + + path= Environment.getExternalStorageDirectory().getAbsolutePath().toString(); + + Date date=new Date(); + filename="/rec"+date.toString().replace(" ", "_").replace(":", "_")+".mp4"; + + //create empty file it must use + File file=new File(path,filename); + + mrec = new MediaRecorder(); + + mCamera.lock(); + mCamera.unlock(); + + // Please maintain sequence of following code. + + // If you change sequence it will not work. + mrec.setCamera(mCamera); + mrec.setVideoSource(MediaRecorder.VideoSource.CAMERA); + mrec.setAudioSource(MediaRecorder.AudioSource.MIC); + mrec.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); + mrec.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP); + mrec.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); + mrec.setPreviewDisplay(surfaceHolder.getSurface()); + mrec.setOutputFile(path+filename); + mrec.prepare(); + mrec.start(); + + + } + + protected void stopRecording() { + + if(mrec!=null) + { + mrec.stop(); + mrec.release(); + mCamera.release(); + mCamera.lock(); + } + } + + private void releaseMediaRecorder() { + + if (mrec != null) { + mrec.reset(); // clear recorder configuration + mrec.release(); // release the recorder object + } + } + + private void releaseCamera() { + if (mCamera != null) { + mCamera.release(); // release the camera for other applications + mCamera = null; + } + + } + + @Override + public void surfaceChanged(SurfaceHolder holder, int format, int width,int height) { + + } + + @Override + public void surfaceCreated(SurfaceHolder holder) { + + if (mCamera != null) { + Parameters params = mCamera.getParameters(); + mCamera.setParameters(params); + Log.i("Surface", "Created"); + } + else { + Toast.makeText(getApplicationContext(), "Camera not available!", + Toast.LENGTH_LONG).show(); + + finish(); + } + + } + + @Override + public void surfaceDestroyed(SurfaceHolder holder) { + mCamera.stopPreview(); + mCamera.release(); + //http://stackoverflow.com/questions/13235306/method-called-after-release-exception-camera-preview + //mCamera=null; + } + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + + if(requestCode == RESULT_OK && requestCode == 10){ + uriSound=data.getData(); + } + } +} -- cgit v1.2.3