summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjunjiez <junjiez@codeaurora.org>2017-06-29 13:44:15 +0800
committerjunjiez <junjiez@codeaurora.org>2017-07-26 15:28:52 +0800
commitef407574ede2694755abbd5a872936623030c1d7 (patch)
treed89371f4fdc74d928f032bc6bba3d921a0bad01d
parent73c61caa5c7d17f02153bd559e5dbe340dbff245 (diff)
downloadandroid_packages_apps_Snap-ef407574ede2694755abbd5a872936623030c1d7.tar.gz
android_packages_apps_Snap-ef407574ede2694755abbd5a872936623030c1d7.tar.bz2
android_packages_apps_Snap-ef407574ede2694755abbd5a872936623030c1d7.zip
SnapdragonCamera:RTB UI
1.add a new icon on the top of camera control to enable bokeh mode. 2.add toast to show the distance,lighting and effect alert. 3.add debug mode to save all the images received from HAL separately 4.modify ui according to the spec Change-Id: I1178015f48c29cade4e14bb531c9727665905fec
-rwxr-xr-xres/drawable-hdpi/bokeh_shutter_01.pngbin0 -> 42999 bytes
-rwxr-xr-xres/drawable-hdpi/bokeh_shutter_02.pngbin0 -> 43225 bytes
-rwxr-xr-xres/drawable-hdpi/bokeh_shutter_03.pngbin0 -> 42931 bytes
-rwxr-xr-xres/drawable-hdpi/bokeh_shutter_04.pngbin0 -> 42412 bytes
-rwxr-xr-xres/drawable-hdpi/bokeh_shutter_05.pngbin0 -> 41767 bytes
-rwxr-xr-xres/drawable-hdpi/bokeh_shutter_06.pngbin0 -> 41226 bytes
-rwxr-xr-xres/drawable-hdpi/bokeh_shutter_07.pngbin0 -> 40408 bytes
-rwxr-xr-xres/drawable-hdpi/ic_bokeh_off.pngbin0 -> 20343 bytes
-rwxr-xr-xres/drawable-hdpi/ic_bokeh_on.pngbin0 -> 20586 bytes
-rwxr-xr-xres/drawable-mdpi/ic_bokeh_off.pngbin0 -> 19836 bytes
-rwxr-xr-xres/drawable-mdpi/ic_bokeh_on.pngbin0 -> 20054 bytes
-rwxr-xr-x[-rw-r--r--]res/layout/camera_controls.xml4
-rwxr-xr-xres/layout/photo_module.xml16
-rwxr-xr-x[-rw-r--r--]res/values/arrays.xml15
-rwxr-xr-xres/xml/camera_preferences.xml4
-rw-r--r--src/com/android/camera/PhotoMenu.java46
-rwxr-xr-xsrc/com/android/camera/PhotoModule.java98
-rw-r--r--src/com/android/camera/PhotoUI.java32
-rwxr-xr-xsrc/com/android/camera/VideoUI.java5
-rwxr-xr-x[-rw-r--r--]src/com/android/camera/ui/CameraControls.java93
-rwxr-xr-x[-rw-r--r--]src/com/android/camera/ui/PieRenderer.java116
21 files changed, 387 insertions, 42 deletions
diff --git a/res/drawable-hdpi/bokeh_shutter_01.png b/res/drawable-hdpi/bokeh_shutter_01.png
new file mode 100755
index 000000000..051bc372d
--- /dev/null
+++ b/res/drawable-hdpi/bokeh_shutter_01.png
Binary files differ
diff --git a/res/drawable-hdpi/bokeh_shutter_02.png b/res/drawable-hdpi/bokeh_shutter_02.png
new file mode 100755
index 000000000..ccbf3361a
--- /dev/null
+++ b/res/drawable-hdpi/bokeh_shutter_02.png
Binary files differ
diff --git a/res/drawable-hdpi/bokeh_shutter_03.png b/res/drawable-hdpi/bokeh_shutter_03.png
new file mode 100755
index 000000000..861e07972
--- /dev/null
+++ b/res/drawable-hdpi/bokeh_shutter_03.png
Binary files differ
diff --git a/res/drawable-hdpi/bokeh_shutter_04.png b/res/drawable-hdpi/bokeh_shutter_04.png
new file mode 100755
index 000000000..dc9ff6864
--- /dev/null
+++ b/res/drawable-hdpi/bokeh_shutter_04.png
Binary files differ
diff --git a/res/drawable-hdpi/bokeh_shutter_05.png b/res/drawable-hdpi/bokeh_shutter_05.png
new file mode 100755
index 000000000..89bd851ad
--- /dev/null
+++ b/res/drawable-hdpi/bokeh_shutter_05.png
Binary files differ
diff --git a/res/drawable-hdpi/bokeh_shutter_06.png b/res/drawable-hdpi/bokeh_shutter_06.png
new file mode 100755
index 000000000..66a6c7a94
--- /dev/null
+++ b/res/drawable-hdpi/bokeh_shutter_06.png
Binary files differ
diff --git a/res/drawable-hdpi/bokeh_shutter_07.png b/res/drawable-hdpi/bokeh_shutter_07.png
new file mode 100755
index 000000000..021f32d18
--- /dev/null
+++ b/res/drawable-hdpi/bokeh_shutter_07.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_bokeh_off.png b/res/drawable-hdpi/ic_bokeh_off.png
new file mode 100755
index 000000000..d773fe2ba
--- /dev/null
+++ b/res/drawable-hdpi/ic_bokeh_off.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_bokeh_on.png b/res/drawable-hdpi/ic_bokeh_on.png
new file mode 100755
index 000000000..34232e862
--- /dev/null
+++ b/res/drawable-hdpi/ic_bokeh_on.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_bokeh_off.png b/res/drawable-mdpi/ic_bokeh_off.png
new file mode 100755
index 000000000..45a87e3cf
--- /dev/null
+++ b/res/drawable-mdpi/ic_bokeh_off.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_bokeh_on.png b/res/drawable-mdpi/ic_bokeh_on.png
new file mode 100755
index 000000000..91a9c9867
--- /dev/null
+++ b/res/drawable-mdpi/ic_bokeh_on.png
Binary files differ
diff --git a/res/layout/camera_controls.xml b/res/layout/camera_controls.xml
index 59f395b19..5e337096d 100644..100755
--- a/res/layout/camera_controls.xml
+++ b/res/layout/camera_controls.xml
@@ -112,6 +112,10 @@
android:id="@+id/ts_makeup_switcher"
style="@style/ToggleButton" />
+ <com.android.camera.ui.RotateImageView
+ android:id="@+id/bokeh_switcher"
+ style="@style/ToggleButton" />
+
<LinearLayout
android:id="@+id/remaining_photos"
android:layout_width="wrap_content"
diff --git a/res/layout/photo_module.xml b/res/layout/photo_module.xml
index 77c4def21..b1f12dcc7 100755
--- a/res/layout/photo_module.xml
+++ b/res/layout/photo_module.xml
@@ -116,12 +116,18 @@
style="?android:attr/seekBarStyle"
android:id="@+id/blur_degree_bar"
android:orientation="horizontal"
- android:layout_gravity="bottom"
- android:layout_width="match_parent"
+ android:layout_width="200dp"
android:layout_height="wrap_content"
- android:layout_marginBottom="160dip"
- android:layout_marginLeft="30dip"
- android:layout_marginRight="30dip"
+ android:visibility="gone"/>
+ <TextView
+ android:id="@+id/bokeh_tip_text"
+ android:background="@android:color/darker_gray"
+ android:textColor="@android:color/white"
+ android:textSize="20sp"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="130dip"
+ android:layout_gravity="bottom|center_horizontal"
android:visibility="gone"/>
</FrameLayout>
</merge>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 40b55892f..cc1f64777 100644..100755
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -635,6 +635,11 @@
<item>@drawable/ic_hdr</item>
</string-array>
+ <string-array name="pref_camera_bokeh_icons" translatable="false">
+ <item>@drawable/ic_bokeh_on</item>
+ <item>@drawable/ic_bokeh_off</item>
+ </string-array>
+
<string-array name="pref_camera_hdr_entryvalues" translatable="false">
<item>@string/setting_off_value</item>
<item>@string/setting_on_value</item>
@@ -666,6 +671,16 @@
<item>@drawable/ic_exposure_p3</item>
</array>
+ <array name="bokeh_shutter_icons" translatable="false">
+ <item>@drawable/bokeh_shutter_01</item>
+ <item>@drawable/bokeh_shutter_02</item>
+ <item>@drawable/bokeh_shutter_03</item>
+ <item>@drawable/bokeh_shutter_04</item>
+ <item>@drawable/bokeh_shutter_05</item>
+ <item>@drawable/bokeh_shutter_06</item>
+ <item>@drawable/bokeh_shutter_07</item>
+ </array>
+
<!-- Labels for Countdown timer -->
<string-array name="pref_camera_countdown_labels">
<item>@string/pref_camera_countdown_label_off</item>
diff --git a/res/xml/camera_preferences.xml b/res/xml/camera_preferences.xml
index bf9263ca4..d380a27be 100755
--- a/res/xml/camera_preferences.xml
+++ b/res/xml/camera_preferences.xml
@@ -380,11 +380,13 @@
camera:entries="@array/pref_camera_instant_capture_entries"
camera:entryValues="@array/pref_camera_instant_capture_entry_values" />
- <ListPreference
+ <IconListPreference
camera:key="pref_camera_bokeh_mode_key"
camera:defaultValue="@string/pref_camera_bokeh_mode_default"
camera:title="@string/pref_camera_bokeh_mode_title"
camera:entries="@array/pref_camera_bokeh_mode_entries"
+ camera:icons="@array/pref_camera_bokeh_icons"
+ camera:largeIcons="@array/pref_camera_bokeh_icons"
camera:entryValues="@array/pref_camera_bokeh_mode_entry_values" />
<ListPreference
diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java
index 7debfc7ef..083647bf9 100644
--- a/src/com/android/camera/PhotoMenu.java
+++ b/src/com/android/camera/PhotoMenu.java
@@ -98,6 +98,7 @@ public class PhotoMenu extends MenuController
private int mSceneStatus;
private View mHdrSwitcher;
private View mTsMakeupSwitcher;
+ private View mBokehSwitcher;
private View mFrontBackSwitcher;
private View mSceneModeSwitcher;
private View mFilterModeSwitcher;
@@ -132,6 +133,7 @@ public class PhotoMenu extends MenuController
mHdrSwitcher = ui.getRootView().findViewById(R.id.hdr_switcher);
mTsMakeupSwitcher = ui.getRootView().findViewById(R.id.ts_makeup_switcher);
mSceneModeSwitcher = ui.getRootView().findViewById(R.id.scene_mode_switcher);
+ mBokehSwitcher = ui.getRootView().findViewById(R.id.bokeh_switcher);
mFilterModeSwitcher = ui.getRootView().findViewById(R.id.filter_mode_switcher);
mMakeupListener = makeupListener;
mSettingMenu = ui.getRootView().findViewById(R.id.menu);
@@ -167,6 +169,7 @@ public class PhotoMenu extends MenuController
} else {
mHdrSwitcher.setVisibility(View.INVISIBLE);
}
+ initBokehModeButton(mBokehSwitcher);
mFrontBackSwitcher.setVisibility(View.INVISIBLE);
if(!TsMakeupManager.HAS_TS_MAKEUP) {
@@ -848,6 +851,49 @@ public class PhotoMenu extends MenuController
});
}
+ public void initBokehModeButton(View button) {
+ button.setVisibility(View.INVISIBLE);
+ final IconListPreference pref = (IconListPreference) mPreferenceGroup.findPreference(
+ CameraSettings.KEY_BOKEH_MODE);
+ if (pref == null) {
+ button.setVisibility(View.GONE);
+ return;
+ }
+
+ int[] iconIds = pref.getLargeIconIds();
+ int resid = -1;
+ int index = pref.findIndexOfValue(pref.getValue());
+ if (!pref.getUseSingleIcon() && iconIds != null) {
+ resid = iconIds[index];
+ } else {
+ resid = pref.getSingleIcon();
+ }
+ ImageView iv = (ImageView) button;
+ iv.setImageResource(resid);
+
+ button.setVisibility(View.VISIBLE);
+
+ button.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ListPreference bokehPref =
+ mPreferenceGroup.findPreference(CameraSettings.KEY_BOKEH_MODE);
+ String bokeh = (bokehPref != null) ? bokehPref.getValue() : null;
+ if (bokeh != null) {
+ CharSequence[] values = bokehPref.getEntryValues();
+ int index = (bokehPref.getCurrentIndex() + 1) % values.length;
+ bokehPref.setValueIndex(index);
+ ((ImageView) v).setImageResource(
+ ((IconListPreference) pref).getLargeIconIds()[index]);
+ reloadPreference(pref);
+ onSettingChanged(bokehPref);
+ } else {
+
+ }
+ }
+ });
+ }
+
public void initMakeupModeButton(View button) {
if(!TsMakeupManager.HAS_TS_MAKEUP) {
return;
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index e8775f6aa..292349e31 100755
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -53,6 +53,7 @@ import android.os.Looper;
import android.os.Message;
import android.os.MessageQueue;
import android.os.SystemClock;
+import android.preference.Preference;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.util.DisplayMetrics;
@@ -164,6 +165,15 @@ public class PhotoModule
private static final int SWITCH_TO_GCAM_MODULE = 12;
private static final int ON_PREVIEW_STARTED = 13;
+ private static final int NO_DEPTH_EFFECT = 0;
+ private static final int DEPTH_EFFECT_SUCCESS = 1;
+ private static final int TOO_NEAR = 2;
+ private static final int TOO_FAR = 3;
+ private static final int LOW_LIGHT = 4;
+ private static final int SUBJECT_NOT_FOUND = 5;
+ private static final int TOUCH_TO_FOCUS = 6;
+
+
// The subset of parameters we need to update in setCameraParameters().
private static final int UPDATE_PARAM_INITIALIZE = 1;
private static final int UPDATE_PARAM_ZOOM = 2;
@@ -228,6 +238,9 @@ public class PhotoModule
private static final boolean PERSIST_SKIP_MEM_CHECK = PersistUtil.isSkipMemoryCheckEnabled();
+ private static final String PERSISI_BOKEH_DEBUG = "persist.camera.bokeh.debug";
+ private static final boolean PERSIST_BOKEH_DEBUG_CHECK =
+ android.os.SystemProperties.getBoolean(PERSISI_BOKEH_DEBUG, false);
private static final int MINIMUM_BRIGHTNESS = 0;
private static final int MAXIMUM_BRIGHTNESS = 6;
private static final int DEFAULT_BRIGHTNESS = 3;
@@ -236,7 +249,6 @@ public class PhotoModule
private ProgressBar brightnessProgressBar;
// Constant from android.hardware.Camera.Parameters
private static final String KEY_PICTURE_FORMAT = "picture-format";
- private SeekBar mBlurDegreeProgressBar;
private static final String KEY_QC_RAW_PICUTRE_SIZE = "raw-size";
public static final String PIXEL_FORMAT_JPEG = "jpeg";
@@ -270,6 +282,9 @@ public class PhotoModule
private int mLastJpegOrientation = 0;
private boolean mIsBokehMode = false;
+ private TextView mBokehTipText;
+ private boolean mDepthSuccess = false;
+ private boolean mSaveBokehXmp = false;
private Runnable mDoSnapRunnable = new Runnable() {
@Override
@@ -604,9 +619,9 @@ public class PhotoModule
mSensorManager = (SensorManager)(mActivity.getSystemService(Context.SENSOR_SERVICE));
brightnessProgressBar = (ProgressBar)mRootView.findViewById(R.id.progress);
- mBlurDegreeProgressBar = (SeekBar)mRootView.findViewById(R.id.blur_degree_bar);
- mBlurDegreeProgressBar.setOnSeekBarChangeListener(mBlurDegreeListener);
- mBlurDegreeProgressBar.setMax(100);
+
+ mBokehTipText = (TextView) mRootView.findViewById(R.id.bokeh_tip_text);
+
if (brightnessProgressBar instanceof SeekBar) {
SeekBar seeker = (SeekBar) brightnessProgressBar;
seeker.setOnSeekBarChangeListener(mSeekListener);
@@ -1193,6 +1208,10 @@ public class PhotoModule
private final class MetaDataCallback
implements android.hardware.Camera.CameraMetaDataCallback{
+ private static final int QCAMERA_METADATA_HDR = 3;
+ private static final int QCAMERA_METADATA_RTB = 5;
+ private int mLastMessage = -1;
+
@Override
public void onCameraMetaData (byte[] data, android.hardware.Camera camera) {
int metadata[] = new int[3];
@@ -1200,8 +1219,8 @@ public class PhotoModule
for (int i =0;i<3;i++) {
metadata[i] = byteToInt( (byte []) data, i*4);
}
- // Checking if the meta data is for auto HDR
- if (metadata[0] == 3) {
+ /* Checking if the meta data is for auto HDR */
+ if (metadata[0] == QCAMERA_METADATA_HDR) {
if (metadata[2] == 1) {
mAutoHdrEnable = true;
mActivity.runOnUiThread(new Runnable() {
@@ -1220,6 +1239,40 @@ public class PhotoModule
}
});
}
+ } else if (metadata[0] == QCAMERA_METADATA_RTB) {
+ final String tip;
+ Log.d(TAG,"QCAMERA_METADATA_RTB msgtype =" +metadata[2]);
+ switch (metadata[2]) {
+ case TOO_FAR:
+ tip = "Too far";
+ break;
+ case TOO_NEAR:
+ tip = "Too near";
+ break;
+ case LOW_LIGHT:
+ tip = "Low light";
+ break;
+ case SUBJECT_NOT_FOUND:
+ tip = "Object not found";
+ break;
+ case DEPTH_EFFECT_SUCCESS:
+ tip = "Depth effect success";
+ break;
+ case NO_DEPTH_EFFECT:
+ tip = "NO depth effect";
+ break;
+ default:
+ tip = "Message type =" + metadata[2];
+ }
+ mDepthSuccess = metadata[2] == DEPTH_EFFECT_SUCCESS;
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ if (mBokehTipText != null) {
+ mBokehTipText.setText(tip);
+ }
+ }
+ });
}
}
}
@@ -1362,7 +1415,7 @@ public class PhotoModule
@Override
public void onPictureTaken(byte [] jpegData, CameraProxy camera) {
mCallTime ++;
- if (mIsBokehMode) {
+ if (mIsBokehMode && !PERSIST_BOKEH_DEBUG_CHECK && mSaveBokehXmp) {
if (jpegData != null && mCallTime == 1) {
mBokeh = jpegData;
}
@@ -1533,7 +1586,7 @@ public class PhotoModule
}
String mPictureFormat = mParameters.get(KEY_PICTURE_FORMAT);
Log.d(TAG, "capture:" + title + "." + mPictureFormat);
- if (mIsBokehMode) {
+ if (mIsBokehMode && !PERSIST_BOKEH_DEBUG_CHECK && mSaveBokehXmp) {
if (jpegData != null && mCallTime == 3) {
if (mOrigin != null && mBokeh != null) {
GImage gImage = new GImage(mOrigin, "image/jpeg");
@@ -1643,6 +1696,7 @@ public class PhotoModule
mParameters.set(CameraSettings.KEY_QC_BOKEH_BLUR_VALUE, progress);
mCameraDevice.setParameters(mParameters);
Log.d(TAG,"seekbar bokeh degree = "+ progress);
+ mUI.setBokehRenderDegree(progress);
}
}
public void onStopTrackingTouch(SeekBar bar) {
@@ -1841,6 +1895,8 @@ public class PhotoModule
mCameraDevice.enableShutterSound(!mRefocus);
}
+ mSaveBokehXmp = mIsBokehMode && mDepthSuccess;
+
if (mCameraState == LONGSHOT) {
mLongShotCaptureCountLimit = SystemProperties.getInt(
"persist.sys.camera.longshot.shotnum", 0);
@@ -3796,7 +3852,13 @@ public class PhotoModule
String bokehBlurDegree = mPreferences.getString(
CameraSettings.KEY_BOKEH_BLUR_VALUE,
mActivity.getString(R.string.pref_camera_bokeh_blur_degree_default));
- CameraSettings.getSupportedDegreesOfBlur(mParameters);
+ final boolean supportBokeh = CameraSettings.isBokehModeSupported(mParameters);;
+ mActivity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mUI.getCameraControls().setBokehMode(supportBokeh);
+ }
+ });
if (!bokehMode.equals(mActivity.getString(
R.string.pref_camera_bokeh_mode_entry_value_disable))) {
@@ -3816,6 +3878,9 @@ public class PhotoModule
if(mManual3AEnabled != 0) {
mManual3AEnabled = 0;
}
+ if (mCameraDevice != null) {
+ mCameraDevice.setMetadataCb(mMetaDataCallback);
+ }
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivity);
final int degree = prefs.getInt(CameraSettings.KEY_BOKEH_BLUR_VALUE,50);
bokehBlurDegree = String.valueOf(degree);
@@ -3829,8 +3894,11 @@ public class PhotoModule
mUI.overrideSettings(CameraSettings.KEY_FLASH_MODE, "off");
mUI.overrideSettings(CameraSettings.KEY_LONGSHOT,
mActivity.getString(R.string.pref_camera_longshot_default));
- mBlurDegreeProgressBar.setVisibility(View.VISIBLE);
- mBlurDegreeProgressBar.setProgress(degree);
+ mUI.getBokehDegreeBar().setProgress(degree);
+ mUI.getBokehDegreeBar().setOnSeekBarChangeListener(mBlurDegreeListener);
+ mUI.enableBokehRender(true);
+ mUI.setBokehRenderDegree(degree);
+ mBokehTipText.setVisibility(View.VISIBLE);
}
});
} else {
@@ -3843,9 +3911,15 @@ public class PhotoModule
mActivity.getString(R.string.pref_camera_bokeh_mpo_default));
mUI.overrideSettings(CameraSettings.KEY_BOKEH_BLUR_VALUE,
mActivity.getString(R.string.pref_camera_bokeh_blur_degree_default));
- mBlurDegreeProgressBar.setVisibility(View.GONE);
+ mUI.getBokehDegreeBar().setOnSeekBarChangeListener(null);
+ mUI.getBokehDegreeBar().setVisibility(View.GONE);
+ mUI.enableBokehRender(false);
+ mBokehTipText.setVisibility(View.GONE);
}
});
+ if (mCameraDevice != null) {
+ mCameraDevice.setMetadataCb(null);
+ }
}
mParameters.set(CameraSettings.KEY_QC_BOKEH_MODE, bokehMode);
mParameters.set(CameraSettings.KEY_QC_BOKEH_MPO_MODE, bokehMpo);
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index ef0d827b8..29d3c3df2 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -38,6 +38,7 @@ import android.hardware.Camera.Face;
import android.os.AsyncTask;
import android.preference.PreferenceManager;
import android.util.Log;
+import android.util.Size;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
@@ -55,6 +56,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.PopupWindow;
+import android.widget.SeekBar;
import android.widget.Toast;
import com.android.camera.CameraPreference.OnPreferenceChangedListener;
@@ -116,6 +118,7 @@ public class PhotoUI implements PieListener,
private CameraControls mCameraControls;
private MenuHelp mMenuHelp;
private AlertDialog mLocationDialog;
+ private SeekBar mBlurDegreeProgressBar;
// Small indicators which show the camera settings in the viewfinder.
private OnScreenIndicators mOnScreenIndicators;
@@ -288,6 +291,9 @@ public class PhotoUI implements PieListener,
RotateImageView muteButton = (RotateImageView)mRootView.findViewById(R.id.mute_button);
muteButton.setVisibility(View.GONE);
+ mBlurDegreeProgressBar = (SeekBar)mRootView.findViewById(R.id.blur_degree_bar);
+ mBlurDegreeProgressBar.setMax(100);
+
mCameraControls = (CameraControls) mRootView.findViewById(R.id.camera_controls);
ViewStub faceViewStub = (ViewStub) mRootView
.findViewById(R.id.face_view_stub);
@@ -309,6 +315,10 @@ public class PhotoUI implements PieListener,
showFirstTimeHelp();
}
+ public SeekBar getBokehDegreeBar() {
+ return mBlurDegreeProgressBar;
+ }
+
private void calculateMargins(Point size) {
int l = size.x > size.y ? size.x : size.y;
int tm = mActivity.getResources().getDimensionPixelSize(R.dimen.preview_top_margin);
@@ -1130,6 +1140,28 @@ public class PhotoUI implements PieListener,
}
}
+ @Override
+ public void onPieMoved(int centerX, int centerY) {
+ Size bokehCircle = mPieRenderer.getBokehFocusSize();
+ mBlurDegreeProgressBar.setX(centerX - bokehCircle.getWidth()/2);
+ mBlurDegreeProgressBar.setY(centerY + bokehCircle.getHeight()/2);
+ if (mBlurDegreeProgressBar.getVisibility() != View.VISIBLE) {
+ mBlurDegreeProgressBar.setVisibility(View.VISIBLE);
+ }
+ }
+
+ public void enableBokehRender(boolean enable) {
+ if (mPieRenderer != null) {
+ mPieRenderer.setBokehMode(enable);
+ }
+ }
+
+ public void setBokehRenderDegree(int degree) {
+ if (mPieRenderer != null) {
+ mPieRenderer.setBokehDegree(degree);
+ }
+ }
+
public void setSwipingEnabled(boolean enable) {
mActivity.setSwipingEnabled(enable);
}
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index 3a21a060a..30e70dcf0 100755
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -964,6 +964,11 @@ public class VideoUI implements PieRenderer.PieListener,
setSwipingEnabled(true);
}
+ @Override
+ public void onPieMoved(int centerX, int centerY) {
+
+ }
+
public void setSwipingEnabled(boolean enable) {
mActivity.setSwipingEnabled(enable);
}
diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java
index 2a2222804..73afcd5a0 100644..100755
--- a/src/com/android/camera/ui/CameraControls.java
+++ b/src/com/android/camera/ui/CameraControls.java
@@ -59,6 +59,7 @@ public class CameraControls extends RotatableLayout {
private View mFrontBackSwitcher;
private View mHdrSwitcher;
private View mTsMakeupSwitcher;
+ private View mBokehSwitcher;
private View mIndicators;
private View mPreview;
private View mSceneModeSwitcher;
@@ -69,7 +70,7 @@ public class CameraControls extends RotatableLayout {
private ArrowTextView mRefocusToast;
private int mSize;
- private static final int WIDTH_GRID = 5;
+ private static int WIDTH_GRID = 5;
private static final int HEIGHT_GRID = 7;
private static boolean isAnimating = false;
private ArrayList<View> mViewList;
@@ -86,7 +87,8 @@ public class CameraControls extends RotatableLayout {
private static final int MUTE_INDEX = 9;
private static final int VIDEO_SHUTTER_INDEX = 10;
private static final int EXIT_PANORAMA_INDEX = 11;
- private static final int MAX_INDEX= 12;
+ private static final int BOKEH_INDEX = 12;
+ private static final int MAX_INDEX= 13;
private static final int ANIME_DURATION = 300;
private float[][] mLocX = new float[4][MAX_INDEX];
private float[][] mLocY = new float[4][MAX_INDEX];
@@ -106,6 +108,8 @@ public class CameraControls extends RotatableLayout {
private static final int LOW_REMAINING_PHOTOS = 20;
private static final int HIGH_REMAINING_PHOTOS = 1000000;
+ private boolean mIsBokehMode = false;
+
AnimatorListener outlistener = new AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
@@ -126,9 +130,11 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.setVisibility(View.INVISIBLE);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.setVisibility(View.INVISIBLE);
+ }
mSceneModeSwitcher.setVisibility(View.INVISIBLE);
mFilterModeSwitcher.setVisibility(View.INVISIBLE);
-
mSwitcher.setVisibility(View.INVISIBLE);
mShutter.setVisibility(View.INVISIBLE);
mVideoShutter.setVisibility(View.INVISIBLE);
@@ -151,9 +157,11 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.setVisibility(View.INVISIBLE);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.setVisibility(View.INVISIBLE);
+ }
mSceneModeSwitcher.setVisibility(View.INVISIBLE);
mFilterModeSwitcher.setVisibility(View.INVISIBLE);
-
mSwitcher.setVisibility(View.INVISIBLE);
mShutter.setVisibility(View.INVISIBLE);
mVideoShutter.setVisibility(View.INVISIBLE);
@@ -231,6 +239,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.setPressed(false);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.setPressed(false);
+ }
mSceneModeSwitcher.setPressed(false);
}
@@ -247,6 +258,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.setEnabled(enable);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.setEnabled(enable);
+ }
mPreview.setEnabled(enable);
}
@@ -262,6 +276,11 @@ public class CameraControls extends RotatableLayout {
if (mHdrSwitcher.getVisibility() == View.VISIBLE)
mViewList.add(mHdrSwitcher);
}
+ if (mIsBokehMode) {
+ if (mBokehSwitcher.getVisibility() == View.VISIBLE) {
+ mViewList.add(mBokehSwitcher);
+ }
+ }
if (mSceneModeSwitcher.getVisibility() == View.VISIBLE)
mViewList.add(mSceneModeSwitcher);
if (mFilterModeSwitcher.getVisibility() == View.VISIBLE)
@@ -299,6 +318,7 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher = findViewById(R.id.hdr_switcher);
}
+ mBokehSwitcher = findViewById(R.id.bokeh_switcher);
mMenu = findViewById(R.id.menu);
mMute = findViewById(R.id.mute_button);
mExitPanorama = findViewById(R.id.exit_panorama);
@@ -379,7 +399,12 @@ public class CameraControls extends RotatableLayout {
private void setLocation(int w, int h) {
int rotation = getUnifiedRotation();
- toIndex(mSwitcher, w, h, rotation, 4, 6, SWITCHER_INDEX);
+ if (mIsBokehMode) {
+ toIndex(mSwitcher, w, h, rotation, 5, 6, SWITCHER_INDEX);
+ toIndex(mBokehSwitcher,w,h,rotation,5,0,BOKEH_INDEX);
+ } else {
+ toIndex(mSwitcher, w, h, rotation, 4, 6, SWITCHER_INDEX);
+ }
toIndex(mVideoShutter, w, h, rotation, 3, 6, VIDEO_SHUTTER_INDEX);
toIndex(mMenu, w, h, rotation, 4, 0, MENU_INDEX);
toIndex(mMute, w, h, rotation, 3, 0, MUTE_INDEX);
@@ -490,6 +515,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.setX(mLocX[idx1][HDR_INDEX] + x);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.setX(mLocX[idx1][BOKEH_INDEX] + x);
+ }
mSceneModeSwitcher.setX(mLocX[idx1][SCENE_MODE_INDEX] + x);
mFilterModeSwitcher.setX(mLocX[idx1][FILTER_MODE_INDEX] + x);
mMenu.setX(mLocX[idx1][MENU_INDEX] + x);
@@ -507,6 +535,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.setY(mLocY[idx1][HDR_INDEX] + y);
}
+ if (mIsBokehMode){
+ mBokehSwitcher.setY(mLocY[idx1][BOKEH_INDEX] + y);
+ }
mSceneModeSwitcher.setY(mLocY[idx1][SCENE_MODE_INDEX] + y);
mFilterModeSwitcher.setY(mLocY[idx1][FILTER_MODE_INDEX] + y);
mMenu.setY(mLocY[idx1][MENU_INDEX] + y);
@@ -529,6 +560,20 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.setVisibility(status);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.setVisibility(status);
+ }
+ }
+
+ public void setBokehMode(boolean enable) {
+ mIsBokehMode = enable;
+ if (mIsBokehMode) {
+ WIDTH_GRID = 6;
+ } else {
+ WIDTH_GRID = 5;
+ mBokehSwitcher.setVisibility(GONE);
+ }
+ requestLayout();
}
public void hideUI() {
@@ -542,6 +587,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.animate().cancel();
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.animate().cancel();
+ }
mSceneModeSwitcher.animate().cancel();
mFilterModeSwitcher.animate().cancel();
mSwitcher.animate().cancel();
@@ -564,6 +612,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ }
mSceneModeSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
mFilterModeSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
mMenu.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
@@ -583,6 +634,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ }
mSceneModeSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
mFilterModeSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
mMenu.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
@@ -602,6 +656,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ }
mSceneModeSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
mFilterModeSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
mMenu.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
@@ -621,6 +678,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ }
mSceneModeSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
mFilterModeSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
mMenu.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
@@ -649,6 +709,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.animate().cancel();
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.animate().cancel();
+ }
mSceneModeSwitcher.animate().cancel();
mFilterModeSwitcher.animate().cancel();
mSwitcher.animate().cancel();
@@ -683,6 +746,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
+ }
mSceneModeSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
mFilterModeSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
mMenu.animate().translationYBy(mSize).setDuration(ANIME_DURATION);
@@ -704,6 +770,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
+ }
mSceneModeSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
mFilterModeSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
mMenu.animate().translationXBy(mSize).setDuration(ANIME_DURATION);
@@ -725,6 +794,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
+ }
mSceneModeSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
mFilterModeSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
mMenu.animate().translationYBy(-mSize).setDuration(ANIME_DURATION);
@@ -746,6 +818,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
+ }
mSceneModeSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
mFilterModeSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
mMenu.animate().translationXBy(-mSize).setDuration(ANIME_DURATION);
@@ -1024,7 +1099,7 @@ public class CameraControls extends RotatableLayout {
mOrientation = orientation;
View[] views = {
mSceneModeSwitcher, mFilterModeSwitcher, mFrontBackSwitcher,
- TsMakeupManager.HAS_TS_MAKEUP ? mTsMakeupSwitcher : mHdrSwitcher,
+ TsMakeupManager.HAS_TS_MAKEUP ? mTsMakeupSwitcher : mHdrSwitcher,mBokehSwitcher,
mMenu, mShutter, mPreview, mSwitcher, mMute, mReviewRetakeButton,
mReviewCancelButton, mReviewDoneButton, mExitPanorama
};
@@ -1044,6 +1119,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.setVisibility(View.INVISIBLE);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.setVisibility(View.INVISIBLE);
+ }
mSceneModeSwitcher.setVisibility(View.INVISIBLE);
mFilterModeSwitcher.setVisibility(View.INVISIBLE);
mMenu.setVisibility(View.INVISIBLE);
@@ -1056,6 +1134,9 @@ public class CameraControls extends RotatableLayout {
} else {
mHdrSwitcher.setVisibility(View.VISIBLE);
}
+ if (mIsBokehMode) {
+ mBokehSwitcher.setVisibility(View.VISIBLE);
+ }
mSceneModeSwitcher.setVisibility(View.VISIBLE);
mFilterModeSwitcher.setVisibility(View.VISIBLE);
mMenu.setVisibility(View.VISIBLE);
diff --git a/src/com/android/camera/ui/PieRenderer.java b/src/com/android/camera/ui/PieRenderer.java
index 3712de1b7..323973301 100644..100755
--- a/src/com/android/camera/ui/PieRenderer.java
+++ b/src/com/android/camera/ui/PieRenderer.java
@@ -21,6 +21,9 @@ import android.animation.Animator.AnimatorListener;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.Resources;
+import android.content.res.TypedArray;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
@@ -28,13 +31,21 @@ import android.graphics.Path;
import android.graphics.Point;
import android.graphics.PointF;
import android.graphics.RectF;
+import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
import android.util.FloatMath;
+import android.util.Log;
+import android.util.Size;
import android.view.MotionEvent;
+import android.view.View;
import android.view.ViewConfiguration;
+import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Transformation;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+import android.widget.SeekBar;
import com.android.camera.CameraActivity;
import com.android.camera.drawable.TextDrawable;
@@ -82,6 +93,7 @@ public class PieRenderer extends OverlayRenderer
private static final int MSG_OPEN = 0;
private static final int MSG_CLOSE = 1;
private static final int MSG_OPENSUBMENU = 2;
+ private static final int MSG_MOVED = 3;
protected static float CENTER = (float) Math.PI / 2;
protected static float RAD24 = (float)(24 * Math.PI / 180);
@@ -147,25 +159,35 @@ public class PieRenderer extends OverlayRenderer
private int mDeadZone;
private int mAngleZone;
private float mCenterAngle;
+ private boolean mIsBokehMode = false;
+ private TypedArray mBokehFocusResId;
+ private Bitmap mBokehFocusCircle;
+ private int mBokehFocusIndex = 0;
+
private ProgressRenderer mProgressRenderer;
private Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
switch(msg.what) {
- case MSG_OPEN:
- if (mListener != null) {
- mListener.onPieOpened(mPieCenterX, mPieCenterY);
- }
- break;
- case MSG_CLOSE:
- if (mListener != null) {
- mListener.onPieClosed();
- }
- break;
- case MSG_OPENSUBMENU:
- onEnterOpen();
- break;
+ case MSG_OPEN:
+ if (mListener != null) {
+ mListener.onPieOpened(mPieCenterX, mPieCenterY);
+ }
+ break;
+ case MSG_CLOSE:
+ if (mListener != null) {
+ mListener.onPieClosed();
+ }
+ break;
+ case MSG_OPENSUBMENU:
+ onEnterOpen();
+ break;
+ case MSG_MOVED:
+ if (mListener != null) {
+ mListener.onPieMoved(mFocusX, mFocusY);
+ }
+ break;
}
}
@@ -176,6 +198,7 @@ public class PieRenderer extends OverlayRenderer
static public interface PieListener {
public void onPieOpened(int centerX, int centerY);
public void onPieClosed();
+ public void onPieMoved(int centerX,int centerY);
}
public void setPieListener(PieListener pl) {
@@ -248,6 +271,55 @@ public class PieRenderer extends OverlayRenderer
getRoot().addItem(item);
}
+ public void setBokehMode(boolean enable) {
+ mIsBokehMode = enable;
+ if (mIsBokehMode){
+ mBokehFocusResId = getContext().getResources().obtainTypedArray(
+ R.array.bokeh_shutter_icons);
+ int resid = mBokehFocusResId.getResourceId(mBokehFocusIndex,0);
+ mBokehFocusCircle = BitmapFactory.decodeResource(getContext().getResources(),resid);
+ } else {
+ if (mBokehFocusCircle != null)
+ mBokehFocusCircle.recycle();
+ }
+ mOverlay.update();
+ }
+
+ public void setBokehDegree(int degree) {
+ if (degree >=0 && degree <= 100) {
+ int index = (int)degree/15;
+ Log.d("ZJJ","index="+index);
+ if (mBokehFocusIndex == index)
+ return;
+ mBokehFocusIndex = index;
+ int resid = mBokehFocusResId.getResourceId(mBokehFocusIndex,0);
+ Log.d("ZJJ","resid = "+resid );
+ if (mBokehFocusCircle != null) {
+ mBokehFocusCircle.recycle();
+ }
+ mBokehFocusCircle = BitmapFactory.decodeResource(getContext().getResources(),resid);
+ mOverlay.update();
+ }
+ }
+
+ public Size getBokehFocusSize() {
+ if (mIsBokehMode && mBokehFocusCircle != null) {
+ return new Size(mBokehFocusCircle.getWidth(),mBokehFocusCircle.getHeight());
+ }
+ return new Size(0,0);
+ }
+
+ private void drawBokehFocus(Canvas canvas) {
+ if (mBokehFocusCircle != null) {
+ float x = mFocusX-mBokehFocusCircle.getWidth()/2;
+ float y = mFocusY-mBokehFocusCircle.getHeight()/2;
+ canvas.drawBitmap(
+ mBokehFocusCircle,x,y,new Paint());
+ }
+ mHandler.sendEmptyMessage(MSG_MOVED);
+ return;
+ }
+
public void clearItems() {
getRoot().clearItems();
}
@@ -307,7 +379,12 @@ public class PieRenderer extends OverlayRenderer
mLabel.setText("");
}
}
- setVisible(show);
+ if (mIsBokehMode) {
+ setVisible(true);
+ } else {
+ setVisible(show);
+ }
+
mHandler.sendEmptyMessage(show ? MSG_OPEN : MSG_CLOSE);
}
@@ -535,7 +612,6 @@ public class PieRenderer extends OverlayRenderer
@Override
public void onDraw(Canvas canvas) {
mProgressRenderer.onDraw(canvas, mFocusX, mFocusY);
-
float alpha = 1;
if (mXFade != null) {
alpha = (Float) mXFade.getAnimatedValue();
@@ -549,8 +625,12 @@ public class PieRenderer extends OverlayRenderer
float sf = 0.9f + alpha * 0.1f;
canvas.scale(sf, sf, mPieCenterX, mPieCenterY);
}
- if (mState != STATE_PIE) {
- drawFocus(canvas);
+ if (mIsBokehMode) {
+ drawBokehFocus(canvas);
+ } else {
+ if (mState != STATE_PIE) {
+ drawFocus(canvas);
+ }
}
if (mState == STATE_FINISHING) {
canvas.restoreToCount(state);
@@ -1109,7 +1189,7 @@ public class PieRenderer extends OverlayRenderer
private class Disappear implements Runnable {
@Override
public void run() {
- if (mState == STATE_PIE) return;
+ if (mState == STATE_PIE || mIsBokehMode) return;
setVisible(false);
mFocusX = mCenterX;
mFocusY = mCenterY;