diff options
25 files changed, 1416 insertions, 41 deletions
diff --git a/SnapdragonCamera/res/drawable/ic_ts_makeup_clean_selector.xml b/SnapdragonCamera/res/drawable/ic_ts_makeup_clean_selector.xml new file mode 100644 index 000000000..791658dd4 --- /dev/null +++ b/SnapdragonCamera/res/drawable/ic_ts_makeup_clean_selector.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014,2015 Thundersoft Corporation + All rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_selected="true" android:drawable="@drawable/ic_ts_makeup_clean_selected" /> + <item android:drawable="@drawable/ic_ts_makeup_clean" /> +</selector> diff --git a/SnapdragonCamera/res/drawable/ic_ts_makeup_custom_selector.xml b/SnapdragonCamera/res/drawable/ic_ts_makeup_custom_selector.xml new file mode 100644 index 000000000..eecc2c7ce --- /dev/null +++ b/SnapdragonCamera/res/drawable/ic_ts_makeup_custom_selector.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014,2015 Thundersoft Corporation + All rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_selected="true" android:drawable="@drawable/ic_ts_makeup_custom_selected" /> + <item android:drawable="@drawable/ic_ts_makeup_custom" /> +</selector> diff --git a/SnapdragonCamera/res/drawable/ic_ts_makeup_level_1_selector.xml b/SnapdragonCamera/res/drawable/ic_ts_makeup_level_1_selector.xml new file mode 100644 index 000000000..38e9193ab --- /dev/null +++ b/SnapdragonCamera/res/drawable/ic_ts_makeup_level_1_selector.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014,2015 Thundersoft Corporation + All rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_selected="true" android:drawable="@drawable/ic_ts_makeup_level_1_selected" /> + <item android:drawable="@drawable/ic_ts_makeup_level_1" /> +</selector> diff --git a/SnapdragonCamera/res/drawable/ic_ts_makeup_level_2_selector.xml b/SnapdragonCamera/res/drawable/ic_ts_makeup_level_2_selector.xml new file mode 100644 index 000000000..76d40bd88 --- /dev/null +++ b/SnapdragonCamera/res/drawable/ic_ts_makeup_level_2_selector.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014,2015 Thundersoft Corporation + All rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_selected="true" android:drawable="@drawable/ic_ts_makeup_level_2_selected" /> + <item android:drawable="@drawable/ic_ts_makeup_level_2" /> +</selector> diff --git a/SnapdragonCamera/res/drawable/ic_ts_makeup_level_3_selector.xml b/SnapdragonCamera/res/drawable/ic_ts_makeup_level_3_selector.xml new file mode 100644 index 000000000..e26ecdfa5 --- /dev/null +++ b/SnapdragonCamera/res/drawable/ic_ts_makeup_level_3_selector.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014,2015 Thundersoft Corporation + All rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_selected="true" android:drawable="@drawable/ic_ts_makeup_level_3_selected" /> + <item android:drawable="@drawable/ic_ts_makeup_level_3" /> +</selector> diff --git a/SnapdragonCamera/res/drawable/ic_ts_makeup_level_off_selector.xml b/SnapdragonCamera/res/drawable/ic_ts_makeup_level_off_selector.xml new file mode 100644 index 000000000..e1939673a --- /dev/null +++ b/SnapdragonCamera/res/drawable/ic_ts_makeup_level_off_selector.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014,2015 Thundersoft Corporation + All rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_selected="true" android:drawable="@drawable/ic_ts_makeup_level_off_selected" /> + <item android:drawable="@drawable/ic_ts_makeup_level_off" /> +</selector> diff --git a/SnapdragonCamera/res/drawable/ic_ts_makeup_whiten_selector.xml b/SnapdragonCamera/res/drawable/ic_ts_makeup_whiten_selector.xml new file mode 100644 index 000000000..f1284b604 --- /dev/null +++ b/SnapdragonCamera/res/drawable/ic_ts_makeup_whiten_selector.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014,2015 Thundersoft Corporation + All rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + <item android:state_selected="true" android:drawable="@drawable/ic_ts_makeup_whiten_selected" /> + <item android:drawable="@drawable/ic_ts_makeup_whiten" /> +</selector> diff --git a/SnapdragonCamera/res/layout/ts_makeup_item_view.xml b/SnapdragonCamera/res/layout/ts_makeup_item_view.xml new file mode 100644 index 000000000..4b5a050cf --- /dev/null +++ b/SnapdragonCamera/res/layout/ts_makeup_item_view.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014,2015 Thundersoft Corporation + All rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<com.android.camera.ui.RotateLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="center" + android:gravity="center" + android:orientation="vertical" > + + <LinearLayout + android:id="@+id/border" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="center" + android:gravity="center" + android:orientation="vertical" > + + <ImageView + android:id="@+id/image" + android:layout_width="48dip" + android:layout_height="48dip" + android:layout_gravity="center" + android:gravity="center" /> + + <TextView + android:id="@+id/label" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:gravity="center" + android:singleLine="true" + android:textColor="@android:color/white" + android:textSize="13sp" + android:textStyle="bold" /> + </LinearLayout> + +</com.android.camera.ui.RotateLayout>
\ No newline at end of file diff --git a/SnapdragonCamera/res/layout/ts_makeup_level_view_land.xml b/SnapdragonCamera/res/layout/ts_makeup_level_view_land.xml new file mode 100644 index 000000000..0d02562ff --- /dev/null +++ b/SnapdragonCamera/res/layout/ts_makeup_level_view_land.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014,2015 Thundersoft Corporation + All rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/id_makeup_level_root" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_gravity="right" + android:layout_alignParentRight="true" + android:alpha="0.85" + android:orientation="vertical" > + +</LinearLayout>
\ No newline at end of file diff --git a/SnapdragonCamera/res/layout/ts_makeup_level_view_port.xml b/SnapdragonCamera/res/layout/ts_makeup_level_view_port.xml new file mode 100644 index 000000000..4ffaba5dd --- /dev/null +++ b/SnapdragonCamera/res/layout/ts_makeup_level_view_port.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014,2015 Thundersoft Corporation + All rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/id_makeup_level_root" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="bottom" + android:layout_alignParentBottom="true" + android:alpha="0.85" + android:orientation="horizontal" > + +</LinearLayout>
\ No newline at end of file diff --git a/SnapdragonCamera/res/layout/ts_makeup_single_level_view_port.xml b/SnapdragonCamera/res/layout/ts_makeup_single_level_view_port.xml new file mode 100644 index 000000000..fbfafeec3 --- /dev/null +++ b/SnapdragonCamera/res/layout/ts_makeup_single_level_view_port.xml @@ -0,0 +1,154 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014,2015 Thundersoft Corporation + All rights Reserved + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/id_makeup_single_level_root" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:layout_gravity="bottom" + android:orientation="vertical" > + + <SeekBar + android:id="@+id/seekbar_makeup_level" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="8dip" + android:visibility="gone" /> + + <LinearLayout + android:layout_width="match_parent" + android:layout_height="@dimen/tsmakeup_mode_level_size" + android:layout_gravity="center" + android:gravity="center" > + + <LinearLayout + android:id="@+id/id_layout_makeup_back" + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_gravity="center" + android:layout_weight="2.0" + android:gravity="center" > + + <ImageView + android:id="@+id/id_iv_makeup_back" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:src="@drawable/ic_ts_makeup_back" /> + </LinearLayout> + + <LinearLayout + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_gravity="center" + android:layout_weight="1.0" + android:gravity="center" > + + <View + android:layout_width="1dip" + android:layout_height="36dip" + android:layout_gravity="center" + android:background="@drawable/ic_ts_makeup_vline" /> + </LinearLayout> + + <com.android.camera.ui.RotateLayout + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_gravity="center" + android:layout_weight="3.5" + android:gravity="center" + android:orientation="vertical" > + + <LinearLayout + android:id="@+id/id_layout_makeup_clean" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="center" + android:gravity="center" + android:orientation="vertical" + android:padding="2dip" > + + <ImageView + android:id="@+id/id_iv_makeup_clean" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:src="@drawable/ic_ts_makeup_clean_selector" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:gravity="center" + android:shadowColor="@android:color/black" + android:shadowDx="1" + android:shadowDy="1" + android:shadowRadius="2" + android:singleLine="true" + android:text="@string/pref_camera_tsmakeup_level_clean" + android:textColor="@android:color/white" + android:textSize="13sp" + android:textStyle="bold" /> + </LinearLayout> + </com.android.camera.ui.RotateLayout> + + <com.android.camera.ui.RotateLayout + android:layout_width="0dip" + android:layout_height="match_parent" + android:layout_gravity="center" + android:layout_weight="3.5" + android:gravity="center" + android:orientation="vertical" > + + <LinearLayout + android:id="@+id/id_layout_makeup_whiten" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="center" + android:gravity="center" + android:orientation="vertical" + android:padding="2dp" > + + <ImageView + android:id="@+id/id_iv_makeup_whiten" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:src="@drawable/ic_ts_makeup_whiten_selector" /> + + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:gravity="center" + android:shadowColor="@android:color/black" + android:shadowDx="1" + android:shadowDy="1" + android:shadowRadius="2" + android:singleLine="true" + android:text="@string/pref_camera_tsmakeup_level_whiten" + android:textColor="@android:color/white" + android:textSize="13sp" + android:textStyle="bold" /> + </LinearLayout> + </com.android.camera.ui.RotateLayout> + </LinearLayout> + +</LinearLayout>
\ No newline at end of file diff --git a/SnapdragonCamera/src/com/android/camera/TsMakeupManager.java b/SnapdragonCamera/src/com/android/camera/TsMakeupManager.java new file mode 100644 index 000000000..db3505b45 --- /dev/null +++ b/SnapdragonCamera/src/com/android/camera/TsMakeupManager.java @@ -0,0 +1,476 @@ +/* +* Copyright (C) 2014,2015 Thundersoft Corporation +* All rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +package com.android.camera; + +import android.content.Context; +import android.content.res.Resources; +import android.text.TextUtils; +import android.util.Log; +import android.view.Display; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.view.View.OnClickListener; +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; +import android.widget.LinearLayout.LayoutParams; +import android.widget.SeekBar.OnSeekBarChangeListener; + +import com.android.camera.ui.RotateLayout; +import com.android.camera.util.CameraUtil; + +import org.codeaurora.snapcam.R; + +public class TsMakeupManager implements OnSeekBarChangeListener { + private static final String TAG = "TsMakeupManager"; + private PhotoUI mUI; + private PhotoMenu mMenu; + private CameraActivity mActivity; + private PreferenceGroup mPreferenceGroup; + private View mTsMakeupSwitcher; + + private RelativeLayout mMakeupLayoutRoot; + private LinearLayout mMakeupLevelRoot; + private LinearLayout mMakeupSingleRoot; + + public static final String MAKEUP_ON = "On"; + public static final String MAKEUP_OFF = "Off"; + public static final String MAKEUP_NONE = "none"; + + private static final int MODE_NONE = 0; + private static final int MODE_WHITEN = 1; + private static final int MODE_CLEAN = 2; + private int mMode = MODE_NONE; + private int mSingleSelectedIndex = MODE_NONE; + + private static final int MAKEUP_UI_STATUS_NONE = 0; + private static final int MAKEUP_UI_STATUS_ON = 1; + private static final int MAKEUP_UI_STATUS_OFF = 2; + private static final int MAKEUP_UI_STATUS_DISMISS = 3; + private int mMakeupUIStatus = MAKEUP_UI_STATUS_NONE; + + private static final int CLICK_THRESHOLD = 200; + + public static final boolean HAS_TS_MAKEUP = android.os.SystemProperties.getBoolean("persist.ts.rtmakeup", false); + + private MakeupLevelListener mMakeupLevelListener; + interface MakeupLevelListener { + void onMakeupLevel(String key, String value); + } + + public void setMakeupLevelListener(MakeupLevelListener l) { + mMakeupLevelListener = l; + } + + public TsMakeupManager(CameraActivity activity, PhotoMenu menu, PhotoUI ui, PreferenceGroup preferenceGroup, View makeupSwitcher) { + mActivity = activity; + mUI = ui; + mMenu = menu; + mPreferenceGroup = preferenceGroup; + mTsMakeupSwitcher = makeupSwitcher; + + mMakeupLayoutRoot = (RelativeLayout) mUI.getRootView().findViewById(R.id.id_tsmakeup_level_layout_root); + + mMakeupUIStatus = MAKEUP_UI_STATUS_NONE; + } + + public View getMakeupLayoutRoot() { + return mMakeupLayoutRoot; + } + + public boolean isShowMakeup() { + return mMakeupLayoutRoot != null && mMakeupLayoutRoot.isShown(); + } + + public void removeAllViews() { + if(mMakeupSingleRoot != null) { + mMakeupSingleRoot.removeAllViews(); + mMakeupSingleRoot = null; + } + if(mMakeupLevelRoot != null) { + mMakeupLevelRoot.removeAllViews(); + mMakeupLevelRoot = null; + } + if(mMakeupLayoutRoot != null) { + mMakeupLayoutRoot.removeAllViews(); + } + } + + public void dismissMakeupUI() { + mMakeupUIStatus = MAKEUP_UI_STATUS_DISMISS; + removeAllViews(); + if(mMakeupLayoutRoot != null) { + mMakeupLayoutRoot.setVisibility(View.GONE); + } + } + + public void resetMakeupUIStatus() { + mMakeupUIStatus = MAKEUP_UI_STATUS_NONE; + } + + private void changeMakeupIcon(String value) { + if( !TextUtils.isEmpty(value) ) { + String prefValue = MAKEUP_ON; + if(MAKEUP_OFF.equals(value)) { + prefValue = MAKEUP_OFF; + } + final IconListPreference pref = (IconListPreference) mPreferenceGroup + .findPreference(CameraSettings.KEY_TS_MAKEUP_UILABLE); + if(pref == null) + return; + pref.setValue(prefValue); + int index = pref.getCurrentIndex(); + ImageView iv = (ImageView) mTsMakeupSwitcher; + iv.setImageResource(((IconListPreference) pref).getLargeIconIds()[index]); + pref.setMakeupSeekBarValue(prefValue); + } + } + + public void hideMakeupUI() { + final IconListPreference pref = (IconListPreference) mPreferenceGroup + .findPreference(CameraSettings.KEY_TS_MAKEUP_UILABLE); + if(pref == null) + return; + mMakeupUIStatus = MAKEUP_UI_STATUS_NONE; + String tsMakeupOn = pref.getValue(); + Log.d(TAG, "TsMakeupManager.hideMakeupUI(): tsMakeupOn is " + tsMakeupOn); + if(MAKEUP_ON.equals(tsMakeupOn)) { + int index = pref.findIndexOfValue(pref.getValue()); + CharSequence[] values = pref.getEntryValues(); + index = (index + 1) % values.length; + pref.setMakeupSeekBarValue((String)values[index]); + ImageView iv = (ImageView) mTsMakeupSwitcher; + iv.setImageResource(((IconListPreference) pref).getLargeIconIds()[index]); + mMakeupLevelListener.onMakeupLevel(CameraSettings.KEY_TS_MAKEUP_LEVEL, pref.getValue()); + + IconListPreference levelPref = (IconListPreference) mPreferenceGroup + .findPreference(CameraSettings.KEY_TS_MAKEUP_LEVEL); + levelPref.setValueIndex(0); //Turn Off the Makeup feature; + + + mMakeupLayoutRoot.setVisibility(View.GONE); + mMakeupLayoutRoot.removeAllViews(); + if(mMakeupSingleRoot != null) { + mMakeupSingleRoot.removeAllViews(); + mMakeupSingleRoot = null; + } + if(mMakeupLevelRoot != null) { + mMakeupLevelRoot.removeAllViews(); + mMakeupLevelRoot = null; + } + } + } + + public void showMakeupView() { + mMakeupUIStatus = MAKEUP_UI_STATUS_OFF; + mMakeupLayoutRoot.setVisibility(View.GONE); + mMakeupLayoutRoot.removeAllViews(); + if(mMakeupSingleRoot != null) { + mMakeupSingleRoot.removeAllViews(); + mMakeupSingleRoot = null; + } + if(mMakeupLevelRoot != null) { + mMakeupLevelRoot.removeAllViews(); + mMakeupLevelRoot = null; + } + + if(mMakeupSingleRoot != null && mMakeupSingleRoot.getVisibility() == View.VISIBLE) { + showSingleView(MAKEUP_NONE); + return; + } + + if(mMakeupUIStatus == MAKEUP_UI_STATUS_DISMISS) + return; + + mMakeupLayoutRoot.setVisibility(View.VISIBLE); + final IconListPreference pref = (IconListPreference) mPreferenceGroup + .findPreference(CameraSettings.KEY_TS_MAKEUP_LEVEL); + if (pref == null) + return; + + if(mMakeupLevelRoot != null) { + mMakeupLevelRoot.removeAllViews(); + mMakeupLevelRoot = null; + } + mMakeupLayoutRoot.removeAllViews(); + + mMakeupUIStatus = MAKEUP_UI_STATUS_ON; + + int rotation = CameraUtil.getDisplayRotation(mActivity); + boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity); + if (!mIsDefaultToPortrait) { + rotation = (rotation + 90) % 360; + } + CharSequence[] entries = pref.getEntries(); + int[] thumbnails = pref.getThumbnailIds(); + + WindowManager wm = (WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE); + Display display = wm.getDefaultDisplay(); + int width = display.getWidth(); + int height = display.getHeight(); + Resources r = mActivity.getResources(); + int margin = (int) (r.getDimension(R.dimen.tsmakeup_mode_paddingBottom)); + int levelBgSize = (int) (r.getDimension(R.dimen.tsmakeup_mode_level_size)); + + Log.d(TAG, "TsMakeupManager.showMakeupView(): rotation is " + rotation + ", WH is (" + width + ", " + height + "), margin is " + + margin + ", levelBgSize is " + levelBgSize); + + int gridRes = 0; + boolean portrait = (rotation == 0) || (rotation == 180); + int size = height; + if (portrait) { + gridRes = R.layout.ts_makeup_level_view_port; + size = width; + } else { + gridRes = R.layout.ts_makeup_level_view_land; + size = height; + } + int itemWidth = size / entries.length; + + LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + LinearLayout layout = (LinearLayout) inflater.inflate(gridRes, null, false); + mMakeupLevelRoot = layout; + mUI.setMakeupMenuLayout(layout); + + LinearLayout.LayoutParams params = null; + if(portrait) { + params = new LayoutParams(itemWidth, itemWidth); + params.gravity = Gravity.CENTER_VERTICAL; + } else { + params = new LayoutParams(itemWidth, itemWidth); + params.gravity = Gravity.CENTER_HORIZONTAL; + } + + RelativeLayout.LayoutParams rootParams = null; + if(rotation == 0) { + rootParams = new RelativeLayout.LayoutParams(size, levelBgSize); +// rootParams.bottomMargin = margin; + rootParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); + } else if(rotation == 90) { + rootParams = new RelativeLayout.LayoutParams(levelBgSize, size); +// rootParams.rightMargin = margin; + rootParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); + } else if(rotation == 180) { + rootParams = new RelativeLayout.LayoutParams(size, levelBgSize); +// rootParams.topMargin = margin; + rootParams.addRule(RelativeLayout.ALIGN_PARENT_TOP); + } else if(rotation == 270) { + rootParams = new RelativeLayout.LayoutParams(levelBgSize, size); +// rootParams.leftMargin = margin; + rootParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT); + } + + final View[] views = new View[entries.length]; + int init = pref.getCurrentIndex(); + for (int i = 0; i < entries.length; i++) { + RotateLayout layout2 = (RotateLayout) inflater.inflate( + R.layout.ts_makeup_item_view, null, false); + + ImageView imageView = (ImageView) layout2.findViewById(R.id.image); + TextView label = (TextView) layout2.findViewById(R.id.label); + final int j = i; + + layout2.setOnTouchListener(new View.OnTouchListener() { + private long startTime; + + @Override + public boolean onTouch(View v, MotionEvent event) { + if (event.getAction() == MotionEvent.ACTION_DOWN) { + startTime = System.currentTimeMillis(); + } else if (event.getAction() == MotionEvent.ACTION_UP) { + if (System.currentTimeMillis() - startTime < CLICK_THRESHOLD) { + pref.setValueIndex(j); + changeMakeupIcon(pref.getValue()); + mMakeupLevelListener.onMakeupLevel(pref.getKey(), pref.getValue()); + for (View v1 : views) { + v1.setSelected(false); + } + View border = v.findViewById(R.id.image); + border.setSelected(true); + + showSingleView(pref.getValue()); + mUI.adjustOrientation(); + } + } + return true; + } + }); + + View border = layout2.findViewById(R.id.image); + views[j] = border; + if (i == init) { + border.setSelected(true); + } + imageView.setImageResource(thumbnails[i]); + label.setText(entries[i]); + layout.addView(layout2, params); + } + mMakeupLayoutRoot.addView(layout, rootParams); + } + + private void showSingleView(String value) { + if(MAKEUP_NONE.equals(value)) { + if(mMakeupSingleRoot != null) { + mMakeupSingleRoot.removeAllViews(); + mMakeupSingleRoot = null; + } + mMakeupLayoutRoot.removeAllViews(); + int rotation = CameraUtil.getDisplayRotation(mActivity); + boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity); + if (!mIsDefaultToPortrait) { + rotation = (rotation + 90) % 360; + } + + WindowManager wm = (WindowManager) mActivity.getSystemService(Context.WINDOW_SERVICE); + Display display = wm.getDefaultDisplay(); + int width = display.getWidth(); + int height = display.getHeight(); + Resources r = mActivity.getResources(); + int margin = (int) (r.getDimension(R.dimen.tsmakeup_mode_paddingBottom)); + int levelBgSize = (int) (r.getDimension(R.dimen.tsmakeup_mode_level_size)); + + Log.d(TAG, "TsMakeupManager.showSingleView(): rotation is " + rotation + ", WH is (" + width + ", " + height + "), margin is " + + margin + ", levelBgSize is " + levelBgSize); + + int gridRes = R.layout.ts_makeup_single_level_view_port; + int size = width; + + LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + + final LinearLayout layout = (LinearLayout) inflater.inflate(gridRes, null, false); + mMakeupSingleRoot = layout; + mUI.setMakeupMenuLayout(layout); + + RelativeLayout.LayoutParams rootParams = new RelativeLayout.LayoutParams(size, android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT); + rootParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM); + + mMakeupLayoutRoot.addView(layout, rootParams); + final SeekBar seekBar = (SeekBar) layout.findViewById(R.id.seekbar_makeup_level); + seekBar.setOnSeekBarChangeListener(this); + setSingleView(layout); + + mMode = MODE_NONE; + + layout.findViewById(R.id.id_layout_makeup_back).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + mMakeupSingleRoot.removeAllViews(); + mMakeupLayoutRoot.removeView(mMakeupSingleRoot); + mMakeupSingleRoot = null; + + mSingleSelectedIndex = MODE_NONE; + mMode = MODE_NONE; + + showMakeupView(); + mUI.adjustOrientation(); + } + }); + + layout.findViewById(R.id.id_layout_makeup_whiten).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if(mMode == MODE_WHITEN) { + seekBar.setVisibility(View.GONE); + mMode = MODE_NONE; + return; + } + mSingleSelectedIndex = MODE_WHITEN; + seekBar.setVisibility(View.VISIBLE); + seekBar.setProgress(getPrefValue(CameraSettings.KEY_TS_MAKEUP_LEVEL_WHITEN)); + mMode = MODE_WHITEN; + setSingleView(layout); + } + }); + + layout.findViewById(R.id.id_layout_makeup_clean).setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if(mMode == MODE_CLEAN) { + seekBar.setVisibility(View.GONE); + mMode = MODE_NONE; + return; + } + mSingleSelectedIndex = MODE_CLEAN; + seekBar.setVisibility(View.VISIBLE); + seekBar.setProgress(getPrefValue(CameraSettings.KEY_TS_MAKEUP_LEVEL_CLEAN)); + mMode = MODE_CLEAN; + setSingleView(layout); + } + }); + } + } + + private void setSingleView(LinearLayout layout) { + if(mSingleSelectedIndex == MODE_WHITEN) { + layout.findViewById(R.id.id_iv_makeup_whiten).setSelected(true); + layout.findViewById(R.id.id_iv_makeup_clean).setSelected(false); + } else if(mSingleSelectedIndex == MODE_CLEAN) { + layout.findViewById(R.id.id_iv_makeup_whiten).setSelected(false); + layout.findViewById(R.id.id_iv_makeup_clean).setSelected(true); + } + } + + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + setSeekbarValue(seekBar.getProgress()); + } + + private void setSeekbarValue(int value) { + String key = CameraSettings.KEY_TS_MAKEUP_LEVEL_WHITEN; + if(mMode == MODE_CLEAN) { + key = CameraSettings.KEY_TS_MAKEUP_LEVEL_CLEAN; + } + Log.d(TAG, "TsMakeupManager.onStopTrackingTouch(): value is " + value + ", key is " + key); + setEffectValue(key, String.valueOf(value)); + } + + private void setEffectValue(String key, String value) { + final ListPreference pref = (ListPreference) mPreferenceGroup.findPreference(key); + if (pref == null) + return; + + pref.setMakeupSeekBarValue(value); + mMakeupLevelListener.onMakeupLevel(key, value); + } + + private int getPrefValue(String key) { + ListPreference pref = mPreferenceGroup.findPreference(key); + String value = pref.getValue(); + Log.d(TAG, "TsMakeupManager.getPrefValue(): value is " + value + ", key is " + key); + if(TextUtils.isEmpty(value)) { + value = mActivity.getString(R.string.pref_camera_tsmakeup_level_default); + } + return Integer.parseInt(value); + } +} diff --git a/res/layout-port/camera_controls.xml b/res/layout-port/camera_controls.xml index bc85432d9..af47a13b6 100644 --- a/res/layout-port/camera_controls.xml +++ b/res/layout-port/camera_controls.xml @@ -83,6 +83,10 @@ android:id="@+id/filter_mode_switcher" style="@style/ToggleButton" /> + <com.android.camera.ui.RotateImageView + android:id="@+id/ts_makeup_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 c6d895771..e0aaa147f 100644 --- a/res/layout/photo_module.xml +++ b/res/layout/photo_module.xml @@ -99,4 +99,10 @@ <include layout="@layout/camera_controls" android:layout_gravity="center" style="@style/CameraControls"/> + + <RelativeLayout + android:id="@+id/id_tsmakeup_level_layout_root" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:visibility="gone" /> </merge> diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index e248a4523..af9fdfada 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -529,4 +529,15 @@ <string name="camera_gesture_title">打开相机</string> <string name="remaining_photos_format">剩余 %d 张</string> + <string name="pref_camera_tsmakeup_title">美颜</string> + <string name="pref_camera_tsmakeup_entry_on">开</string> + <string name="pref_camera_tsmakeup_entry_off">关</string> + <string name="pref_camera_tsmakeup_custom">自定义</string> + <string name="pref_camera_tsmakeup_level_whiten">美白</string> + <string name="pref_camera_tsmakeup_level_clean">磨皮</string> + <string name="text_tsmakeup_alert_title">警告</string> + <string name="text_tsmakeup_alert_msg">实时美颜需要开启人脸检测功能,是否开启?</string> + <string name="text_tsmakeup_alert_continue">继续</string> + <string name="text_tsmakeup_alert_quit">退出</string> + </resources> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 64e55adc7..1ba60c825 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -167,6 +167,8 @@ <dimen name="filter_mode_padding">10dp</dimen> <dimen name="remaining_photos_margin">67dp</dimen> + <dimen name="tsmakeup_mode_paddingBottom">96dp</dimen> + <dimen name="tsmakeup_mode_level_size">96dp</dimen> <!-- Margins for 4:3 preview on 16:9 screen with 640dp height --> <dimen name="preview_top_margin">57dp</dimen> diff --git a/res/values/qcomarrays.xml b/res/values/qcomarrays.xml index 23ba3d382..ca6ddc2e8 100644 --- a/res/values/qcomarrays.xml +++ b/res/values/qcomarrays.xml @@ -767,6 +767,45 @@ <item>@string/pref_hdr_need_1x_value_false</item> <item>@string/pref_hdr_need_1x_value_true</item> </string-array> + <string-array name="pref_camera_tsmakeup_entries"> + <item>@string/pref_camera_tsmakeup_entry_off</item> + <item>@string/pref_camera_tsmakeup_entry_on</item> + </string-array> + + <!-- Do not localize entryvalues --> + <string-array name="pref_camera_tsmakeup_entryvalues"> + <item>Off</item> + <item>On</item> + </string-array> + + <!-- Camera Preferences Color effect dialog box entries --> + <string-array name="pref_camera_tsmakeup_level_entries" translatable="false"> + <item>@string/pref_camera_tsmakeup_entry_off</item> + <item>1</item> + <item>2</item> + <item>3</item> + <item>@string/pref_camera_tsmakeup_custom</item> + </string-array> + + <array name="tsmakeup_level_thumbnails" translatable="false"> + <item>@drawable/ic_ts_makeup_level_off_selector</item> + <item>@drawable/ic_ts_makeup_level_1_selector</item> + <item>@drawable/ic_ts_makeup_level_2_selector</item> + <item>@drawable/ic_ts_makeup_level_3_selector</item> + <item>@drawable/ic_ts_makeup_custom_selector</item> + </array> + + <string-array name="pref_camera_tsmakeup_level_entryvalues" translatable="false"> + <item>@string/pref_camera_tsmakeup_default</item> + <item>20</item> + <item>60</item> + <item>100</item> + <item>none</item> + </string-array> + <string-array name="pref_ts_makeup_icons" translatable="false"> + <item>@drawable/ic_ts_makeup_off</item> + <item>@drawable/ic_ts_makeup_on</item> + </string-array> </resources> diff --git a/res/values/qcomstrings.xml b/res/values/qcomstrings.xml index c7d8df589..a2b6b7231 100644 --- a/res/values/qcomstrings.xml +++ b/res/values/qcomstrings.xml @@ -868,6 +868,18 @@ <!-- The alas of CameraActivity for gesture operation --> <string name="camera_gesture_title">Launch camera</string> + <string name="pref_camera_tsmakeup_title">Beautification</string> + <string name="pref_camera_tsmakeup_entry_on">On</string> + <string name="pref_camera_tsmakeup_entry_off">Off</string> + <string name="pref_camera_tsmakeup_default" translatable="false">Off</string> + <string name="pref_camera_tsmakeup_level_default" translatable="false">60</string> + <string name="pref_camera_tsmakeup_custom">Custom</string> + <string name="pref_camera_tsmakeup_level_whiten">Whiten</string> + <string name="pref_camera_tsmakeup_level_clean">Soften</string> + <string name="text_tsmakeup_alert_title">Warning</string> + <string name="text_tsmakeup_alert_msg">The beautification must turn on Face Detection, Continue or Quit?</string> + <string name="text_tsmakeup_alert_continue">Continue</string> + <string name="text_tsmakeup_alert_quit">Quit</string> <string name="all_in_focus">All in Focus</string> </resources> diff --git a/res/xml/camera_preferences.xml b/res/xml/camera_preferences.xml index c9008c3a7..6fc88a35f 100644 --- a/res/xml/camera_preferences.xml +++ b/res/xml/camera_preferences.xml @@ -231,6 +231,31 @@ camera:singleIcon="@drawable/ic_settings_facerec" camera:entryValues="@array/pref_camera_facedetection_entryvalues" /> <IconListPreference + camera:key="pref_camera_tsmakeup_key" + camera:defaultValue="@string/pref_camera_tsmakeup_default" + camera:title="@string/pref_camera_tsmakeup_title" + camera:entries="@array/pref_camera_tsmakeup_entries" + camera:singleIcon="@drawable/ic_ts_makeup_off" + camera:icons="@array/pref_ts_makeup_icons" + camera:largeIcons="@array/pref_ts_makeup_icons" + camera:entryValues="@array/pref_camera_tsmakeup_entryvalues" /> + <IconListPreference + camera:key="pref_camera_tsmakeup_level_key" + camera:defaultValue="@string/pref_camera_tsmakeup_default" + camera:title="@string/pref_camera_tsmakeup_title" + camera:entries="@array/pref_camera_tsmakeup_level_entries" + camera:thumbnails="@array/tsmakeup_level_thumbnails" + camera:singleIcon="@drawable/ic_ts_makeup_off" + camera:entryValues="@array/pref_camera_tsmakeup_level_entryvalues" /> + <ListPreference + camera:key="pref_camera_tsmakeup_whiten" + camera:defaultValue="@string/pref_camera_tsmakeup_level_default" + camera:title="@string/pref_camera_tsmakeup_title" /> + <ListPreference + camera:key="pref_camera_tsmakeup_clean" + camera:defaultValue="@string/pref_camera_tsmakeup_level_default" + camera:title="@string/pref_camera_tsmakeup_title" /> + <IconListPreference camera:key="pref_camera_redeyereduction_key" camera:defaultValue="@string/pref_camera_redeyereduction_default" camera:title="@string/pref_camera_redeyereduction_title" diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java index c057ee01f..234ad18d5 100644 --- a/src/com/android/camera/CameraSettings.java +++ b/src/com/android/camera/CameraSettings.java @@ -229,6 +229,14 @@ public class CameraSettings { public static final String KEY_QC_SUPPORTED_MANUAL_EXPOSURE_MODES = "manual-exposure-modes"; public static final String KEY_QC_SUPPORTED_MANUAL_WB_MODES = "manual-wb-modes"; + public static final String KEY_TS_MAKEUP_UILABLE = "pref_camera_tsmakeup_key"; + public static final String KEY_TS_MAKEUP_PARAM = "tsmakeup"; // on/of + public static final String KEY_TS_MAKEUP_PARAM_WHITEN = "tsmakeup_whiten"; // 0~100 + public static final String KEY_TS_MAKEUP_PARAM_CLEAN = "tsmakeup_clean"; // 0~100 + public static final String KEY_TS_MAKEUP_LEVEL = "pref_camera_tsmakeup_level_key"; + public static final String KEY_TS_MAKEUP_LEVEL_WHITEN = "pref_camera_tsmakeup_whiten"; + public static final String KEY_TS_MAKEUP_LEVEL_CLEAN = "pref_camera_tsmakeup_clean"; + public static final String EXPOSURE_DEFAULT_VALUE = "0"; public static final int CURRENT_VERSION = 5; diff --git a/src/com/android/camera/ListPreference.java b/src/com/android/camera/ListPreference.java index b856d460e..c79d18c1a 100644 --- a/src/com/android/camera/ListPreference.java +++ b/src/com/android/camera/ListPreference.java @@ -135,6 +135,11 @@ public class ListPreference extends CameraPreference { persistStringValue(value); } + public void setMakeupSeekBarValue(String value) { + mValue = value; + persistStringValue(value); + } + public void setValueIndex(int index) { setValue(mEntryValues[index].toString()); } diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java index 3bf0b3a88..1c8815845 100644 --- a/src/com/android/camera/PhotoMenu.java +++ b/src/com/android/camera/PhotoMenu.java @@ -20,12 +20,18 @@ import java.util.Locale; import android.animation.Animator; import android.animation.Animator.AnimatorListener; +import android.app.Activity; +import android.app.AlertDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.SharedPreferences; import android.content.res.Resources; import android.hardware.Camera.Parameters; import android.graphics.Rect; +import android.os.Handler; +import android.os.Message; import android.preference.PreferenceManager; +import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; @@ -42,6 +48,7 @@ import android.widget.FrameLayout; import android.widget.FrameLayout.LayoutParams; import com.android.camera.CameraPreference.OnPreferenceChangedListener; +import com.android.camera.TsMakeupManager.MakeupLevelListener; import com.android.camera.ui.CameraControls; import com.android.camera.ui.CountdownTimerPopup; import com.android.camera.ui.ListSubMenu; @@ -74,14 +81,17 @@ public class PhotoMenu extends MenuController private static final int POPUP_SECOND_LEVEL = 2; private static final int POPUP_IN_ANIMATION_SLIDE = 3; private static final int POPUP_IN_ANIMATION_FADE = 4; + private static final int POPUP_IN_MAKEUP = 5; private static final int PREVIEW_MENU_NONE = 0; private static final int PREVIEW_MENU_IN_ANIMATION = 1; private static final int PREVIEW_MENU_ON = 2; private static final int MODE_SCENE = 0; private static final int MODE_FILTER = 1; + private static final int MODE_MAKEUP = 2; private static final int DEVELOPER_MENU_TOUCH_COUNT = 10; private int mSceneStatus; private View mHdrSwitcher; + private View mTsMakeupSwitcher; private View mFrontBackSwitcher; private View mSceneModeSwitcher; private View mFilterModeSwitcher; @@ -97,8 +107,12 @@ public class PhotoMenu extends MenuController private static final int ANIMATION_DURATION = 300; private static final int CLICK_THRESHOLD = 200; private int previewMenuSize; + private TsMakeupManager mTsMakeupManager; + private MakeupLevelListener mMakeupListener; + private MakeupHandler mHandler = new MakeupHandler(); + private static final int MAKEUP_MESSAGE_ID = 0; - public PhotoMenu(CameraActivity activity, PhotoUI ui) { + public PhotoMenu(CameraActivity activity, PhotoUI ui, MakeupLevelListener makeupListener) { super(activity); mUI = ui; mSettingOff = activity.getString(R.string.setting_off_value); @@ -106,8 +120,10 @@ public class PhotoMenu extends MenuController mActivity = activity; mFrontBackSwitcher = ui.getRootView().findViewById(R.id.front_back_switcher); 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); mFilterModeSwitcher = ui.getRootView().findViewById(R.id.filter_mode_switcher); + mMakeupListener = makeupListener; } public void initialize(PreferenceGroup group) { @@ -120,19 +136,36 @@ public class PhotoMenu extends MenuController Locale locale = res.getConfiguration().locale; // The order is from left to right in the menu. + if(TsMakeupManager.HAS_TS_MAKEUP) { + if(mTsMakeupManager != null) { + mTsMakeupManager.removeAllViews(); + mTsMakeupManager = null; + } + if(mTsMakeupManager == null) { + mTsMakeupManager = new TsMakeupManager(mActivity, this, mUI, mPreferenceGroup, mTsMakeupSwitcher); + mTsMakeupManager.setMakeupLevelListener(mMakeupListener); + } + } + initSceneModeButton(mSceneModeSwitcher); initFilterModeButton(mFilterModeSwitcher); - mHdrSwitcher.setVisibility(View.INVISIBLE); - - mFrontBackSwitcher.setVisibility(View.INVISIBLE); - // HDR. - if (group.findPreference(CameraSettings.KEY_CAMERA_HDR) != null) { - mHdrSwitcher.setVisibility(View.VISIBLE); - initSwitchItem(CameraSettings.KEY_CAMERA_HDR, mHdrSwitcher); + if(TsMakeupManager.HAS_TS_MAKEUP) { + initMakeupModeButton(mTsMakeupSwitcher); } else { mHdrSwitcher.setVisibility(View.INVISIBLE); } + mFrontBackSwitcher.setVisibility(View.INVISIBLE); + if(!TsMakeupManager.HAS_TS_MAKEUP) { + // HDR. + if (group.findPreference(CameraSettings.KEY_CAMERA_HDR) != null) { + mHdrSwitcher.setVisibility(View.VISIBLE); + initSwitchItem(CameraSettings.KEY_CAMERA_HDR, mHdrSwitcher); + } else { + mHdrSwitcher.setVisibility(View.INVISIBLE); + } + } + mOtherKeys1 = new String[] { CameraSettings.KEY_FLASH_MODE, CameraSettings.KEY_RECORD_LOCATION, @@ -191,6 +224,18 @@ public class PhotoMenu extends MenuController initSwitchItem(CameraSettings.KEY_CAMERA_ID, mFrontBackSwitcher); } + protected class MakeupHandler extends Handler { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MAKEUP_MESSAGE_ID: + mTsMakeupManager.showMakeupView(); + mUI.adjustOrientation(); + break; + } + } + } + @Override // Hit when an item in a popup gets selected public void onListPrefChanged(ListPreference pref) { @@ -200,6 +245,14 @@ public class PhotoMenu extends MenuController } public boolean handleBackKey() { + if(TsMakeupManager.HAS_TS_MAKEUP && mTsMakeupManager.isShowMakeup()) { + mTsMakeupManager.dismissMakeupUI(); + closeMakeupMode(true); + mTsMakeupManager.resetMakeupUIStatus(); + mPopupStatus = POPUP_NONE; + mPreviewMenuStatus = PREVIEW_MENU_NONE; + return true; + } if (mPreviewMenuStatus == PREVIEW_MENU_ON) { animateSlideOut(mPreviewMenu); return true; @@ -219,6 +272,10 @@ public class PhotoMenu extends MenuController mUI.removeSceneModeMenu(); } + public void closeMakeupMode(boolean isMakeup) { + mUI.removeSceneModeMenu(); + } + public void tryToCloseSubList() { if (mListMenu != null) ((ListMenu) mListMenu).resetHighlight(); @@ -379,6 +436,13 @@ public class PhotoMenu extends MenuController } public void animateSlideOutPreviewMenu() { + if(TsMakeupManager.HAS_TS_MAKEUP && mTsMakeupManager.isShowMakeup()) { + mPreviewMenuStatus = PREVIEW_MENU_NONE; + mTsMakeupManager.dismissMakeupUI(); + closeMakeupMode(true); + mTsMakeupManager.resetMakeupUIStatus(); + } + if (mPreviewMenu == null) return; animateSlideOut(mPreviewMenu); @@ -601,8 +665,10 @@ public class PhotoMenu extends MenuController mActivity.getString(R.string.pref_camera_advanced_feature_default)); popup1.setPreferenceEnabled(CameraSettings.KEY_ADVANCED_FEATURES, false); - if (mHdrSwitcher.getVisibility() == View.VISIBLE) { - buttonSetEnabled(mHdrSwitcher, true); + if(!TsMakeupManager.HAS_TS_MAKEUP) { + if (mHdrSwitcher.getVisibility() == View.VISIBLE) { + buttonSetEnabled(mHdrSwitcher, true); + } } } else { if ((advancedFeatures != null) && (advancedFeatures.equals(ubiFocusOn) || @@ -622,12 +688,16 @@ public class PhotoMenu extends MenuController popup1.setPreferenceEnabled(CameraSettings.KEY_SCENE_MODE, false); setPreference(CameraSettings.KEY_CAMERA_HDR, mSettingOff); - if (mHdrSwitcher.getVisibility() == View.VISIBLE) { - buttonSetEnabled(mHdrSwitcher, false); + if(!TsMakeupManager.HAS_TS_MAKEUP) { + if (mHdrSwitcher.getVisibility() == View.VISIBLE) { + buttonSetEnabled(mHdrSwitcher, false); + } } } else { - if (mHdrSwitcher.getVisibility() == View.VISIBLE) { - buttonSetEnabled(mHdrSwitcher, true); + if(!TsMakeupManager.HAS_TS_MAKEUP) { + if (mHdrSwitcher.getVisibility() == View.VISIBLE) { + buttonSetEnabled(mHdrSwitcher, true); + } } } } @@ -688,6 +758,101 @@ public class PhotoMenu extends MenuController }); } + public void initMakeupModeButton(View button) { + if(!TsMakeupManager.HAS_TS_MAKEUP) { + return; + } + button.setVisibility(View.INVISIBLE); + final IconListPreference pref = (IconListPreference) mPreferenceGroup + .findPreference(CameraSettings.KEY_TS_MAKEUP_UILABLE); + if (pref == null) + return; + + int[] iconIds = pref.getLargeIconIds(); + int resid = -1; + int index = pref.findIndexOfValue(pref.getValue()); + if (!pref.getUseSingleIcon() && iconIds != null) { + // Each entry has a corresponding icon. + resid = iconIds[index]; + } else { + // The preference only has a single icon to represent it. + resid = pref.getSingleIcon(); + } + ImageView iv = (ImageView) mTsMakeupSwitcher; + iv.setImageResource(resid); + + button.setVisibility(View.VISIBLE); + + String makeupOn = pref.getValue(); + Log.d(TAG, "PhotoMenu.initMakeupModeButton():current init makeupOn is " + makeupOn); + + button.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + ListPreference faceDetectPref = mPreferenceGroup.findPreference(CameraSettings.KEY_FACE_DETECTION); + String faceDetection = (faceDetectPref != null) ? faceDetectPref.getValue() : null; + Log.d(TAG, "initMakeupModeButton().onClick(): faceDetection is " + faceDetection); + if ((faceDetection != null) && Parameters.FACE_DETECTION_OFF.equals(faceDetection)) { + showAlertDialog(faceDetectPref); + } else { + toggleMakeupSettings(); + } + } + }); + } + + private void initMakeupMenu() { + if(!TsMakeupManager.HAS_TS_MAKEUP) { + return; + } + mPopupStatus = POPUP_NONE; + mHandler.removeMessages(MAKEUP_MESSAGE_ID); + mSceneStatus = MODE_MAKEUP; + mPreviewMenuStatus = PREVIEW_MENU_ON; + mHandler.sendEmptyMessageDelayed(MAKEUP_MESSAGE_ID, ANIMATION_DURATION); + } + + private void showAlertDialog(final ListPreference faceDetectPref) { + if(mActivity.isFinishing()) { + return; + } + new AlertDialog.Builder(mActivity) + .setIcon(android.R.drawable.ic_dialog_alert) + .setMessage(R.string.text_tsmakeup_alert_msg) + .setPositiveButton(R.string.text_tsmakeup_alert_continue, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + toggleMakeupSettings(); + + faceDetectPref.setValue(Parameters.FACE_DETECTION_ON); + onSettingChanged(faceDetectPref); + } + }) + .setNegativeButton(R.string.text_tsmakeup_alert_quit, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + } + }) + .show(); + } + + private void toggleMakeupSettings() { + mUI.hideUI(); + initMakeupMenu(); + } + + private void closeMakeup() { + if(TsMakeupManager.HAS_TS_MAKEUP) { + if(mTsMakeupManager.isShowMakeup()) { + mTsMakeupManager.hideMakeupUI(); + closeMakeupMode(false); + mPreviewMenuStatus = PREVIEW_MENU_NONE; + } else { + mTsMakeupManager.hideMakeupUI(); + } + } + } + public void initSceneModeButton(View button) { button.setVisibility(View.INVISIBLE); final IconListPreference pref = (IconListPreference) mPreferenceGroup @@ -850,6 +1015,8 @@ public class PhotoMenu extends MenuController button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { + closeMakeup(); + addFilterMode(); ViewGroup menuLayout = mUI.getPreviewMenuLayout(); if (menuLayout != null) { @@ -963,14 +1130,24 @@ public class PhotoMenu extends MenuController } public void openFirstLevel() { - if (isMenuBeingShown() || CameraControls.isAnimating()) + if (isMenuBeingShown() || CameraControls.isAnimating()) { return; + } + if(TsMakeupManager.HAS_TS_MAKEUP) { + if(mTsMakeupManager.isShowMakeup()) { + mTsMakeupManager.dismissMakeupUI(); + closeMakeupMode(false); + mPreviewMenuStatus = PREVIEW_MENU_NONE; + } else { + mTsMakeupManager.dismissMakeupUI(); + } + mTsMakeupManager.resetMakeupUIStatus(); + } if (mListMenu == null || mPopupStatus != POPUP_FIRST_LEVEL) { initializePopup(); mPopupStatus = POPUP_FIRST_LEVEL; } mUI.showPopup(mListMenu, 1, true); - } public void popupDismissed(boolean dismissAll) { diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java index b23a99783..74d3ec1f2 100644 --- a/src/com/android/camera/PhotoModule.java +++ b/src/com/android/camera/PhotoModule.java @@ -66,6 +66,7 @@ import com.android.camera.CameraManager.CameraPictureCallback; import com.android.camera.CameraManager.CameraProxy; import com.android.camera.CameraManager.CameraShutterCallback; import com.android.camera.PhotoModule.NamedImages.NamedEntity; +import com.android.camera.TsMakeupManager.MakeupLevelListener; import com.android.camera.exif.ExifInterface; import com.android.camera.exif.ExifTag; import com.android.camera.exif.Rational; @@ -82,6 +83,7 @@ import android.widget.EditText; import android.app.AlertDialog; import android.content.DialogInterface; import android.text.InputType; +import android.text.TextUtils; import com.android.internal.util.MemInfoReader; import android.app.ActivityManager; @@ -110,7 +112,7 @@ public class PhotoModule ShutterButton.OnShutterButtonListener, MediaSaveService.Listener, OnCountDownFinishedListener, - SensorEventListener { + SensorEventListener, MakeupLevelListener { private static final String TAG = "CAM_PhotoModule"; @@ -690,7 +692,7 @@ public class PhotoModule private void openCameraCommon() { loadCameraPreferences(); - mUI.onCameraOpened(mPreferenceGroup, mPreferences, mParameters, this); + mUI.onCameraOpened(mPreferenceGroup, mPreferences, mParameters, this, this); if (mIsImageCaptureIntent) { mUI.overrideSettings(CameraSettings.KEY_CAMERA_HDR_PLUS, mActivity.getString(R.string.setting_off_value)); @@ -3539,6 +3541,21 @@ public class PhotoModule if (mContinuousFocusSupported && ApiHelper.HAS_AUTO_FOCUS_MOVE_CALLBACK) { updateAutoFocusMoveCallback(); } + + String makeupParamValue = mPreferences.getString(CameraSettings.KEY_TS_MAKEUP_UILABLE, + mActivity.getString(R.string.pref_camera_tsmakeup_default)); + mParameters.set(CameraSettings.KEY_TS_MAKEUP_PARAM, makeupParamValue); + Log.v(TAG,"updateCameraParametersPreference(): TSMakeup " + CameraSettings.KEY_TS_MAKEUP_PARAM +" value = " + makeupParamValue); + + if(TsMakeupManager.MAKEUP_ON.equals(makeupParamValue)) { + String makeupWhitenValue = mPreferences.getString(CameraSettings.KEY_TS_MAKEUP_LEVEL_WHITEN, + mActivity.getString(R.string.pref_camera_tsmakeup_level_default)); + String makeupCleanValue = mPreferences.getString(CameraSettings.KEY_TS_MAKEUP_LEVEL_CLEAN, + mActivity.getString(R.string.pref_camera_tsmakeup_level_default)); + mParameters.set(CameraSettings.KEY_TS_MAKEUP_PARAM_WHITEN, makeupWhitenValue); + mParameters.set(CameraSettings.KEY_TS_MAKEUP_PARAM_CLEAN, makeupCleanValue); + } + //QCom related parameters updated here. qcomUpdateCameraParametersPreference(); return doGcamModeSwitch; @@ -4338,6 +4355,73 @@ public class PhotoModule } } } + + @Override + public void onMakeupLevel(String key, String value) { + Log.d(TAG, "PhotoModule.onMakeupLevel(): key is " + key + ", value is " + value); + + if(TextUtils.isEmpty(value)) { + return; + } + + String prefValue = TsMakeupManager.MAKEUP_ON; + if(TsMakeupManager.MAKEUP_OFF.equals(value)) { + prefValue = TsMakeupManager.MAKEUP_OFF; + } + + Log.d(TAG, "onMakeupLevel(): prefValue is " + prefValue); + mParameters.set(CameraSettings.KEY_TS_MAKEUP_PARAM, prefValue); + + if(!TextUtils.isDigitsOnly(value)) { + if(TsMakeupManager.MAKEUP_NONE.equals(value)) { + ListPreference pref = mPreferenceGroup.findPreference(CameraSettings.KEY_TS_MAKEUP_LEVEL_WHITEN); + if(pref != null) { + String whitenValue = pref.getValue(); + if(TextUtils.isEmpty(whitenValue)) { + whitenValue = mActivity.getString(R.string.pref_camera_tsmakeup_level_default); + } + pref.setMakeupSeekBarValue(whitenValue); + mParameters.set(CameraSettings.KEY_TS_MAKEUP_PARAM_WHITEN, Integer.parseInt(whitenValue)); + } + + pref = mPreferenceGroup.findPreference(CameraSettings.KEY_TS_MAKEUP_LEVEL_CLEAN); + if(pref != null) { + String cleanValue = pref.getValue(); + if(TextUtils.isEmpty(cleanValue)) { + cleanValue = mActivity.getString(R.string.pref_camera_tsmakeup_level_default); + } + pref.setMakeupSeekBarValue(cleanValue); + mParameters.set(CameraSettings.KEY_TS_MAKEUP_PARAM_CLEAN, Integer.parseInt(cleanValue)); + } + } + } else { + if(CameraSettings.KEY_TS_MAKEUP_LEVEL.equals(key)) { + if(mParameters != null) { + mParameters.set(CameraSettings.KEY_TS_MAKEUP_PARAM_WHITEN, Integer.parseInt(value)); + mParameters.set(CameraSettings.KEY_TS_MAKEUP_PARAM_CLEAN, Integer.parseInt(value)); + } + ListPreference pref = mPreferenceGroup.findPreference(CameraSettings.KEY_TS_MAKEUP_LEVEL_WHITEN); + if(pref != null) { + pref.setMakeupSeekBarValue(value); + } + pref = mPreferenceGroup.findPreference(CameraSettings.KEY_TS_MAKEUP_LEVEL_CLEAN); + if(pref != null) { + pref.setMakeupSeekBarValue(value); + } + } else if(CameraSettings.KEY_TS_MAKEUP_LEVEL_WHITEN.equals(key)) { + if(mParameters != null) { + mParameters.set(CameraSettings.KEY_TS_MAKEUP_PARAM_WHITEN, Integer.parseInt(value)); + } + } else if(CameraSettings.KEY_TS_MAKEUP_LEVEL_CLEAN.equals(key)) { + if(mParameters != null) { + mParameters.set(CameraSettings.KEY_TS_MAKEUP_PARAM_CLEAN, Integer.parseInt(value)); + } + } + } + + mCameraDevice.setParameters(mParameters); + mParameters = mCameraDevice.getParameters(); + } } /* Below is no longer needed, except to get rid of compile error diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java index 3f2000cd9..65a822d74 100644 --- a/src/com/android/camera/PhotoUI.java +++ b/src/com/android/camera/PhotoUI.java @@ -56,6 +56,7 @@ import android.graphics.drawable.AnimationDrawable; import com.android.camera.CameraPreference.OnPreferenceChangedListener; import com.android.camera.FocusOverlayManager.FocusUI; +import com.android.camera.TsMakeupManager.MakeupLevelListener; import com.android.camera.ui.AbstractSettingPopup; import com.android.camera.ui.CameraControls; import com.android.camera.ui.CameraRootView; @@ -144,6 +145,7 @@ public class PhotoUI implements PieListener, private RotateLayout mMenuLayout; private RotateLayout mSubMenuLayout; private LinearLayout mPreviewMenuLayout; + private LinearLayout mMakeupMenuLayout; private boolean mUIhidden = false; private int mPreviewOrientation = -1; @@ -471,7 +473,7 @@ public class PhotoUI implements PieListener, } public void onCameraOpened(PreferenceGroup prefGroup, ComboPreferences prefs, - Camera.Parameters params, OnPreferenceChangedListener listener) { + Camera.Parameters params, OnPreferenceChangedListener listener, MakeupLevelListener makeupListener) { if (mPieRenderer == null) { mPieRenderer = new PieRenderer(mActivity); mPieRenderer.setPieListener(this); @@ -479,7 +481,7 @@ public class PhotoUI implements PieListener, } if (mMenu == null) { - mMenu = new PhotoMenu(mActivity, this); + mMenu = new PhotoMenu(mActivity, this, makeupListener); mMenu.setListener(listener); } mMenu.initialize(prefGroup); @@ -798,6 +800,10 @@ public class PhotoUI implements PieListener, return mPreviewMenuLayout; } + public void setMakeupMenuLayout(LinearLayout layout) { + mMakeupMenuLayout = layout; + } + public void showPopup(ListView popup, int level, boolean animate) { FrameLayout.LayoutParams params; hideUI(); @@ -1267,6 +1273,27 @@ public class PhotoUI implements PieListener, } } } + if(mMakeupMenuLayout != null) { + View view = mMakeupMenuLayout.getChildAt(0); + if(view instanceof RotateLayout) { + for(int i = mMakeupMenuLayout.getChildCount() -1; i >= 0; --i) { + RotateLayout l = (RotateLayout) mMakeupMenuLayout.getChildAt(i); + l.setOrientation(orientation, animation); + } + } else { + ViewGroup vg = (ViewGroup) mMakeupMenuLayout.getChildAt(1); + if(vg != null) { + for (int i = vg.getChildCount() - 1; i >= 0; --i) { + ViewGroup vewiGroup = (ViewGroup) vg.getChildAt(i); + if(vewiGroup instanceof RotateLayout) { + RotateLayout l = (RotateLayout) vewiGroup; + l.setOrientation(orientation, animation); + } + } + } + } + + } if (mCountDownView != null) mCountDownView.setOrientation(orientation); RotateTextToast.setOrientation(orientation); diff --git a/src/com/android/camera/ui/CameraControls.java b/src/com/android/camera/ui/CameraControls.java index 59222b929..c0defea06 100644 --- a/src/com/android/camera/ui/CameraControls.java +++ b/src/com/android/camera/ui/CameraControls.java @@ -42,6 +42,7 @@ import com.android.camera.ui.ModuleSwitcher; import com.android.camera.ui.RotateImageView; import com.android.camera.ShutterButton; import com.android.camera.util.CameraUtil; +import com.android.camera.TsMakeupManager; public class CameraControls extends RotatableLayout { @@ -53,6 +54,7 @@ public class CameraControls extends RotatableLayout { private View mMenu; private View mFrontBackSwitcher; private View mHdrSwitcher; + private View mTsMakeupSwitcher; private View mIndicators; private View mPreview; private View mSceneModeSwitcher; @@ -66,6 +68,7 @@ public class CameraControls extends RotatableLayout { private ArrayList<View> mViewList; private static final int FRONT_BACK_INDEX = 0; private static final int HDR_INDEX = 1; + private static final int TS_MAKEUP_INDEX = 1; private static final int SCENE_MODE_INDEX = 2; private static final int FILTER_MODE_INDEX = 3; private static final int MENU_INDEX = 4; @@ -104,7 +107,11 @@ public class CameraControls extends RotatableLayout { resetLocation(0, 0); mFrontBackSwitcher.setVisibility(View.INVISIBLE); - mHdrSwitcher.setVisibility(View.INVISIBLE); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.setVisibility(View.INVISIBLE); + } else { + mHdrSwitcher.setVisibility(View.INVISIBLE); + } mSceneModeSwitcher.setVisibility(View.INVISIBLE); mFilterModeSwitcher.setVisibility(View.INVISIBLE); @@ -122,7 +129,11 @@ public class CameraControls extends RotatableLayout { resetLocation(0, 0); mFrontBackSwitcher.setVisibility(View.INVISIBLE); - mHdrSwitcher.setVisibility(View.INVISIBLE); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.setVisibility(View.INVISIBLE); + } else { + mHdrSwitcher.setVisibility(View.INVISIBLE); + } mSceneModeSwitcher.setVisibility(View.INVISIBLE); mFilterModeSwitcher.setVisibility(View.INVISIBLE); @@ -188,7 +199,11 @@ public class CameraControls extends RotatableLayout { mSwitcher.setPressed(false); mMenu.setPressed(false); mFrontBackSwitcher.setPressed(false); - mHdrSwitcher.setPressed(false); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.setPressed(false); + } else { + mHdrSwitcher.setPressed(false); + } mSceneModeSwitcher.setPressed(false); mFilterModeSwitcher.setPressed(false); } else { @@ -198,7 +213,11 @@ public class CameraControls extends RotatableLayout { ((ModuleSwitcher) mSwitcher).enableTouch(enable); mMenu.setEnabled(enable); mFrontBackSwitcher.setEnabled(enable); - mHdrSwitcher.setEnabled(enable); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.setEnabled(enable); + } else { + mHdrSwitcher.setEnabled(enable); + } mSceneModeSwitcher.setEnabled(enable); mPreview.setEnabled(enable); mFilterModeSwitcher.setEnabled(enable && mTempEnabled[FILTER_MODE_INDEX]); @@ -208,8 +227,13 @@ public class CameraControls extends RotatableLayout { mViewList = new ArrayList<View>(); if (mFrontBackSwitcher.getVisibility() == View.VISIBLE) mViewList.add(mFrontBackSwitcher); - if (mHdrSwitcher.getVisibility() == View.VISIBLE) - mViewList.add(mHdrSwitcher); + if(TsMakeupManager.HAS_TS_MAKEUP) { + if (mTsMakeupSwitcher.getVisibility() == View.VISIBLE) + mViewList.add(mTsMakeupSwitcher); + } else { + if (mHdrSwitcher.getVisibility() == View.VISIBLE) + mViewList.add(mHdrSwitcher); + } if (mSceneModeSwitcher.getVisibility() == View.VISIBLE) mViewList.add(mSceneModeSwitcher); if (mFilterModeSwitcher.getVisibility() == View.VISIBLE) @@ -229,7 +253,11 @@ public class CameraControls extends RotatableLayout { mSwitcher = findViewById(R.id.camera_switcher); mShutter = findViewById(R.id.shutter_button); mFrontBackSwitcher = findViewById(R.id.front_back_switcher); - mHdrSwitcher = findViewById(R.id.hdr_switcher); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher = findViewById(R.id.ts_makeup_switcher); + } else { + mHdrSwitcher = findViewById(R.id.hdr_switcher); + } mMenu = findViewById(R.id.menu); mIndicators = findViewById(R.id.on_screen_indicators); mPreview = findViewById(R.id.preview_thumb); @@ -307,7 +335,11 @@ public class CameraControls extends RotatableLayout { toIndex(mIndicators, w, h, rotation, 0, 6, INDICATOR_INDEX); toIndex(mFrontBackSwitcher, w, h, rotation, 2, 0, FRONT_BACK_INDEX); toIndex(mPreview, w, h, rotation, 0, 6, PREVIEW_INDEX); - toIndex(mHdrSwitcher, w, h, rotation, 3, 0, HDR_INDEX); + if(TsMakeupManager.HAS_TS_MAKEUP) { + toIndex(mTsMakeupSwitcher, w, h, rotation, 3, 0, TS_MAKEUP_INDEX); + } else { + toIndex(mHdrSwitcher, w, h, rotation, 3, 0, HDR_INDEX); + } toIndex(mFilterModeSwitcher, w, h, rotation, 1, 0, FILTER_MODE_INDEX); toIndex(mSceneModeSwitcher, w, h, rotation, 0, 0, SCENE_MODE_INDEX); layoutToast(mRefocusToast, w, h, rotation); @@ -401,7 +433,11 @@ public class CameraControls extends RotatableLayout { int idx1 = rotation / 90; mFrontBackSwitcher.setX(mLocX[idx1][FRONT_BACK_INDEX] + x); - mHdrSwitcher.setX(mLocX[idx1][HDR_INDEX] + x); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.setX(mLocX[idx1][TS_MAKEUP_INDEX] + x); + } else { + mHdrSwitcher.setX(mLocX[idx1][HDR_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); @@ -411,7 +447,11 @@ public class CameraControls extends RotatableLayout { mPreview.setX(mLocX[idx1][PREVIEW_INDEX] - x); mFrontBackSwitcher.setY(mLocY[idx1][FRONT_BACK_INDEX] + y); - mHdrSwitcher.setY(mLocY[idx1][HDR_INDEX] + y); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.setY(mLocY[idx1][TS_MAKEUP_INDEX] + y); + } else { + mHdrSwitcher.setY(mLocY[idx1][HDR_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); @@ -426,7 +466,11 @@ public class CameraControls extends RotatableLayout { enableTouch(false); int rotation = getUnifiedRotation(); mFrontBackSwitcher.animate().cancel(); - mHdrSwitcher.animate().cancel(); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.animate().cancel(); + } else { + mHdrSwitcher.animate().cancel(); + } mSceneModeSwitcher.animate().cancel(); mFilterModeSwitcher.animate().cancel(); mSwitcher.animate().cancel(); @@ -441,7 +485,11 @@ public class CameraControls extends RotatableLayout { switch (rotation) { case 0: mFrontBackSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION); - mHdrSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION); + } else { + mHdrSwitcher.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); @@ -453,7 +501,11 @@ public class CameraControls extends RotatableLayout { break; case 90: mFrontBackSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION); - mHdrSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION); + } else { + mHdrSwitcher.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); @@ -465,7 +517,11 @@ public class CameraControls extends RotatableLayout { break; case 180: mFrontBackSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION); - mHdrSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION); + } else { + mHdrSwitcher.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); @@ -477,7 +533,11 @@ public class CameraControls extends RotatableLayout { break; case 270: mFrontBackSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION); - mHdrSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION); + } else { + mHdrSwitcher.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); @@ -497,7 +557,11 @@ public class CameraControls extends RotatableLayout { enableTouch(false); int rotation = getUnifiedRotation(); mFrontBackSwitcher.animate().cancel(); - mHdrSwitcher.animate().cancel(); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.animate().cancel(); + } else { + mHdrSwitcher.animate().cancel(); + } mSceneModeSwitcher.animate().cancel(); mFilterModeSwitcher.animate().cancel(); mSwitcher.animate().cancel(); @@ -524,7 +588,11 @@ public class CameraControls extends RotatableLayout { resetLocation(0, -mSize); mFrontBackSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION); - mHdrSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.animate().translationYBy(mSize).setDuration(ANIME_DURATION); + } else { + mHdrSwitcher.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); @@ -538,7 +606,11 @@ public class CameraControls extends RotatableLayout { resetLocation(-mSize, 0); mFrontBackSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION); - mHdrSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.animate().translationXBy(mSize).setDuration(ANIME_DURATION); + } else { + mHdrSwitcher.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); @@ -552,7 +624,11 @@ public class CameraControls extends RotatableLayout { resetLocation(0, mSize); mFrontBackSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION); - mHdrSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.animate().translationYBy(-mSize).setDuration(ANIME_DURATION); + } else { + mHdrSwitcher.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); @@ -566,7 +642,11 @@ public class CameraControls extends RotatableLayout { resetLocation(mSize, 0); mFrontBackSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION); - mHdrSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION); + if(TsMakeupManager.HAS_TS_MAKEUP) { + mTsMakeupSwitcher.animate().translationXBy(-mSize).setDuration(ANIME_DURATION); + } else { + mHdrSwitcher.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); @@ -827,7 +907,8 @@ public class CameraControls extends RotatableLayout { mOrientation = orientation; View[] views = { mSceneModeSwitcher, mFilterModeSwitcher, mFrontBackSwitcher, - mHdrSwitcher, mMenu, mShutter, mPreview, mSwitcher + TsMakeupManager.HAS_TS_MAKEUP ? mTsMakeupSwitcher : mHdrSwitcher, + mMenu, mShutter, mPreview, mSwitcher }; for (View v : views) { ((RotateImageView) v).setOrientation(orientation, animation); |