summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorByunghun Jeon <bjeon@codeaurora.org>2016-09-16 12:59:14 -0700
committerByunghun Jeon <bjeon@codeaurora.org>2016-11-14 11:01:16 -0800
commit70790e941a1c23dc62b2bf06236cb4d8dde2bec9 (patch)
treea13050484ff747e0e4587ae0d30153ebaf906591
parentea7548840f9152b636e75f36b3ef9cd66f363108 (diff)
downloadandroid_packages_apps_Snap-70790e941a1c23dc62b2bf06236cb4d8dde2bec9.tar.gz
android_packages_apps_Snap-70790e941a1c23dc62b2bf06236cb4d8dde2bec9.tar.bz2
android_packages_apps_Snap-70790e941a1c23dc62b2bf06236cb4d8dde2bec9.zip
SnapdragonCamera: Add ProMode
Add ProMode. User can change iso, white balance, exposure, and focus mode using this new scene mode Change-Id: I58885d3a05d6d9e8264e58cb8c4de2e1f13646b0 CRs-Fixed: 1089100
-rw-r--r--res/drawable/auto_blue.pngbin0 -> 15604 bytes
-rw-r--r--res/drawable/cloudy.pngbin0 -> 15579 bytes
-rw-r--r--res/drawable/cloudy_blue.pngbin0 -> 16055 bytes
-rw-r--r--res/drawable/fluorescent.pngbin0 -> 15489 bytes
-rw-r--r--res/drawable/fluorescent_blue.pngbin0 -> 15780 bytes
-rw-r--r--res/drawable/icon_exposure.pngbin0 -> 15376 bytes
-rw-r--r--res/drawable/icon_exposure_blue.pngbin0 -> 15822 bytes
-rw-r--r--res/drawable/icon_iso.pngbin0 -> 15154 bytes
-rw-r--r--res/drawable/icon_iso_blue.pngbin0 -> 15587 bytes
-rw-r--r--res/drawable/icon_manual.pngbin0 -> 15598 bytes
-rw-r--r--res/drawable/icon_manual_blue.pngbin0 -> 16161 bytes
-rw-r--r--res/drawable/icon_white_balance.pngbin0 -> 15152 bytes
-rw-r--r--res/drawable/icon_white_balance_blue.pngbin0 -> 15610 bytes
-rw-r--r--res/drawable/icon_x.pngbin0 -> 14900 bytes
-rw-r--r--res/drawable/incandecent.pngbin0 -> 15932 bytes
-rw-r--r--res/drawable/incandecent_blue.pngbin0 -> 16688 bytes
-rw-r--r--res/drawable/promode.pngbin0 -> 15598 bytes
-rw-r--r--res/drawable/radial_menu.pngbin0 -> 29304 bytes
-rw-r--r--res/drawable/selected_dot.pngbin0 -> 15155 bytes
-rw-r--r--res/drawable/sunlight.pngbin0 -> 16575 bytes
-rw-r--r--res/drawable/sunlight_blue.pngbin0 -> 17676 bytes
-rw-r--r--res/drawable/white_dot.pngbin0 -> 14571 bytes
-rw-r--r--res/layout/one_ui_layout.xml12
-rw-r--r--res/layout/pro_mode_layout.xml148
-rw-r--r--res/values/camera2arrays.xml3
-rw-r--r--res/values/qcomstrings.xml1
-rw-r--r--src/com/android/camera/CaptureModule.java51
-rw-r--r--src/com/android/camera/CaptureUI.java14
-rw-r--r--src/com/android/camera/SettingsManager.java39
-rw-r--r--src/com/android/camera/ui/OneUICameraControls.java160
-rw-r--r--src/com/android/camera/ui/ProMode.java372
31 files changed, 779 insertions, 21 deletions
diff --git a/res/drawable/auto_blue.png b/res/drawable/auto_blue.png
new file mode 100644
index 000000000..acf632e16
--- /dev/null
+++ b/res/drawable/auto_blue.png
Binary files differ
diff --git a/res/drawable/cloudy.png b/res/drawable/cloudy.png
new file mode 100644
index 000000000..b29ab9e5d
--- /dev/null
+++ b/res/drawable/cloudy.png
Binary files differ
diff --git a/res/drawable/cloudy_blue.png b/res/drawable/cloudy_blue.png
new file mode 100644
index 000000000..303a2703e
--- /dev/null
+++ b/res/drawable/cloudy_blue.png
Binary files differ
diff --git a/res/drawable/fluorescent.png b/res/drawable/fluorescent.png
new file mode 100644
index 000000000..d25f7473e
--- /dev/null
+++ b/res/drawable/fluorescent.png
Binary files differ
diff --git a/res/drawable/fluorescent_blue.png b/res/drawable/fluorescent_blue.png
new file mode 100644
index 000000000..7fb7836dd
--- /dev/null
+++ b/res/drawable/fluorescent_blue.png
Binary files differ
diff --git a/res/drawable/icon_exposure.png b/res/drawable/icon_exposure.png
new file mode 100644
index 000000000..ff5397251
--- /dev/null
+++ b/res/drawable/icon_exposure.png
Binary files differ
diff --git a/res/drawable/icon_exposure_blue.png b/res/drawable/icon_exposure_blue.png
new file mode 100644
index 000000000..544b98ab4
--- /dev/null
+++ b/res/drawable/icon_exposure_blue.png
Binary files differ
diff --git a/res/drawable/icon_iso.png b/res/drawable/icon_iso.png
new file mode 100644
index 000000000..85662af5e
--- /dev/null
+++ b/res/drawable/icon_iso.png
Binary files differ
diff --git a/res/drawable/icon_iso_blue.png b/res/drawable/icon_iso_blue.png
new file mode 100644
index 000000000..001d8c9f5
--- /dev/null
+++ b/res/drawable/icon_iso_blue.png
Binary files differ
diff --git a/res/drawable/icon_manual.png b/res/drawable/icon_manual.png
new file mode 100644
index 000000000..53e2ff5ec
--- /dev/null
+++ b/res/drawable/icon_manual.png
Binary files differ
diff --git a/res/drawable/icon_manual_blue.png b/res/drawable/icon_manual_blue.png
new file mode 100644
index 000000000..52b2daa19
--- /dev/null
+++ b/res/drawable/icon_manual_blue.png
Binary files differ
diff --git a/res/drawable/icon_white_balance.png b/res/drawable/icon_white_balance.png
new file mode 100644
index 000000000..1fbd36fd3
--- /dev/null
+++ b/res/drawable/icon_white_balance.png
Binary files differ
diff --git a/res/drawable/icon_white_balance_blue.png b/res/drawable/icon_white_balance_blue.png
new file mode 100644
index 000000000..ca84b89d8
--- /dev/null
+++ b/res/drawable/icon_white_balance_blue.png
Binary files differ
diff --git a/res/drawable/icon_x.png b/res/drawable/icon_x.png
new file mode 100644
index 000000000..a807409c8
--- /dev/null
+++ b/res/drawable/icon_x.png
Binary files differ
diff --git a/res/drawable/incandecent.png b/res/drawable/incandecent.png
new file mode 100644
index 000000000..d601e4b5c
--- /dev/null
+++ b/res/drawable/incandecent.png
Binary files differ
diff --git a/res/drawable/incandecent_blue.png b/res/drawable/incandecent_blue.png
new file mode 100644
index 000000000..0c3eabf13
--- /dev/null
+++ b/res/drawable/incandecent_blue.png
Binary files differ
diff --git a/res/drawable/promode.png b/res/drawable/promode.png
new file mode 100644
index 000000000..53e2ff5ec
--- /dev/null
+++ b/res/drawable/promode.png
Binary files differ
diff --git a/res/drawable/radial_menu.png b/res/drawable/radial_menu.png
new file mode 100644
index 000000000..a5757f1a0
--- /dev/null
+++ b/res/drawable/radial_menu.png
Binary files differ
diff --git a/res/drawable/selected_dot.png b/res/drawable/selected_dot.png
new file mode 100644
index 000000000..9114f6ce6
--- /dev/null
+++ b/res/drawable/selected_dot.png
Binary files differ
diff --git a/res/drawable/sunlight.png b/res/drawable/sunlight.png
new file mode 100644
index 000000000..cc33dcc3d
--- /dev/null
+++ b/res/drawable/sunlight.png
Binary files differ
diff --git a/res/drawable/sunlight_blue.png b/res/drawable/sunlight_blue.png
new file mode 100644
index 000000000..c390ec653
--- /dev/null
+++ b/res/drawable/sunlight_blue.png
Binary files differ
diff --git a/res/drawable/white_dot.png b/res/drawable/white_dot.png
new file mode 100644
index 000000000..847fd84fe
--- /dev/null
+++ b/res/drawable/white_dot.png
Binary files differ
diff --git a/res/layout/one_ui_layout.xml b/res/layout/one_ui_layout.xml
index 2a87b6cd2..de6c8b401 100644
--- a/res/layout/one_ui_layout.xml
+++ b/res/layout/one_ui_layout.xml
@@ -21,6 +21,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
+ <com.android.camera.ui.ProMode
+ android:id="@+id/promode_slider"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content" />
+
<com.android.camera.ui.FlashToggleButton
android:id="@+id/flash_button"
style="@style/OneUIMenuButton"
@@ -156,4 +161,11 @@
android:visibility="gone" />
</LinearLayout>
+ <include layout="@layout/pro_mode_layout" />
+
+ <ImageView
+ android:id="@+id/promode_close_button"
+ android:layout_height="20dp"
+ android:layout_width="20dp"
+ android:src="@drawable/icon_x" />
</com.android.camera.ui.OneUICameraControls>
diff --git a/res/layout/pro_mode_layout.xml b/res/layout/pro_mode_layout.xml
new file mode 100644
index 000000000..54ccb556c
--- /dev/null
+++ b/res/layout/pro_mode_layout.xml
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2016, The Linux Foundation. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/pro_mode_layout"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:visibility="invisible">
+
+ <com.android.camera.ui.RotateLayout
+ android:id="@+id/exposure_rotate_layout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1">
+
+ <LinearLayout
+ android:id="@+id/exposure_layout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:orientation="vertical">
+
+ <ImageView
+ android:id="@+id/exposure"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
+ android:layout_gravity="center"
+ android:src="@drawable/icon_exposure" />
+
+ <TextView
+ android:id="@+id/exposure_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center" />
+ </LinearLayout>
+ </com.android.camera.ui.RotateLayout>
+
+ <com.android.camera.ui.RotateLayout
+ android:id="@+id/manual_rotate_layout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1">
+
+ <LinearLayout
+ android:id="@+id/manual_layout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:orientation="vertical">
+
+ <ImageView
+ android:id="@+id/manual"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
+ android:layout_gravity="center"
+ android:src="@drawable/icon_manual" />
+
+ <TextView
+ android:id="@+id/manual_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center" />
+ </LinearLayout>
+ </com.android.camera.ui.RotateLayout>
+
+ <com.android.camera.ui.RotateLayout
+ android:id="@+id/white_balance_rotate_layout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1">
+
+ <LinearLayout
+ android:id="@+id/white_balance_layout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:orientation="vertical">
+
+ <ImageView
+ android:id="@+id/white_balance"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
+ android:layout_gravity="center"
+ android:src="@drawable/icon_white_balance" />
+
+ <TextView
+ android:id="@+id/white_balance_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center" />
+ </LinearLayout>
+ </com.android.camera.ui.RotateLayout>
+
+ <com.android.camera.ui.RotateLayout
+ android:id="@+id/iso_rotate_layout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1">
+
+ <LinearLayout
+ android:id="@+id/iso_layout"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:gravity="center"
+ android:orientation="vertical">
+
+ <ImageView
+ android:id="@+id/iso"
+ android:layout_width="30dp"
+ android:layout_height="30dp"
+ android:layout_gravity="center"
+ android:src="@drawable/icon_iso" />
+
+ <TextView
+ android:id="@+id/iso_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center" />
+ </LinearLayout>
+ </com.android.camera.ui.RotateLayout>
+
+</LinearLayout>
diff --git a/res/values/camera2arrays.xml b/res/values/camera2arrays.xml
index 80c695d58..31d6b5a62 100644
--- a/res/values/camera2arrays.xml
+++ b/res/values/camera2arrays.xml
@@ -157,6 +157,7 @@
<item>107</item>
<item>108</item>
<item>104</item>
+ <item>109</item>
</string-array>
<!-- Camera Preferences Scene Mode dialog box entries -->
@@ -183,6 +184,7 @@
<item>@string/pref_camera_scenemode_entry_sharpshooter</item>
<item>@string/pref_camera_scenemode_entry_trackingfocus</item>
<item>@string/pref_camera_scenemode_entry_panorama</item>
+ <item>@string/pref_camera_scenemode_entry_promode</item>
</string-array>
<array name="pref_camera2_scenemode_thumbnails" translatable="false">
@@ -208,6 +210,7 @@
<item>@drawable/sharp_photo</item>
<item>@drawable/tracking_focus</item>
<item>@drawable/scene_panorama</item>
+ <item>@drawable/promode</item>
</array>
<string-array name="pref_camera2_whitebalance_entryvalues" translatable="false">
diff --git a/res/values/qcomstrings.xml b/res/values/qcomstrings.xml
index 34c9b32cf..df14f54de 100644
--- a/res/values/qcomstrings.xml
+++ b/res/values/qcomstrings.xml
@@ -1029,6 +1029,7 @@
<string name="pref_camera_scenemode_entry_sharpshooter" translatable="true">SharpPhoto</string>
<string name="pref_camera_scenemode_entry_trackingfocus" translatable="true">TrackingFocus</string>
<string name="pref_camera_scenemode_entry_panorama" translatable="true">Panorama</string>
+ <string name="pref_camera_scenemode_entry_promode" translatable="true">ProMode</string>
<string name="bestpicture_done" translatable="true">DONE</string>
<string name="bestpicture_at_least_one_picture" translatable="true">At least, one picture has to be chosen.</string>
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 1f33c1022..6541df0f6 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -193,6 +193,12 @@ public class CaptureModule implements CameraModule, PhotoController,
public static CameraCharacteristics.Key<Byte> MetaDataMonoOnlyKey =
new CameraCharacteristics.Key<>("org.codeaurora.qcamera3.sensor_meta_data.is_mono_only",
Byte.class);
+ public static CaptureRequest.Key<Integer> SELECT_PRIORITY =
+ new CaptureRequest.Key<>("org.codeaurora.qcamera3.iso_exp_priority.select_priority",
+ Integer.class);
+ public static CaptureRequest.Key<Long> ISO_EXP =
+ new CaptureRequest.Key<>("org.codeaurora.qcamera3.iso_exp_priority.use_iso_exp_priority",
+ Long.class);
private boolean[] mTakingPicture = new boolean[MAX_NUM_CAM];
private int mControlAFMode = CameraMetadata.CONTROL_AF_MODE_CONTINUOUS_PICTURE;
private int mLastResultAFState = -1;
@@ -781,6 +787,13 @@ public class CaptureModule implements CameraModule, PhotoController,
}
}
+ private void applyFocusDistance(CaptureRequest.Builder builder, String value) {
+ if (value == null) return;
+ float valueF = Float.valueOf(value);
+ builder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_OFF);
+ builder.set(CaptureRequest.LENS_FOCUS_DISTANCE, valueF);
+ }
+
private void createSessions() {
if (mPaused || !mCamerasOpened || !mSurfaceReady) return;
if (isBackCamera()) {
@@ -2066,6 +2079,13 @@ public class CaptureModule implements CameraModule, PhotoController,
mUI.enableShutter(true);
String scene = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
+ boolean promode = false;
+ if (scene != null) {
+ int mode = Integer.parseInt(scene);
+ if (mode == SettingsManager.SCENE_MODE_PROMODE_INT) promode = true;
+ }
+ mUI.initializeProMode(promode);
+
if(isPanoSetting(scene)) {
mActivity.onModuleSelected(ModuleSwitcher.PANOCAPTURE_MODULE_INDEX);
}
@@ -2246,16 +2266,17 @@ public class CaptureModule implements CameraModule, PhotoController,
}
private boolean isTouchToFocusAllowed() {
- if (isTakingPicture() || mIsRecordingVideo || isSceneModeOn()) return false;
+ if (isTakingPicture() || mIsRecordingVideo || isTouchAfEnabledSceneMode()) return false;
return true;
}
- private boolean isSceneModeOn() {
+ private boolean isTouchAfEnabledSceneMode() {
String scene = mSettingsManager.getValue(SettingsManager.KEY_SCENE_MODE);
if (scene == null) return false;
int mode = Integer.parseInt(scene);
- if (mode != SettingsManager.SCENE_MODE_DUAL_INT && mode != CaptureRequest
- .CONTROL_SCENE_MODE_DISABLED) return true;
+ if (mode != CaptureRequest.CONTROL_SCENE_MODE_DISABLED
+ && mode < SettingsManager.SCENE_MODE_CUSTOM_START)
+ return true;
return false;
}
@@ -3190,6 +3211,9 @@ public class CaptureModule implements CameraModule, PhotoController,
updatePreview = true;
applyFaceDetection(mPreviewRequestBuilder[cameraId]);
break;
+ case SettingsManager.KEY_FOCUS_DISTANCE:
+ updatePreview = true;
+ applyFocusDistance(mPreviewRequestBuilder[cameraId], value);
}
return updatePreview;
}
@@ -3239,8 +3263,9 @@ public class CaptureModule implements CameraModule, PhotoController,
request.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_AUTO);
return;
}
- if (mode != CaptureRequest.CONTROL_SCENE_MODE_DISABLED && mode !=
- SettingsManager.SCENE_MODE_DUAL_INT) {
+ if (mode != CaptureRequest.CONTROL_SCENE_MODE_DISABLED
+ && mode != SettingsManager.SCENE_MODE_DUAL_INT
+ && mode != SettingsManager.SCENE_MODE_PROMODE_INT) {
request.set(CaptureRequest.CONTROL_SCENE_MODE, mode);
request.set(CaptureRequest.CONTROL_MODE, CaptureRequest.CONTROL_MODE_USE_SCENE_MODE);
} else {
@@ -3258,9 +3283,14 @@ public class CaptureModule implements CameraModule, PhotoController,
private void applyIso(CaptureRequest.Builder request) {
String value = mSettingsManager.getValue(SettingsManager.KEY_ISO);
if (value == null) return;
- if (value.equals("auto")) return;
- int intValue = Integer.parseInt(value);
- request.set(CaptureRequest.SENSOR_SENSITIVITY, intValue);
+ if (value.equals("auto")) {
+ request.set(SELECT_PRIORITY, null);
+ request.set(ISO_EXP, null);
+ } else {
+ long intValue = Integer.parseInt(value);
+ request.set(SELECT_PRIORITY, 0);
+ request.set(ISO_EXP, intValue);
+ }
}
private void applyColorEffect(CaptureRequest.Builder request) {
@@ -3504,6 +3534,9 @@ public class CaptureModule implements CameraModule, PhotoController,
case SettingsManager.KEY_FLASH_MODE:
if (count == 0) restartSession(false);
return;
+ case SettingsManager.KEY_SCENE_MODE:
+ restartAll();
+ return;
}
if (isBackCamera()) {
diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java
index 7c426073d..df40edb00 100644
--- a/src/com/android/camera/CaptureUI.java
+++ b/src/com/android/camera/CaptureUI.java
@@ -184,6 +184,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
private PauseButton mPauseButton;
private RotateImageView mMuteButton;
private ImageView mSeekbarToggleButton;
+ private View mProModeCloseButton;
int mPreviewWidth;
int mPreviewHeight;
@@ -283,6 +284,13 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
});
setMakeupButtonIcon();
mFlashButton = (FlashToggleButton) mRootView.findViewById(R.id.flash_button);
+ mProModeCloseButton = mRootView.findViewById(R.id.promode_close_button);
+ mProModeCloseButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mSettingsManager.setValue(SettingsManager.KEY_SCENE_MODE, "" + SettingsManager.SCENE_MODE_AUTO_INT);
+ }
+ });
initFilterModeButton();
initSceneModeButton();
initSwitchCamera();
@@ -425,6 +433,12 @@ public class CaptureUI implements FocusOverlayManager.FocusUI,
}
}
+ public void initializeProMode(boolean promode) {
+ mCameraControls.setProMode(promode);
+ if (promode) mVideoButton.setVisibility(View.INVISIBLE);
+ else mVideoButton.setVisibility(View.VISIBLE);
+ }
+
// called from onResume but only the first time
public void initializeFirstTime() {
// Initialize shutter button.
diff --git a/src/com/android/camera/SettingsManager.java b/src/com/android/camera/SettingsManager.java
index 0cacaa594..e0f13c9ea 100644
--- a/src/com/android/camera/SettingsManager.java
+++ b/src/com/android/camera/SettingsManager.java
@@ -85,15 +85,17 @@ public class SettingsManager implements ListMenu.SettingsListener {
public static final int SCENE_MODE_NIGHT_INT = 5;
// Custom-Scenemodes start from 100
- public static final int SCENE_MODE_DUAL_INT = 100;
- public static final int SCENE_MODE_OPTIZOOM_INT = 101;
- public static final int SCENE_MODE_UBIFOCUS_INT = 102;
- public static final int SCENE_MODE_BESTPICTURE_INT = 103;
- public static final int SCENE_MODE_PANORAMA_INT = 104;
- public static final int SCENE_MODE_CHROMAFLASH_INT = 105;
- public static final int SCENE_MODE_BLURBUSTER_INT = 106;
- public static final int SCENE_MODE_SHARPSHOOTER_INT = 107;
- public static final int SCENE_MODE_TRACKINGFOCUS_INT = 108;
+ public static final int SCENE_MODE_CUSTOM_START = 100;
+ public static final int SCENE_MODE_DUAL_INT = SCENE_MODE_CUSTOM_START;
+ public static final int SCENE_MODE_OPTIZOOM_INT = SCENE_MODE_CUSTOM_START + 1;
+ public static final int SCENE_MODE_UBIFOCUS_INT = SCENE_MODE_CUSTOM_START + 2;
+ public static final int SCENE_MODE_BESTPICTURE_INT = SCENE_MODE_CUSTOM_START + 3;
+ public static final int SCENE_MODE_PANORAMA_INT = SCENE_MODE_CUSTOM_START + 4;
+ public static final int SCENE_MODE_CHROMAFLASH_INT = SCENE_MODE_CUSTOM_START + 5;
+ public static final int SCENE_MODE_BLURBUSTER_INT = SCENE_MODE_CUSTOM_START + 6;
+ public static final int SCENE_MODE_SHARPSHOOTER_INT = SCENE_MODE_CUSTOM_START + 7;
+ public static final int SCENE_MODE_TRACKINGFOCUS_INT = SCENE_MODE_CUSTOM_START + 8;
+ public static final int SCENE_MODE_PROMODE_INT = SCENE_MODE_CUSTOM_START + 9;
public static final String SCENE_MODE_DUAL_STRING = "100";
public static final String KEY_CAMERA_SAVEPATH = "pref_camera2_savepath_key";
public static final String KEY_RECORD_LOCATION = "pref_camera2_recordlocation_key";
@@ -133,6 +135,7 @@ public class SettingsManager implements ListMenu.SettingsListener {
public static final String KEY_SHUTTER_SOUND = "pref_camera2_shutter_sound_key";
public static final String KEY_DEVELOPER_MENU = "pref_camera2_developer_menu_key";
public static final String KEY_RESTORE_DEFAULT = "pref_camera2_restore_default_key";
+ public static final String KEY_FOCUS_DISTANCE = "pref_camera2_focus_distance_key";
private static final String TAG = "SnapCam_SettingsManager";
private static SettingsManager sInstance;
@@ -424,6 +427,10 @@ public class SettingsManager implements ListMenu.SettingsListener {
}
}
+ public int getCurrentCameraId() {
+ return mCameraId;
+ }
+
public String getValue(String key) {
Values values = mValuesMap.get(key);
if (values == null) return null;
@@ -466,6 +473,14 @@ public class SettingsManager implements ListMenu.SettingsListener {
}
}
+ public void setFocusDistance(float value) {
+ List<SettingState> list = new ArrayList<>();
+ Values values = new Values("" + value, null);
+ SettingState ss = new SettingState(KEY_FOCUS_DISTANCE, values);
+ list.add(ss);
+ notifyListeners(list);
+ }
+
private void updateMapAndNotify(ListPreference pref) {
String key = pref.getKey();
List changed = checkDependencyAndUpdate(key);
@@ -995,6 +1010,11 @@ public class SettingsManager implements ListMenu.SettingsListener {
return modes;
}
+ public float getMinimumFocusDistance(int cameraId) {
+ return mCharacteristics.get(cameraId)
+ .get(CameraCharacteristics.LENS_INFO_MINIMUM_FOCUS_DISTANCE);
+ }
+
private List<String> getSupportedWhiteBalanceModes(int cameraId) {
int[] whiteBalanceModes = mCharacteristics.get(cameraId).get(CameraCharacteristics
.CONTROL_AWB_AVAILABLE_MODES);
@@ -1019,6 +1039,7 @@ public class SettingsManager implements ListMenu.SettingsListener {
if (BlurbusterFilter.isSupportedStatic()) modes.add(SCENE_MODE_BLURBUSTER_INT + "");
if (SharpshooterFilter.isSupportedStatic()) modes.add(SCENE_MODE_SHARPSHOOTER_INT + "");
if (TrackingFocusFrameListener.isSupportedStatic()) modes.add(SCENE_MODE_TRACKINGFOCUS_INT + "");
+ modes.add("" + SCENE_MODE_PROMODE_INT);
for (int mode : sceneModes) {
modes.add("" + mode);
}
diff --git a/src/com/android/camera/ui/OneUICameraControls.java b/src/com/android/camera/ui/OneUICameraControls.java
index 63e1b5b4d..413221211 100644
--- a/src/com/android/camera/ui/OneUICameraControls.java
+++ b/src/com/android/camera/ui/OneUICameraControls.java
@@ -27,15 +27,16 @@ import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
-import org.codeaurora.snapcam.R;
-
import com.android.camera.Storage;
import com.android.camera.imageprocessor.filter.BeautificationFilter;
+import org.codeaurora.snapcam.R;
+
public class OneUICameraControls extends RotatableLayout {
private static final String TAG = "CAM_Controls";
@@ -53,6 +54,8 @@ public class OneUICameraControls extends RotatableLayout {
private View mMakeupSeekBarLowText;
private View mMakeupSeekBarHighText;
private View mMakeupSeekBarLayout;
+ private ViewGroup mProModeLayout;
+ private View mProModeCloseButton;
private ArrowTextView mRefocusToast;
@@ -76,9 +79,27 @@ public class OneUICameraControls extends RotatableLayout {
private int mHeight;
private boolean mVisible;
+ private ProMode mProMode;
+ private ImageView mExposureIcon;
+ private ImageView mManualIcon;
+ private ImageView mWhiteBalanceIcon;
+ private ImageView mIsoIcon;
+ private TextView mExposureText;
+ private TextView mManualText;
+ private TextView mWhiteBalanceText;
+ private TextView mIsoText;
+ private boolean mProModeOn = false;
+ private LinearLayout mExposureLayout;
+ private LinearLayout mManualLayout;
+ private LinearLayout mWhiteBalanceLayout;
+ private LinearLayout mIsoLayout;
+ private RotateLayout mExposureRotateLayout;
+ private RotateLayout mManualRotateLayout;
+ private RotateLayout mWhiteBalanceRotateLayout;
+ private RotateLayout mIsoRotateLayout;
+
public OneUICameraControls(Context context, AttributeSet attrs) {
super(context, attrs);
-
mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
setWillNotDraw(false);
@@ -117,6 +138,83 @@ public class OneUICameraControls extends RotatableLayout {
mFilterModeSwitcher = findViewById(R.id.filter_mode_switcher);
mRemainingPhotos = (LinearLayout) findViewById(R.id.remaining_photos);
mRemainingPhotosText = (TextView) findViewById(R.id.remaining_photos_text);
+ mProModeLayout = (ViewGroup) findViewById(R.id.pro_mode_layout);
+ mProModeCloseButton = findViewById(R.id.promode_close_button);
+
+ mExposureIcon = (ImageView) findViewById(R.id.exposure);
+ mManualIcon = (ImageView) findViewById(R.id.manual);
+ mWhiteBalanceIcon = (ImageView) findViewById(R.id.white_balance);
+ mIsoIcon = (ImageView) findViewById(R.id.iso);
+ mExposureText = (TextView) findViewById(R.id.exposure_value);
+ mManualText = (TextView) findViewById(R.id.manual_value);
+ mWhiteBalanceText = (TextView) findViewById(R.id.white_balance_value);
+ mIsoText = (TextView) findViewById(R.id.iso_value);
+ mProMode = (ProMode) findViewById(R.id.promode_slider);
+ mProMode.initialize(this);
+
+ mExposureLayout = (LinearLayout) findViewById(R.id.exposure_layout);
+ mManualLayout = (LinearLayout) findViewById(R.id.manual_layout);
+ mWhiteBalanceLayout = (LinearLayout) findViewById(R.id.white_balance_layout);
+ mIsoLayout = (LinearLayout) findViewById(R.id.iso_layout);
+
+ mExposureRotateLayout = (RotateLayout) findViewById(R.id.exposure_rotate_layout);
+ mManualRotateLayout = (RotateLayout) findViewById(R.id.manual_rotate_layout);
+ mWhiteBalanceRotateLayout = (RotateLayout) findViewById(R.id.white_balance_rotate_layout);
+ mIsoRotateLayout = (RotateLayout) findViewById(R.id.iso_rotate_layout);
+
+ mExposureLayout.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ resetProModeIcons();
+ int mode = mProMode.getMode();
+ if (mode == ProMode.EXPOSURE_MODE) {
+ mProMode.setMode(ProMode.NO_MODE);
+ } else {
+ mExposureIcon.setImageResource(R.drawable.icon_exposure_blue);
+ mProMode.setMode(ProMode.EXPOSURE_MODE);
+ }
+ }
+ });
+ mManualLayout.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ resetProModeIcons();
+ int mode = mProMode.getMode();
+ if (mode == ProMode.MANUAL_MODE) {
+ mProMode.setMode(ProMode.NO_MODE);
+ } else {
+ mManualIcon.setImageResource(R.drawable.icon_manual_blue);
+ mProMode.setMode(ProMode.MANUAL_MODE);
+ }
+ }
+ });
+ mWhiteBalanceLayout.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ resetProModeIcons();
+ int mode = mProMode.getMode();
+ if (mode == ProMode.WHITE_BALANCE_MODE) {
+ mProMode.setMode(ProMode.NO_MODE);
+ } else {
+ mWhiteBalanceIcon.setImageResource(R.drawable.icon_white_balance_blue);
+ mProMode.setMode(ProMode.WHITE_BALANCE_MODE);
+ }
+ }
+ });
+ mIsoLayout.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ resetProModeIcons();
+ int mode = mProMode.getMode();
+ if (mode == ProMode.ISO_MODE) {
+ mProMode.setMode(ProMode.NO_MODE);
+ } else {
+ mIsoIcon.setImageResource(R.drawable.icon_iso_blue);
+ mProMode.setMode(ProMode.ISO_MODE);
+ }
+ }
+ });
+
mViews = new View[]{
mSceneModeSwitcher, mFilterModeSwitcher, mFrontBackSwitcher,
mTsMakeupSwitcher, mFlashButton, mShutter, mPreview, mVideoShutter
@@ -142,6 +240,14 @@ public class OneUICameraControls extends RotatableLayout {
if(mMakeupSeekBar != null) {
mMakeupSeekBar.setMinimumWidth(mWidth/2);
}
+
+ LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(mWidth/ 4,mWidth/4);
+ mExposureLayout.setLayoutParams(lp);
+
+ mManualLayout.setLayoutParams(lp);
+ mWhiteBalanceLayout.setLayoutParams(lp);
+ mIsoLayout.setLayoutParams(lp);
+ initializeProMode(mProModeOn);
}
public boolean isControlRegion(int x, int y) {
@@ -212,6 +318,7 @@ public class OneUICameraControls extends RotatableLayout {
setLocation(mShutter, false, 2);
setLocation(mVideoShutter, false, 3.15f);
setLocationCustomBottom(mMakeupSeekBarLayout, 0, 1);
+ setLocation(mProModeCloseButton, false, 4);
layoutToast(mRefocusToast, w, h, rotation);
}
@@ -332,6 +439,11 @@ public class OneUICameraControls extends RotatableLayout {
((Rotatable) v).setOrientation(orientation, animation);
}
}
+ mExposureRotateLayout.setOrientation(orientation, animation);
+ mManualRotateLayout.setOrientation(orientation, animation);
+ mWhiteBalanceRotateLayout.setOrientation(orientation, animation);
+ mIsoRotateLayout.setOrientation(orientation, animation);
+ mProMode.setOrientation(orientation);
layoutRemaingPhotos();
}
@@ -377,4 +489,46 @@ public class OneUICameraControls extends RotatableLayout {
mPath.lineTo(x1, y1);
}
}
+
+ public void setProMode(boolean promode) {
+ mProModeOn = promode;
+ initializeProMode(mProModeOn);
+ resetProModeIcons();
+ }
+
+ private void resetProModeIcons() {
+ mExposureIcon.setImageResource(R.drawable.icon_exposure);
+ mManualIcon.setImageResource(R.drawable.icon_manual);
+ mWhiteBalanceIcon.setImageResource(R.drawable.icon_white_balance);
+ mIsoIcon.setImageResource(R.drawable.icon_iso);
+ }
+
+ public void initializeProMode(boolean promode) {
+ if (!promode) {
+ mProMode.setMode(ProMode.NO_MODE);
+ mProModeLayout.setVisibility(INVISIBLE);
+ mProModeCloseButton.setVisibility(INVISIBLE);
+ return;
+ }
+ mProModeLayout.setVisibility(VISIBLE);
+ mProModeCloseButton.setVisibility(VISIBLE);
+ mProModeLayout.setY(mHeight - mBottom - mProModeLayout.getHeight());
+ }
+
+ public void updateProModeText(int mode, String value) {
+ switch (mode) {
+ case ProMode.EXPOSURE_MODE:
+ mExposureText.setText(value);
+ break;
+ case ProMode.MANUAL_MODE:
+ mManualText.setText(value);
+ break;
+ case ProMode.WHITE_BALANCE_MODE:
+ mWhiteBalanceText.setText(value);
+ break;
+ case ProMode.ISO_MODE:
+ mIsoText.setText(value);
+ break;
+ }
+ }
}
diff --git a/src/com/android/camera/ui/ProMode.java b/src/com/android/camera/ui/ProMode.java
new file mode 100644
index 000000000..9f7d576dc
--- /dev/null
+++ b/src/com/android/camera/ui/ProMode.java
@@ -0,0 +1,372 @@
+/*
+ * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package com.android.camera.ui;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.PathMeasure;
+import android.graphics.Point;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import com.android.camera.SettingsManager;
+
+import org.codeaurora.snapcam.R;
+
+import java.util.ArrayList;
+
+public class ProMode extends View {
+ public static final int NO_MODE = -1;
+ public static final int EXPOSURE_MODE = 0;
+ public static final int MANUAL_MODE = 1;
+ public static final int WHITE_BALANCE_MODE = 2;
+ public static final int ISO_MODE = 3;
+ private static final int DRAG_Y_THRESHOLD = 100;
+ private static final int DRAG_X_THRESHOLD = 30;
+ private static final int BLUE = 0xff4693fb;
+ private static final int SELECTED_DOT_SIZE = 20;
+ private static final int DOT_SIZE = 10;
+ private static final int[] wbIcons = {R.drawable.auto, R.drawable.incandecent,
+ R.drawable.fluorescent, R.drawable.sunlight, R.drawable.cloudy};
+ private static final int[] wbIconsBlue = {R.drawable.auto_blue, R.drawable.incandecent_blue,
+ R.drawable.fluorescent_blue, R.drawable.sunlight_blue, R.drawable.cloudy_blue};
+ private static final int WB_ICON_SIZE = 80;
+ private PathMeasure mCurveMeasure;
+ private int mCurveLeft;
+ private int mCurveRight;
+ private float mSlider = -1;
+ private Paint mPaint = new Paint();
+ private int mNums;
+ private int mIndex;
+ private Point[] mPoints;
+ private float mClickThreshold;
+ private int mStride;
+ private SettingsManager mSettingsManager;
+ private int mMode = NO_MODE;
+ private Context mContext;
+ private ViewGroup mParent;
+ private float minFocus;
+ private OneUICameraControls mUI;
+ private int mWidth;
+ private int mHeight;
+ private int mCurveY;
+ private ArrayList<View> mAddedViews;
+ private float curveCoordinate[] = new float[2];
+ private Path mCurvePath = new Path();
+ private int mCurveHeight;
+ private int mOrientation;
+
+ public ProMode(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ mContext = context;
+ mPaint.setStrokeWidth(7f);
+ mSettingsManager = SettingsManager.getInstance();
+ }
+
+ private void init() {
+ init(EXPOSURE_MODE);
+ init(WHITE_BALANCE_MODE);
+ init(ISO_MODE);
+ mUI.updateProModeText(MANUAL_MODE, "Manual");
+ }
+
+ private void init(int mode) {
+ String key = getKey(mode);
+ if (key == null) return;
+ int index = mSettingsManager.getValueIndex(key);
+ CharSequence[] cc = mSettingsManager.getEntries(key);
+ mUI.updateProModeText(mode, cc[index].toString());
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ if (mMode != NO_MODE) {
+ mPaint.setColor(Color.WHITE);
+ mPaint.setStyle(Paint.Style.STROKE);
+ canvas.drawPath(mCurvePath, mPaint);
+ }
+ mPaint.setStyle(Paint.Style.FILL);
+ if (mMode == MANUAL_MODE) {
+ mPaint.setColor(Color.WHITE);
+ canvas.drawCircle(mCurveLeft, mCurveY, DOT_SIZE, mPaint);
+ canvas.drawCircle(mCurveRight, mCurveY, DOT_SIZE, mPaint);
+ mPaint.setColor(BLUE);
+ if (mSlider >= 0f) {
+ mCurveMeasure.getPosTan(mCurveMeasure.getLength() * mSlider, curveCoordinate, null);
+ canvas.drawCircle(curveCoordinate[0], curveCoordinate[1], SELECTED_DOT_SIZE,
+ mPaint);
+ }
+ } else {
+ for (int i = 0; i < mNums; i++) {
+ if (i == mIndex) {
+ mPaint.setColor(BLUE);
+ canvas.drawCircle(mPoints[i].x, mPoints[i].y, SELECTED_DOT_SIZE, mPaint);
+ } else {
+ mPaint.setColor(Color.WHITE);
+ canvas.drawCircle(mPoints[i].x, mPoints[i].y, DOT_SIZE, mPaint);
+ }
+ }
+ }
+ }
+
+ public void initialize(OneUICameraControls ui) {
+ mParent = (ViewGroup) getParent();
+ mUI = ui;
+ init();
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+ mWidth = right - left;
+ mHeight = bottom - top;
+ mCurveLeft = mWidth / 10;
+ mCurveRight = mWidth - mCurveLeft;
+ mCurveHeight = mWidth / 7;
+ mCurveY = (int) (mHeight * 0.67);
+
+ float cx = (mCurveLeft + mCurveRight) / 2;
+ mCurvePath.moveTo(mCurveLeft, mCurveY);
+ mCurvePath.quadTo(cx, mCurveY - mCurveHeight, mCurveRight, mCurveY);
+ mCurveMeasure = new PathMeasure(mCurvePath, false);
+ }
+
+ public void setOrientation(int orientation) {
+ mOrientation = orientation;
+ if (mAddedViews != null) {
+ int rotation = mOrientation;
+ if (rotation == 90 || rotation == 270) rotation += 180;
+ rotation %= 360;
+ for (View v : mAddedViews) {
+ v.setRotation(rotation);
+ }
+ }
+ }
+
+ public int getMode() {
+ return mMode;
+ }
+
+ public void setMode(int mode) {
+ mMode = mode;
+ removeViews();
+ if (mMode == NO_MODE) {
+ setVisibility(INVISIBLE);
+ return;
+ } else {
+ setVisibility(VISIBLE);
+ }
+ mIndex = -1;
+ String key = currentKey();
+ if (mMode == MANUAL_MODE) {
+ minFocus = mSettingsManager
+ .getMinimumFocusDistance(mSettingsManager.getCurrentCameraId());
+ float value = 0.5f;
+ setSlider(value);
+ int stride = mCurveRight - mCurveLeft;
+ for (int i = 0; i < 2; i++) {
+ TextView v = new TextView(mContext);
+ String s = "infinity";
+ if (i == 1) s = "macro";
+ v.setText(s);
+ v.setTextColor(Color.WHITE);
+ v.measure(0, 0);
+ ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(v.getMeasuredWidth(),
+ v.getMeasuredHeight());
+ v.setLayoutParams(lp);
+ v.setX(mCurveLeft + i * stride - v.getMeasuredWidth() / 2);
+ v.setY(mCurveY - 2 * v.getMeasuredHeight());
+ mParent.addView(v);
+ mAddedViews.add(v);
+ }
+ } else {
+ if (key == null) return;
+ CharSequence[] cc = mSettingsManager.getEntries(key);
+ int length = mSettingsManager.getEntryValues(key).length;
+ int index = mSettingsManager.getValueIndex(key);
+ updateSlider(length);
+
+ for (int i = 0; i < length; i++) {
+ View v;
+ if (mMode == WHITE_BALANCE_MODE) {
+ v = new ImageView(mContext);
+ ((ImageView) v).setImageResource(wbIcons[i]);
+ ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(
+ WB_ICON_SIZE, WB_ICON_SIZE);
+ v.setLayoutParams(lp);
+ v.setX(mPoints[i].x - WB_ICON_SIZE / 2);
+ v.setY(mPoints[i].y - 2 * WB_ICON_SIZE);
+ } else {
+ v = new TextView(mContext);
+ ((TextView) v).setText(cc[i]);
+ ((TextView) v).setTextColor(Color.WHITE);
+ v.measure(0, 0);
+ ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(v.getMeasuredWidth(),
+ v.getMeasuredHeight());
+ v.setLayoutParams(lp);
+ v.setX(mPoints[i].x - v.getMeasuredWidth() / 2);
+ v.setY(mPoints[i].y - 2 * v.getMeasuredHeight());
+ }
+
+
+ mParent.addView(v);
+ mAddedViews.add(v);
+ }
+ setIndex(index, true);
+ }
+ setOrientation(mOrientation);
+ }
+
+ private String getKey(int mode) {
+ switch (mode) {
+ case EXPOSURE_MODE:
+ return SettingsManager.KEY_EXPOSURE;
+ case WHITE_BALANCE_MODE:
+ return SettingsManager.KEY_WHITE_BALANCE;
+ case ISO_MODE:
+ return SettingsManager.KEY_ISO;
+ }
+ return null;
+ }
+
+ private String currentKey() {
+ return getKey(mMode);
+ }
+
+ private void updateSlider(int n) {
+ mNums = n;
+ mStride = (mCurveRight - mCurveLeft) / (mNums - 1);
+ mClickThreshold = mStride * 0.45f;
+ mPoints = new Point[mNums];
+
+ float slide = 1f / (mNums - 1);
+ for (int i = 0; i < mNums; i++) {
+ mCurveMeasure.getPosTan(mCurveMeasure.getLength() * (slide * i), curveCoordinate, null);
+ mPoints[i] = new Point((int) curveCoordinate[0], (int) curveCoordinate[1]);
+ }
+
+ invalidate();
+ }
+
+ public void setSlider(float slider) {
+ mSlider = slider;
+ mSettingsManager.setFocusDistance(mSlider * minFocus);
+ mUI.updateProModeText(mMode, "Manual");
+ invalidate();
+ }
+
+ private void setIndex(int index, boolean force) {
+ if (mIndex == index && !force) return;
+ if (mIndex != -1) {
+ View v = mAddedViews.get(mIndex);
+ if (v instanceof TextView) {
+ ((TextView) v).setTextColor(Color.WHITE);
+ } else if (v instanceof ImageView) {
+ if (mMode == WHITE_BALANCE_MODE) {
+ ((ImageView) v).setImageResource(wbIcons[mIndex]);
+ }
+ }
+ }
+
+ mIndex = index;
+ String key = currentKey();
+ View v = mAddedViews.get(mIndex);
+ if (v instanceof TextView) {
+ ((TextView) v).setTextColor(BLUE);
+ } else if (v instanceof ImageView) {
+ if (mMode == WHITE_BALANCE_MODE) {
+ ((ImageView) v).setImageResource(wbIconsBlue[mIndex]);
+ }
+ }
+ if (key != null) mSettingsManager.setValueIndex(key, mIndex);
+ CharSequence[] cc = mSettingsManager.getEntries(key);
+ mUI.updateProModeText(mMode, cc[mIndex].toString());
+ invalidate();
+ }
+
+ private void removeViews() {
+ ViewGroup vg = (ViewGroup) getParent();
+ if (mAddedViews != null) {
+ for (int i = 0; i < mAddedViews.size(); i++) {
+ vg.removeView(mAddedViews.get(i));
+ }
+ }
+ mAddedViews = new ArrayList<View>();
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent event) {
+ if (mMode == MANUAL_MODE) {
+ float slider = getSlider(event.getX(), event.getY());
+ if (slider >= 0) {
+ setSlider(slider);
+ }
+ } else {
+ int idx = findButton(event.getX(), event.getY());
+ if (idx != -1) {
+ setIndex(idx, false);
+ }
+ return true;
+ }
+ return true;
+ }
+
+ private int findButton(float x, float y) {
+ for (int i = 0; i < mNums; i++) {
+ float xdiff = Math.abs(mPoints[i].x - x);
+ float ydiff = Math.abs(mPoints[i].y - y);
+ float dist = xdiff * xdiff + ydiff * ydiff;
+ if (dist < mClickThreshold * mClickThreshold) return i;
+ }
+ return -1;
+ }
+
+ private float getSlider(float x, float y) {
+ if (x > mCurveLeft - DRAG_X_THRESHOLD && x < mCurveRight + DRAG_X_THRESHOLD
+ && y > mCurveY - mCurveHeight - DRAG_Y_THRESHOLD
+ && y < mCurveY + DRAG_Y_THRESHOLD) {
+ if (x < mCurveLeft) x = mCurveLeft;
+ if (x > mCurveRight) x = mCurveRight;
+ return (x - mCurveLeft) / (mCurveRight - mCurveLeft);
+ } else {
+ return -1;
+ }
+ }
+
+}