Skip to content

Commit e109b5f

Browse files
committed
initial commit
0 parents  commit e109b5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+349
-0
lines changed

.classpath

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry kind="src" path="gen"/>
5+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
6+
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
7+
<classpathentry kind="output" path="bin/classes"/>
8+
</classpath>

.project

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>CameraExample</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.jdt.core.javabuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
<buildCommand>
24+
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
25+
<arguments>
26+
</arguments>
27+
</buildCommand>
28+
</buildSpec>
29+
<natures>
30+
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
31+
<nature>org.eclipse.jdt.core.javanature</nature>
32+
</natures>
33+
</projectDescription>

AndroidManifest.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.example.cameraexample"
3+
android:versionCode="1"
4+
android:versionName="1.0" >
5+
6+
<uses-sdk
7+
android:minSdkVersion="16"
8+
android:targetSdkVersion="15" />
9+
10+
<uses-permission android:name="android.permission.CAMERA" />
11+
12+
<uses-feature android:name="android.hardware.camera" />
13+
14+
<application
15+
android:icon="@drawable/ic_launcher"
16+
android:label="@string/app_name"
17+
android:theme="@style/AppTheme" >
18+
<activity
19+
android:name=".CameraActivity"
20+
android:label="@string/title_activity_camera" >
21+
<intent-filter>
22+
<action android:name="android.intent.action.MAIN" />
23+
24+
<category android:name="android.intent.category.LAUNCHER" />
25+
</intent-filter>
26+
</activity>
27+
</application>
28+
29+
</manifest>

bin/AndroidManifest.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.example.cameraexample"
3+
android:versionCode="1"
4+
android:versionName="1.0" >
5+
6+
<uses-sdk
7+
android:minSdkVersion="16"
8+
android:targetSdkVersion="15" />
9+
10+
<uses-permission android:name="android.permission.CAMERA" />
11+
12+
<uses-feature android:name="android.hardware.camera" />
13+
14+
<application
15+
android:icon="@drawable/ic_launcher"
16+
android:label="@string/app_name"
17+
android:theme="@style/AppTheme" >
18+
<activity
19+
android:name=".CameraActivity"
20+
android:label="@string/title_activity_camera" >
21+
<intent-filter>
22+
<action android:name="android.intent.action.MAIN" />
23+
24+
<category android:name="android.intent.category.LAUNCHER" />
25+
</intent-filter>
26+
</activity>
27+
</application>
28+
29+
</manifest>

bin/CameraExample.apk

153 KB
Binary file not shown.

bin/classes.dex

320 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
361 Bytes
Binary file not shown.
Binary file not shown.
488 Bytes
Binary file not shown.
Binary file not shown.
420 Bytes
Binary file not shown.
Binary file not shown.
416 Bytes
Binary file not shown.
688 Bytes
Binary file not shown.
409 Bytes

bin/res/drawable-hdpi/ic_launcher.png

3.64 KB

bin/res/drawable-ldpi/ic_launcher.png

1.65 KB
311 Bytes

bin/res/drawable-mdpi/ic_launcher.png

1.97 KB
491 Bytes
4.77 KB

bin/resources.ap_

18.2 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/** Automatically generated file. DO NOT MODIFY */
2+
package com.example.cameraexample;
3+
4+
public final class BuildConfig {
5+
public final static boolean DEBUG = true;
6+
}

