aboutsummaryrefslogtreecommitdiff
path: root/apps/TestingCamera
diff options
context:
space:
mode:
authorEino-Ville Talvala <etalvala@google.com>2012-07-30 15:50:09 -0700
committerEino-Ville Talvala <etalvala@google.com>2012-08-02 17:11:58 -0700
commit4ae1a87883045d820ffd6e1b8a95c13b1919e00a (patch)
treef779d0eaa57b2c2353c7479abbf2013b263c5f35 /apps/TestingCamera
parent9bf609a961cdb19fe96421c536a0aaba56492c94 (diff)
downloadpdk-4ae1a87883045d820ffd6e1b8a95c13b1919e00a.tar.gz
TestingCamera: Add camera info, camcorder profiles, improve UI
Bug: 6243944 Change-Id: I9e5412271afa9c8b759c21044097cf41d34eba44
Diffstat (limited to 'apps/TestingCamera')
-rw-r--r--apps/TestingCamera/.classpath4
-rw-r--r--apps/TestingCamera/Android.mk2
-rw-r--r--apps/TestingCamera/AndroidManifest.xml2
-rw-r--r--apps/TestingCamera/res/layout/fragment_info.xml29
-rw-r--r--apps/TestingCamera/res/layout/fragment_snapshot.xml30
-rw-r--r--apps/TestingCamera/res/layout/main.xml93
-rw-r--r--apps/TestingCamera/res/layout/snapshot_dialog.xml18
-rw-r--r--apps/TestingCamera/res/values/colors.xml5
-rw-r--r--apps/TestingCamera/res/values/dimens.xml5
-rw-r--r--apps/TestingCamera/res/values/strings.xml14
-rw-r--r--apps/TestingCamera/src/com/android/testingcamera/InfoDialogFragment.java68
-rw-r--r--apps/TestingCamera/src/com/android/testingcamera/SnapshotDialogFragment.java54
-rw-r--r--apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java205
13 files changed, 473 insertions, 56 deletions
diff --git a/apps/TestingCamera/.classpath b/apps/TestingCamera/.classpath
index a4763d1..3f9691c 100644
--- a/apps/TestingCamera/.classpath
+++ b/apps/TestingCamera/.classpath
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
diff --git a/apps/TestingCamera/Android.mk b/apps/TestingCamera/Android.mk
index d7e00d1..132679c 100644
--- a/apps/TestingCamera/Android.mk
+++ b/apps/TestingCamera/Android.mk
@@ -22,6 +22,8 @@ LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_STATIC_JAVA_LIBRARIES += android-support-v4
+
LOCAL_PACKAGE_NAME := TestingCamera
include $(BUILD_PACKAGE)
diff --git a/apps/TestingCamera/AndroidManifest.xml b/apps/TestingCamera/AndroidManifest.xml
index a897e9d..bb48524 100644
--- a/apps/TestingCamera/AndroidManifest.xml
+++ b/apps/TestingCamera/AndroidManifest.xml
@@ -22,7 +22,7 @@
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
- <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="16"/>
+ <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="16"/>
<uses-feature android:name="android.hardware.camera.front" android:required="false"/>
<application
android:icon="@mipmap/launcher_testingcamera"
diff --git a/apps/TestingCamera/res/layout/fragment_info.xml b/apps/TestingCamera/res/layout/fragment_info.xml
new file mode 100644
index 0000000..c3d229e
--- /dev/null
+++ b/apps/TestingCamera/res/layout/fragment_info.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <ScrollView
+ android:id="@+id/info_text_scroll"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1" >
+
+ <TextView
+ android:id="@+id/info_text"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:paddingLeft="3dp"
+ android:paddingRight="3dp" />
+
+ </ScrollView>
+
+ <Button
+ android:id="@+id/info_ok_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center"
+ android:text="@string/info_ok_button_label" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/apps/TestingCamera/res/layout/fragment_snapshot.xml b/apps/TestingCamera/res/layout/fragment_snapshot.xml
new file mode 100644
index 0000000..faf141f
--- /dev/null
+++ b/apps/TestingCamera/res/layout/fragment_snapshot.xml
@@ -0,0 +1,30 @@
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/layout_root"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical"
+ android:padding="10dp" >
+
+ <ImageView
+ android:id="@+id/snapshot_image"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginRight="10dp"
+ android:layout_weight="4"
+ android:contentDescription="@string/still_image_description" />
+
+ <TextView
+ android:id="@+id/snapshot_text"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/snapshot_text_default"
+ android:textColor="#FFF" />
+
+ <Button
+ android:id="@+id/snapshot_ok"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/snapshot_ok_label" />
+
+</LinearLayout>
diff --git a/apps/TestingCamera/res/layout/main.xml b/apps/TestingCamera/res/layout/main.xml
index 5485f42..06f3628 100644
--- a/apps/TestingCamera/res/layout/main.xml
+++ b/apps/TestingCamera/res/layout/main.xml
@@ -44,14 +44,27 @@
android:id="@+id/control_bar"
android:layout_width="0px"
android:layout_height="match_parent"
- android:layout_weight="2" >
+ android:layout_weight="2"
+ android:fadingEdgeLength="100dp"
+ android:requiresFadingEdge="vertical"
+ android:scrollbarAlwaysDrawVerticalTrack="true" >
<LinearLayout
android:id="@+id/control_bar_contents"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginLeft="5dp"
android:orientation="vertical" >
+ <TextView
+ android:id="@+id/camera_spinner_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="5dp"
+ android:layout_weight="1"
+ android:text="@string/camera_selection_prompt"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
<Spinner
android:id="@+id/camera_spinner"
android:layout_width="fill_parent"
@@ -59,6 +72,29 @@
android:layout_weight="1"
android:prompt="@string/camera_selection_prompt" />
+ <Button
+ android:id="@+id/info_button"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/show_info" />
+
+ <View
+ android:id="@+id/horizontal_rule_1"
+ android:layout_width="fill_parent"
+ android:layout_height="1dip"
+ android:layout_marginBottom="@dimen/horiz_rule_btm_margin"
+ android:layout_marginTop="@dimen/horiz_rule_top_margin"
+ android:background="@color/horiz_rule_color" />
+
+ <TextView
+ android:id="@+id/preview_size_spinner_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/preview_resolution_prompt"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
<Spinner
android:id="@+id/preview_size_spinner"
android:layout_width="fill_parent"
@@ -71,9 +107,33 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
+ android:textColorLink="@android:color/holo_blue_light"
android:textOff="@string/preview_off_label"
android:textOn="@string/preview_on_label" />
+ <View
+ android:id="@+id/horizontal_rule_2"
+ android:layout_width="fill_parent"
+ android:layout_height="1dip"
+ android:layout_marginBottom="@dimen/horiz_rule_btm_margin"
+ android:layout_marginTop="@dimen/horiz_rule_top_margin"
+ android:layout_weight="1"
+ android:background="@color/horiz_rule_color" />
+
+ <TextView
+ android:id="@+id/textView1"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/snapshot_size_spinner_label"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <Spinner
+ android:id="@+id/snapshot_size_spinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" />
+
<Button
android:id="@+id/take_picture"
android:layout_width="fill_parent"
@@ -81,6 +141,37 @@
android:layout_weight="1"
android:text="@string/take_picture_label" />
+ <View
+ android:id="@+id/horizontal_rule_3"
+ android:layout_width="fill_parent"
+ android:layout_height="1dip"
+ android:layout_marginBottom="@dimen/horiz_rule_btm_margin"
+ android:layout_marginTop="@dimen/horiz_rule_top_margin"
+ android:layout_weight="1"
+ android:background="@color/horiz_rule_color" />
+
+ <TextView
+ android:id="@+id/camcorder_profile_spinner_label"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="@string/camcorder_profile_prompt"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+
+ <Spinner
+ android:id="@+id/camcorder_profile_spinner"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1" />
+
+ <ToggleButton
+ android:id="@+id/start_record"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:textColorLink="@android:color/holo_red_dark"
+ android:textOff="@string/record_off_label"
+ android:textOn="@string/record_on_label" />
</LinearLayout>
</ScrollView>
diff --git a/apps/TestingCamera/res/layout/snapshot_dialog.xml b/apps/TestingCamera/res/layout/snapshot_dialog.xml
deleted file mode 100644
index 1e84b14..0000000
--- a/apps/TestingCamera/res/layout/snapshot_dialog.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/layout_root"
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:padding="10dp"
- >
- <ImageView android:id="@+id/snapshot_image"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:layout_marginRight="10dp"
- />
- <TextView android:id="@+id/snapshot_text"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:textColor="#FFF"
- />
-</LinearLayout>
diff --git a/apps/TestingCamera/res/values/colors.xml b/apps/TestingCamera/res/values/colors.xml
new file mode 100644
index 0000000..8e09e17
--- /dev/null
+++ b/apps/TestingCamera/res/values/colors.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="horiz_rule_color">#777777</color>
+
+</resources> \ No newline at end of file
diff --git a/apps/TestingCamera/res/values/dimens.xml b/apps/TestingCamera/res/values/dimens.xml
new file mode 100644
index 0000000..dbea0fa
--- /dev/null
+++ b/apps/TestingCamera/res/values/dimens.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <dimen name="horiz_rule_top_margin">8dp</dimen>
+ <dimen name="horiz_rule_btm_margin">4dp</dimen>
+</resources>
diff --git a/apps/TestingCamera/res/values/strings.xml b/apps/TestingCamera/res/values/strings.xml
index 45ddaa2..69c57da 100644
--- a/apps/TestingCamera/res/values/strings.xml
+++ b/apps/TestingCamera/res/values/strings.xml
@@ -21,7 +21,17 @@
<string name="preview_on_label">Preview On</string>
<string name="preview_off_label">Preview Off</string>
<string name="take_picture_label">Take picture</string>
- <string name="preview_resolution_prompt">Select preview resolution</string>
- <string name="camera_selection_prompt">Select camera</string>
+ <string name="preview_resolution_prompt">Preview size</string>
+ <string name="camera_selection_prompt">Camera ID</string>
<string name="default_camera_entry">No cameras found</string>
+ <string name="snapshot_text_default">Snapshot text</string>
+ <string name="snapshot_size_spinner_label">Still capture size</string>
+ <string name="record_on_label">Recording on</string>
+ <string name="record_off_label">Recording off</string>
+ <string name="camcorder_profile_prompt">Camcorder profile</string>
+ <string name="horiz_rule_color">#777777</string>
+ <string name="show_info">Info</string>
+ <string name="info_ok_button_label">OK</string>
+ <string name="snapshot_ok_label">OK</string>
+ <string name="still_image_description">Captured still image</string>
</resources>
diff --git a/apps/TestingCamera/src/com/android/testingcamera/InfoDialogFragment.java b/apps/TestingCamera/src/com/android/testingcamera/InfoDialogFragment.java
new file mode 100644
index 0000000..ce76f6b
--- /dev/null
+++ b/apps/TestingCamera/src/com/android/testingcamera/InfoDialogFragment.java
@@ -0,0 +1,68 @@
+package com.android.testingcamera;
+
+import android.hardware.Camera;
+import android.hardware.Camera.CameraInfo;
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
+
+public class InfoDialogFragment extends DialogFragment implements View.OnClickListener {
+
+ Button mOkButton;
+ TextView mInfoText;
+
+ String mTitleString = "";
+ String mInfoString = "";
+
+ public InfoDialogFragment() {
+ // Empty constructor required for DialogFragment
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_info, container);
+
+ mOkButton = (Button) view.findViewById(R.id.info_ok_button);
+ mOkButton.setOnClickListener(this);
+
+ mInfoText= (TextView) view.findViewById(R.id.info_text);
+ mInfoText.setText(mInfoString);
+
+ getDialog().setTitle(mTitleString);
+ return view;
+ }
+
+ @Override
+ public void onClick(View v) {
+ this.dismiss();
+ }
+
+ public void updateInfo(int cameraId, Camera camera) {
+ mTitleString = "Current camera " + cameraId + " state";
+ StringBuilder b = new StringBuilder();
+
+ CameraInfo cameraInfo = new CameraInfo();
+ Camera.getCameraInfo(cameraId, cameraInfo);
+ b.append("getInfo() output:\n");
+ b.append(" Facing: ");
+ b.append(cameraInfo.facing == CameraInfo.CAMERA_FACING_FRONT ? "FRONT\n" : "BACK\n");
+ b.append(" Orientation: ");
+ b.append(cameraInfo.orientation);
+ b.append("\n\n");
+ b.append("getParameters() output:\n ");
+ Camera.Parameters p = camera.getParameters();
+ String[] flatP = p.flatten().split(";");
+ for (String param : flatP) {
+ b.append(param);
+ b.append("\n ");
+ }
+
+ mInfoString = b.toString();
+ }
+
+}
diff --git a/apps/TestingCamera/src/com/android/testingcamera/SnapshotDialogFragment.java b/apps/TestingCamera/src/com/android/testingcamera/SnapshotDialogFragment.java
new file mode 100644
index 0000000..2fe82e6
--- /dev/null
+++ b/apps/TestingCamera/src/com/android/testingcamera/SnapshotDialogFragment.java
@@ -0,0 +1,54 @@
+package com.android.testingcamera;
+import com.android.testingcamera.R;
+
+import android.graphics.Bitmap;
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+public class SnapshotDialogFragment extends DialogFragment implements View.OnClickListener{
+
+ private ImageView mInfoImage;
+ private TextView mInfoText;
+ private Button mOkButton;
+
+ private Bitmap mImage;
+ private String mImageString;
+
+
+ public SnapshotDialogFragment() {
+ // Empty constructor required for DialogFragment
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_snapshot, container);
+
+ mOkButton = (Button) view.findViewById(R.id.snapshot_ok);
+ mOkButton.setOnClickListener(this);
+
+ mInfoImage = (ImageView) view.findViewById(R.id.snapshot_image);
+ mInfoImage.setImageBitmap(mImage);
+ mInfoText= (TextView) view.findViewById(R.id.snapshot_text);
+ mInfoText.setText(mImageString);
+
+ getDialog().setTitle("Snapshot result");
+ return view;
+ }
+
+ @Override
+ public void onClick(View v) {
+ // TODO Auto-generated method stub
+ this.dismiss();
+ }
+
+ public void updateImage(Bitmap image) {
+ mImage = image;
+ }
+}
diff --git a/apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java b/apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java
index 645dc61..cefb8a4 100644
--- a/apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java
+++ b/apps/TestingCamera/src/com/android/testingcamera/TestingCamera.java
@@ -21,10 +21,12 @@ import android.app.Dialog;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.hardware.Camera;
+import android.media.CamcorderProfile;
import android.os.Bundle;
import android.view.View;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
+import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
@@ -34,6 +36,8 @@ import android.widget.Spinner;
import android.widget.CompoundButton;
import android.widget.TextView;
import android.widget.ToggleButton;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentManager;
import android.util.Log;
import java.io.IOException;
@@ -48,19 +52,20 @@ import java.util.TreeSet;
* The goal of this application is to allow all camera API features to be
* excercised, and all information provided by the API to be shown.
*/
-public class TestingCamera extends Activity implements SurfaceHolder.Callback {
+public class TestingCamera extends FragmentActivity implements SurfaceHolder.Callback {
/** UI elements */
private SurfaceView mPreviewView;
private SurfaceHolder mPreviewHolder;
private Spinner mCameraSpinner;
+ private Button mInfoButton;
private Spinner mPreviewSizeSpinner;
private ToggleButton mPreviewToggle;
+ private Spinner mSnapshotSizeSpinner;
private Button mTakePictureButton;
-
- private TextView mSnapshotText;
- private ImageView mSnapshotImg;
+ private Spinner mCamcorderProfileSpinner;
+ private ToggleButton mRecordToggle;
/** Camera state */
private int mCameraId = 0;
@@ -68,6 +73,10 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback {
private Camera.Parameters mParams;
private List<Camera.Size> mPreviewSizes;
private int mPreviewSize = 0;
+ private List<Camera.Size> mSnapshotSizes;
+ private int mSnapshotSize = 0;
+ private List<CamcorderProfile> mCamcorderProfiles;
+ private int mCamcorderProfile = 0;
private static final int CAMERA_UNINITIALIZED = 0;
private static final int CAMERA_OPEN = 1;
@@ -92,15 +101,27 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback {
mCameraSpinner = (Spinner) findViewById(R.id.camera_spinner);
mCameraSpinner.setOnItemSelectedListener(mCameraSpinnerListener);
+ mInfoButton = (Button) findViewById(R.id.info_button);
+ mInfoButton.setOnClickListener(mInfoButtonListener);
+
mPreviewSizeSpinner = (Spinner) findViewById(R.id.preview_size_spinner);
mPreviewSizeSpinner.setOnItemSelectedListener(mPreviewSizeListener);
mPreviewToggle = (ToggleButton) findViewById(R.id.start_preview);
mPreviewToggle.setOnClickListener(mPreviewToggleListener);
+ mSnapshotSizeSpinner = (Spinner) findViewById(R.id.snapshot_size_spinner);
+ mSnapshotSizeSpinner.setOnItemSelectedListener(mSnapshotSizeListener);
+
mTakePictureButton = (Button) findViewById(R.id.take_picture);
mTakePictureButton.setOnClickListener(mTakePictureListener);
+ mCamcorderProfileSpinner = (Spinner) findViewById(R.id.camcorder_profile_spinner);
+ mCamcorderProfileSpinner.setOnItemSelectedListener(mCamcorderProfileListener);
+
+ mRecordToggle = (ToggleButton) findViewById(R.id.start_record);
+ mRecordToggle.setOnClickListener(mRecordToggleListener);
+
int numCameras = Camera.getNumberOfCameras();
String[] cameraNames = new String[numCameras];
for (int i = 0; i < numCameras; i++) {
@@ -127,21 +148,6 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback {
mState = CAMERA_UNINITIALIZED;
}
- protected Dialog onCreateDialog(int id) {
- Dialog dialog = new Dialog(this);
- dialog.setContentView(R.layout.snapshot_dialog);
- dialog.setTitle("Snapshot");
-
- mSnapshotText =
- (TextView) dialog.findViewById(R.id.snapshot_text);
- mSnapshotText.setText("Snapshot title");
-
- mSnapshotImg =
- (ImageView) dialog.findViewById(R.id.snapshot_image);
-
- return dialog;
- }
-
// SurfaceHolder.Callback methods
@Override
public void surfaceChanged(SurfaceHolder holder,
@@ -174,19 +180,31 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback {
// UI listeners
private AdapterView.OnItemSelectedListener mCameraSpinnerListener =
- new AdapterView.OnItemSelectedListener() {
- public void onItemSelected(AdapterView<?> parent,
+ new AdapterView.OnItemSelectedListener() {
+ public void onItemSelected(AdapterView<?> parent,
View view, int pos, long id) {
- if (mCameraId != pos) {
+ if (mCameraId != pos) {
mCameraId = pos;
setUpCamera();
- }
}
+ }
- public void onNothingSelected(AdapterView parent) {
+ public void onNothingSelected(AdapterView parent) {
+ }
+ };
+
+ private OnClickListener mInfoButtonListener = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ FragmentManager fm = getSupportFragmentManager();
+ InfoDialogFragment infoDialog = new InfoDialogFragment();
+ infoDialog.updateInfo(mCameraId, mCamera);
+ infoDialog.show(fm, "info_dialog_fragment");
}
- };
+
+ };
private AdapterView.OnItemSelectedListener mPreviewSizeListener =
new AdapterView.OnItemSelectedListener() {
@@ -241,6 +259,26 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback {
}
};
+ private AdapterView.OnItemSelectedListener mSnapshotSizeListener =
+ new AdapterView.OnItemSelectedListener() {
+ public void onItemSelected(AdapterView<?> parent,
+ View view, int pos, long id) {
+ if (pos == mSnapshotSize) return;
+ Log.d(TAG, "Switching snapshot sizes");
+
+ mSnapshotSize = pos;
+ int width = mSnapshotSizes.get(mSnapshotSize).width;
+ int height = mSnapshotSizes.get(mSnapshotSize).height;
+ mParams.setPictureSize(width, height);
+
+ mCamera.setParameters(mParams);
+ }
+
+ public void onNothingSelected(AdapterView parent) {
+
+ }
+ };
+
private View.OnClickListener mTakePictureListener =
new View.OnClickListener() {
public void onClick(View v) {
@@ -259,6 +297,24 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback {
}
};
+ private AdapterView.OnItemSelectedListener mCamcorderProfileListener =
+ new AdapterView.OnItemSelectedListener() {
+ public void onItemSelected(AdapterView<?> parent,
+ View view, int pos, long id) {
+ mCamcorderProfile = pos;
+ }
+
+ public void onNothingSelected(AdapterView parent) {
+
+ }
+ };
+
+ private View.OnClickListener mRecordToggleListener =
+ new View.OnClickListener() {
+ public void onClick(View v) {
+ }
+ };
+
private Camera.ShutterCallback mShutterCb = new Camera.ShutterCallback() {
public void onShutter() {
Log.d(TAG, "Shutter cb fired");
@@ -280,11 +336,12 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback {
private Camera.PictureCallback mJpegCb = new Camera.PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
Log.d(TAG, "JPEG cb fired");
-
- showDialog(1);
+ FragmentManager fm = getSupportFragmentManager();
+ SnapshotDialogFragment snapshotDialog = new SnapshotDialogFragment();
Bitmap img = BitmapFactory.decodeByteArray(data, 0, data.length);
- mSnapshotImg.setImageBitmap(img);
+ snapshotDialog.updateImage(img);
+ snapshotDialog.show(fm, "snapshot_dialog_fragment");
mPreviewToggle.setEnabled(true);
@@ -306,13 +363,16 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback {
mState = CAMERA_OPEN;
mParams = mCamera.getParameters();
+
+ // Set up preview size selection
mPreviewSizes = mParams.getSupportedPreviewSizes();
String[] availableSizeNames = new String[mPreviewSizes.size()];
- for (int i = 0; i < mPreviewSizes.size(); i++) {
- availableSizeNames[i] =
- Integer.toString(mPreviewSizes.get(i).width) + " x " +
- Integer.toString(mPreviewSizes.get(i).height);
+ int i = 0;
+ for (Camera.Size previewSize: mPreviewSizes) {
+ availableSizeNames[i++] =
+ Integer.toString(previewSize.width) + " x " +
+ Integer.toString(previewSize.height);
}
mPreviewSizeSpinner.setAdapter(
new ArrayAdapter<String>(
@@ -324,6 +384,32 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback {
int height = mPreviewSizes.get(mPreviewSize).height;
mParams.setPreviewSize(width, height);
+ // Set up snapshot size selection
+
+ mSnapshotSizes = mParams.getSupportedPictureSizes();
+
+ availableSizeNames = new String[mSnapshotSizes.size()];
+ i = 0;
+ for (Camera.Size snapshotSize : mSnapshotSizes) {
+ availableSizeNames[i++] =
+ Integer.toString(snapshotSize.width) + " x " +
+ Integer.toString(snapshotSize.height);
+ }
+ mSnapshotSizeSpinner.setAdapter(
+ new ArrayAdapter<String>(
+ this, R.layout.spinner_item, availableSizeNames));
+
+ mSnapshotSize = 0;
+
+ width = mSnapshotSizes.get(mSnapshotSize).width;
+ height = mSnapshotSizes.get(mSnapshotSize).height;
+ mParams.setPictureSize(width, height);
+
+ // Set up camcorder profile selection
+ updateCamcorderProfile(mCameraId);
+
+ // Update parameters based on above defaults
+
mCamera.setParameters(mParams);
if (mPreviewHolder != null) {
@@ -346,6 +432,61 @@ public class TestingCamera extends Activity implements SurfaceHolder.Callback {
}
}
+ private void updateCamcorderProfile(int cameraId) {
+ // Have to query all of these individually,
+ final int PROFILES[] = new int[] {
+ CamcorderProfile.QUALITY_1080P,
+ CamcorderProfile.QUALITY_480P,
+ CamcorderProfile.QUALITY_720P,
+ CamcorderProfile.QUALITY_CIF,
+ CamcorderProfile.QUALITY_HIGH,
+ CamcorderProfile.QUALITY_LOW,
+ CamcorderProfile.QUALITY_QCIF,
+ CamcorderProfile.QUALITY_QVGA,
+ CamcorderProfile.QUALITY_TIME_LAPSE_1080P,
+ CamcorderProfile.QUALITY_TIME_LAPSE_480P,
+ CamcorderProfile.QUALITY_TIME_LAPSE_720P,
+ CamcorderProfile.QUALITY_TIME_LAPSE_CIF,
+ CamcorderProfile.QUALITY_TIME_LAPSE_HIGH,
+ CamcorderProfile.QUALITY_TIME_LAPSE_LOW,
+ CamcorderProfile.QUALITY_TIME_LAPSE_QCIF,
+ CamcorderProfile.QUALITY_TIME_LAPSE_QVGA
+ };
+
+ final String PROFILE_NAMES[] = new String[] {
+ "1080P",
+ "480P",
+ "720P",
+ "CIF",
+ "HIGH",
+ "LOW",
+ "QCIF",
+ "QVGA",
+ "TIME_LAPSE_1080P",
+ "TIME_LAPSE_480P",
+ "TIME_LAPSE_720P",
+ "TIME_LAPSE_CIF",
+ "TIME_LAPSE_HIGH",
+ "TIME_LAPSE_LOW",
+ "TIME_LAPSE_QCIF",
+ "TIME_LAPSE_QVGA"
+ };
+
+ List<String> availableCamcorderProfileNames = new ArrayList<String>();
+ mCamcorderProfiles = new ArrayList<CamcorderProfile>();
+
+ for (int i = 0; i < PROFILES.length; i++) {
+ if (CamcorderProfile.hasProfile(cameraId, PROFILES[i])) {
+ availableCamcorderProfileNames.add(PROFILE_NAMES[i]);
+ mCamcorderProfiles.add(CamcorderProfile.get(cameraId, PROFILES[i]));
+ }
+ }
+ String[] nameArray = (String[])availableCamcorderProfileNames.toArray(new String[0]);
+ mCamcorderProfileSpinner.setAdapter(
+ new ArrayAdapter<String>(
+ this, R.layout.spinner_item, nameArray));
+ }
+
void resizePreview(int width, int height) {
if (mPreviewHolder != null) {
int viewHeight = mPreviewView.getHeight();