diff options
-rw-r--r-- | assets/dependency.json | 6 | ||||
-rw-r--r-- | res/layout/one_ui_layout.xml | 35 | ||||
-rw-r--r-- | res/values/qcomstrings.xml | 2 | ||||
-rw-r--r-- | res/xml/capture_preferences.xml | 2 | ||||
-rw-r--r-- | src/com/android/camera/CaptureUI.java | 11 | ||||
-rw-r--r-- | src/com/android/camera/imageprocessor/filter/BeautificationFilter.java | 14 | ||||
-rw-r--r-- | src/com/android/camera/ui/OneUICameraControls.java | 18 |
7 files changed, 75 insertions, 13 deletions
diff --git a/assets/dependency.json b/assets/dependency.json index afe682119..8cc09f127 100644 --- a/assets/dependency.json +++ b/assets/dependency.json @@ -60,5 +60,11 @@ {"pref_camera2_hfr_key":"off"} , "0":{} + }, + "pref_camera2_makeup_key": + { + "0":{}, + "default": + {"pref_camera2_facedetection_key":"on"} } } diff --git a/res/layout/one_ui_layout.xml b/res/layout/one_ui_layout.xml index b6de2c5db..3b4f0b334 100644 --- a/res/layout/one_ui_layout.xml +++ b/res/layout/one_ui_layout.xml @@ -85,11 +85,40 @@ android:id="@+id/ts_makeup_switcher" style="@style/OneUIMenuButton" /> - <SeekBar + <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" - android:id="@+id/ts_makeup_seekbar" - android:visibility="gone"/> + android:id="@+id/makeup_seekbar_layout" + android:visibility="gone"> + <com.android.camera.ui.RotateLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentLeft="true" + android:id="@+id/makeup_low_text"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/makeup_seekbar_low"> + </TextView> + </com.android.camera.ui.RotateLayout> + <SeekBar + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingLeft="100dp" + android:paddingRight="100dp" + android:id="@+id/makeup_seekbar"/> + <com.android.camera.ui.RotateLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_alignParentRight="true" + android:id="@+id/makeup_high_text"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/makeup_seekbar_high"> + </TextView> + </com.android.camera.ui.RotateLayout> + </RelativeLayout> <LinearLayout android:id="@+id/remaining_photos" diff --git a/res/values/qcomstrings.xml b/res/values/qcomstrings.xml index b7d30bca7..986ff8b3d 100644 --- a/res/values/qcomstrings.xml +++ b/res/values/qcomstrings.xml @@ -1049,5 +1049,7 @@ <string name="panocapture_direction_is_not_determined" translatable="true">Direction is not detected.</string> <string name="makeup_ui_title" translatable="true">Please choose the strength of the beautification.</string> <string name="makeup_ui_ok_button" translatable="true">OK</string> + <string name="makeup_seekbar_low" translatable="true">low</string> + <string name="makeup_seekbar_high" translatable="true">high</string> </resources> diff --git a/res/xml/capture_preferences.xml b/res/xml/capture_preferences.xml index 93b55bde1..fd1424f50 100644 --- a/res/xml/capture_preferences.xml +++ b/res/xml/capture_preferences.xml @@ -182,7 +182,7 @@ camera:entryValues="@array/pref_camera2_initial_camera_entryvalues"/> <ListPreference - camera:defaultValue="off" + camera:defaultValue="0" camera:key="pref_camera2_makeup_key" camera:entries="@array/pref_camera2_makeup_entries" camera:entryValues="@array/pref_camera2_makeup_entryvalues" diff --git a/src/com/android/camera/CaptureUI.java b/src/com/android/camera/CaptureUI.java index 07fff52e6..1394bfce2 100644 --- a/src/com/android/camera/CaptureUI.java +++ b/src/com/android/camera/CaptureUI.java @@ -49,6 +49,7 @@ import android.view.WindowManager; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.RelativeLayout; import android.widget.SeekBar; import android.widget.TextView; @@ -171,6 +172,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, private View mFrontBackSwitcher; private ImageView mMakeupButton; private SeekBar mMakeupSeekBar; + private View mMakeupSeekBarLayout; private TextView mRecordingTimeView; private View mTimeLapseLabel; private RotateLayout mRecordingTimeRect; @@ -239,7 +241,8 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mFrontBackSwitcher = mRootView.findViewById(R.id.front_back_switcher); mMakeupButton = (ImageView) mRootView.findViewById(R.id.ts_makeup_switcher); setMakeupButtonIcon(); - mMakeupSeekBar = (SeekBar)mRootView.findViewById(R.id.ts_makeup_seekbar); + mMakeupSeekBarLayout = mRootView.findViewById(R.id.makeup_seekbar_layout); + mMakeupSeekBar = (SeekBar)mRootView.findViewById(R.id.makeup_seekbar); mMakeupSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) { @@ -346,7 +349,7 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, private void showOrHideMakeupSeekBar() { String value = mSettingsManager.getValue(SettingsManager.KEY_MAKEUP); - if(mMakeupSeekBar.getVisibility() == View.VISIBLE) { + if(mMakeupSeekBarLayout.getVisibility() == View.VISIBLE) { if(value != null && value.equals("0")) { if(mIsVideoUI) { return; @@ -354,9 +357,9 @@ public class CaptureUI implements FocusOverlayManager.FocusUI, mSettingsManager.setValue(SettingsManager.KEY_FACE_DETECTION, "off"); mModule.restartSession(true); } - mMakeupSeekBar.setVisibility(View.GONE); + mMakeupSeekBarLayout.setVisibility(View.GONE); } else { - mMakeupSeekBar.setVisibility(View.VISIBLE); + mMakeupSeekBarLayout.setVisibility(View.VISIBLE); if(value != null && value.equals("0")) { mSettingsManager.setValue(SettingsManager.KEY_MAKEUP, "40"); mMakeupSeekBar.setProgress(40); diff --git a/src/com/android/camera/imageprocessor/filter/BeautificationFilter.java b/src/com/android/camera/imageprocessor/filter/BeautificationFilter.java index 3f0a10bbf..c9c559d3e 100644 --- a/src/com/android/camera/imageprocessor/filter/BeautificationFilter.java +++ b/src/com/android/camera/imageprocessor/filter/BeautificationFilter.java @@ -57,6 +57,8 @@ public class BeautificationFilter implements ImageFilter { private static String TAG = "BeautificationFilter"; private static boolean mIsSupported = false; private int mStrengthValue = 0; + private static int FACE_TIMEOUT_VALUE = 60; //in frame count + private int mFaceTimeOut = FACE_TIMEOUT_VALUE; public BeautificationFilter(CaptureModule module) { mModule = module; @@ -101,6 +103,14 @@ public class BeautificationFilter implements ImageFilter { Face[] faces; if(((Boolean)isPreview).booleanValue()) { faces = mModule.getPreviewFaces(); + if(faces == null || faces.length == 0) { + if(mFaceTimeOut > 0) { + faces = mModule.getStickyFaces(); + mFaceTimeOut--; + } + } else { + mFaceTimeOut = FACE_TIMEOUT_VALUE; + } } else { faces = mModule.getStickyFaces(); } @@ -113,11 +123,13 @@ public class BeautificationFilter implements ImageFilter { int value = nativeBeautificationProcess(bY, bVU, mWidth, mHeight, mStrideY, (int)(rect.left*widthRatio), (int)(rect.top*heightRatio), (int)(rect.right*widthRatio), (int)(rect.bottom*heightRatio), mStrengthValue, mStrengthValue); - if(DEBUG && value < 0) { + if(DEBUG) { if(value == -1) { Log.d(TAG, "library initialization is failed."); } else if(value == -2) { Log.d(TAG, "No face is recognized"); + } else if(value >= 0 && !((Boolean)isPreview).booleanValue()){ + Log.d(TAG, "Successful beautification"); } } } diff --git a/src/com/android/camera/ui/OneUICameraControls.java b/src/com/android/camera/ui/OneUICameraControls.java index b2368faa8..12ce5325b 100644 --- a/src/com/android/camera/ui/OneUICameraControls.java +++ b/src/com/android/camera/ui/OneUICameraControls.java @@ -50,6 +50,9 @@ public class OneUICameraControls extends RotatableLayout { private View mSceneModeSwitcher; private View mFilterModeSwitcher; private View mMakeupSeekBar; + private View mMakeupSeekBarLowText; + private View mMakeupSeekBarHighText; + private View mMakeupSeekBarLayout; private ArrowTextView mRefocusToast; @@ -102,7 +105,10 @@ public class OneUICameraControls extends RotatableLayout { mVideoShutter = findViewById(R.id.video_button); mFrontBackSwitcher = findViewById(R.id.front_back_switcher); mTsMakeupSwitcher = findViewById(R.id.ts_makeup_switcher); - mMakeupSeekBar = findViewById(R.id.ts_makeup_seekbar); + mMakeupSeekBarLowText = findViewById(R.id.makeup_low_text); + mMakeupSeekBarHighText = findViewById(R.id.makeup_high_text); + mMakeupSeekBar = findViewById(R.id.makeup_seekbar); + mMakeupSeekBarLayout = findViewById(R.id.makeup_seekbar_layout); ((SeekBar)mMakeupSeekBar).setMax(100); mFlashButton = findViewById(R.id.flash_button); mMute = findViewById(R.id.mute_button); @@ -133,6 +139,9 @@ public class OneUICameraControls extends RotatableLayout { mHeight = b; setLocation(r - l, b - t); layoutRemaingPhotos(); + if(mMakeupSeekBar != null) { + mMakeupSeekBar.setMinimumWidth(mWidth/2); + } } public boolean isControlRegion(int x, int y) { @@ -203,7 +212,7 @@ public class OneUICameraControls extends RotatableLayout { setLocation(mPreview, false, 0); setLocation(mShutter, false, 2); setLocation(mVideoShutter, false, 3.15f); - setLocationCustomBottom(mMakeupSeekBar, 0, 1); + setLocationCustomBottom(mMakeupSeekBarLayout, 0, 1); layoutToast(mRefocusToast, w, h, rotation); } @@ -315,12 +324,13 @@ public class OneUICameraControls extends RotatableLayout { mOrientation = orientation; View[] views = { mSceneModeSwitcher, mFilterModeSwitcher, mFrontBackSwitcher, - mTsMakeupSwitcher, mFlashButton, mPreview, mMute, mShutter, mVideoShutter + mTsMakeupSwitcher, mFlashButton, mPreview, mMute, mShutter, mVideoShutter, + mMakeupSeekBarLowText, mMakeupSeekBarHighText }; for (View v : views) { if (v != null) { - ((RotateImageView) v).setOrientation(orientation, animation); + ((Rotatable) v).setOrientation(orientation, animation); } } layoutRemaingPhotos(); |