gen/com/example/cameraexample/R.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/* AUTO-GENERATED FILE. DO NOT MODIFY.
2+
*
3+
* This class was automatically generated by the
4+
* aapt tool from the resource data it found. It
5+
* should not be modified by hand.
6+
*/
7+
8+
package com.example.cameraexample;
9+
10+
public final class R {
11+
public static final class attr {
12+
}
13+
public static final class drawable {
14+
public static final int ic_action_search=0x7f020000;
15+
public static final int ic_launcher=0x7f020001;
16+
}
17+
public static final class id {
18+
public static final int camera_preview=0x7f070000;
19+
public static final int menu_settings=0x7f070002;
20+
public static final int shutter_button=0x7f070001;
21+
}
22+
public static final class layout {
23+
public static final int activity_camera=0x7f030000;
24+
}
25+
public static final class menu {
26+
public static final int activity_camera=0x7f060000;
27+
}
28+
public static final class string {
29+
public static final int app_name=0x7f040000;
30+
public static final int hello_world=0x7f040001;
31+
public static final int menu_settings=0x7f040002;
32+
public static final int title_activity_camera=0x7f040003;
33+
}
34+
public static final class style {
35+
public static final int AppTheme=0x7f050000;
36+
}
37+
}

ic_launcher-web.png

32 KB

libs/android-support-v4.jar

341 KB
Binary file not shown.

proguard-project.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# To enable ProGuard in your project, edit project.properties
2+
# to define the proguard.config property as described in that file.
3+
#
4+
# Add project specific ProGuard rules here.
5+
# By default, the flags in this file are appended to flags specified
6+
# in ${sdk.dir}/tools/proguard/proguard-android.txt
7+
# You can edit the include path and order by changing the ProGuard
8+
# include property in project.properties.
9+
#
10+
# For more details, see
11+
# http://developer.android.com/guide/developing/tools/proguard.html
12+
13+
# Add any project specific keep options here:
14+
15+
# If your project uses WebView with JS, uncomment the following
16+
# and specify the fully qualified class name to the JavaScript interface
17+
# class:
18+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19+
# public *;
20+
#}

project.properties

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This file is automatically generated by Android Tools.
2+
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3+
#
4+
# This file must be checked in Version Control Systems.
5+
#
6+
# To customize properties used by the Ant build system edit
7+
# "ant.properties", and override values to adapt the script to your
8+
# project structure.
9+
#
10+
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11+
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12+
13+
# Project target.
14+
target=android-16
3.05 KB

res/drawable-hdpi/ic_launcher.png

2.73 KB

res/drawable-ldpi/ic_launcher.png

1.39 KB
2.96 KB

res/drawable-mdpi/ic_launcher.png

1.74 KB
3.12 KB

res/drawable-xhdpi/ic_launcher.png

3.62 KB

res/layout/activity_camera.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="fill_parent"
4+
android:layout_height="fill_parent"
5+
android:orientation="vertical" >
6+
7+
<FrameLayout
8+
android:id="@+id/camera_preview"
9+
android:layout_width="fill_parent"
10+
android:layout_height="0dp"
11+
android:layout_weight="1" />
12+
13+
<Button
14+
android:id="@+id/shutter_button"
15+
android:layout_width="wrap_content"
16+
android:layout_height="wrap_content"
17+
android:layout_gravity="center"
18+
android:text="Take Picture" />
19+
20+
</LinearLayout>

res/menu/activity_camera.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<menu xmlns:android="http://schemas.android.com/apk/res/android">
2+
<item android:id="@+id/menu_settings"
3+
android:title="@string/menu_settings"
4+
android:orderInCategory="100"
5+
android:showAsAction="never" />
6+
</menu>

res/values-v11/styles.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<resources>
2+
3+
<style name="AppTheme" parent="android:Theme.Holo.Light" />
4+
5+
</resources>

res/values-v14/styles.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<resources>
2+
3+
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar" />
4+
5+
</resources>

res/values/strings.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<resources>
2+
3+
<string name="app_name">CameraExample</string>
4+
<string name="hello_world">Hello world!</string>
5+
<string name="menu_settings">Settings</string>
6+
<string name="title_activity_camera">CameraActivity</string>
7+
8+
</resources>

res/values/styles.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<resources>
2+
3+
<style name="AppTheme" parent="android:Theme.Light" />
4+
5+
</resources>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.example.cameraexample;
2+
3+
import android.hardware.Camera;
4+
import android.hardware.Camera.PictureCallback;
5+
import android.os.Bundle;
6+
import android.app.Activity;
7+
import android.view.Menu;
8+
import android.view.View;
9+
import android.view.View.OnClickListener;
10+
import android.widget.Button;
11+
import android.widget.FrameLayout;
12+
13+
public class CameraActivity extends Activity implements OnClickListener, PictureCallback {
14+
15+
CameraSurfaceView cameraSurfaceView;
16+
Button shutterButton;
17+
18+
@Override
19+
public void onCreate(Bundle savedInstanceState) {
20+
super.onCreate(savedInstanceState);
21+
setContentView(R.layout.activity_camera);
22+
23+
// set up our preview surface
24+
FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview);
25+
cameraSurfaceView = new CameraSurfaceView(this);
26+
preview.addView(cameraSurfaceView);
27+
28+
// grab out shutter button so we can reference it later
29+
shutterButton = (Button) findViewById(R.id.shutter_button);
30+
shutterButton.setOnClickListener(this);
31+
}
32+
33+
@Override
34+
public boolean onCreateOptionsMenu(Menu menu) {
35+
getMenuInflater().inflate(R.menu.activity_camera, menu);
36+
return true;
37+
}
38+
39+
@Override
40+
public void onClick(View v) {
41+
takePicture();
42+
}
43+
44+
private void takePicture() {
45+
shutterButton.setEnabled(false);
46+
cameraSurfaceView.takePicture(this);
47+
}
48+
49+
@Override
50+
public void onPictureTaken(byte[] data, Camera camera) {
51+
// TODO something with the image data
52+
53+
// Restart the preview and re-enable the shutter button so that we can take another picture
54+
camera.startPreview();
55+
shutterButton.setEnabled(true);
56+
}
57+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.example.cameraexample;
2+
3+
import java.io.IOException;
4+
5+
import android.content.Context;
6+
import android.hardware.Camera;
7+
import android.hardware.Camera.PictureCallback;
8+
import android.view.SurfaceHolder;
9+
import android.view.SurfaceView;
10+
11+
class CameraSurfaceView extends SurfaceView implements SurfaceHolder.Callback {
12+
13+
Camera camera;
14+
15+
CameraSurfaceView(Context context) {
16+
super(context);
17+
18+
// Install a SurfaceHolder.Callback so we get notified when the
19+
// underlying surface is created and destroyed.
20+
SurfaceHolder holder = this.getHolder();
21+
holder.addCallback(this);
22+
}
23+
24+
@Override
25+
public void surfaceChanged(SurfaceHolder holder, int format, int width,
26+
int height) {
27+
28+
// The default orientation is landscape, so for a portrait app like this
29+
// one we need to rotate the view 90 degrees.
30+
camera.setDisplayOrientation(90);
31+
32+
// IMPORTANT: We must call startPreview() on the camera before we take
33+
// any pictures
34+
camera.startPreview();
35+
}
36+
37+
@Override
38+
public void surfaceCreated(SurfaceHolder holder) {
39+
try {
40+
// Open the Camera in preview mode
41+
this.camera = Camera.open();
42+
this.camera.setPreviewDisplay(holder);
43+
} catch (IOException ioe) {
44+
ioe.printStackTrace(System.out);
45+
}
46+
47+
}
48+
49+
@Override
50+
public void surfaceDestroyed(SurfaceHolder holder) {
51+
// Surface will be destroyed when replaced with a new screen
52+
// Always make sure to release the Camera instance
53+
camera.stopPreview();
54+
camera.release();
55+
camera = null;
56+
}
57+
58+
@Override
59+
protected void onLayout(boolean changed, int l, int t, int r, int b) {
60+
// TODO Auto-generated method stub
61+
}
62+
63+
public void takePicture(PictureCallback imageCallback) {
64+
camera.takePicture(null, null, imageCallback);
65+
}
66+
67+
}

0 commit comments

Comments
 (0)