Revert "SnapdragonCamera: Add back missing setting menus"

This reverts commit 673e935015a954e7cb40201408199a22f1aa63a9.
diff --git a/src/com/android/camera/CustomPhotoMenu.java b/src/com/android/camera/CustomPhotoMenu.java
new file mode 100644
index 0000000..551412a
--- /dev/null
+++ b/src/com/android/camera/CustomPhotoMenu.java
@@ -0,0 +1,1009 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
+ *
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * 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 java.util.Locale;
+
+import android.animation.Animator;
+import android.animation.Animator.AnimatorListener;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.res.Resources;
+import android.hardware.Camera.Parameters;
+import android.graphics.Rect;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewPropertyAnimator;
+import android.widget.ListView;
+import android.widget.Toast;
+import android.widget.TextView;
+import android.widget.GridView;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.FrameLayout;
+import android.widget.FrameLayout.LayoutParams;
+
+import com.android.camera.CameraPreference.OnPreferenceChangedListener;
+import com.android.camera.ui.CameraControls;
+import com.android.camera.ui.CountdownTimerPopup;
+import com.android.camera.ui.ListSubMenu;
+import com.android.camera.ui.PieItem;
+import com.android.camera.ui.ListMenu;
+import com.android.camera.ui.RotateImageView;
+import org.codeaurora.snapcam.R;
+import android.widget.HorizontalScrollView;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.view.Display;
+import com.android.camera.util.CameraUtil;
+
+public class CustomPhotoMenu extends MenuController
+        implements ListMenu.Listener,
+        CountdownTimerPopup.Listener,
+        ListSubMenu.Listener {
+    private static String TAG = "CustomPhotoMenu";
+
+    private final String mSettingOff;
+
+    private String[] mOtherKeys1;
+    private String[] mOtherKeys2;
+    private ListMenu mListMenu;
+    private View mPreviewMenu;
+    private static final int POPUP_NONE = 0;
+    private static final int POPUP_FIRST_LEVEL = 1;
+    private static final int POPUP_SECOND_LEVEL = 2;
+    private static final int POPUP_IN_ANIMATION = 3;
+    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 DEVELOPER_MENU_TOUCH_COUNT = 10;
+    private int mSceneStatus;
+    private View mHdrSwitcher;
+    private View mFrontBackSwitcher;
+    private View mSceneModeSwitcher;
+    private View mFilterModeSwitcher;
+    private PhotoUI mUI;
+    private int mPopupStatus;
+    private int mPreviewMenuStatus;
+    private ListSubMenu mListSubMenu;
+    private CameraActivity mActivity;
+    private boolean mHdrOn = false;
+    private int privateCounter = 0;
+    private static final int ANIMATION_DURATION = 300;
+    private static final int CLICK_THRESHOLD = 200;
+    private int previewMenuSize;
+
+    public CustomPhotoMenu(CameraActivity activity, PhotoUI ui) {
+        super(activity);
+        mUI = ui;
+        mSettingOff = activity.getString(R.string.setting_off_value);
+        mActivity = activity;
+        mFrontBackSwitcher = ui.getRootView().findViewById(R.id.front_back_switcher);
+        mHdrSwitcher = ui.getRootView().findViewById(R.id.hdr_switcher);
+        mSceneModeSwitcher = ui.getRootView().findViewById(R.id.scene_mode_switcher);
+        mFilterModeSwitcher = ui.getRootView().findViewById(R.id.filter_mode_switcher);
+    }
+
+    public void initialize(PreferenceGroup group) {
+        super.initialize(group);
+        mListSubMenu = null;
+        mListMenu = null;
+        mPopupStatus = POPUP_NONE;
+        mPreviewMenuStatus = POPUP_NONE;
+        final Resources res = mActivity.getResources();
+        Locale locale = res.getConfiguration().locale;
+        // The order is from left to right in the menu.
+
+        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);
+        } else {
+            mHdrSwitcher.setVisibility(View.INVISIBLE);
+        }
+
+        mOtherKeys1 = new String[] {
+                CameraSettings.KEY_RECORD_LOCATION,
+                CameraSettings.KEY_PICTURE_SIZE,
+                CameraSettings.KEY_JPEG_QUALITY,
+                CameraSettings.KEY_TIMER,
+                CameraSettings.KEY_CAMERA_SAVEPATH,
+                CameraSettings.KEY_LONGSHOT,
+                CameraSettings.KEY_FACE_DETECTION,
+                CameraSettings.KEY_ISO,
+                CameraSettings.KEY_EXPOSURE,
+                CameraSettings.KEY_WHITE_BALANCE,
+                CameraSettings.KEY_FOCUS_MODE,
+                CameraSettings.KEY_REDEYE_REDUCTION
+        };
+
+        mOtherKeys2 = new String[] {
+                CameraSettings.KEY_RECORD_LOCATION,
+                CameraSettings.KEY_PICTURE_SIZE,
+                CameraSettings.KEY_JPEG_QUALITY,
+                CameraSettings.KEY_TIMER,
+                CameraSettings.KEY_CAMERA_SAVEPATH,
+                CameraSettings.KEY_LONGSHOT,
+                CameraSettings.KEY_FACE_DETECTION,
+                CameraSettings.KEY_ISO,
+                CameraSettings.KEY_EXPOSURE,
+                CameraSettings.KEY_WHITE_BALANCE,
+                CameraSettings.KEY_FOCUS_MODE,
+                CameraSettings.KEY_REDEYE_REDUCTION,
+                CameraSettings.KEY_HISTOGRAM,
+                CameraSettings.KEY_ZSL,
+                CameraSettings.KEY_TIMER_SOUND_EFFECTS,
+                CameraSettings.KEY_FACE_RECOGNITION,
+                CameraSettings.KEY_TOUCH_AF_AEC,
+                CameraSettings.KEY_SELECTABLE_ZONE_AF,
+                CameraSettings.KEY_PICTURE_FORMAT,
+                CameraSettings.KEY_SATURATION,
+                CameraSettings.KEY_CONTRAST,
+                CameraSettings.KEY_SHARPNESS,
+                CameraSettings.KEY_AUTOEXPOSURE,
+                CameraSettings.KEY_ANTIBANDING,
+                CameraSettings.KEY_DENOISE,
+                CameraSettings.KEY_ADVANCED_FEATURES,
+                CameraSettings.KEY_AE_BRACKET_HDR
+        };
+
+        initSwitchItem(CameraSettings.KEY_CAMERA_ID, mFrontBackSwitcher);
+    }
+
+    @Override
+    // Hit when an item in a popup gets selected
+    public void onListPrefChanged(ListPreference pref) {
+        animateFadeOut(mListSubMenu, 2);
+        onSettingChanged(pref);
+        ((ListMenu) mListMenu).resetHighlight();
+    }
+
+    public boolean handleBackKey() {
+        if (mPreviewMenuStatus == PREVIEW_MENU_ON) {
+            animateSlideOut(mPreviewMenu);
+            return true;
+        }
+        if (mPopupStatus == POPUP_NONE)
+            return false;
+        if (mPopupStatus == POPUP_FIRST_LEVEL) {
+            animateSlideOut(mListMenu, 1);
+        } else if (mPopupStatus == POPUP_SECOND_LEVEL) {
+            animateFadeOut(mListSubMenu, 2);
+            ((ListMenu) mListMenu).resetHighlight();
+        }
+        return true;
+    }
+
+    public void closeSceneMode() {
+        mUI.removeSceneModeMenu();
+    }
+
+    public void tryToCloseSubList() {
+        if (mListMenu != null)
+            ((ListMenu) mListMenu).resetHighlight();
+
+        if (mPopupStatus == POPUP_SECOND_LEVEL) {
+            mUI.dismissLevel2();
+            mPopupStatus = POPUP_FIRST_LEVEL;
+        }
+    }
+
+    private void animateFadeOut(final ListView v, final int level) {
+        if (v == null || mPopupStatus == POPUP_IN_ANIMATION)
+            return;
+        mPopupStatus = POPUP_IN_ANIMATION;
+
+        ViewPropertyAnimator vp = v.animate();
+        vp.alpha(0f).setDuration(ANIMATION_DURATION);
+        vp.setListener(new AnimatorListener() {
+            @Override
+            public void onAnimationStart(Animator animation) {
+            }
+
+            @Override
+            public void onAnimationRepeat(Animator animation) {
+
+            }
+
+            @Override
+            public void onAnimationEnd(Animator animation) {
+                if (level == 1) {
+                    mUI.dismissLevel1();
+                    initializePopup();
+                    mPopupStatus = POPUP_NONE;
+                    mUI.cleanupListview();
+                }
+                else if (level == 2) {
+                    mUI.dismissLevel2();
+                    mPopupStatus = POPUP_FIRST_LEVEL;
+                }
+            }
+
+            @Override
+            public void onAnimationCancel(Animator animation) {
+                if (level == 1) {
+                    mUI.dismissLevel1();
+                    initializePopup();
+                    mPopupStatus = POPUP_NONE;
+                    mUI.cleanupListview();
+                }
+                else if (level == 2) {
+                    mUI.dismissLevel2();
+                    mPopupStatus = POPUP_FIRST_LEVEL;
+                }
+
+            }
+        });
+        vp.start();
+    }
+
+    private void animateSlideOut(final ListView v, final int level) {
+        if (v == null || mPopupStatus == POPUP_IN_ANIMATION)
+            return;
+        mPopupStatus = POPUP_IN_ANIMATION;
+
+        ViewPropertyAnimator vp = v.animate();
+        vp.translationX(v.getX() - v.getWidth()).setDuration(ANIMATION_DURATION);
+        vp.setListener(new AnimatorListener() {
+            @Override
+            public void onAnimationStart(Animator animation) {
+            }
+
+            @Override
+            public void onAnimationRepeat(Animator animation) {
+
+            }
+
+            @Override
+            public void onAnimationEnd(Animator animation) {
+                if (level == 1) {
+                    mUI.dismissLevel1();
+                    initializePopup();
+                    mPopupStatus = POPUP_NONE;
+                    mUI.cleanupListview();
+                }
+                else if (level == 2) {
+                    mUI.dismissLevel2();
+                    mPopupStatus = POPUP_FIRST_LEVEL;
+                }
+            }
+
+            @Override
+            public void onAnimationCancel(Animator animation) {
+                if (level == 1) {
+                    mUI.dismissLevel1();
+                    initializePopup();
+                    mPopupStatus = POPUP_NONE;
+                    mUI.cleanupListview();
+                }
+                else if (level == 2) {
+                    mUI.dismissLevel2();
+                    mPopupStatus = POPUP_FIRST_LEVEL;
+                }
+
+            }
+        });
+        vp.start();
+    }
+
+    public void animateFadeIn(final ListView v) {
+        ViewPropertyAnimator vp = v.animate();
+        vp.alpha(0.85f).setDuration(ANIMATION_DURATION);
+        vp.start();
+    }
+
+    public void animateSlideIn(final View v, int delta, boolean settingMenu) {
+        int rotation = CameraUtil.getDisplayRotation(mActivity);
+        boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
+        if (!mIsDefaultToPortrait) {
+            rotation = (rotation + 90) % 360;
+        }
+        boolean portrait = (rotation == 0) || (rotation == 180);
+        if (settingMenu)
+            portrait = true;
+        ViewPropertyAnimator vp = v.animate();
+        if (portrait) {
+            float dest = v.getX();
+            v.setX(dest - delta);
+            vp.translationX(dest).setDuration(ANIMATION_DURATION);
+        }
+        else {
+            float dest = v.getY();
+            v.setY(dest + delta);
+            vp.translationY(dest).setDuration(ANIMATION_DURATION);
+        }
+        vp.start();
+    }
+
+    public void animateSlideOutPreviewMenu() {
+        if (mPreviewMenu == null)
+            return;
+        animateSlideOut(mPreviewMenu);
+    }
+
+    private void animateSlideOut(final View v) {
+        if (v == null || mPreviewMenuStatus == PREVIEW_MENU_IN_ANIMATION)
+            return;
+        mPreviewMenuStatus = PREVIEW_MENU_IN_ANIMATION;
+        int rotation = CameraUtil.getDisplayRotation(mActivity);
+        boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
+        if (!mIsDefaultToPortrait) {
+            rotation = (rotation + 90) % 360;
+        }
+        boolean portrait = (rotation == 0) || (rotation == 180);
+        ViewPropertyAnimator vp = v.animate();
+        if (portrait) {
+            vp.translationX(v.getX() - v.getWidth()).setDuration(ANIMATION_DURATION);
+
+        } else {
+            vp.translationY(v.getY() + v.getHeight()).setDuration(ANIMATION_DURATION);
+
+        }
+        vp.setListener(new AnimatorListener() {
+            @Override
+            public void onAnimationStart(Animator animation) {
+            }
+
+            @Override
+            public void onAnimationRepeat(Animator animation) {
+
+            }
+
+            @Override
+            public void onAnimationEnd(Animator animation) {
+                closeSceneMode();
+                mPreviewMenuStatus = PREVIEW_MENU_NONE;
+            }
+
+            @Override
+            public void onAnimationCancel(Animator animation) {
+                closeSceneMode();
+                mPreviewMenuStatus = PREVIEW_MENU_NONE;
+
+            }
+        });
+        vp.start();
+    }
+
+    private void buttonSetEnabled(View v, boolean enable) {
+        v.setEnabled(enable);
+        if (v instanceof ViewGroup) {
+            View v2 = ((ViewGroup) v).getChildAt(0);
+            if (v2 != null)
+                v2.setEnabled(enable);
+
+        }
+
+    }
+
+    public boolean isOverMenu(MotionEvent ev) {
+        if (mPopupStatus == POPUP_NONE || mPopupStatus == POPUP_IN_ANIMATION)
+            return false;
+        if (mUI.getMenuLayout() == null)
+            return false;
+        Rect rec = new Rect();
+        mUI.getMenuLayout().getChildAt(0).getHitRect(rec);
+        return rec.contains((int) ev.getX(), (int) ev.getY());
+    }
+
+    public boolean isOverPreviewMenu(MotionEvent ev) {
+        if (mPreviewMenuStatus != PREVIEW_MENU_ON)
+            return false;
+        if (mUI.getPreviewMenuLayout() == null)
+            return false;
+        Rect rec = new Rect();
+        mUI.getPreviewMenuLayout().getChildAt(0).getHitRect(rec);
+        rec.top += (int) mUI.getPreviewMenuLayout().getY();
+        rec.bottom += (int) mUI.getPreviewMenuLayout().getY();
+        return rec.contains((int) ev.getX(), (int) ev.getY());
+    }
+
+    public boolean isMenuBeingShown() {
+        return mPopupStatus != POPUP_NONE;
+    }
+
+    public boolean isMenuBeingAnimated() {
+        return mPopupStatus == POPUP_IN_ANIMATION;
+    }
+
+    public boolean isPreviewMenuBeingShown() {
+        return mPreviewMenuStatus == PREVIEW_MENU_ON;
+    }
+
+    public boolean isPreviewMenuBeingAnimated() {
+        return mPreviewMenuStatus == PREVIEW_MENU_IN_ANIMATION;
+    }
+
+    public boolean sendTouchToPreviewMenu(MotionEvent ev) {
+        return mUI.sendTouchToPreviewMenu(ev);
+    }
+
+    public boolean sendTouchToMenu(MotionEvent ev) {
+        return mUI.sendTouchToMenu(ev);
+    }
+
+    @Override
+    public void overrideSettings(final String... keyvalues) {
+        for (int i = 0; i < keyvalues.length; i += 2) {
+            if (keyvalues[i].equals(CameraSettings.KEY_SCENE_MODE)) {
+                buttonSetEnabled(mSceneModeSwitcher, keyvalues[i + 1] == null);
+            }
+        }
+        super.overrideSettings(keyvalues);
+        if ((mListMenu == null))
+            initializePopup();
+        mListMenu.overrideSettings(keyvalues);
+    }
+
+    protected void initializePopup() {
+        LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
+                Context.LAYOUT_INFLATER_SERVICE);
+        ListMenu popup1 = (ListMenu) inflater.inflate(
+                R.layout.list_menu, null, false);
+
+        popup1.setSettingChangedListener(this);
+
+        String[] keys = mOtherKeys1;
+        if (mActivity.isDeveloperMenuEnabled())
+            keys = mOtherKeys2;
+        popup1.initialize(mPreferenceGroup, keys);
+        if (mActivity.isSecureCamera()) {
+            // Prevent location preference from getting changed in secure camera
+            // mode
+            popup1.setPreferenceEnabled(CameraSettings.KEY_RECORD_LOCATION, false);
+        }
+        mListMenu = popup1;
+
+        ListPreference pref = mPreferenceGroup.findPreference(
+                CameraSettings.KEY_SCENE_MODE);
+        String sceneMode = (pref != null) ? pref.getValue() : null;
+        pref = mPreferenceGroup.findPreference(CameraSettings.KEY_FACE_DETECTION);
+        String faceDetection = (pref != null) ? pref.getValue() : null;
+        pref = mPreferenceGroup.findPreference(CameraSettings.KEY_ZSL);
+        String zsl = (pref != null) ? pref.getValue() : null;
+        if ((sceneMode != null) && !Parameters.SCENE_MODE_AUTO.equals(sceneMode)) {
+            popup1.setPreferenceEnabled(CameraSettings.KEY_FOCUS_MODE, false);
+            popup1.setPreferenceEnabled(CameraSettings.KEY_AUTOEXPOSURE, false);
+            popup1.setPreferenceEnabled(CameraSettings.KEY_TOUCH_AF_AEC, false);
+            popup1.setPreferenceEnabled(CameraSettings.KEY_SATURATION, false);
+            popup1.setPreferenceEnabled(CameraSettings.KEY_CONTRAST, false);
+            popup1.setPreferenceEnabled(CameraSettings.KEY_SHARPNESS, false);
+            popup1.setPreferenceEnabled(CameraSettings.KEY_COLOR_EFFECT, false);
+            popup1.setPreferenceEnabled(CameraSettings.KEY_FLASH_MODE, false);
+            popup1.setPreferenceEnabled(CameraSettings.KEY_WHITE_BALANCE, false);
+            popup1.setPreferenceEnabled(CameraSettings.KEY_EXPOSURE, false);
+        }
+        if ((zsl != null) && Parameters.ZSL_ON.equals(zsl)) {
+            popup1.setPreferenceEnabled(CameraSettings.KEY_FOCUS_MODE, false);
+        }
+        if ((faceDetection != null) && !Parameters.FACE_DETECTION_ON.equals(faceDetection)) {
+            popup1.setPreferenceEnabled(CameraSettings.KEY_FACE_RECOGNITION, false);
+        }
+
+        pref = mPreferenceGroup.findPreference(CameraSettings.KEY_ADVANCED_FEATURES);
+        String advancedFeatures = (pref != null) ? pref.getValue() : null;
+
+        String ubiFocusOn = mActivity.getString(R.string.
+                pref_camera_advanced_feature_value_ubifocus_on);
+        String chromaFlashOn = mActivity.getString(R.string.
+                pref_camera_advanced_feature_value_chromaflash_on);
+        String optiZoomOn = mActivity.getString(R.string.
+                pref_camera_advanced_feature_value_optizoom_on);
+
+        if ((zsl != null) && Parameters.ZSL_OFF.equals(zsl)) {
+            popup1.overrideSettings(CameraSettings.KEY_ADVANCED_FEATURES,
+                    mActivity.getString(R.string.pref_camera_advanced_feature_default));
+
+            popup1.setPreferenceEnabled(CameraSettings.KEY_ADVANCED_FEATURES, false);
+            if (mHdrSwitcher.getVisibility() == View.VISIBLE) {
+                buttonSetEnabled(mHdrSwitcher, true);
+            }
+        } else {
+            if ((advancedFeatures != null) && (advancedFeatures.equals(ubiFocusOn) ||
+                    advancedFeatures.equals(chromaFlashOn) ||
+                    advancedFeatures.equals(optiZoomOn))) {
+                popup1.setPreferenceEnabled(CameraSettings.KEY_FOCUS_MODE, false);
+                popup1.setPreferenceEnabled(CameraSettings.KEY_FLASH_MODE, false);
+                popup1.setPreferenceEnabled(CameraSettings.KEY_AE_BRACKET_HDR, false);
+                popup1.setPreferenceEnabled(CameraSettings.KEY_REDEYE_REDUCTION, false);
+                popup1.setPreferenceEnabled(CameraSettings.KEY_EXPOSURE, false);
+                popup1.setPreferenceEnabled(CameraSettings.KEY_COLOR_EFFECT, false);
+                popup1.setPreferenceEnabled(CameraSettings.KEY_TOUCH_AF_AEC, false);
+                popup1.setPreferenceEnabled(CameraSettings.KEY_SCENE_MODE, false);
+
+                setPreference(CameraSettings.KEY_CAMERA_HDR, mSettingOff);
+                if (mHdrSwitcher.getVisibility() == View.VISIBLE) {
+                    buttonSetEnabled(mHdrSwitcher, false);
+                }
+            } else {
+                if (mHdrSwitcher.getVisibility() == View.VISIBLE) {
+                    buttonSetEnabled(mHdrSwitcher, true);
+                }
+            }
+        }
+
+        pref = mPreferenceGroup.findPreference(CameraSettings.KEY_SCENE_MODE);
+        if (pref != null) {
+            if (notSame(pref, CameraSettings.KEY_SCENE_MODE, Parameters.SCENE_MODE_AUTO)) {
+                buttonSetEnabled(mFilterModeSwitcher, false);
+            } else {
+                buttonSetEnabled(mFilterModeSwitcher, true);
+            }
+        }
+
+        if (mListener != null) {
+            mListener.onSharedPreferenceChanged();
+        }
+    }
+
+    public void initSwitchItem(final String prefKey, View switcher) {
+        final IconListPreference pref =
+                (IconListPreference) mPreferenceGroup.findPreference(prefKey);
+        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) ((FrameLayout) switcher).getChildAt(0);
+        iv.setImageResource(resid);
+        switcher.setVisibility(View.VISIBLE);
+        mPreferences.add(pref);
+        mPreferenceMap.put(pref, switcher);
+        switcher.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                IconListPreference pref = (IconListPreference) mPreferenceGroup
+                        .findPreference(prefKey);
+                if (pref == null)
+                    return;
+                int index = pref.findIndexOfValue(pref.getValue());
+                CharSequence[] values = pref.getEntryValues();
+                index = (index + 1) % values.length;
+                pref.setValueIndex(index);
+                ImageView iv = (ImageView) ((FrameLayout) v).getChildAt(0);
+                iv.setImageResource(((IconListPreference) pref).getLargeIconIds()[index]);
+                if (prefKey.equals(CameraSettings.KEY_CAMERA_ID))
+                    mListener.onCameraPickerClicked(index);
+                reloadPreference(pref);
+                onSettingChanged(pref);
+            }
+        });
+    }
+
+    public void initSceneModeButton(View button) {
+        button.setVisibility(View.INVISIBLE);
+        updateSceneModeIcon();
+        button.setVisibility(View.VISIBLE);
+        button.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                addSceneMode();
+                View view = mUI.getPreviewMenuLayout().getChildAt(0);
+                animateSlideIn(view, previewMenuSize, false);
+            }
+        });
+    }
+
+    public void addModeBack() {
+        if (mSceneStatus == MODE_SCENE) {
+            addSceneMode();
+        }
+        if (mSceneStatus == MODE_FILTER) {
+            addFilterMode();
+        }
+    }
+
+    public void addSceneMode() {
+        final IconListPreference pref = (IconListPreference) mPreferenceGroup
+                .findPreference(CameraSettings.KEY_SCENE_MODE);
+        if (pref == null)
+            return;
+
+        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();
+
+        CharSequence[] entries = pref.getEntries();
+
+        int[] thumbnails = pref.getThumbnailIds();
+
+        Resources r = mActivity.getResources();
+        int height = (int) (r.getDimension(R.dimen.scene_mode_height) + 2
+                * r.getDimension(R.dimen.scene_mode_padding) + 1);
+        int width = (int) (r.getDimension(R.dimen.scene_mode_width) + 2
+                * r.getDimension(R.dimen.scene_mode_padding) + 1);
+
+        int gridRes = 0;
+        boolean portrait = (rotation == 0) || (rotation == 180);
+        int size = height;
+        if (portrait) {
+            gridRes = R.layout.vertical_grid;
+            size = width;
+        } else {
+            gridRes = R.layout.horiz_grid;
+        }
+        previewMenuSize = size;
+        mUI.hideUI();
+        mPreviewMenuStatus = PREVIEW_MENU_ON;
+        mSceneStatus = MODE_SCENE;
+
+        LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
+                Context.LAYOUT_INFLATER_SERVICE);
+        FrameLayout basic = (FrameLayout) inflater.inflate(
+                gridRes, null, false);
+
+        mUI.dismissSceneModeMenu();
+        LinearLayout previewMenuLayout = new LinearLayout(mActivity);
+        mUI.setPreviewMenuLayout(previewMenuLayout);
+        ViewGroup.LayoutParams params = null;
+        if (portrait) {
+            params = new ViewGroup.LayoutParams(size, LayoutParams.MATCH_PARENT);
+            previewMenuLayout.setLayoutParams(params);
+            ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout);
+        } else {
+            params = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, size);
+
+            previewMenuLayout.setLayoutParams(params);
+            ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout);
+            previewMenuLayout.setY(display.getHeight() - size);
+        }
+        basic.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
+                LayoutParams.MATCH_PARENT));
+        LinearLayout layout = (LinearLayout) basic.findViewById(R.id.layout);
+
+        final View[] views = new View[entries.length];
+        int init = pref.getCurrentIndex();
+        for (int i = 0; i < entries.length; i++) {
+            LinearLayout layout2 = (LinearLayout) inflater.inflate(
+                    R.layout.scene_mode_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);
+                            onSettingChanged(pref);
+                            updateSceneModeIcon();
+                            for (View v1 : views) {
+                                v1.setBackgroundResource(R.drawable.scene_mode_view_border);
+                            }
+                            View border = v.findViewById(R.id.border);
+                            border.setBackgroundResource(R.drawable.scene_mode_view_border_selected);
+                        }
+
+                    }
+                    return true;
+                }
+            });
+
+            View border = layout2.findViewById(R.id.border);
+            views[j] = border;
+            if (i == init)
+                border.setBackgroundResource(R.drawable.scene_mode_view_border_selected);
+            imageView.setImageResource(thumbnails[i]);
+            label.setText(entries[i]);
+            layout.addView(layout2);
+        }
+        previewMenuLayout.addView(basic);
+        mPreviewMenu = basic;
+    }
+
+    public void updateSceneModeIcon() {
+        final IconListPreference pref = (IconListPreference) mPreferenceGroup
+                .findPreference(CameraSettings.KEY_SCENE_MODE);
+        if (pref == null)
+            return;
+        ImageView iv = (ImageView) ((FrameLayout) mSceneModeSwitcher).getChildAt(0);
+        int[] thumbnails = pref.getThumbnailIds();
+        int ind = pref.getCurrentIndex();
+        if (ind == -1)
+            ind = 0;
+        iv.setImageResource(thumbnails[ind]);
+    }
+
+    public void initFilterModeButton(View button) {
+        button.setVisibility(View.INVISIBLE);
+        final IconListPreference pref = (IconListPreference) mPreferenceGroup
+                .findPreference(CameraSettings.KEY_COLOR_EFFECT);
+        if (pref == null)
+            return;
+
+        int[] iconIds = pref.getLargeIconIds();
+        int resid = -1;
+        // The preference only has a single icon to represent it.
+        resid = pref.getSingleIcon();
+        ImageView iv = (ImageView) ((FrameLayout) button).getChildAt(0);
+        iv.setImageResource(resid);
+        button.setVisibility(View.VISIBLE);
+        button.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                addFilterMode();
+                View view = mUI.getPreviewMenuLayout().getChildAt(0);
+                animateSlideIn(view, previewMenuSize, false);
+            }
+        });
+    }
+
+    public void addFilterMode() {
+        final IconListPreference pref = (IconListPreference) mPreferenceGroup
+                .findPreference(CameraSettings.KEY_COLOR_EFFECT);
+        if (pref == null)
+            return;
+
+        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();
+        CharSequence[] entries = pref.getEntries();
+
+        Resources r = mActivity.getResources();
+        int height = (int) (r.getDimension(R.dimen.filter_mode_height) + 2
+                * r.getDimension(R.dimen.filter_mode_padding) + 1);
+        int width = (int) (r.getDimension(R.dimen.filter_mode_width) + 2
+                * r.getDimension(R.dimen.filter_mode_padding) + 1);
+
+        int gridRes = 0;
+        boolean portrait = (rotation == 0) || (rotation == 180);
+        int size = height;
+        if (portrait) {
+            gridRes = R.layout.vertical_grid;
+            size = width;
+        } else {
+            gridRes = R.layout.horiz_grid;
+        }
+        previewMenuSize = size;
+        mUI.hideUI();
+        mPreviewMenuStatus = PREVIEW_MENU_ON;
+        mSceneStatus = MODE_FILTER;
+
+        int[] thumbnails = pref.getThumbnailIds();
+
+        LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
+                Context.LAYOUT_INFLATER_SERVICE);
+        FrameLayout basic = (FrameLayout) inflater.inflate(
+                gridRes, null, false);
+
+        mUI.dismissSceneModeMenu();
+        LinearLayout previewMenuLayout = new LinearLayout(mActivity);
+        mUI.setPreviewMenuLayout(previewMenuLayout);
+        ViewGroup.LayoutParams params = null;
+        if (portrait) {
+            params = new ViewGroup.LayoutParams(size, LayoutParams.MATCH_PARENT);
+            previewMenuLayout.setLayoutParams(params);
+            ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout);
+        } else {
+            params = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, size);
+            previewMenuLayout.setLayoutParams(params);
+            ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout);
+            previewMenuLayout.setY(display.getHeight() - size);
+        }
+        basic.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
+                LayoutParams.MATCH_PARENT));
+        LinearLayout layout = (LinearLayout) basic.findViewById(R.id.layout);
+        final View[] views = new View[entries.length];
+        int init = pref.getCurrentIndex();
+        for (int i = 0; i < entries.length; i++) {
+            LinearLayout layout2 = (LinearLayout) inflater.inflate(
+                    R.layout.filter_mode_view, null, false);
+            ImageView imageView = (ImageView) layout2.findViewById(R.id.image);
+            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);
+                            onSettingChanged(pref);
+                            for (View v1 : views) {
+                                v1.setBackground(null);
+                            }
+                            ImageView image = (ImageView) v.findViewById(R.id.image);
+                            image.setBackgroundColor(0xff33b5e5);
+                        }
+                    }
+                    return true;
+                }
+            });
+
+            views[j] = imageView;
+            if (i == init)
+                imageView.setBackgroundColor(0xff33b5e5);
+            TextView label = (TextView) layout2.findViewById(R.id.label);
+            imageView.setImageResource(thumbnails[i]);
+            label.setText(entries[i]);
+            layout.addView(layout2);
+        }
+        previewMenuLayout.addView(basic);
+        mPreviewMenu = basic;
+    }
+
+    public void openFirstLevel() {
+        if (isMenuBeingShown() || CameraControls.isAnimating())
+            return;
+        if (mListMenu == null || mPopupStatus != POPUP_FIRST_LEVEL) {
+            initializePopup();
+            mPopupStatus = POPUP_FIRST_LEVEL;
+        }
+        mUI.showPopup(mListMenu, 1, true);
+
+    }
+
+    public void popupDismissed(boolean dismissAll) {
+        if (!dismissAll && mPopupStatus == POPUP_SECOND_LEVEL) {
+            initializePopup();
+            mPopupStatus = POPUP_FIRST_LEVEL;
+            mUI.showPopup(mListMenu, 1, false);
+            if (mListMenu != null)
+                mListMenu = null;
+
+        } else {
+            initializePopup();
+        }
+
+    }
+
+    @Override
+    // Hit when an item in the first-level popup gets selected, then bring up
+    // the second-level popup
+    public void onPreferenceClicked(ListPreference pref) {
+        onPreferenceClicked(pref, 0);
+    }
+
+    public void onPreferenceClicked(ListPreference pref, int y) {
+        if (!mActivity.isDeveloperMenuEnabled()) {
+            if (pref.getKey().equals(CameraSettings.KEY_REDEYE_REDUCTION)) {
+                privateCounter++;
+                if (privateCounter >= DEVELOPER_MENU_TOUCH_COUNT) {
+                    mActivity.enableDeveloperMenu();
+                    SharedPreferences prefs = PreferenceManager
+                            .getDefaultSharedPreferences(mActivity);
+                    prefs.edit().putBoolean(CameraSettings.KEY_DEVELOPER_MENU, true).apply();
+                    Toast toast = Toast.makeText(mActivity,
+                            "Camera developer option is enabled now", Toast.LENGTH_SHORT);
+                    toast.show();
+                }
+            } else {
+                privateCounter = 0;
+            }
+        }
+
+        LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
+                Context.LAYOUT_INFLATER_SERVICE);
+        ListSubMenu basic = (ListSubMenu) inflater.inflate(
+                R.layout.list_sub_menu, null, false);
+        basic.initialize(pref, y);
+        basic.setSettingChangedListener(this);
+        basic.setAlpha(0f);
+        mListSubMenu = basic;
+        mUI.removeLevel2();
+        if (mPopupStatus == POPUP_SECOND_LEVEL) {
+            mUI.showPopup(mListSubMenu, 2, false);
+        } else {
+            mUI.showPopup(mListSubMenu, 2, true);
+        }
+        mPopupStatus = POPUP_SECOND_LEVEL;
+    }
+
+    public void onListMenuTouched() {
+        mUI.removeLevel2();
+    }
+
+    public void closeAllView() {
+        if (mUI != null)
+            mUI.removeLevel2();
+
+        if (mListMenu != null) {
+            animateSlideOut(mListMenu, 1);
+        }
+        animateSlideOutPreviewMenu();
+    }
+
+    public void closeView() {
+        if (mUI != null)
+            mUI.removeLevel2();
+
+        if (mListMenu != null && mPopupStatus != POPUP_NONE)
+            animateSlideOut(mListMenu, 1);
+    }
+
+    // Return true if the preference has the specified key but not the value.
+    private static boolean notSame(ListPreference pref, String key, String value) {
+        return (key.equals(pref.getKey()) && !value.equals(pref.getValue()));
+    }
+
+    private void setPreference(String key, String value) {
+        ListPreference pref = mPreferenceGroup.findPreference(key);
+        if (pref != null && !value.equals(pref.getValue())) {
+            pref.setValue(value);
+            reloadPreferences();
+        }
+    }
+
+    @Override
+    public void onSettingChanged(ListPreference pref) {
+        // Reset the scene mode if HDR is set to on. Reset HDR if scene mode is
+        // set to non-auto.
+        if (notSame(pref, CameraSettings.KEY_CAMERA_HDR, mSettingOff)) {
+            setPreference(CameraSettings.KEY_SCENE_MODE, Parameters.SCENE_MODE_AUTO);
+            setPreference(CameraSettings.KEY_ZSL, mSettingOff);
+            Toast.makeText(mActivity, R.string.hdr_enable_message,
+                    Toast.LENGTH_LONG).show();
+            mHdrOn = true;
+        } else if (notSame(pref, CameraSettings.KEY_SCENE_MODE, Parameters.SCENE_MODE_AUTO)) {
+            setPreference(CameraSettings.KEY_CAMERA_HDR, mSettingOff);
+            if (mHdrOn) {
+                Toast.makeText(mActivity, R.string.scene_enable_message,
+                        Toast.LENGTH_LONG).show();
+            }
+            mHdrOn = false;
+        }
+        if (notSame(pref, CameraSettings.KEY_ZSL, mSettingOff)) {
+            setPreference(CameraSettings.KEY_CAMERA_HDR, mSettingOff);
+        }
+        if (notSame(pref, CameraSettings.KEY_SCENE_MODE, Parameters.SCENE_MODE_AUTO)) {
+            buttonSetEnabled(mFilterModeSwitcher, false);
+        } else {
+            buttonSetEnabled(mFilterModeSwitcher, true);
+        }
+        super.onSettingChanged(pref);
+    }
+
+}
diff --git a/src/com/android/camera/CustomVideoMenu.java b/src/com/android/camera/CustomVideoMenu.java
new file mode 100644
index 0000000..6c4eada
--- /dev/null
+++ b/src/com/android/camera/CustomVideoMenu.java
@@ -0,0 +1,689 @@
+/*
+ * Copyright (c) 2014, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
+ *
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * 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.animation.Animator;
+import android.animation.Animator.AnimatorListener;
+import android.content.Context;
+import android.content.res.Resources;
+import android.content.SharedPreferences;
+import android.graphics.Rect;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.view.ViewPropertyAnimator;
+import android.widget.ListView;
+import android.widget.TextView;
+import android.widget.GridView;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.FrameLayout;
+import android.widget.FrameLayout.LayoutParams;
+
+import com.android.camera.ui.CameraControls;
+import com.android.camera.ui.ListSubMenu;
+import com.android.camera.ui.ListMenu;
+import com.android.camera.ui.TimeIntervalPopup;
+import com.android.camera.ui.RotateImageView;
+import org.codeaurora.snapcam.R;
+import android.widget.HorizontalScrollView;
+import android.view.ViewGroup;
+import android.view.WindowManager;
+import android.view.Display;
+import com.android.camera.util.CameraUtil;
+
+public class CustomVideoMenu extends MenuController
+        implements ListMenu.Listener,
+        ListSubMenu.Listener,
+        TimeIntervalPopup.Listener {
+
+    private static String TAG = "CustomVideoMenu";
+
+    private VideoUI mUI;
+    private String[] mOtherKeys1;
+    private String[] mOtherKeys2;
+
+    private ListMenu mListMenu;
+    private ListSubMenu mListSubMenu;
+    private View mPreviewMenu;
+    private static final int POPUP_NONE = 0;
+    private static final int POPUP_FIRST_LEVEL = 1;
+    private static final int POPUP_SECOND_LEVEL = 2;
+    private static final int POPUP_IN_ANIMATION = 3;
+    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_FILTER = 1;
+    private int mSceneStatus;
+    private View mFrontBackSwitcher;
+    private View mFilterModeSwitcher;
+    private int mPopupStatus;
+    private int mPreviewMenuStatus;
+    private CameraActivity mActivity;
+    private static final int ANIMATION_DURATION = 300;
+    private static final int CLICK_THRESHOLD = 200;
+    private int previewMenuSize;
+
+    public CustomVideoMenu(CameraActivity activity, VideoUI ui) {
+        super(activity);
+        mUI = ui;
+        mActivity = activity;
+        mFrontBackSwitcher = ui.getRootView().findViewById(R.id.front_back_switcher);
+        mFilterModeSwitcher = ui.getRootView().findViewById(R.id.filter_mode_switcher);
+    }
+
+    public void initialize(PreferenceGroup group) {
+        super.initialize(group);
+        mListMenu = null;
+        mListSubMenu = null;
+        mPopupStatus = POPUP_NONE;
+        mPreviewMenuStatus = POPUP_NONE;
+        initFilterModeButton(mFilterModeSwitcher);
+        // settings popup
+        mOtherKeys1 = new String[] {
+                CameraSettings.KEY_VIDEO_QUALITY,
+                CameraSettings.KEY_VIDEO_DURATION,
+                CameraSettings.KEY_RECORD_LOCATION,
+                CameraSettings.KEY_CAMERA_SAVEPATH,
+                CameraSettings.KEY_WHITE_BALANCE,
+                CameraSettings.KEY_VIDEO_HIGH_FRAME_RATE,
+                CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE
+        };
+        mOtherKeys2 = new String[] {
+                CameraSettings.KEY_VIDEO_QUALITY,
+                CameraSettings.KEY_VIDEO_DURATION,
+                CameraSettings.KEY_RECORD_LOCATION,
+                CameraSettings.KEY_CAMERA_SAVEPATH,
+                CameraSettings.KEY_WHITE_BALANCE,
+                CameraSettings.KEY_VIDEO_HIGH_FRAME_RATE,
+                CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE,
+                CameraSettings.KEY_DIS,
+                CameraSettings.KEY_VIDEO_EFFECT,
+                CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL,
+                CameraSettings.KEY_VIDEO_ENCODER,
+                CameraSettings.KEY_AUDIO_ENCODER,
+                CameraSettings.KEY_VIDEO_HDR,
+                CameraSettings.KEY_POWER_MODE
+        };
+        mFrontBackSwitcher.setVisibility(View.INVISIBLE);
+        initSwitchItem(CameraSettings.KEY_CAMERA_ID, mFrontBackSwitcher);
+    }
+
+    public boolean handleBackKey() {
+        if (mPreviewMenuStatus == PREVIEW_MENU_ON) {
+            animateSlideOut(mPreviewMenu);
+            return true;
+        }
+        if (mPopupStatus == POPUP_NONE)
+            return false;
+        if (mPopupStatus == POPUP_FIRST_LEVEL) {
+            animateSlideOut(mListMenu, 1);
+        } else if (mPopupStatus == POPUP_SECOND_LEVEL) {
+            animateFadeOut(mListSubMenu, 2);
+            ((ListMenu) mListMenu).resetHighlight();
+        }
+        return true;
+    }
+
+    public void closeSceneMode() {
+        mUI.removeSceneModeMenu();
+    }
+
+    public void tryToCloseSubList() {
+        if (mListMenu != null)
+            ((ListMenu) mListMenu).resetHighlight();
+
+        if (mPopupStatus == POPUP_SECOND_LEVEL) {
+            mUI.dismissLevel2();
+            mPopupStatus = POPUP_FIRST_LEVEL;
+        }
+    }
+
+    private void animateFadeOut(final ListView v, final int level) {
+        if (v == null || mPopupStatus == POPUP_IN_ANIMATION)
+            return;
+        mPopupStatus = POPUP_IN_ANIMATION;
+
+        ViewPropertyAnimator vp = v.animate();
+        vp.alpha(0f).setDuration(ANIMATION_DURATION);
+        vp.setListener(new AnimatorListener() {
+            @Override
+            public void onAnimationStart(Animator animation) {
+            }
+
+            @Override
+            public void onAnimationRepeat(Animator animation) {
+
+            }
+
+            @Override
+            public void onAnimationEnd(Animator animation) {
+                if (level == 1) {
+                    mUI.dismissLevel1();
+                    initializePopup();
+                    mPopupStatus = POPUP_NONE;
+                    mUI.cleanupListview();
+                }
+                else if (level == 2) {
+                    mUI.dismissLevel2();
+                    mPopupStatus = POPUP_FIRST_LEVEL;
+                }
+            }
+
+            @Override
+            public void onAnimationCancel(Animator animation) {
+                if (level == 1) {
+                    mUI.dismissLevel1();
+                    initializePopup();
+                    mPopupStatus = POPUP_NONE;
+                    mUI.cleanupListview();
+                }
+                else if (level == 2) {
+                    mUI.dismissLevel2();
+                    mPopupStatus = POPUP_FIRST_LEVEL;
+                }
+
+            }
+        });
+        vp.start();
+    }
+
+    private void animateSlideOut(final ListView v, final int level) {
+        if (v == null || mPopupStatus == POPUP_IN_ANIMATION)
+            return;
+        mPopupStatus = POPUP_IN_ANIMATION;
+
+        ViewPropertyAnimator vp = v.animate();
+        vp.translationX(v.getX() - v.getWidth()).setDuration(ANIMATION_DURATION);
+        vp.setListener(new AnimatorListener() {
+            @Override
+            public void onAnimationStart(Animator animation) {
+            }
+
+            @Override
+            public void onAnimationRepeat(Animator animation) {
+
+            }
+
+            @Override
+            public void onAnimationEnd(Animator animation) {
+                if (level == 1) {
+                    mUI.dismissLevel1();
+                    initializePopup();
+                    mPopupStatus = POPUP_NONE;
+                    mUI.cleanupListview();
+                }
+                else if (level == 2) {
+                    mUI.dismissLevel2();
+                    mPopupStatus = POPUP_FIRST_LEVEL;
+                }
+            }
+
+            @Override
+            public void onAnimationCancel(Animator animation) {
+                if (level == 1) {
+                    mUI.dismissLevel1();
+                    initializePopup();
+                    mPopupStatus = POPUP_NONE;
+                    mUI.cleanupListview();
+                }
+                else if (level == 2) {
+                    mUI.dismissLevel2();
+                    mPopupStatus = POPUP_FIRST_LEVEL;
+                }
+
+            }
+        });
+        vp.start();
+    }
+
+    public void animateFadeIn(final ListView v) {
+        ViewPropertyAnimator vp = v.animate();
+        vp.alpha(0.85f).setDuration(ANIMATION_DURATION);
+        vp.start();
+    }
+
+    public void animateSlideIn(final View v, int delta, boolean settingMenu) {
+        int rotation = CameraUtil.getDisplayRotation(mActivity);
+        boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
+        if (!mIsDefaultToPortrait) {
+            rotation = (rotation + 90) % 360;
+        }
+        boolean portrait = (rotation == 0) || (rotation == 180);
+        if (settingMenu)
+            portrait = true;
+        ViewPropertyAnimator vp = v.animate();
+        if (portrait) {
+            float dest = v.getX();
+            v.setX(dest - delta);
+            vp.translationX(dest).setDuration(ANIMATION_DURATION);
+        }
+        else {
+            float dest = v.getY();
+            v.setY(dest + delta);
+            vp.translationY(dest).setDuration(ANIMATION_DURATION);
+        }
+        vp.start();
+    }
+
+    public void animateSlideOutPreviewMenu() {
+        if (mPreviewMenu == null)
+            return;
+        animateSlideOut(mPreviewMenu);
+    }
+
+    private void animateSlideOut(final View v) {
+        if (v == null || mPreviewMenuStatus == PREVIEW_MENU_IN_ANIMATION)
+            return;
+        mPreviewMenuStatus = PREVIEW_MENU_IN_ANIMATION;
+        int rotation = CameraUtil.getDisplayRotation(mActivity);
+        boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
+        if (!mIsDefaultToPortrait) {
+            rotation = (rotation + 90) % 360;
+        }
+        boolean portrait = (rotation == 0) || (rotation == 180);
+        ViewPropertyAnimator vp = v.animate();
+        if (portrait) {
+            vp.translationX(v.getX() - v.getWidth()).setDuration(ANIMATION_DURATION);
+
+        } else {
+            vp.translationY(v.getY() + v.getHeight()).setDuration(ANIMATION_DURATION);
+
+        }
+        vp.setListener(new AnimatorListener() {
+            @Override
+            public void onAnimationStart(Animator animation) {
+            }
+
+            @Override
+            public void onAnimationRepeat(Animator animation) {
+
+            }
+
+            @Override
+            public void onAnimationEnd(Animator animation) {
+                closeSceneMode();
+                mPreviewMenuStatus = PREVIEW_MENU_NONE;
+            }
+
+            @Override
+            public void onAnimationCancel(Animator animation) {
+                closeSceneMode();
+                mPreviewMenuStatus = PREVIEW_MENU_NONE;
+            }
+        });
+        vp.start();
+    }
+
+    public boolean isOverMenu(MotionEvent ev) {
+        if (mPopupStatus == POPUP_NONE || mPopupStatus == POPUP_IN_ANIMATION)
+            return false;
+        if (mUI.getMenuLayout() == null)
+            return false;
+        Rect rec = new Rect();
+        mUI.getMenuLayout().getChildAt(0).getHitRect(rec);
+        return rec.contains((int) ev.getX(), (int) ev.getY());
+    }
+
+    public boolean isOverPreviewMenu(MotionEvent ev) {
+        if (mPreviewMenuStatus != PREVIEW_MENU_ON)
+            return false;
+        if (mUI.getPreviewMenuLayout() == null)
+            return false;
+        Rect rec = new Rect();
+        mUI.getPreviewMenuLayout().getChildAt(0).getHitRect(rec);
+        rec.top += (int) mUI.getPreviewMenuLayout().getY();
+        rec.bottom += (int) mUI.getPreviewMenuLayout().getY();
+        return rec.contains((int) ev.getX(), (int) ev.getY());
+    }
+
+    public boolean isMenuBeingShown() {
+        return mPopupStatus != POPUP_NONE;
+    }
+
+    public boolean isMenuBeingAnimated() {
+        return mPopupStatus == POPUP_IN_ANIMATION;
+    }
+
+    public boolean isPreviewMenuBeingShown() {
+        return mPreviewMenuStatus == PREVIEW_MENU_ON;
+    }
+
+    public boolean isPreviewMenuBeingAnimated() {
+        return mPreviewMenuStatus == PREVIEW_MENU_IN_ANIMATION;
+    }
+
+    public boolean sendTouchToPreviewMenu(MotionEvent ev) {
+        return mUI.sendTouchToPreviewMenu(ev);
+    }
+
+    public boolean sendTouchToMenu(MotionEvent ev) {
+        return mUI.sendTouchToMenu(ev);
+    }
+
+    public void initSwitchItem(final String prefKey, View switcher) {
+        final IconListPreference pref =
+                (IconListPreference) mPreferenceGroup.findPreference(prefKey);
+        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) ((FrameLayout) switcher).getChildAt(0);
+        iv.setImageResource(resid);
+        switcher.setVisibility(View.VISIBLE);
+        mPreferences.add(pref);
+        mPreferenceMap.put(pref, switcher);
+        switcher.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                IconListPreference pref = (IconListPreference) mPreferenceGroup
+                        .findPreference(prefKey);
+                if (pref == null)
+                    return;
+                int index = pref.findIndexOfValue(pref.getValue());
+                CharSequence[] values = pref.getEntryValues();
+                index = (index + 1) % values.length;
+                pref.setValueIndex(index);
+                ImageView iv = (ImageView) ((FrameLayout) v).getChildAt(0);
+                iv.setImageResource(((IconListPreference) pref).getLargeIconIds()[index]);
+                if (prefKey.equals(CameraSettings.KEY_CAMERA_ID))
+                    mListener.onCameraPickerClicked(index);
+                reloadPreference(pref);
+                onSettingChanged(pref);
+            }
+        });
+    }
+
+    public void initFilterModeButton(View button) {
+        button.setVisibility(View.INVISIBLE);
+        final IconListPreference pref = (IconListPreference) mPreferenceGroup
+                .findPreference(CameraSettings.KEY_COLOR_EFFECT);
+        if (pref == null)
+            return;
+
+        int[] iconIds = pref.getLargeIconIds();
+        int resid = -1;
+        // The preference only has a single icon to represent it.
+        resid = pref.getSingleIcon();
+        ImageView iv = (ImageView) ((FrameLayout) button).getChildAt(0);
+        iv.setImageResource(resid);
+        button.setVisibility(View.VISIBLE);
+        button.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                addFilterMode();
+                View view = mUI.getPreviewMenuLayout().getChildAt(0);
+                animateSlideIn(view, previewMenuSize, false);
+            }
+        });
+    }
+
+    public void addModeBack() {
+        if (mSceneStatus == MODE_FILTER) {
+            addFilterMode();
+        }
+    }
+
+    public void addFilterMode() {
+        final IconListPreference pref = (IconListPreference) mPreferenceGroup
+                .findPreference(CameraSettings.KEY_COLOR_EFFECT);
+        if (pref == null)
+            return;
+
+        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();
+        CharSequence[] entries = pref.getEntries();
+
+        Resources r = mActivity.getResources();
+        int height = (int) (r.getDimension(R.dimen.filter_mode_height) + 2
+                * r.getDimension(R.dimen.filter_mode_padding) + 1);
+        int width = (int) (r.getDimension(R.dimen.filter_mode_width) + 2
+                * r.getDimension(R.dimen.filter_mode_padding) + 1);
+
+        int gridRes = 0;
+        boolean portrait = (rotation == 0) || (rotation == 180);
+        int size = height;
+        if (portrait) {
+            gridRes = R.layout.vertical_grid;
+            size = width;
+        } else {
+            gridRes = R.layout.horiz_grid;
+        }
+        previewMenuSize = size;
+        mUI.hideUI();
+        mPreviewMenuStatus = PREVIEW_MENU_ON;
+        mSceneStatus = MODE_FILTER;
+
+        int[] thumbnails = pref.getThumbnailIds();
+
+        LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
+                Context.LAYOUT_INFLATER_SERVICE);
+        FrameLayout basic = (FrameLayout) inflater.inflate(
+                gridRes, null, false);
+
+        mUI.dismissSceneModeMenu();
+        LinearLayout previewMenuLayout = new LinearLayout(mActivity);
+        mUI.setPreviewMenuLayout(previewMenuLayout);
+        ViewGroup.LayoutParams params = null;
+        if (portrait) {
+            params = new ViewGroup.LayoutParams(size, LayoutParams.MATCH_PARENT);
+            previewMenuLayout.setLayoutParams(params);
+            ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout);
+        } else {
+            params = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, size);
+            previewMenuLayout.setLayoutParams(params);
+            ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout);
+            previewMenuLayout.setY(display.getHeight() - size);
+        }
+        basic.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
+                LayoutParams.MATCH_PARENT));
+        LinearLayout layout = (LinearLayout) basic.findViewById(R.id.layout);
+
+        final View[] views = new View[entries.length];
+        int init = pref.getCurrentIndex();
+        for (int i = 0; i < entries.length; i++) {
+            LinearLayout layout2 = (LinearLayout) inflater.inflate(
+                    R.layout.filter_mode_view, null, false);
+
+            ImageView imageView = (ImageView) layout2.findViewById(R.id.image);
+            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);
+                            for (View v1 : views) {
+                                v1.setBackground(null);
+                            }
+                            ImageView image = (ImageView) v.findViewById(R.id.image);
+                            image.setBackgroundColor(0xff33b5e5);
+                            onSettingChanged(pref);
+                        }
+
+                    }
+                    return true;
+                }
+            });
+
+            views[j] = imageView;
+            if (i == init)
+                imageView.setBackgroundColor(0xff33b5e5);
+            TextView label = (TextView) layout2.findViewById(R.id.label);
+            imageView.setImageResource(thumbnails[i]);
+            label.setText(entries[i]);
+            layout.addView(layout2);
+        }
+        previewMenuLayout.addView(basic);
+        mPreviewMenu = basic;
+    }
+
+    public void openFirstLevel() {
+        if (isMenuBeingShown() || CameraControls.isAnimating())
+            return;
+        if (mListMenu == null || mPopupStatus != POPUP_FIRST_LEVEL) {
+            initializePopup();
+            mPopupStatus = POPUP_FIRST_LEVEL;
+        }
+        mUI.showPopup(mListMenu, 1, true);
+    }
+
+    @Override
+    public void overrideSettings(final String... keyvalues) {
+        super.overrideSettings(keyvalues);
+        if (((mListMenu == null)) || mPopupStatus != POPUP_FIRST_LEVEL) {
+            mPopupStatus = POPUP_FIRST_LEVEL;
+            initializePopup();
+        }
+        mListMenu.overrideSettings(keyvalues);
+
+    }
+
+    @Override
+    // Hit when an item in the second-level popup gets selected
+    public void onListPrefChanged(ListPreference pref) {
+        if (mPopupStatus == POPUP_SECOND_LEVEL) {
+            mListMenu.reloadPreference();
+            animateFadeOut(mListSubMenu, 2);
+        }
+        super.onSettingChanged(pref);
+        ((ListMenu) mListMenu).resetHighlight();
+    }
+
+    protected void initializePopup() {
+        LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
+                Context.LAYOUT_INFLATER_SERVICE);
+
+        ListMenu popup1 = (ListMenu) inflater.inflate(
+                R.layout.list_menu, null, false);
+        popup1.setSettingChangedListener(this);
+        String[] keys = mOtherKeys1;
+        if (mActivity.isDeveloperMenuEnabled())
+            keys = mOtherKeys2;
+        popup1.initialize(mPreferenceGroup, keys);
+        if (mActivity.isSecureCamera()) {
+            // Prevent location preference from getting changed in secure camera
+            // mode
+            popup1.setPreferenceEnabled(CameraSettings.KEY_RECORD_LOCATION, false);
+        }
+        mListMenu = popup1;
+
+    }
+
+    public void popupDismissed(boolean topPopupOnly) {
+        // if the 2nd level popup gets dismissed
+        if (mPopupStatus == POPUP_SECOND_LEVEL) {
+            initializePopup();
+            mPopupStatus = POPUP_FIRST_LEVEL;
+            if (topPopupOnly) {
+                mUI.showPopup(mListMenu, 1, false);
+            }
+        } else {
+            initializePopup();
+        }
+    }
+
+    public void hideUI() {
+        mFrontBackSwitcher.setVisibility(View.INVISIBLE);
+        mFilterModeSwitcher.setVisibility(View.INVISIBLE);
+    }
+
+    public void showUI() {
+        mFrontBackSwitcher.setVisibility(View.VISIBLE);
+        mFilterModeSwitcher.setVisibility(View.VISIBLE);
+    }
+
+    @Override
+    // Hit when an item in the first-level popup gets selected, then bring up
+    // the second-level popup
+    public void onPreferenceClicked(ListPreference pref) {
+        onPreferenceClicked(pref, 0);
+    }
+
+    @Override
+    // Hit when an item in the first-level popup gets selected, then bring up
+    // the second-level popup
+    public void onPreferenceClicked(ListPreference pref, int y) {
+        LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
+                Context.LAYOUT_INFLATER_SERVICE);
+
+        ListSubMenu basic = (ListSubMenu) inflater.inflate(
+                R.layout.list_sub_menu, null, false);
+        basic.initialize(pref, y);
+        basic.setSettingChangedListener(this);
+        mUI.removeLevel2();
+        mListSubMenu = basic;
+        if (mPopupStatus == POPUP_SECOND_LEVEL) {
+            mUI.showPopup(mListSubMenu, 2, false);
+        } else {
+            mUI.showPopup(mListSubMenu, 2, true);
+        }
+        mPopupStatus = POPUP_SECOND_LEVEL;
+    }
+
+    public void onListMenuTouched() {
+        mUI.removeLevel2();
+    }
+
+    public void closeAllView() {
+        if (mUI != null)
+            mUI.removeLevel2();
+
+        if (mListMenu != null)
+            animateSlideOut(mListMenu, 1);
+        animateSlideOutPreviewMenu();
+    }
+
+    public void closeView() {
+        if (mUI != null)
+            mUI.removeLevel2();
+
+        if (mListMenu != null)
+            animateSlideOut(mListMenu, 1);
+    }
+
+    @Override
+    public void onSettingChanged(ListPreference pref) {
+        super.onSettingChanged(pref);
+    }
+
+}
diff --git a/src/com/android/camera/PhotoMenu.java b/src/com/android/camera/PhotoMenu.java
index c8522ee..629d915 100644
--- a/src/com/android/camera/PhotoMenu.java
+++ b/src/com/android/camera/PhotoMenu.java
@@ -18,154 +18,105 @@
 
 import java.util.Locale;
 
-import android.animation.Animator;
-import android.animation.Animator.AnimatorListener;
-import android.content.Context;
-import android.content.SharedPreferences;
 import android.content.res.Resources;
 import android.hardware.Camera.Parameters;
-import android.graphics.Rect;
-import android.preference.PreferenceManager;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewPropertyAnimator;
-import android.widget.ListView;
-import android.widget.Toast;
-import android.widget.TextView;
-import android.widget.GridView;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.FrameLayout;
-import android.widget.FrameLayout.LayoutParams;
 
-import com.android.camera.CameraPreference.OnPreferenceChangedListener;
-import com.android.camera.ui.CameraControls;
+import com.android.camera.ui.AbstractSettingPopup;
 import com.android.camera.ui.CountdownTimerPopup;
-import com.android.camera.ui.ListSubMenu;
-import com.android.camera.ui.ListMenu;
-import com.android.camera.ui.RotateImageView;
+import com.android.camera.ui.ListPrefSettingPopup;
+import com.android.camera.ui.MoreSettingPopup;
+import com.android.camera.ui.PieItem;
+import com.android.camera.ui.PieItem.OnClickListener;
+import com.android.camera.ui.PieRenderer;
 import org.codeaurora.snapcam.R;
-import android.widget.HorizontalScrollView;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.view.Display;
-import com.android.camera.util.CameraUtil;
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.widget.Toast;
+import android.util.Log;
 
-public class PhotoMenu extends MenuController
-        implements ListMenu.Listener,
-        CountdownTimerPopup.Listener,
-        ListSubMenu.Listener {
+import java.util.Locale;
+
+public class PhotoMenu extends PieController
+        implements MoreSettingPopup.Listener,
+         CountdownTimerPopup.Listener,
+        ListPrefSettingPopup.Listener {
     private static String TAG = "PhotoMenu";
 
     private final String mSettingOff;
 
     private String[] mOtherKeys1;
     private String[] mOtherKeys2;
-    private ListMenu mListMenu;
-    private View mPreviewMenu;
+    private String[] mOtherKeys3;
+    private MoreSettingPopup mPopup1;
+    private MoreSettingPopup mPopup2;
+    private MoreSettingPopup mPopup3;
     private static final int POPUP_NONE = 0;
     private static final int POPUP_FIRST_LEVEL = 1;
     private static final int POPUP_SECOND_LEVEL = 2;
-    private static final int POPUP_IN_ANIMATION = 3;
-    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 DEVELOPER_MENU_TOUCH_COUNT = 10;
-    private int mSceneStatus;
-    private View mHdrSwitcher;
-    private View mFrontBackSwitcher;
-    private View mSceneModeSwitcher;
-    private View mFilterModeSwitcher;
     private PhotoUI mUI;
     private int mPopupStatus;
-    private int mPreviewMenuStatus;
-    private ListSubMenu mListSubMenu;
+    private AbstractSettingPopup mPopup;
     private CameraActivity mActivity;
+    private int popupNum = 0;
+    private PieItem mHdrItem = null;
+    private PieItem mHdrPlusItem = null;
     private String mPrevSavedCDS;
     private boolean mIsTNREnabled = false;
     private boolean mIsCDSUpdated = false;
-    private int privateCounter = 0;
-    private static final int ANIMATION_DURATION = 300;
-    private static final int CLICK_THRESHOLD = 200;
-    private int previewMenuSize;
 
-    public PhotoMenu(CameraActivity activity, PhotoUI ui) {
-        super(activity);
+    public PhotoMenu(CameraActivity activity, PhotoUI ui, PieRenderer pie) {
+        super(activity, pie);
         mUI = ui;
         mSettingOff = activity.getString(R.string.setting_off_value);
         mActivity = activity;
-        mFrontBackSwitcher = ui.getRootView().findViewById(R.id.front_back_switcher);
-        mHdrSwitcher = ui.getRootView().findViewById(R.id.hdr_switcher);
-        mSceneModeSwitcher = ui.getRootView().findViewById(R.id.scene_mode_switcher);
-        mFilterModeSwitcher = ui.getRootView().findViewById(R.id.filter_mode_switcher);
     }
 
     public void initialize(PreferenceGroup group) {
         super.initialize(group);
-        mListSubMenu = null;
-        mListMenu = null;
+        mPopup = null;
+        mPopup1 = null;
+        mPopup2 = null;
+        mPopup3 = null;
         mPopupStatus = POPUP_NONE;
-        mPreviewMenuStatus = POPUP_NONE;
+        PieItem item = null;
+        popupNum = 0;
         final Resources res = mActivity.getResources();
         Locale locale = res.getConfiguration().locale;
         // The order is from left to right in the menu.
 
-        initSceneModeButton(mSceneModeSwitcher);
-        initFilterModeButton(mFilterModeSwitcher);
-        mHdrSwitcher.setVisibility(View.INVISIBLE);
+        // HDR+ (GCam).
+        if (group.findPreference(CameraSettings.KEY_CAMERA_HDR_PLUS) != null) {
+            mHdrPlusItem = makeSwitchItem(CameraSettings.KEY_CAMERA_HDR_PLUS, true);
+            mRenderer.addItem(mHdrPlusItem);
+        }
 
-        mFrontBackSwitcher.setVisibility(View.INVISIBLE);
         // HDR.
         if (group.findPreference(CameraSettings.KEY_CAMERA_HDR) != null) {
-            mHdrSwitcher.setVisibility(View.VISIBLE);
-            initSwitchItem(CameraSettings.KEY_CAMERA_HDR, mHdrSwitcher);
-        } else {
-            mHdrSwitcher.setVisibility(View.INVISIBLE);
+            mHdrItem = makeSwitchItem(CameraSettings.KEY_CAMERA_HDR, true);
+            mRenderer.addItem(mHdrItem);
         }
 
         mOtherKeys1 = new String[] {
+                CameraSettings.KEY_SCENE_MODE,
                 CameraSettings.KEY_RECORD_LOCATION,
                 CameraSettings.KEY_PICTURE_SIZE,
+                CameraSettings.KEY_HISTOGRAM,
                 CameraSettings.KEY_JPEG_QUALITY,
+                CameraSettings.KEY_ZSL,
                 CameraSettings.KEY_TIMER,
+                CameraSettings.KEY_TIMER_SOUND_EFFECTS,
                 CameraSettings.KEY_CAMERA_SAVEPATH,
                 CameraSettings.KEY_LONGSHOT,
-                CameraSettings.KEY_FACE_DETECTION,
-                CameraSettings.KEY_ISO,
-                CameraSettings.KEY_EXPOSURE,
-                CameraSettings.KEY_WHITE_BALANCE,
-                CameraSettings.KEY_FLASH_MODE,
-                CameraSettings.KEY_FOCUS_MODE,
-                CameraSettings.KEY_REDEYE_REDUCTION
-        };
-
-        mOtherKeys2 = new String[] {
-                CameraSettings.KEY_RECORD_LOCATION,
-                CameraSettings.KEY_PICTURE_SIZE,
-                CameraSettings.KEY_JPEG_QUALITY,
-                CameraSettings.KEY_TIMER,
-                CameraSettings.KEY_CAMERA_SAVEPATH,
-                CameraSettings.KEY_LONGSHOT,
-                CameraSettings.KEY_FACE_DETECTION,
-                CameraSettings.KEY_ISO,
-                CameraSettings.KEY_EXPOSURE,
-                CameraSettings.KEY_WHITE_BALANCE,
-                CameraSettings.KEY_FLASH_MODE,
-                CameraSettings.KEY_FOCUS_MODE,
-                CameraSettings.KEY_REDEYE_REDUCTION,
                 CameraSettings.KEY_AUTO_HDR,
                 CameraSettings.KEY_HDR_MODE,
                 CameraSettings.KEY_HDR_NEED_1X,
                 CameraSettings.KEY_CDS_MODE,
-                CameraSettings.KEY_TNR_MODE,
-                CameraSettings.KEY_HISTOGRAM,
-                CameraSettings.KEY_ZSL,
-                CameraSettings.KEY_TIMER_SOUND_EFFECTS,
+                CameraSettings.KEY_TNR_MODE
+        };
+
+        mOtherKeys2 = new String[] {
+                CameraSettings.KEY_COLOR_EFFECT,
+                CameraSettings.KEY_FACE_DETECTION,
                 CameraSettings.KEY_FACE_RECOGNITION,
                 CameraSettings.KEY_TOUCH_AF_AEC,
                 CameraSettings.KEY_SELECTABLE_ZONE_AF,
@@ -173,294 +124,106 @@
                 CameraSettings.KEY_SATURATION,
                 CameraSettings.KEY_CONTRAST,
                 CameraSettings.KEY_SHARPNESS,
-                CameraSettings.KEY_AUTOEXPOSURE,
+                CameraSettings.KEY_AUTOEXPOSURE
+        };
+
+        mOtherKeys3 = new String[] {
                 CameraSettings.KEY_ANTIBANDING,
+                CameraSettings.KEY_ISO,
                 CameraSettings.KEY_DENOISE,
                 CameraSettings.KEY_ADVANCED_FEATURES,
+                CameraSettings.KEY_EXPOSURE,
+                CameraSettings.KEY_WHITE_BALANCE,
+                CameraSettings.KEY_FLASH_MODE,
+                CameraSettings.KEY_FOCUS_MODE,
+                CameraSettings.KEY_REDEYE_REDUCTION,
                 CameraSettings.KEY_AE_BRACKET_HDR,
                 CameraSettings.KEY_MANUAL_EXPOSURE,
                 CameraSettings.KEY_MANUAL_WB,
                 CameraSettings.KEY_MANUAL_FOCUS
         };
 
-        initSwitchItem(CameraSettings.KEY_CAMERA_ID, mFrontBackSwitcher);
+        PieItem item1 = makeItem(R.drawable.ic_settings_holo_light_01);
+        item1.setLabel(mActivity.getResources().getString(R.string.camera_menu_more_label));
+        item1.setOnClickListener(new OnClickListener() {
+             @Override
+            public void onClick(PieItem item) {
+                if (mPopup1 == null || mPopupStatus != POPUP_FIRST_LEVEL){
+                    initializePopup();
+                mPopupStatus = POPUP_FIRST_LEVEL;
+                }
+                mUI.showPopup(mPopup1);
+                popupNum = 1;
+            }
+        });
+        mRenderer.addItem(item1);
+
+        PieItem item2 = makeItem(R.drawable.ic_settings_holo_light_02);
+        item2.setLabel(mActivity.getResources().getString(R.string.camera_menu_more_label));
+        item2.setOnClickListener(new OnClickListener() {
+             @Override
+            public void onClick(PieItem item) {
+                if (mPopup2 == null || mPopupStatus != POPUP_FIRST_LEVEL) {
+                    initializePopup();
+                    mPopupStatus = POPUP_FIRST_LEVEL;
+                }
+                mUI.showPopup(mPopup2);
+                popupNum = 2;
+            }
+        });
+        mRenderer.addItem(item2);
+
+        PieItem item3= makeItem(R.drawable.ic_settings_holo_light_03);
+        item3.setLabel(mActivity.getResources().getString(R.string.camera_menu_more_label));
+        item3.setOnClickListener(new OnClickListener() {
+             @Override
+            public void onClick(PieItem item) {
+                if (mPopup3 == null || mPopupStatus != POPUP_FIRST_LEVEL) {
+                    initializePopup();
+                    mPopupStatus = POPUP_FIRST_LEVEL;
+                }
+                mUI.showPopup(mPopup3);
+                popupNum = 3;
+            }
+        });
+        mRenderer.addItem(item3);
+
+        // Camera switcher.
+        if (group.findPreference(CameraSettings.KEY_CAMERA_ID) != null) {
+            item = makeSwitchItem(CameraSettings.KEY_CAMERA_ID, false);
+            final PieItem fitem = item;
+            item.setOnClickListener(new OnClickListener() {
+                @Override
+                public void onClick(PieItem item) {
+                    // Find the index of next camera.
+                    ListPreference pref = mPreferenceGroup
+                            .findPreference(CameraSettings.KEY_CAMERA_ID);
+                    if (pref != null) {
+                        int index = pref.findIndexOfValue(pref.getValue());
+                        CharSequence[] values = pref.getEntryValues();
+                        index = (index + 1) % values.length;
+                        pref.setValueIndex(index);
+                        mListener.onCameraPickerClicked(index);
+                    }
+                    updateItem(fitem, CameraSettings.KEY_CAMERA_ID);
+                }
+            });
+            mRenderer.addItem(item);
+        }
     }
 
     @Override
     // Hit when an item in a popup gets selected
     public void onListPrefChanged(ListPreference pref) {
-        animateFadeOut(mListSubMenu, 2);
+        if (mPopup != null && mPopup1 != null && mPopup2 != null && mPopup3 != null) {
+               mUI.dismissPopup();
+        }
         onSettingChanged(pref);
-        ((ListMenu) mListMenu).resetHighlight();
-    }
-
-    public boolean handleBackKey() {
-        if (mPreviewMenuStatus == PREVIEW_MENU_ON) {
-            animateSlideOut(mPreviewMenu);
-            return true;
-        }
-        if (mPopupStatus == POPUP_NONE)
-            return false;
-        if (mPopupStatus == POPUP_FIRST_LEVEL) {
-            animateSlideOut(mListMenu, 1);
-        } else if (mPopupStatus == POPUP_SECOND_LEVEL) {
-            animateFadeOut(mListSubMenu, 2);
-            ((ListMenu) mListMenu).resetHighlight();
-        }
-        return true;
-    }
-
-    public void closeSceneMode() {
-        mUI.removeSceneModeMenu();
-    }
-
-    public void tryToCloseSubList() {
-        if (mListMenu != null)
-            ((ListMenu) mListMenu).resetHighlight();
-
-        if (mPopupStatus == POPUP_SECOND_LEVEL) {
-            mUI.dismissLevel2();
-            mPopupStatus = POPUP_FIRST_LEVEL;
-        }
-    }
-
-    private void animateFadeOut(final ListView v, final int level) {
-        if (v == null || mPopupStatus == POPUP_IN_ANIMATION)
-            return;
-        mPopupStatus = POPUP_IN_ANIMATION;
-
-        ViewPropertyAnimator vp = v.animate();
-        vp.alpha(0f).setDuration(ANIMATION_DURATION);
-        vp.setListener(new AnimatorListener() {
-            @Override
-            public void onAnimationStart(Animator animation) {
-            }
-
-            @Override
-            public void onAnimationRepeat(Animator animation) {
-
-            }
-
-            @Override
-            public void onAnimationEnd(Animator animation) {
-                if (level == 1) {
-                    mUI.dismissLevel1();
-                    initializePopup();
-                    mPopupStatus = POPUP_NONE;
-                    mUI.cleanupListview();
-                }
-                else if (level == 2) {
-                    mUI.dismissLevel2();
-                    mPopupStatus = POPUP_FIRST_LEVEL;
-                }
-            }
-
-            @Override
-            public void onAnimationCancel(Animator animation) {
-                if (level == 1) {
-                    mUI.dismissLevel1();
-                    initializePopup();
-                    mPopupStatus = POPUP_NONE;
-                    mUI.cleanupListview();
-                }
-                else if (level == 2) {
-                    mUI.dismissLevel2();
-                    mPopupStatus = POPUP_FIRST_LEVEL;
-                }
-
-            }
-        });
-        vp.start();
-    }
-
-    private void animateSlideOut(final ListView v, final int level) {
-        if (v == null || mPopupStatus == POPUP_IN_ANIMATION)
-            return;
-        mPopupStatus = POPUP_IN_ANIMATION;
-
-        ViewPropertyAnimator vp = v.animate();
-        vp.translationX(v.getX() - v.getWidth()).setDuration(ANIMATION_DURATION);
-        vp.setListener(new AnimatorListener() {
-            @Override
-            public void onAnimationStart(Animator animation) {
-            }
-
-            @Override
-            public void onAnimationRepeat(Animator animation) {
-
-            }
-
-            @Override
-            public void onAnimationEnd(Animator animation) {
-                if (level == 1) {
-                    mUI.dismissLevel1();
-                    initializePopup();
-                    mPopupStatus = POPUP_NONE;
-                    mUI.cleanupListview();
-                }
-                else if (level == 2) {
-                    mUI.dismissLevel2();
-                    mPopupStatus = POPUP_FIRST_LEVEL;
-                }
-            }
-
-            @Override
-            public void onAnimationCancel(Animator animation) {
-                if (level == 1) {
-                    mUI.dismissLevel1();
-                    initializePopup();
-                    mPopupStatus = POPUP_NONE;
-                    mUI.cleanupListview();
-                }
-                else if (level == 2) {
-                    mUI.dismissLevel2();
-                    mPopupStatus = POPUP_FIRST_LEVEL;
-                }
-
-            }
-        });
-        vp.start();
-    }
-
-    public void animateFadeIn(final ListView v) {
-        ViewPropertyAnimator vp = v.animate();
-        vp.alpha(0.85f).setDuration(ANIMATION_DURATION);
-        vp.start();
-    }
-
-    public void animateSlideIn(final View v, int delta, boolean settingMenu) {
-        int rotation = CameraUtil.getDisplayRotation(mActivity);
-        boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
-        if (!mIsDefaultToPortrait) {
-            rotation = (rotation + 90) % 360;
-        }
-        boolean portrait = (rotation == 0) || (rotation == 180);
-        if (settingMenu)
-            portrait = true;
-        ViewPropertyAnimator vp = v.animate();
-        if (portrait) {
-            float dest = v.getX();
-            v.setX(dest - delta);
-            vp.translationX(dest).setDuration(ANIMATION_DURATION);
-        }
-        else {
-            float dest = v.getY();
-            v.setY(dest + delta);
-            vp.translationY(dest).setDuration(ANIMATION_DURATION);
-        }
-        vp.start();
-    }
-
-    public void animateSlideOutPreviewMenu() {
-        if (mPreviewMenu == null)
-            return;
-        animateSlideOut(mPreviewMenu);
-    }
-
-    private void animateSlideOut(final View v) {
-        if (v == null || mPreviewMenuStatus == PREVIEW_MENU_IN_ANIMATION)
-            return;
-        mPreviewMenuStatus = PREVIEW_MENU_IN_ANIMATION;
-        int rotation = CameraUtil.getDisplayRotation(mActivity);
-        boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
-        if (!mIsDefaultToPortrait) {
-            rotation = (rotation + 90) % 360;
-        }
-        boolean portrait = (rotation == 0) || (rotation == 180);
-        ViewPropertyAnimator vp = v.animate();
-        if (portrait) {
-            vp.translationX(v.getX() - v.getWidth()).setDuration(ANIMATION_DURATION);
-
-        } else {
-            vp.translationY(v.getY() + v.getHeight()).setDuration(ANIMATION_DURATION);
-
-        }
-        vp.setListener(new AnimatorListener() {
-            @Override
-            public void onAnimationStart(Animator animation) {
-            }
-
-            @Override
-            public void onAnimationRepeat(Animator animation) {
-
-            }
-
-            @Override
-            public void onAnimationEnd(Animator animation) {
-                closeSceneMode();
-                mPreviewMenuStatus = PREVIEW_MENU_NONE;
-            }
-
-            @Override
-            public void onAnimationCancel(Animator animation) {
-                closeSceneMode();
-                mPreviewMenuStatus = PREVIEW_MENU_NONE;
-
-            }
-        });
-        vp.start();
-    }
-
-    private void buttonSetEnabled(View v, boolean enable) {
-        v.setEnabled(enable);
-        if (v instanceof ViewGroup) {
-            View v2 = ((ViewGroup) v).getChildAt(0);
-            if (v2 != null)
-                v2.setEnabled(enable);
-
-        }
-
-    }
-
-    public boolean isOverMenu(MotionEvent ev) {
-        if (mPopupStatus == POPUP_NONE || mPopupStatus == POPUP_IN_ANIMATION)
-            return false;
-        if (mUI.getMenuLayout() == null)
-            return false;
-        Rect rec = new Rect();
-        mUI.getMenuLayout().getChildAt(0).getHitRect(rec);
-        return rec.contains((int) ev.getX(), (int) ev.getY());
-    }
-
-    public boolean isOverPreviewMenu(MotionEvent ev) {
-        if (mPreviewMenuStatus != PREVIEW_MENU_ON)
-            return false;
-        if (mUI.getPreviewMenuLayout() == null)
-            return false;
-        Rect rec = new Rect();
-        mUI.getPreviewMenuLayout().getChildAt(0).getHitRect(rec);
-        rec.top += (int) mUI.getPreviewMenuLayout().getY();
-        rec.bottom += (int) mUI.getPreviewMenuLayout().getY();
-        return rec.contains((int) ev.getX(), (int) ev.getY());
-    }
-
-    public boolean isMenuBeingShown() {
-        return mPopupStatus != POPUP_NONE;
-    }
-
-    public boolean isMenuBeingAnimated() {
-        return mPopupStatus == POPUP_IN_ANIMATION;
-    }
-
-    public boolean isPreviewMenuBeingShown() {
-        return mPreviewMenuStatus == PREVIEW_MENU_ON;
-    }
-
-    public boolean isPreviewMenuBeingAnimated() {
-        return mPreviewMenuStatus == PREVIEW_MENU_IN_ANIMATION;
-    }
-
-    public boolean sendTouchToPreviewMenu(MotionEvent ev) {
-        return mUI.sendTouchToPreviewMenu(ev);
-    }
-
-    public boolean sendTouchToMenu(MotionEvent ev) {
-        return mUI.sendTouchToMenu(ev);
     }
 
     @Override
-    public void overrideSettings(final String... keyvalues) {
-        if (mListMenu != null) {
+    public void overrideSettings(final String ... keyvalues) {
+        if (mPopup1 != null) {
             ListPreference pref_tnr = mPreferenceGroup.findPreference(CameraSettings.KEY_TNR_MODE);
             ListPreference pref_cds = mPreferenceGroup.findPreference(CameraSettings.KEY_CDS_MODE);
 
@@ -471,11 +234,11 @@
                 mPrevSavedCDS = cds;
             }
 
-            mListMenu.setPreferenceEnabled(CameraSettings.KEY_TNR_MODE, false);
+            mPopup1.setPreferenceEnabled(CameraSettings.KEY_TNR_MODE, false);
             if ((tnr != null) && !mActivity.getString(R.string.
                     pref_camera_tnr_default).equals(tnr)) {
-                mListMenu.setPreferenceEnabled(CameraSettings.KEY_CDS_MODE, false);
-                mListMenu.overrideSettings(CameraSettings.KEY_CDS_MODE,
+                mPopup1.setPreferenceEnabled(CameraSettings.KEY_CDS_MODE, false);
+                mPopup1.overrideSettings(CameraSettings.KEY_CDS_MODE,
                         mActivity.getString(R.string.pref_camera_cds_value_off));
                 mIsTNREnabled = true;
                 if (!mIsCDSUpdated) {
@@ -485,547 +248,187 @@
                     mIsCDSUpdated = true;
                 }
             } else if (tnr != null) {
-                mListMenu.setPreferenceEnabled(CameraSettings.KEY_CDS_MODE, true);
+                mPopup1.setPreferenceEnabled(CameraSettings.KEY_CDS_MODE, true);
                 if (mIsTNREnabled && mPrevSavedCDS != cds) {
-                    mListMenu.overrideSettings(CameraSettings.KEY_CDS_MODE, mPrevSavedCDS);
+                    mPopup1.overrideSettings(CameraSettings.KEY_CDS_MODE, mPrevSavedCDS);
                     mIsTNREnabled = false;
                     mIsCDSUpdated = false;
                 }
             }
         }
-        for (int i = 0; i < keyvalues.length; i += 2) {
-            if (keyvalues[i].equals(CameraSettings.KEY_SCENE_MODE)) {
-                buttonSetEnabled(mSceneModeSwitcher, keyvalues[i + 1] == null);
-            }
-        }
+
         super.overrideSettings(keyvalues);
-        if ((mListMenu == null))
-            initializePopup();
-        mListMenu.overrideSettings(keyvalues);
+        if ((mPopup1 == null) ||  (mPopup2 == null)  ||  (mPopup3 == null)) initializePopup();
+
+        mPopup1.overrideSettings(keyvalues);
+        mPopup2.overrideSettings(keyvalues);
+        mPopup3.overrideSettings(keyvalues);
     }
 
     protected void initializePopup() {
-        LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
-                Context.LAYOUT_INFLATER_SERVICE);
-        ListMenu popup1 = (ListMenu) inflater.inflate(
-                R.layout.list_menu, null, false);
+     LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
+             Context.LAYOUT_INFLATER_SERVICE);
+     MoreSettingPopup popup1 = (MoreSettingPopup) inflater.inflate(
+             R.layout.more_setting_popup, null, false);
+     popup1.setSettingChangedListener(this);
+     popup1.initialize(mPreferenceGroup, mOtherKeys1);
+     if (mActivity.isSecureCamera()) {
+         // Prevent location preference from getting changed in secure camera mode
+       popup1.setPreferenceEnabled(CameraSettings.KEY_RECORD_LOCATION,false);
+     }
+     mPopup1 = popup1;
 
-        popup1.setSettingChangedListener(this);
+     MoreSettingPopup popup2 = (MoreSettingPopup) inflater.inflate(
+             R.layout.more_setting_popup, null, false);
+     popup2.setSettingChangedListener(this);
+     popup2.initialize(mPreferenceGroup, mOtherKeys2);
+     mPopup2 = popup2;
 
-        String[] keys = mOtherKeys1;
-        if (mActivity.isDeveloperMenuEnabled())
-            keys = mOtherKeys2;
-        popup1.initialize(mPreferenceGroup, keys);
-        if (mActivity.isSecureCamera()) {
-            // Prevent location preference from getting changed in secure camera
-            // mode
-            popup1.setPreferenceEnabled(CameraSettings.KEY_RECORD_LOCATION, false);
-        }
-        mListMenu = popup1;
+     MoreSettingPopup popup3 = (MoreSettingPopup) inflater.inflate(
+             R.layout.more_setting_popup, null, false);
+     popup3.setSettingChangedListener(this);
+     popup3.initialize(mPreferenceGroup, mOtherKeys3);
+     mPopup3 = popup3;
 
-        ListPreference pref = mPreferenceGroup.findPreference(
-                CameraSettings.KEY_SCENE_MODE);
-        String sceneMode = (pref != null) ? pref.getValue() : null;
-        pref = mPreferenceGroup.findPreference(CameraSettings.KEY_FACE_DETECTION);
-        String faceDetection = (pref != null) ? pref.getValue() : null;
-        pref = mPreferenceGroup.findPreference(CameraSettings.KEY_ZSL);
-        String zsl = (pref != null) ? pref.getValue() : null;
-        pref = mPreferenceGroup.findPreference(CameraSettings.KEY_AUTO_HDR);
-        String autohdr = (pref != null) ? pref.getValue() : null;
-        if (((sceneMode != null) && !Parameters.SCENE_MODE_AUTO.equals(sceneMode))
-                || ((autohdr != null) && autohdr.equals("enable"))) {
-            popup1.setPreferenceEnabled(CameraSettings.KEY_FOCUS_MODE, false);
-            popup1.setPreferenceEnabled(CameraSettings.KEY_AUTOEXPOSURE, false);
-            popup1.setPreferenceEnabled(CameraSettings.KEY_TOUCH_AF_AEC, false);
-            popup1.setPreferenceEnabled(CameraSettings.KEY_SATURATION, false);
-            popup1.setPreferenceEnabled(CameraSettings.KEY_CONTRAST, false);
-            popup1.setPreferenceEnabled(CameraSettings.KEY_SHARPNESS, false);
-            popup1.setPreferenceEnabled(CameraSettings.KEY_COLOR_EFFECT, false);
-            popup1.setPreferenceEnabled(CameraSettings.KEY_FLASH_MODE, false);
-            popup1.setPreferenceEnabled(CameraSettings.KEY_WHITE_BALANCE, false);
-            popup1.setPreferenceEnabled(CameraSettings.KEY_EXPOSURE, false);
-        }
-        if ((autohdr != null) && autohdr.equals("enable")) {
-            popup1.setPreferenceEnabled(CameraSettings.KEY_SCENE_MODE, false);
-        }
-        if ((zsl != null) && Parameters.ZSL_ON.equals(zsl)) {
-            popup1.setPreferenceEnabled(CameraSettings.KEY_FOCUS_MODE, false);
-            popup1.setPreferenceEnabled(CameraSettings.KEY_MANUAL_EXPOSURE, false);
-            popup1.setPreferenceEnabled(CameraSettings.KEY_MANUAL_WB, false);
-            popup1.setPreferenceEnabled(CameraSettings.KEY_MANUAL_FOCUS, false);
-        }
-        if ((faceDetection != null) && !Parameters.FACE_DETECTION_ON.equals(faceDetection)) {
-            popup1.setPreferenceEnabled(CameraSettings.KEY_FACE_RECOGNITION, false);
-        }
-        popup1.setPreferenceEnabled(CameraSettings.KEY_ZSL, !mUI.isCountingDown());
+     ListPreference pref = mPreferenceGroup.findPreference(
+             CameraSettings.KEY_SCENE_MODE);
+     String sceneMode = (pref != null) ? pref.getValue() : null;
+     pref = mPreferenceGroup.findPreference(CameraSettings.KEY_FACE_DETECTION);
+     String faceDetection = (pref != null) ? pref.getValue() : null;
+     pref = mPreferenceGroup.findPreference(CameraSettings.KEY_ZSL);
+     String zsl = (pref != null) ? pref.getValue() : null;
+     pref = mPreferenceGroup.findPreference (CameraSettings.KEY_AUTO_HDR);
+     String autohdr = (pref != null) ? pref.getValue() : null;
+     if (((sceneMode != null) && !Parameters.SCENE_MODE_AUTO.equals(sceneMode))
+         || ((autohdr != null) && autohdr.equals("enable"))) {
+         popup3.setPreferenceEnabled(CameraSettings.KEY_FOCUS_MODE,false);
+         popup2.setPreferenceEnabled(CameraSettings.KEY_AUTOEXPOSURE,false);
+         popup2.setPreferenceEnabled(CameraSettings.KEY_TOUCH_AF_AEC,false);
+         popup2.setPreferenceEnabled(CameraSettings.KEY_SATURATION,false);
+         popup2.setPreferenceEnabled(CameraSettings.KEY_CONTRAST,false);
+         popup2.setPreferenceEnabled(CameraSettings.KEY_SHARPNESS,false);
+         popup2.setPreferenceEnabled(CameraSettings.KEY_COLOR_EFFECT,false);
+         popup3.setPreferenceEnabled(CameraSettings.KEY_FLASH_MODE,false);
+         popup3.setPreferenceEnabled(CameraSettings.KEY_WHITE_BALANCE,false);
+         popup3.setPreferenceEnabled(CameraSettings.KEY_EXPOSURE,false);
+     }
+     if ((autohdr != null) && autohdr.equals("enable")) {
+         popup1.setPreferenceEnabled(CameraSettings.KEY_SCENE_MODE,false);
+     }
+     if ((zsl != null) && Parameters.ZSL_ON.equals(zsl)) {
+         popup3.setPreferenceEnabled(CameraSettings.KEY_FOCUS_MODE,false);
+         popup3.setPreferenceEnabled(CameraSettings.KEY_MANUAL_EXPOSURE,false);
+         popup3.setPreferenceEnabled(CameraSettings.KEY_MANUAL_WB,false);
+         popup3.setPreferenceEnabled(CameraSettings.KEY_MANUAL_FOCUS,false);
+     }
+     if ((faceDetection != null) && !Parameters.FACE_DETECTION_ON.equals(faceDetection)){
+         popup2.setPreferenceEnabled(CameraSettings.KEY_FACE_RECOGNITION,false);
+     }
+     popup1.setPreferenceEnabled(CameraSettings.KEY_ZSL, !mUI.isCountingDown());
 
-        pref = mPreferenceGroup.findPreference(CameraSettings.KEY_ADVANCED_FEATURES);
-        String advancedFeatures = (pref != null) ? pref.getValue() : null;
+     pref = mPreferenceGroup.findPreference(CameraSettings.KEY_ADVANCED_FEATURES);
+     String advancedFeatures = (pref != null) ? pref.getValue() : null;
 
-        String ubiFocusOn = mActivity.getString(R.string.
-                pref_camera_advanced_feature_value_ubifocus_on);
-        String reFocusOn = mActivity.getString(R.string.
-                pref_camera_advanced_feature_value_refocus_on);
-        String chromaFlashOn = mActivity.getString(R.string.
-                pref_camera_advanced_feature_value_chromaflash_on);
-        String optiZoomOn = mActivity.getString(R.string.
-                pref_camera_advanced_feature_value_optizoom_on);
-        String fssrOn = mActivity.getString(R.string.
-                pref_camera_advanced_feature_value_FSSR_on);
-        String truePortraitOn = mActivity.getString(R.string.
-                pref_camera_advanced_feature_value_trueportrait_on);
-        String multiTouchFocusOn = mActivity.getString(R.string.
-                pref_camera_advanced_feature_value_multi_touch_focus_on);
+     String ubiFocusOn = mActivity.getString(R.string.
+         pref_camera_advanced_feature_value_ubifocus_on);
+     String reFocusOn = mActivity.getString(R.string.
+         pref_camera_advanced_feature_value_refocus_on);
+     String chromaFlashOn = mActivity.getString(R.string.
+         pref_camera_advanced_feature_value_chromaflash_on);
+     String optiZoomOn = mActivity.getString(R.string.
+         pref_camera_advanced_feature_value_optizoom_on);
+     String fssrOn = mActivity.getString(R.string.
+         pref_camera_advanced_feature_value_FSSR_on);
+     String truePortraitOn = mActivity.getString(R.string.
+         pref_camera_advanced_feature_value_trueportrait_on);
+     String multiTouchFocusOn = mActivity.getString(R.string.
+         pref_camera_advanced_feature_value_multi_touch_focus_on);
 
-        if ((zsl != null) && Parameters.ZSL_OFF.equals(zsl)) {
-            popup1.overrideSettings(CameraSettings.KEY_ADVANCED_FEATURES,
-                    mActivity.getString(R.string.pref_camera_advanced_feature_default));
+     if ((zsl != null) && Parameters.ZSL_OFF.equals(zsl)) {
+         popup3.overrideSettings(CameraSettings.KEY_ADVANCED_FEATURES,
+                 mActivity.getString(R.string.pref_camera_advanced_feature_default));
 
-            popup1.setPreferenceEnabled(CameraSettings.KEY_ADVANCED_FEATURES, false);
-            if (mHdrSwitcher.getVisibility() == View.VISIBLE) {
-                buttonSetEnabled(mHdrSwitcher, true);
-            }
-        } else {
-            if ((advancedFeatures != null) && (advancedFeatures.equals(ubiFocusOn) ||
-                    advancedFeatures.equals(chromaFlashOn) ||
-                    advancedFeatures.equals(reFocusOn) ||
-                    advancedFeatures.equals(optiZoomOn) ||
-                    advancedFeatures.equals(fssrOn) ||
-                    advancedFeatures.equals(truePortraitOn) ||
-                    advancedFeatures.equals(multiTouchFocusOn))) {
-                popup1.setPreferenceEnabled(CameraSettings.KEY_FOCUS_MODE, false);
-                popup1.setPreferenceEnabled(CameraSettings.KEY_FLASH_MODE, false);
-                popup1.setPreferenceEnabled(CameraSettings.KEY_AE_BRACKET_HDR, false);
-                popup1.setPreferenceEnabled(CameraSettings.KEY_REDEYE_REDUCTION, false);
-                popup1.setPreferenceEnabled(CameraSettings.KEY_EXPOSURE, false);
-                popup1.setPreferenceEnabled(CameraSettings.KEY_COLOR_EFFECT, false);
-                popup1.setPreferenceEnabled(CameraSettings.KEY_TOUCH_AF_AEC, false);
-                popup1.setPreferenceEnabled(CameraSettings.KEY_SCENE_MODE, false);
+         popup3.setPreferenceEnabled(CameraSettings.KEY_ADVANCED_FEATURES,false);
+         if (mHdrItem != null) {
+             mHdrItem.setEnabled(true);
+         }
+         if (mHdrPlusItem != null) {
+             mHdrPlusItem.setEnabled(true);
+         }
+     } else {
+         if ((advancedFeatures != null) && (advancedFeatures.equals(ubiFocusOn) ||
+                 advancedFeatures.equals(chromaFlashOn) ||
+                 advancedFeatures.equals(reFocusOn) ||
+                 advancedFeatures.equals(optiZoomOn) ||
+                 advancedFeatures.equals(fssrOn) ||
+                 advancedFeatures.equals(truePortraitOn) ||
+                 advancedFeatures.equals(multiTouchFocusOn))) {
+             popup3.setPreferenceEnabled(CameraSettings.KEY_FOCUS_MODE,false);
+             popup3.setPreferenceEnabled(CameraSettings.KEY_FLASH_MODE,false);
+             popup3.setPreferenceEnabled(CameraSettings.KEY_AE_BRACKET_HDR,false);
+             popup3.setPreferenceEnabled(CameraSettings.KEY_REDEYE_REDUCTION,false);
+             popup3.setPreferenceEnabled(CameraSettings.KEY_EXPOSURE,false);
+             popup2.setPreferenceEnabled(CameraSettings.KEY_COLOR_EFFECT,false);
+             popup2.setPreferenceEnabled(CameraSettings.KEY_TOUCH_AF_AEC,false);
+             popup1.setPreferenceEnabled(CameraSettings.KEY_SCENE_MODE,false);
 
-                setPreference(CameraSettings.KEY_CAMERA_HDR, mSettingOff);
-                if (mHdrSwitcher.getVisibility() == View.VISIBLE) {
-                    buttonSetEnabled(mHdrSwitcher, false);
-                }
-            } else {
-                if (mHdrSwitcher.getVisibility() == View.VISIBLE) {
-                    buttonSetEnabled(mHdrSwitcher, true);
-                }
-            }
-        }
+             setPreference(CameraSettings.KEY_CAMERA_HDR, mSettingOff);
 
-        pref = mPreferenceGroup.findPreference(CameraSettings.KEY_SCENE_MODE);
-        if (pref != null) {
-            if (notSame(pref, CameraSettings.KEY_SCENE_MODE, Parameters.SCENE_MODE_AUTO)) {
-                buttonSetEnabled(mFilterModeSwitcher, false);
-            } else {
-                buttonSetEnabled(mFilterModeSwitcher, true);
-            }
-        }
+             if (mHdrItem != null) {
+                mHdrItem.setEnabled(false);
+             }
+             if (mHdrPlusItem != null) {
+                mHdrPlusItem.setEnabled(false);
+             }
+         } else {
+             if (mHdrItem != null) {
+                mHdrItem.setEnabled(true);
+             }
+             if (mHdrPlusItem != null) {
+                mHdrPlusItem.setEnabled(true);
+             }
+         }
+     }
 
-        if (mListener != null) {
-            mListener.onSharedPreferenceChanged();
-        }
-    }
-
-    public void initSwitchItem(final String prefKey, View switcher) {
-        final IconListPreference pref =
-                (IconListPreference) mPreferenceGroup.findPreference(prefKey);
-        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) ((FrameLayout) switcher).getChildAt(0);
-        iv.setImageResource(resid);
-        switcher.setVisibility(View.VISIBLE);
-        mPreferences.add(pref);
-        mPreferenceMap.put(pref, switcher);
-        switcher.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                IconListPreference pref = (IconListPreference) mPreferenceGroup
-                        .findPreference(prefKey);
-                if (pref == null)
-                    return;
-                int index = pref.findIndexOfValue(pref.getValue());
-                CharSequence[] values = pref.getEntryValues();
-                index = (index + 1) % values.length;
-                pref.setValueIndex(index);
-                ImageView iv = (ImageView) ((FrameLayout) v).getChildAt(0);
-                iv.setImageResource(((IconListPreference) pref).getLargeIconIds()[index]);
-                if (prefKey.equals(CameraSettings.KEY_CAMERA_ID))
-                    mListener.onCameraPickerClicked(index);
-                reloadPreference(pref);
-                onSettingChanged(pref);
-            }
-        });
-    }
-
-    public void initSceneModeButton(View button) {
-        button.setVisibility(View.INVISIBLE);
-        updateSceneModeIcon();
-        button.setVisibility(View.VISIBLE);
-        button.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                addSceneMode();
-                View view = mUI.getPreviewMenuLayout().getChildAt(0);
-                animateSlideIn(view, previewMenuSize, false);
-            }
-        });
-    }
-
-    public void addModeBack() {
-        if (mSceneStatus == MODE_SCENE) {
-            addSceneMode();
-        }
-        if (mSceneStatus == MODE_FILTER) {
-            addFilterMode();
-        }
-    }
-
-    public void addSceneMode() {
-        final IconListPreference pref = (IconListPreference) mPreferenceGroup
-                .findPreference(CameraSettings.KEY_SCENE_MODE);
-        if (pref == null)
-            return;
-
-        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();
-
-        CharSequence[] entries = pref.getEntries();
-
-        int[] thumbnails = pref.getThumbnailIds();
-
-        Resources r = mActivity.getResources();
-        int height = (int) (r.getDimension(R.dimen.scene_mode_height) + 2
-                * r.getDimension(R.dimen.scene_mode_padding) + 1);
-        int width = (int) (r.getDimension(R.dimen.scene_mode_width) + 2
-                * r.getDimension(R.dimen.scene_mode_padding) + 1);
-
-        int gridRes = 0;
-        boolean portrait = (rotation == 0) || (rotation == 180);
-        int size = height;
-        if (portrait) {
-            gridRes = R.layout.vertical_grid;
-            size = width;
-        } else {
-            gridRes = R.layout.horiz_grid;
-        }
-        previewMenuSize = size;
-        mUI.hideUI();
-        mPreviewMenuStatus = PREVIEW_MENU_ON;
-        mSceneStatus = MODE_SCENE;
-
-        LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
-                Context.LAYOUT_INFLATER_SERVICE);
-        FrameLayout basic = (FrameLayout) inflater.inflate(
-                gridRes, null, false);
-
-        mUI.dismissSceneModeMenu();
-        LinearLayout previewMenuLayout = new LinearLayout(mActivity);
-        mUI.setPreviewMenuLayout(previewMenuLayout);
-        ViewGroup.LayoutParams params = null;
-        if (portrait) {
-            params = new ViewGroup.LayoutParams(size, LayoutParams.MATCH_PARENT);
-            previewMenuLayout.setLayoutParams(params);
-            ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout);
-        } else {
-            params = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, size);
-            previewMenuLayout.setLayoutParams(params);
-            ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout);
-            previewMenuLayout.setY(display.getHeight() - size);
-        }
-        basic.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
-                LayoutParams.MATCH_PARENT));
-        LinearLayout layout = (LinearLayout) basic.findViewById(R.id.layout);
-
-        final View[] views = new View[entries.length];
-        int init = pref.getCurrentIndex();
-        for (int i = 0; i < entries.length; i++) {
-            LinearLayout layout2 = (LinearLayout) inflater.inflate(
-                    R.layout.scene_mode_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);
-                            onSettingChanged(pref);
-                            updateSceneModeIcon();
-                            for (View v1 : views) {
-                                v1.setBackgroundResource(R.drawable.scene_mode_view_border);
-                            }
-                            View border = v.findViewById(R.id.border);
-                            border.setBackgroundResource(R.drawable.scene_mode_view_border_selected);
-                        }
-
-                    }
-                    return true;
-                }
-            });
-
-            View border = layout2.findViewById(R.id.border);
-            views[j] = border;
-            if (i == init)
-                border.setBackgroundResource(R.drawable.scene_mode_view_border_selected);
-            imageView.setImageResource(thumbnails[i]);
-            label.setText(entries[i]);
-            layout.addView(layout2);
-        }
-        previewMenuLayout.addView(basic);
-        mPreviewMenu = basic;
-    }
-
-    public void updateSceneModeIcon() {
-        final IconListPreference pref = (IconListPreference) mPreferenceGroup
-                .findPreference(CameraSettings.KEY_SCENE_MODE);
-        if (pref == null)
-            return;
-        ImageView iv = (ImageView) ((FrameLayout) mSceneModeSwitcher).getChildAt(0);
-        int[] thumbnails = pref.getThumbnailIds();
-        int ind = pref.getCurrentIndex();
-        if (ind == -1)
-            ind = 0;
-        iv.setImageResource(thumbnails[ind]);
-    }
-
-    public void initFilterModeButton(View button) {
-        button.setVisibility(View.INVISIBLE);
-        final IconListPreference pref = (IconListPreference) mPreferenceGroup
-                .findPreference(CameraSettings.KEY_COLOR_EFFECT);
-        if (pref == null)
-            return;
-
-        int[] iconIds = pref.getLargeIconIds();
-        int resid = -1;
-        // The preference only has a single icon to represent it.
-        resid = pref.getSingleIcon();
-        ImageView iv = (ImageView) ((FrameLayout) button).getChildAt(0);
-        iv.setImageResource(resid);
-        button.setVisibility(View.VISIBLE);
-        button.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                addFilterMode();
-                View view = mUI.getPreviewMenuLayout().getChildAt(0);
-                animateSlideIn(view, previewMenuSize, false);
-            }
-        });
-    }
-
-    public void addFilterMode() {
-        final IconListPreference pref = (IconListPreference) mPreferenceGroup
-                .findPreference(CameraSettings.KEY_COLOR_EFFECT);
-        if (pref == null)
-            return;
-
-        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();
-        CharSequence[] entries = pref.getEntries();
-
-        Resources r = mActivity.getResources();
-        int height = (int) (r.getDimension(R.dimen.filter_mode_height) + 2
-                * r.getDimension(R.dimen.filter_mode_padding) + 1);
-        int width = (int) (r.getDimension(R.dimen.filter_mode_width) + 2
-                * r.getDimension(R.dimen.filter_mode_padding) + 1);
-
-        int gridRes = 0;
-        boolean portrait = (rotation == 0) || (rotation == 180);
-        int size = height;
-        if (portrait) {
-            gridRes = R.layout.vertical_grid;
-            size = width;
-        } else {
-            gridRes = R.layout.horiz_grid;
-        }
-        previewMenuSize = size;
-        mUI.hideUI();
-        mPreviewMenuStatus = PREVIEW_MENU_ON;
-        mSceneStatus = MODE_FILTER;
-
-        int[] thumbnails = pref.getThumbnailIds();
-
-        LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
-                Context.LAYOUT_INFLATER_SERVICE);
-        FrameLayout basic = (FrameLayout) inflater.inflate(
-                gridRes, null, false);
-
-        mUI.dismissSceneModeMenu();
-        LinearLayout previewMenuLayout = new LinearLayout(mActivity);
-        mUI.setPreviewMenuLayout(previewMenuLayout);
-        ViewGroup.LayoutParams params = null;
-        if (portrait) {
-            params = new ViewGroup.LayoutParams(size, LayoutParams.MATCH_PARENT);
-            previewMenuLayout.setLayoutParams(params);
-            ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout);
-        } else {
-            params = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, size);
-            previewMenuLayout.setLayoutParams(params);
-            ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout);
-            previewMenuLayout.setY(display.getHeight() - size);
-        }
-        basic.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
-                LayoutParams.MATCH_PARENT));
-        LinearLayout layout = (LinearLayout) basic.findViewById(R.id.layout);
-        final View[] views = new View[entries.length];
-        int init = pref.getCurrentIndex();
-        for (int i = 0; i < entries.length; i++) {
-            LinearLayout layout2 = (LinearLayout) inflater.inflate(
-                    R.layout.filter_mode_view, null, false);
-            ImageView imageView = (ImageView) layout2.findViewById(R.id.image);
-            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);
-                            onSettingChanged(pref);
-                            for (View v1 : views) {
-                                v1.setBackground(null);
-                            }
-                            ImageView image = (ImageView) v.findViewById(R.id.image);
-                            image.setBackgroundColor(0xff33b5e5);
-                        }
-                    }
-                    return true;
-                }
-            });
-
-            views[j] = imageView;
-            if (i == init)
-                imageView.setBackgroundColor(0xff33b5e5);
-            TextView label = (TextView) layout2.findViewById(R.id.label);
-            imageView.setImageResource(thumbnails[i]);
-            label.setText(entries[i]);
-            layout.addView(layout2);
-        }
-        previewMenuLayout.addView(basic);
-        mPreviewMenu = basic;
-    }
-
-    public void openFirstLevel() {
-        if (isMenuBeingShown() || CameraControls.isAnimating())
-            return;
-        if (mListMenu == null || mPopupStatus != POPUP_FIRST_LEVEL) {
-            initializePopup();
-            mPopupStatus = POPUP_FIRST_LEVEL;
-        }
-        mUI.showPopup(mListMenu, 1, true);
-
-    }
+     if (mListener != null) {
+         mListener.onSharedPreferenceChanged();
+     }
+     }
 
     public void popupDismissed(boolean dismissAll) {
         if (!dismissAll && mPopupStatus == POPUP_SECOND_LEVEL) {
             initializePopup();
             mPopupStatus = POPUP_FIRST_LEVEL;
-            mUI.showPopup(mListMenu, 1, false);
-            if (mListMenu != null)
-                mListMenu = null;
-
+                if (popupNum == 1)
+                    mUI.showPopup(mPopup1);
+                else if (popupNum == 2)
+                    mUI.showPopup(mPopup2);
+                else if (popupNum == 3)
+                    mUI.showPopup(mPopup3);
         } else {
             initializePopup();
         }
 
     }
 
-    @Override
+        @Override
     // Hit when an item in the first-level popup gets selected, then bring up
     // the second-level popup
     public void onPreferenceClicked(ListPreference pref) {
-        onPreferenceClicked(pref, 0);
-    }
-
-    public void onPreferenceClicked(ListPreference pref, int y) {
-        if (!mActivity.isDeveloperMenuEnabled()) {
-            if (pref.getKey().equals(CameraSettings.KEY_REDEYE_REDUCTION)) {
-                privateCounter++;
-                if (privateCounter >= DEVELOPER_MENU_TOUCH_COUNT) {
-                    mActivity.enableDeveloperMenu();
-                    SharedPreferences prefs = PreferenceManager
-                            .getDefaultSharedPreferences(mActivity);
-                    prefs.edit().putBoolean(CameraSettings.KEY_DEVELOPER_MENU, true).apply();
-                    Toast toast = Toast.makeText(mActivity,
-                            "Camera developer option is enabled now", Toast.LENGTH_SHORT);
-                    toast.show();
-                }
-            } else {
-                privateCounter = 0;
-            }
-        }
+        if (mPopupStatus != POPUP_FIRST_LEVEL) return;
 
         LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
                 Context.LAYOUT_INFLATER_SERVICE);
-        ListSubMenu basic = (ListSubMenu) inflater.inflate(
-                R.layout.list_sub_menu, null, false);
-        basic.initialize(pref, y);
+        ListPrefSettingPopup basic = (ListPrefSettingPopup) inflater.inflate(
+                R.layout.list_pref_setting_popup, null, false);
+        basic.initialize(pref);
         basic.setSettingChangedListener(this);
-        basic.setAlpha(0f);
-        mListSubMenu = basic;
-        mUI.removeLevel2();
-        if (mPopupStatus == POPUP_SECOND_LEVEL) {
-            mUI.showPopup(mListSubMenu, 2, false);
-        } else {
-            mUI.showPopup(mListSubMenu, 2, true);
-        }
+        mUI.dismissPopup();
+        mPopup = basic;
+        mUI.showPopup(mPopup);
         mPopupStatus = POPUP_SECOND_LEVEL;
     }
 
-    public void onListMenuTouched() {
-        mUI.removeLevel2();
-    }
-
-    public void closeAllView() {
-        if (mUI != null)
-            mUI.removeLevel2();
-
-        if (mListMenu != null) {
-            animateSlideOut(mListMenu, 1);
-        }
-        animateSlideOutPreviewMenu();
-    }
-
-    public void closeView() {
-        if (mUI != null)
-            mUI.removeLevel2();
-
-        if (mListMenu != null && mPopupStatus != POPUP_NONE)
-            animateSlideOut(mListMenu, 1);
-    }
-
     // Return true if the preference has the specified key but not the value.
     private static boolean notSame(ListPreference pref, String key, String value) {
         return (key.equals(pref.getKey()) && !value.equals(pref.getValue()));
@@ -1093,12 +496,6 @@
                 setPreference(CameraSettings.KEY_LONGSHOT, mSettingOff);
             }
         }
-
-        if (notSame(pref, CameraSettings.KEY_SCENE_MODE, Parameters.SCENE_MODE_AUTO)) {
-            buttonSetEnabled(mFilterModeSwitcher, false);
-        } else {
-            buttonSetEnabled(mFilterModeSwitcher, true);
-        }
         super.onSettingChanged(pref);
     }
 
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index 2d6a0f2..5fb7ac7 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -539,7 +539,6 @@
                  CameraSettings.KEY_BRIGHTNESS,
                  DEFAULT_BRIGHTNESS);
         brightnessProgressBar.setProgress(mbrightness);
-        brightnessProgressBar.setVisibility(View.INVISIBLE);
         skinToneSeekBar = (SeekBar) mRootView.findViewById(R.id.skintoneseek);
         skinToneSeekBar.setOnSeekBarChangeListener(mskinToneSeekListener);
         skinToneSeekBar.setVisibility(View.INVISIBLE);
@@ -2476,7 +2475,7 @@
                 Editor editor = mPreferences.edit();
                 editor.putInt(CameraSettings.KEY_BRIGHTNESS, mbrightness);
                 editor.apply();
-                brightnessProgressBar.setVisibility(View.INVISIBLE);
+                brightnessProgressBar.setVisibility(View.VISIBLE);
                 mBrightnessVisible = true;
             }
             break;
@@ -2497,7 +2496,7 @@
                 Editor editor = mPreferences.edit();
                 editor.putInt(CameraSettings.KEY_BRIGHTNESS, mbrightness);
                 editor.apply();
-                brightnessProgressBar.setVisibility(View.INVISIBLE);
+                brightnessProgressBar.setVisibility(View.VISIBLE);
                 mBrightnessVisible = true;
             }
             break;
@@ -4324,7 +4323,7 @@
             Integer.toString(mskinToneValue - MIN_SCE_FACTOR));
         editor.apply();
         if ((brightnessProgressBar != null) && mBrightnessVisible)
-             brightnessProgressBar.setVisibility(View.INVISIBLE);
+             brightnessProgressBar.setVisibility(View.VISIBLE);
 }
 
 /*
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index c823133..4067254 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -103,6 +103,7 @@
 
     private View mMenuButton;
     private PhotoMenu mMenu;
+    private CustomPhotoMenu mCustomPhotoMenu;
     private ModuleSwitcher mSwitcher;
     private CameraControls mCameraControls;
     private AlertDialog mLocationDialog;
@@ -120,6 +121,7 @@
     private int mPreviewWidth = 0;
     private int mPreviewHeight = 0;
     public boolean mMenuInitialized = false;
+    public boolean mCustomPhotoMenuInitialized = false;
     private float mSurfaceTextureUncroppedWidth;
     private float mSurfaceTextureUncroppedHeight;
 
@@ -192,8 +194,8 @@
                 mAspectRatioResize = false;
             }
 
-            if (mMenu != null)
-                mMenu.tryToCloseSubList();
+            if (mCustomPhotoMenu != null)
+                mCustomPhotoMenu.tryToCloseSubList();
         }
     };
 
@@ -427,12 +429,19 @@
         }
 
         if (mMenu == null) {
-            mMenu = new PhotoMenu(mActivity, this);
+            mMenu = new PhotoMenu(mActivity, this, mPieRenderer);
             mMenu.setListener(listener);
         }
         mMenu.initialize(prefGroup);
         mMenuInitialized = true;
 
+        if (mCustomPhotoMenu == null) {
+            mCustomPhotoMenu = new CustomPhotoMenu(mActivity, this);
+            mCustomPhotoMenu.setListener(listener);
+        }
+        mCustomPhotoMenu.initialize(prefGroup);
+        mCustomPhotoMenuInitialized = true;
+
         if (mZoomRenderer == null) {
             mZoomRenderer = new ZoomRenderer(mActivity);
             mRenderOverlay.addRenderer(mZoomRenderer);
@@ -443,7 +452,7 @@
             mGestures = new PreviewGestures(mActivity, this, mZoomRenderer, mPieRenderer);
             mRenderOverlay.setGestures(mGestures);
         }
-        mGestures.setPhotoMenu(mMenu);
+        mGestures.setCustomPhotoMenu(mCustomPhotoMenu);
 
         mGestures.setZoomEnabled(params.isZoomSupported());
         mGestures.setRenderOverlay(mRenderOverlay);
@@ -484,7 +493,7 @@
         mMenuButton.setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View v) {
-                mMenu.openFirstLevel();
+                mCustomPhotoMenu.openFirstLevel();
             }
         });
         if (mController.isImageCaptureIntent()) {
@@ -529,7 +538,7 @@
     }
 
     public void showUI() {
-        if (!mUIhidden || (mMenu != null && mMenu.isMenuBeingShown()))
+        if (!mUIhidden || (mCustomPhotoMenu != null && mCustomPhotoMenu.isMenuBeingShown()))
             return;
         mUIhidden = false;
         mCameraControls.showUI();
@@ -580,6 +589,9 @@
         if (mMenu != null) {
             mMenu.reloadPreferences();
         }
+        if (mCustomPhotoMenu != null) {
+            mCustomPhotoMenu.reloadPreferences();
+        }
     }
 
     public void showLocationDialog() {
@@ -633,6 +645,8 @@
     public void hideGpsOnScreenIndicator() { }
 
     public void overrideSettings(final String ... keyvalues) {
+        if (mCustomPhotoMenu != null)
+            mCustomPhotoMenu.overrideSettings(keyvalues);
         if (mMenu == null)
             return;
         mMenu.overrideSettings(keyvalues);
@@ -682,7 +696,7 @@
     }
 
     public boolean onBackPressed() {
-        if (mMenu != null && mMenu.handleBackKey()) {
+        if (mCustomPhotoMenu != null && mCustomPhotoMenu.handleBackKey()) {
             return true;
         }
 
@@ -769,9 +783,9 @@
         }
         if (animate) {
             if (level == 1)
-                mMenu.animateSlideIn(popup, CameraActivity.SETTING_LIST_WIDTH_1, true);
+                mCustomPhotoMenu.animateSlideIn(popup, CameraActivity.SETTING_LIST_WIDTH_1, true);
             if (level == 2)
-                mMenu.animateFadeIn(popup);
+                mCustomPhotoMenu.animateFadeIn(popup);
         } else
             popup.setAlpha(0.85f);
     }
@@ -795,7 +809,7 @@
                 @Override
                 public void onDismiss() {
                     mPopup = null;
-                    // mMenu.popupDismissed(mDismissAll);
+                    mMenu.popupDismissed(mDismissAll);
                     mDismissAll = false;
                     showUI();
 
@@ -885,8 +899,8 @@
         mSwitcher.closePopup();
         // Remove all the popups/dialog boxes
         boolean ret = false;
-        if (mMenu != null) {
-            mMenu.closeAllView();
+        if (mCustomPhotoMenu != null) {
+            mCustomPhotoMenu.closeAllView();
         }
         if (mPopup != null) {
             dismissAllPopup();
@@ -925,9 +939,9 @@
             mFaceView.setDisplayOrientation(orientation);
         }
         if ((mPreviewOrientation == -1 || mPreviewOrientation != orientation)
-                && mMenu != null && mMenu.isPreviewMenuBeingShown()) {
+                && mCustomPhotoMenu != null && mCustomPhotoMenu.isPreviewMenuBeingShown()) {
             dismissSceneModeMenu();
-            mMenu.addModeBack();
+            mCustomPhotoMenu.addModeBack();
         }
         mPreviewOrientation = orientation;
     }
diff --git a/src/com/android/camera/PreviewGestures.java b/src/com/android/camera/PreviewGestures.java
index ce461aa..f4f8296 100644
--- a/src/com/android/camera/PreviewGestures.java
+++ b/src/com/android/camera/PreviewGestures.java
@@ -21,8 +21,8 @@
 import android.view.ScaleGestureDetector;
 import android.view.View;
 
-import com.android.camera.PhotoMenu;
-import com.android.camera.VideoMenu;
+import com.android.camera.CustomPhotoMenu;
+import com.android.camera.CustomVideoMenu;
 import com.android.camera.ui.PieRenderer;
 import com.android.camera.ui.RenderOverlay;
 import com.android.camera.ui.ZoomRenderer;
@@ -56,8 +56,8 @@
     private boolean mEnabled;
     private boolean mZoomOnly;
     private GestureDetector mGestureDetector;
-    private PhotoMenu mPhotoMenu;
-    private VideoMenu mVideoMenu;
+    private CustomPhotoMenu mCustomPhotoMenu;
+    private CustomVideoMenu mCustomVideoMenu;
     private boolean waitUntilNextDown;
     private boolean setToFalse;
 
@@ -100,15 +100,15 @@
             if (deltaX < 0 && Math.abs(deltaX) > 2 * Math.abs(deltaY)) {
                 // Open menu on swipe left
                 waitUntilNextDown = true;
-                if (mPhotoMenu != null) {
-                    if (!mPhotoMenu.isMenuBeingShown()) {
-                        mPhotoMenu.openFirstLevel();
+                if (mCustomPhotoMenu != null) {
+                    if (!mCustomPhotoMenu.isMenuBeingShown()) {
+                        mCustomPhotoMenu.openFirstLevel();
                     }
                 }
 
-                if (mVideoMenu != null) {
-                    if (!mVideoMenu.isMenuBeingShown()) {
-                        mVideoMenu.openFirstLevel();
+                if (mCustomVideoMenu != null) {
+                    if (!mCustomVideoMenu.isMenuBeingShown()) {
+                        mCustomVideoMenu.openFirstLevel();
                     }
                 }
                 return true;
@@ -152,20 +152,20 @@
         return mEnabled;
     }
 
-    public void setPhotoMenu(PhotoMenu menu) {
-        mPhotoMenu = menu;
+    public void setCustomPhotoMenu(CustomPhotoMenu menu) {
+        mCustomPhotoMenu = menu;
     }
 
-    public void setVideoMenu(VideoMenu menu) {
-        mVideoMenu = menu;
+    public void setCustomVideoMenu(CustomVideoMenu menu) {
+        mCustomVideoMenu = menu;
     }
 
-    public PhotoMenu getPhotoMenu() {
-        return mPhotoMenu;
+    public CustomPhotoMenu getCustomPhotoMenu() {
+        return mCustomPhotoMenu;
     }
 
-    public VideoMenu getVideoMenu() {
-        return mVideoMenu;
+    public CustomVideoMenu getCustomVideoMenu() {
+        return mCustomVideoMenu;
     }
 
     public boolean dispatchTouch(MotionEvent m) {
@@ -196,33 +196,33 @@
             return sendToPie(m);
         }
 
-        if (mPhotoMenu != null) {
-            if (mPhotoMenu.isMenuBeingShown()) {
-                if (!mPhotoMenu.isMenuBeingAnimated()) {
+        if (mCustomPhotoMenu != null) {
+            if (mCustomPhotoMenu.isMenuBeingShown()) {
+                if (!mCustomPhotoMenu.isMenuBeingAnimated()) {
                     waitUntilNextDown = true;
-                    mPhotoMenu.closeView();
+                    mCustomPhotoMenu.closeView();
                 }
                 return true;
             }
-            if (mPhotoMenu.isPreviewMenuBeingShown()) {
+            if (mCustomPhotoMenu.isPreviewMenuBeingShown()) {
                 waitUntilNextDown = true;
-                mPhotoMenu.animateSlideOutPreviewMenu();
+                mCustomPhotoMenu.animateSlideOutPreviewMenu();
                 return true;
             }
         }
 
-        if (mVideoMenu != null) {
-            if (mVideoMenu.isMenuBeingShown()) {
-                if (!mVideoMenu.isMenuBeingAnimated()) {
+        if (mCustomVideoMenu != null) {
+            if (mCustomVideoMenu.isMenuBeingShown()) {
+                if (!mCustomVideoMenu.isMenuBeingAnimated()) {
                     waitUntilNextDown = true;
-                    mVideoMenu.closeView();
+                    mCustomVideoMenu.closeView();
                 }
                 return true;
             }
 
-            if (mVideoMenu.isPreviewMenuBeingShown()) {
+            if (mCustomVideoMenu.isPreviewMenuBeingShown()) {
                 waitUntilNextDown = true;
-                mVideoMenu.animateSlideOutPreviewMenu();
+                mCustomVideoMenu.animateSlideOutPreviewMenu();
                 return true;
             }
         }
diff --git a/src/com/android/camera/VideoMenu.java b/src/com/android/camera/VideoMenu.java
index 3f9cde7..08cb384 100644
--- a/src/com/android/camera/VideoMenu.java
+++ b/src/com/android/camera/VideoMenu.java
@@ -16,559 +16,155 @@
 
 package com.android.camera;
 
-import android.animation.Animator;
-import android.animation.Animator.AnimatorListener;
 import android.content.Context;
-import android.content.res.Resources;
-import android.content.SharedPreferences;
-import android.graphics.Rect;
-import android.preference.PreferenceManager;
-import android.util.Log;
 import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewPropertyAnimator;
-import android.widget.ListView;
-import android.widget.TextView;
-import android.widget.GridView;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.FrameLayout;
-import android.widget.FrameLayout.LayoutParams;
 
-import com.android.camera.ui.CameraControls;
-import com.android.camera.ui.ListSubMenu;
-import com.android.camera.ui.ListMenu;
+import com.android.camera.ui.AbstractSettingPopup;
+import com.android.camera.ui.ListPrefSettingPopup;
+import com.android.camera.ui.MoreSettingPopup;
+import com.android.camera.ui.PieItem;
+import com.android.camera.ui.PieItem.OnClickListener;
+import com.android.camera.ui.PieRenderer;
 import com.android.camera.ui.TimeIntervalPopup;
-import com.android.camera.ui.RotateImageView;
 import org.codeaurora.snapcam.R;
-import android.widget.HorizontalScrollView;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.view.Display;
-import com.android.camera.util.CameraUtil;
 
-public class VideoMenu extends MenuController
-        implements ListMenu.Listener,
-        ListSubMenu.Listener,
+public class VideoMenu extends PieController
+        implements MoreSettingPopup.Listener,
+        ListPrefSettingPopup.Listener,
         TimeIntervalPopup.Listener {
 
-    private static String TAG = "VideoMenu";
+    private static String TAG = "CAM_VideoMenu";
 
     private VideoUI mUI;
     private String[] mOtherKeys1;
     private String[] mOtherKeys2;
 
-    private ListMenu mListMenu;
-    private ListSubMenu mListSubMenu;
-    private View mPreviewMenu;
+    private AbstractSettingPopup mPopup1;
+    private AbstractSettingPopup mPopup2;
+
     private static final int POPUP_NONE = 0;
     private static final int POPUP_FIRST_LEVEL = 1;
     private static final int POPUP_SECOND_LEVEL = 2;
-    private static final int POPUP_IN_ANIMATION = 3;
-    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_FILTER = 1;
-    private int mSceneStatus;
-    private View mFrontBackSwitcher;
-    private View mFilterModeSwitcher;
     private int mPopupStatus;
-    private int mPreviewMenuStatus;
+    private int popupNum;
     private CameraActivity mActivity;
     private String mPrevSavedVideoCDS;
     private boolean mIsVideoTNREnabled = false;
     private boolean mIsVideoCDSUpdated = false;
-    private static final int ANIMATION_DURATION = 300;
-    private static final int CLICK_THRESHOLD = 200;
-    private int previewMenuSize;
 
-    public VideoMenu(CameraActivity activity, VideoUI ui) {
-        super(activity);
+    public VideoMenu(CameraActivity activity, VideoUI ui, PieRenderer pie) {
+        super(activity, pie);
         mUI = ui;
         mActivity = activity;
-        mFrontBackSwitcher = ui.getRootView().findViewById(R.id.front_back_switcher);
-        mFilterModeSwitcher = ui.getRootView().findViewById(R.id.filter_mode_switcher);
     }
 
     public void initialize(PreferenceGroup group) {
         super.initialize(group);
-        mListMenu = null;
-        mListSubMenu = null;
+        mPopup1 = null;
+        mPopup2 = null;
+        popupNum = 0;
         mPopupStatus = POPUP_NONE;
-        mPreviewMenuStatus = POPUP_NONE;
-        initFilterModeButton(mFilterModeSwitcher);
+        PieItem item = null;
         // settings popup
         mOtherKeys1 = new String[] {
+                CameraSettings.KEY_DIS,
+                CameraSettings.KEY_VIDEO_EFFECT,
+                CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL,
                 CameraSettings.KEY_VIDEO_QUALITY,
+                CameraSettings.KEY_VIDEO_ENCODER,
+                CameraSettings.KEY_AUDIO_ENCODER,
                 CameraSettings.KEY_VIDEO_DURATION,
                 CameraSettings.KEY_RECORD_LOCATION,
-                CameraSettings.KEY_CAMERA_SAVEPATH,
-                CameraSettings.KEY_WHITE_BALANCE,
-                CameraSettings.KEY_VIDEO_HIGH_FRAME_RATE,
-                CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE
+                CameraSettings.KEY_CAMERA_SAVEPATH
         };
-        mOtherKeys2 = new String[] {
-                CameraSettings.KEY_VIDEO_QUALITY,
-                CameraSettings.KEY_VIDEO_DURATION,
-                CameraSettings.KEY_RECORD_LOCATION,
-                CameraSettings.KEY_CAMERA_SAVEPATH,
+
+       //settings popup
+       mOtherKeys2 = new String[] {
+                CameraSettings.KEY_COLOR_EFFECT,
+                CameraSettings.KEY_VIDEO_HDR,
+                CameraSettings.KEY_POWER_MODE,
                 CameraSettings.KEY_WHITE_BALANCE,
                 CameraSettings.KEY_VIDEO_HIGH_FRAME_RATE,
                 CameraSettings.KEY_SEE_MORE,
                 CameraSettings.KEY_VIDEOCAMERA_FLASH_MODE,
-                CameraSettings.KEY_DIS,
-                CameraSettings.KEY_VIDEO_EFFECT,
-                CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL,
-                CameraSettings.KEY_VIDEO_ENCODER,
-                CameraSettings.KEY_AUDIO_ENCODER,
-                CameraSettings.KEY_VIDEO_HDR,
-                CameraSettings.KEY_POWER_MODE,
                 CameraSettings.KEY_VIDEO_ROTATION,
                 CameraSettings.KEY_VIDEO_CDS_MODE,
                 CameraSettings.KEY_VIDEO_TNR_MODE
-        };
-        mFrontBackSwitcher.setVisibility(View.INVISIBLE);
-        initSwitchItem(CameraSettings.KEY_CAMERA_ID, mFrontBackSwitcher);
-    }
+       };
 
-    public boolean handleBackKey() {
-        if (mPreviewMenuStatus == PREVIEW_MENU_ON) {
-            animateSlideOut(mPreviewMenu);
-            return true;
-        }
-        if (mPopupStatus == POPUP_NONE)
-            return false;
-        if (mPopupStatus == POPUP_FIRST_LEVEL) {
-            animateSlideOut(mListMenu, 1);
-        } else if (mPopupStatus == POPUP_SECOND_LEVEL) {
-            animateFadeOut(mListSubMenu, 2);
-            ((ListMenu) mListMenu).resetHighlight();
-        }
-        return true;
-    }
-
-    public void closeSceneMode() {
-        mUI.removeSceneModeMenu();
-    }
-
-    public void tryToCloseSubList() {
-        if (mListMenu != null)
-            ((ListMenu) mListMenu).resetHighlight();
-
-        if (mPopupStatus == POPUP_SECOND_LEVEL) {
-            mUI.dismissLevel2();
-            mPopupStatus = POPUP_FIRST_LEVEL;
-        }
-    }
-
-    private void animateFadeOut(final ListView v, final int level) {
-        if (v == null || mPopupStatus == POPUP_IN_ANIMATION)
-            return;
-        mPopupStatus = POPUP_IN_ANIMATION;
-
-        ViewPropertyAnimator vp = v.animate();
-        vp.alpha(0f).setDuration(ANIMATION_DURATION);
-        vp.setListener(new AnimatorListener() {
+        PieItem item1 = makeItem(R.drawable.ic_settings_holo_light_01);
+        item1.setLabel(mActivity.getResources().getString(R.string.camera_menu_more_label));
+        item1.setOnClickListener(new OnClickListener() {
             @Override
-            public void onAnimationStart(Animator animation) {
-            }
-
-            @Override
-            public void onAnimationRepeat(Animator animation) {
-
-            }
-
-            @Override
-            public void onAnimationEnd(Animator animation) {
-                if (level == 1) {
-                    mUI.dismissLevel1();
+            public void onClick(PieItem item) {
+                if (mPopup1 == null || mPopupStatus != POPUP_FIRST_LEVEL) {
                     initializePopup();
-                    mPopupStatus = POPUP_NONE;
-                    mUI.cleanupListview();
-                }
-                else if (level == 2) {
-                    mUI.dismissLevel2();
                     mPopupStatus = POPUP_FIRST_LEVEL;
                 }
+                mUI.showPopup(mPopup1);
+                popupNum = 1;
             }
+        });
+        mRenderer.addItem(item1);
 
+        PieItem item2 = makeItem(R.drawable.ic_settings_holo_light_02);
+        item2.setLabel(mActivity.getResources().getString(R.string.camera_menu_more_label));
+        item2.setOnClickListener(new OnClickListener() {
             @Override
-            public void onAnimationCancel(Animator animation) {
-                if (level == 1) {
-                    mUI.dismissLevel1();
+            public void onClick(PieItem item) {
+                if (mPopup2 == null || mPopupStatus != POPUP_FIRST_LEVEL) {
                     initializePopup();
-                    mPopupStatus = POPUP_NONE;
-                    mUI.cleanupListview();
-                }
-                else if (level == 2) {
-                    mUI.dismissLevel2();
                     mPopupStatus = POPUP_FIRST_LEVEL;
                 }
-
+                mUI.showPopup(mPopup2);
+                popupNum = 2;
             }
         });
-        vp.start();
-    }
+        mRenderer.addItem(item2);
 
-    private void animateSlideOut(final ListView v, final int level) {
-        if (v == null || mPopupStatus == POPUP_IN_ANIMATION)
-            return;
-        mPopupStatus = POPUP_IN_ANIMATION;
+        // camera switcher
+        if (group.findPreference(CameraSettings.KEY_CAMERA_ID) != null) {
+            item = makeItem(R.drawable.ic_switch_back);
+            IconListPreference lpref = (IconListPreference) group.findPreference(
+                    CameraSettings.KEY_CAMERA_ID);
+            item.setLabel(lpref.getLabel());
+            item.setImageResource(mActivity,
+                    ((IconListPreference) lpref).getIconIds()
+                    [lpref.findIndexOfValue(lpref.getValue())]);
 
-        ViewPropertyAnimator vp = v.animate();
-        vp.translationX(v.getX() - v.getWidth()).setDuration(ANIMATION_DURATION);
-        vp.setListener(new AnimatorListener() {
-            @Override
-            public void onAnimationStart(Animator animation) {
-            }
-
-            @Override
-            public void onAnimationRepeat(Animator animation) {
-
-            }
-
-            @Override
-            public void onAnimationEnd(Animator animation) {
-                if (level == 1) {
-                    mUI.dismissLevel1();
-                    initializePopup();
-                    mPopupStatus = POPUP_NONE;
-                    mUI.cleanupListview();
-                }
-                else if (level == 2) {
-                    mUI.dismissLevel2();
-                    mPopupStatus = POPUP_FIRST_LEVEL;
-                }
-            }
-
-            @Override
-            public void onAnimationCancel(Animator animation) {
-                if (level == 1) {
-                    mUI.dismissLevel1();
-                    initializePopup();
-                    mPopupStatus = POPUP_NONE;
-                    mUI.cleanupListview();
-                }
-                else if (level == 2) {
-                    mUI.dismissLevel2();
-                    mPopupStatus = POPUP_FIRST_LEVEL;
-                }
-
-            }
-        });
-        vp.start();
-    }
-
-    public void animateFadeIn(final ListView v) {
-        ViewPropertyAnimator vp = v.animate();
-        vp.alpha(0.85f).setDuration(ANIMATION_DURATION);
-        vp.start();
-    }
-
-    public void animateSlideIn(final View v, int delta, boolean settingMenu) {
-        int rotation = CameraUtil.getDisplayRotation(mActivity);
-        boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
-        if (!mIsDefaultToPortrait) {
-            rotation = (rotation + 90) % 360;
-        }
-        boolean portrait = (rotation == 0) || (rotation == 180);
-        if (settingMenu)
-            portrait = true;
-        ViewPropertyAnimator vp = v.animate();
-        if (portrait) {
-            float dest = v.getX();
-            v.setX(dest - delta);
-            vp.translationX(dest).setDuration(ANIMATION_DURATION);
-        }
-        else {
-            float dest = v.getY();
-            v.setY(dest + delta);
-            vp.translationY(dest).setDuration(ANIMATION_DURATION);
-        }
-        vp.start();
-    }
-
-    public void animateSlideOutPreviewMenu() {
-        if (mPreviewMenu == null)
-            return;
-        animateSlideOut(mPreviewMenu);
-    }
-
-    private void animateSlideOut(final View v) {
-        if (v == null || mPreviewMenuStatus == PREVIEW_MENU_IN_ANIMATION)
-            return;
-        mPreviewMenuStatus = PREVIEW_MENU_IN_ANIMATION;
-        int rotation = CameraUtil.getDisplayRotation(mActivity);
-        boolean mIsDefaultToPortrait = CameraUtil.isDefaultToPortrait(mActivity);
-        if (!mIsDefaultToPortrait) {
-            rotation = (rotation + 90) % 360;
-        }
-        boolean portrait = (rotation == 0) || (rotation == 180);
-        ViewPropertyAnimator vp = v.animate();
-        if (portrait) {
-            vp.translationX(v.getX() - v.getWidth()).setDuration(ANIMATION_DURATION);
-
-        } else {
-            vp.translationY(v.getY() + v.getHeight()).setDuration(ANIMATION_DURATION);
-
-        }
-        vp.setListener(new AnimatorListener() {
-            @Override
-            public void onAnimationStart(Animator animation) {
-            }
-
-            @Override
-            public void onAnimationRepeat(Animator animation) {
-
-            }
-
-            @Override
-            public void onAnimationEnd(Animator animation) {
-                closeSceneMode();
-                mPreviewMenuStatus = PREVIEW_MENU_NONE;
-            }
-
-            @Override
-            public void onAnimationCancel(Animator animation) {
-                closeSceneMode();
-                mPreviewMenuStatus = PREVIEW_MENU_NONE;
-            }
-        });
-        vp.start();
-    }
-
-    public boolean isOverMenu(MotionEvent ev) {
-        if (mPopupStatus == POPUP_NONE || mPopupStatus == POPUP_IN_ANIMATION)
-            return false;
-        if (mUI.getMenuLayout() == null)
-            return false;
-        Rect rec = new Rect();
-        mUI.getMenuLayout().getChildAt(0).getHitRect(rec);
-        return rec.contains((int) ev.getX(), (int) ev.getY());
-    }
-
-    public boolean isOverPreviewMenu(MotionEvent ev) {
-        if (mPreviewMenuStatus != PREVIEW_MENU_ON)
-            return false;
-        if (mUI.getPreviewMenuLayout() == null)
-            return false;
-        Rect rec = new Rect();
-        mUI.getPreviewMenuLayout().getChildAt(0).getHitRect(rec);
-        rec.top += (int) mUI.getPreviewMenuLayout().getY();
-        rec.bottom += (int) mUI.getPreviewMenuLayout().getY();
-        return rec.contains((int) ev.getX(), (int) ev.getY());
-    }
-
-    public boolean isMenuBeingShown() {
-        return mPopupStatus != POPUP_NONE;
-    }
-
-    public boolean isMenuBeingAnimated() {
-        return mPopupStatus == POPUP_IN_ANIMATION;
-    }
-
-    public boolean isPreviewMenuBeingShown() {
-        return mPreviewMenuStatus == PREVIEW_MENU_ON;
-    }
-
-    public boolean isPreviewMenuBeingAnimated() {
-        return mPreviewMenuStatus == PREVIEW_MENU_IN_ANIMATION;
-    }
-
-    public boolean sendTouchToPreviewMenu(MotionEvent ev) {
-        return mUI.sendTouchToPreviewMenu(ev);
-    }
-
-    public boolean sendTouchToMenu(MotionEvent ev) {
-        return mUI.sendTouchToMenu(ev);
-    }
-
-    public void initSwitchItem(final String prefKey, View switcher) {
-        final IconListPreference pref =
-                (IconListPreference) mPreferenceGroup.findPreference(prefKey);
-        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) ((FrameLayout) switcher).getChildAt(0);
-        iv.setImageResource(resid);
-        switcher.setVisibility(View.VISIBLE);
-        mPreferences.add(pref);
-        mPreferenceMap.put(pref, switcher);
-        switcher.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                IconListPreference pref = (IconListPreference) mPreferenceGroup
-                        .findPreference(prefKey);
-                if (pref == null)
-                    return;
-                int index = pref.findIndexOfValue(pref.getValue());
-                CharSequence[] values = pref.getEntryValues();
-                index = (index + 1) % values.length;
-                pref.setValueIndex(index);
-                ImageView iv = (ImageView) ((FrameLayout) v).getChildAt(0);
-                iv.setImageResource(((IconListPreference) pref).getLargeIconIds()[index]);
-                if (prefKey.equals(CameraSettings.KEY_CAMERA_ID))
-                    mListener.onCameraPickerClicked(index);
-                reloadPreference(pref);
-                onSettingChanged(pref);
-            }
-        });
-    }
-
-    public void initFilterModeButton(View button) {
-        button.setVisibility(View.INVISIBLE);
-        final IconListPreference pref = (IconListPreference) mPreferenceGroup
-                .findPreference(CameraSettings.KEY_COLOR_EFFECT);
-        if (pref == null)
-            return;
-
-        int[] iconIds = pref.getLargeIconIds();
-        int resid = -1;
-        // The preference only has a single icon to represent it.
-        resid = pref.getSingleIcon();
-        ImageView iv = (ImageView) ((FrameLayout) button).getChildAt(0);
-        iv.setImageResource(resid);
-        button.setVisibility(View.VISIBLE);
-        button.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                addFilterMode();
-                View view = mUI.getPreviewMenuLayout().getChildAt(0);
-                animateSlideIn(view, previewMenuSize, false);
-            }
-        });
-    }
-
-    public void addModeBack() {
-        if (mSceneStatus == MODE_FILTER) {
-            addFilterMode();
-        }
-    }
-
-    public void addFilterMode() {
-        final IconListPreference pref = (IconListPreference) mPreferenceGroup
-                .findPreference(CameraSettings.KEY_COLOR_EFFECT);
-        if (pref == null)
-            return;
-
-        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();
-        CharSequence[] entries = pref.getEntries();
-
-        Resources r = mActivity.getResources();
-        int height = (int) (r.getDimension(R.dimen.filter_mode_height) + 2
-                * r.getDimension(R.dimen.filter_mode_padding) + 1);
-        int width = (int) (r.getDimension(R.dimen.filter_mode_width) + 2
-                * r.getDimension(R.dimen.filter_mode_padding) + 1);
-
-        int gridRes = 0;
-        boolean portrait = (rotation == 0) || (rotation == 180);
-        int size = height;
-        if (portrait) {
-            gridRes = R.layout.vertical_grid;
-            size = width;
-        } else {
-            gridRes = R.layout.horiz_grid;
-        }
-        previewMenuSize = size;
-        mUI.hideUI();
-        mPreviewMenuStatus = PREVIEW_MENU_ON;
-        mSceneStatus = MODE_FILTER;
-
-        int[] thumbnails = pref.getThumbnailIds();
-
-        LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
-                Context.LAYOUT_INFLATER_SERVICE);
-        FrameLayout basic = (FrameLayout) inflater.inflate(
-                gridRes, null, false);
-
-        mUI.dismissSceneModeMenu();
-        LinearLayout previewMenuLayout = new LinearLayout(mActivity);
-        mUI.setPreviewMenuLayout(previewMenuLayout);
-        ViewGroup.LayoutParams params = null;
-        if (portrait) {
-            params = new ViewGroup.LayoutParams(size, LayoutParams.MATCH_PARENT);
-            previewMenuLayout.setLayoutParams(params);
-            ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout);
-        } else {
-            params = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, size);
-            previewMenuLayout.setLayoutParams(params);
-            ((ViewGroup) mUI.getRootView()).addView(previewMenuLayout);
-            previewMenuLayout.setY(display.getHeight() - size);
-        }
-        basic.setLayoutParams(new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
-                LayoutParams.MATCH_PARENT));
-        LinearLayout layout = (LinearLayout) basic.findViewById(R.id.layout);
-
-        final View[] views = new View[entries.length];
-        int init = pref.getCurrentIndex();
-        for (int i = 0; i < entries.length; i++) {
-            LinearLayout layout2 = (LinearLayout) inflater.inflate(
-                    R.layout.filter_mode_view, null, false);
-
-            ImageView imageView = (ImageView) layout2.findViewById(R.id.image);
-            final int j = i;
-
-            layout2.setOnTouchListener(new View.OnTouchListener() {
-                private long startTime;
+            final PieItem fitem = item;
+            item.setOnClickListener(new OnClickListener() {
 
                 @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);
-                            for (View v1 : views) {
-                                v1.setBackground(null);
-                            }
-                            ImageView image = (ImageView) v.findViewById(R.id.image);
-                            image.setBackgroundColor(0xff33b5e5);
-                            onSettingChanged(pref);
-                        }
-
+                public void onClick(PieItem item) {
+                    // Find the index of next camera.
+                    ListPreference pref =
+                            mPreferenceGroup.findPreference(CameraSettings.KEY_CAMERA_ID);
+                    if (pref != null) {
+                        int index = pref.findIndexOfValue(pref.getValue());
+                        CharSequence[] values = pref.getEntryValues();
+                        index = (index + 1) % values.length;
+                        int newCameraId = Integer.parseInt((String) values[index]);
+                        fitem.setImageResource(mActivity,
+                                ((IconListPreference) pref).getIconIds()[index]);
+                        fitem.setLabel(pref.getLabel());
+                        mListener.onCameraPickerClicked(newCameraId);
                     }
-                    return true;
                 }
             });
-
-            views[j] = imageView;
-            if (i == init)
-                imageView.setBackgroundColor(0xff33b5e5);
-            TextView label = (TextView) layout2.findViewById(R.id.label);
-            imageView.setImageResource(thumbnails[i]);
-            label.setText(entries[i]);
-            layout.addView(layout2);
+            mRenderer.addItem(item);
         }
-        previewMenuLayout.addView(basic);
-        mPreviewMenu = basic;
     }
 
-    public void openFirstLevel() {
-        if (isMenuBeingShown() || CameraControls.isAnimating())
-            return;
-        if (mListMenu == null || mPopupStatus != POPUP_FIRST_LEVEL) {
-            initializePopup();
-            mPopupStatus = POPUP_FIRST_LEVEL;
+    @Override
+    public void reloadPreferences() {
+        super.reloadPreferences();
+        if (mPopup1 != null) {
+            mPopup1.reloadPreference();
         }
-        mUI.showPopup(mListMenu, 1, true);
+        if (mPopup2 != null) {
+            mPopup2.reloadPreference();
+        }
     }
 
     public void setPreference(String key, String value) {
@@ -580,7 +176,7 @@
     }
 
     public void overrideCDSMode() {
-        if (mListMenu != null) {
+        if (mPopup2 != null) {
             ListPreference pref_tnr = mPreferenceGroup.
                     findPreference(CameraSettings.KEY_VIDEO_TNR_MODE);
             ListPreference pref_cds = mPreferenceGroup.
@@ -594,9 +190,9 @@
 
             if ((tnr != null) && !mActivity.getString(R.string.
                     pref_camera_video_tnr_default).equals(tnr)) {
-                mListMenu.setPreferenceEnabled(
+                ((MoreSettingPopup) mPopup2).setPreferenceEnabled(
                         CameraSettings.KEY_VIDEO_CDS_MODE,false);
-                mListMenu.overrideSettings(
+                ((MoreSettingPopup) mPopup2).overrideSettings(
                         CameraSettings.KEY_VIDEO_CDS_MODE,
                         mActivity.getString(R.string.pref_camera_video_cds_value_off));
                 mIsVideoTNREnabled = true;
@@ -607,10 +203,10 @@
                     mIsVideoCDSUpdated = true;
                 }
             } else if (tnr != null) {
-                mListMenu.setPreferenceEnabled(
+                ((MoreSettingPopup) mPopup2).setPreferenceEnabled(
                         CameraSettings.KEY_VIDEO_CDS_MODE,true);
                 if (mIsVideoTNREnabled) {
-                    mListMenu.overrideSettings(
+                    ((MoreSettingPopup) mPopup2).overrideSettings(
                             CameraSettings.KEY_VIDEO_CDS_MODE, mPrevSavedVideoCDS);
                     mIsVideoTNREnabled = false;
                     mIsVideoCDSUpdated = false;
@@ -620,46 +216,49 @@
     }
 
     @Override
-    public void overrideSettings(final String... keyvalues) {
+    public void overrideSettings(final String ... keyvalues) {
         overrideCDSMode();
         super.overrideSettings(keyvalues);
-        if (((mListMenu == null)) || mPopupStatus != POPUP_FIRST_LEVEL) {
+        if (((mPopup1 == null) && (mPopup2 == null)) || mPopupStatus != POPUP_FIRST_LEVEL) {
             mPopupStatus = POPUP_FIRST_LEVEL;
             initializePopup();
         }
-        mListMenu.overrideSettings(keyvalues);
-
+        ((MoreSettingPopup) mPopup1).overrideSettings(keyvalues);
+        ((MoreSettingPopup) mPopup2).overrideSettings(keyvalues);
     }
 
     @Override
     // Hit when an item in the second-level popup gets selected
     public void onListPrefChanged(ListPreference pref) {
-        if (mPopupStatus == POPUP_SECOND_LEVEL) {
-            mListMenu.reloadPreference();
-            animateFadeOut(mListSubMenu, 2);
+        if (mPopup1 != null && mPopup2 != null) {
+            if (mPopupStatus == POPUP_SECOND_LEVEL) {
+                mUI.dismissPopup(true);
+                mPopup1.reloadPreference();
+                mPopup2.reloadPreference();
+            }
         }
         super.onSettingChanged(pref);
-        ((ListMenu) mListMenu).resetHighlight();
     }
 
     protected void initializePopup() {
         LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
                 Context.LAYOUT_INFLATER_SERVICE);
 
-        ListMenu popup1 = (ListMenu) inflater.inflate(
-                R.layout.list_menu, null, false);
+        MoreSettingPopup popup1 = (MoreSettingPopup) inflater.inflate(
+                R.layout.more_setting_popup, null, false);
         popup1.setSettingChangedListener(this);
-        String[] keys = mOtherKeys1;
-        if (mActivity.isDeveloperMenuEnabled())
-            keys = mOtherKeys2;
-        popup1.initialize(mPreferenceGroup, keys);
+        popup1.initialize(mPreferenceGroup, mOtherKeys1);
         if (mActivity.isSecureCamera()) {
-            // Prevent location preference from getting changed in secure camera
-            // mode
+            // Prevent location preference from getting changed in secure camera mode
             popup1.setPreferenceEnabled(CameraSettings.KEY_RECORD_LOCATION, false);
         }
-        mListMenu = popup1;
+        mPopup1 = popup1;
 
+        MoreSettingPopup popup2 = (MoreSettingPopup) inflater.inflate(
+                R.layout.more_setting_popup, null, false);
+        popup2.setSettingChangedListener(this);
+        popup2.initialize(mPreferenceGroup, mOtherKeys2);
+        mPopup2 = popup2;
         overrideCDSMode();
     }
 
@@ -669,75 +268,40 @@
             initializePopup();
             mPopupStatus = POPUP_FIRST_LEVEL;
             if (topPopupOnly) {
-                mUI.showPopup(mListMenu, 1, false);
+                if(popupNum == 1) mUI.showPopup(mPopup1);
+                else if(popupNum == 2) mUI.showPopup(mPopup2);
             }
         } else {
             initializePopup();
         }
     }
 
-    public void hideUI() {
-        mFrontBackSwitcher.setVisibility(View.INVISIBLE);
-        mFilterModeSwitcher.setVisibility(View.INVISIBLE);
-    }
-
-    public void showUI() {
-        mFrontBackSwitcher.setVisibility(View.VISIBLE);
-        mFilterModeSwitcher.setVisibility(View.VISIBLE);
-    }
-
     @Override
     // Hit when an item in the first-level popup gets selected, then bring up
     // the second-level popup
     public void onPreferenceClicked(ListPreference pref) {
-        onPreferenceClicked(pref, 0);
-    }
+        if (mPopupStatus != POPUP_FIRST_LEVEL) return;
 
-    @Override
-    // Hit when an item in the first-level popup gets selected, then bring up
-    // the second-level popup
-    public void onPreferenceClicked(ListPreference pref, int y) {
         LayoutInflater inflater = (LayoutInflater) mActivity.getSystemService(
                 Context.LAYOUT_INFLATER_SERVICE);
 
-        ListSubMenu basic = (ListSubMenu) inflater.inflate(
-                R.layout.list_sub_menu, null, false);
-        basic.initialize(pref, y);
-        basic.setSettingChangedListener(this);
-        mUI.removeLevel2();
-        mListSubMenu = basic;
-        if (mPopupStatus == POPUP_SECOND_LEVEL) {
-            mUI.showPopup(mListSubMenu, 2, false);
+        if (CameraSettings.KEY_VIDEO_TIME_LAPSE_FRAME_INTERVAL.equals(pref.getKey())) {
+            TimeIntervalPopup timeInterval = (TimeIntervalPopup) inflater.inflate(
+                    R.layout.time_interval_popup, null, false);
+            timeInterval.initialize((IconListPreference) pref);
+            timeInterval.setSettingChangedListener(this);
+            mUI.dismissPopup(true);
+            mPopup1 = timeInterval;
         } else {
-            mUI.showPopup(mListSubMenu, 2, true);
+            ListPrefSettingPopup basic = (ListPrefSettingPopup) inflater.inflate(
+                    R.layout.list_pref_setting_popup, null, false);
+            basic.initialize(pref);
+            basic.setSettingChangedListener(this);
+            mUI.dismissPopup(true);
+            mPopup1 = basic;
         }
+        mUI.showPopup(mPopup1);
         mPopupStatus = POPUP_SECOND_LEVEL;
     }
 
-    public void onListMenuTouched() {
-        mUI.removeLevel2();
-    }
-
-    public void closeAllView() {
-        if (mUI != null)
-            mUI.removeLevel2();
-
-        if (mListMenu != null)
-            animateSlideOut(mListMenu, 1);
-        animateSlideOutPreviewMenu();
-    }
-
-    public void closeView() {
-        if (mUI != null)
-            mUI.removeLevel2();
-
-        if (mListMenu != null)
-            animateSlideOut(mListMenu, 1);
-    }
-
-    @Override
-    public void onSettingChanged(ListPreference pref) {
-        super.onSettingChanged(pref);
-    }
-
 }
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index 80ba0c0..6dd793d 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -103,6 +103,7 @@
     private LinearLayout mMenuLayout;
     private LinearLayout mSubMenuLayout;
     private LinearLayout mPreviewMenuLayout;
+    private CustomVideoMenu mCustomVideoMenu;
 
     private View mPreviewCover;
     private SurfaceView mSurfaceView = null;
@@ -172,7 +173,7 @@
                 setTransformMatrix(width, height);
                 mAspectRatioResize = false;
             }
-            mVideoMenu.tryToCloseSubList();
+            mCustomVideoMenu.tryToCloseSubList();
         }
     };
 
@@ -195,7 +196,7 @@
             super.dismiss();
             popupDismissed();
             showUI();
-            // mVideoMenu.popupDismissed(topLevelOnly);
+            mVideoMenu.popupDismissed(topLevelOnly);
 
             // Switch back into fullscreen/lights-out mode after popup
             // is dimissed.
@@ -276,7 +277,7 @@
         mMenuButton.setOnClickListener(new OnClickListener() {
             @Override
             public void onClick(View v) {
-                mVideoMenu.openFirstLevel();
+                mCustomVideoMenu.openFirstLevel();
             }
         });
 
@@ -425,7 +426,7 @@
     }
 
     public void showUI() {
-        if (!mUIhidden || (mVideoMenu != null && mVideoMenu.isMenuBeingShown()))
+        if (!mUIhidden || (mCustomVideoMenu != null && mCustomVideoMenu.isMenuBeingShown()))
             return;
         mUIhidden = false;
         mCameraControls.showUI();
@@ -447,8 +448,8 @@
     public boolean collapseCameraControls() {
         boolean ret = false;
         mSwitcher.closePopup();
-        if (mVideoMenu != null) {
-            mVideoMenu.closeAllView();
+        if (mCustomVideoMenu != null) {
+            mCustomVideoMenu.closeAllView();
         }
         if (mPopup != null) {
             dismissPopup(false);
@@ -480,9 +481,9 @@
 
     public void setDisplayOrientation(int orientation) {
         if ((mPreviewOrientation == -1 || mPreviewOrientation != orientation)
-                && mVideoMenu != null && mVideoMenu.isPreviewMenuBeingShown()) {
+                && mCustomVideoMenu != null && mCustomVideoMenu.isPreviewMenuBeingShown()) {
             dismissSceneModeMenu();
-            mVideoMenu.addModeBack();
+            mCustomVideoMenu.addModeBack();
         }
         mPreviewOrientation = orientation;
     }
@@ -491,7 +492,6 @@
         ((CameraRootView) mRootView).removeDisplayChangeListener();
     }
 
-// no customvideo?
     public void overrideSettings(final String... keyvalues) {
         if (mVideoMenu != null) {
             mVideoMenu.overrideSettings(keyvalues);
@@ -531,11 +531,11 @@
         mRenderOverlay = (RenderOverlay) mRootView.findViewById(R.id.render_overlay);
         if (mPieRenderer == null) {
             mPieRenderer = new PieRenderer(mActivity);
-            // mVideoMenu = new VideoMenu(mActivity, this, mPieRenderer);
+            mVideoMenu = new VideoMenu(mActivity, this, mPieRenderer);
             mPieRenderer.setPieListener(this);
         }
-        if (mVideoMenu == null) {
-            mVideoMenu = new VideoMenu(mActivity, this);
+        if (mCustomVideoMenu == null) {
+            mCustomVideoMenu = new CustomVideoMenu(mActivity, this);
         }
         mRenderOverlay.addRenderer(mPieRenderer);
         if (mZoomRenderer == null) {
@@ -546,7 +546,7 @@
             mGestures = new PreviewGestures(mActivity, this, mZoomRenderer, mPieRenderer);
             mRenderOverlay.setGestures(mGestures);
         }
-        mGestures.setVideoMenu(mVideoMenu);
+        mGestures.setCustomVideoMenu(mCustomVideoMenu);
 
         mGestures.setRenderOverlay(mRenderOverlay);
 
@@ -566,6 +566,7 @@
 
     public void setPrefChangedListener(OnPreferenceChangedListener listener) {
         mVideoMenu.setListener(listener);
+        mCustomVideoMenu.setListener(listener);
     }
 
     private void initializeMiscControls() {
@@ -641,7 +642,7 @@
     }
 
     public boolean onBackPressed() {
-        if (mVideoMenu != null && mVideoMenu.handleBackKey()) {
+        if (mCustomVideoMenu != null && mCustomVideoMenu.handleBackKey()) {
             return true;
         }
         if (hidePieRenderer()) {
@@ -729,9 +730,9 @@
         }
         if (animate) {
             if (level == 1)
-                mVideoMenu.animateSlideIn(popup, CameraActivity.SETTING_LIST_WIDTH_1, true);
+                mCustomVideoMenu.animateSlideIn(popup, CameraActivity.SETTING_LIST_WIDTH_1, true);
             if (level == 2)
-                mVideoMenu.animateFadeIn(popup);
+                mCustomVideoMenu.animateFadeIn(popup);
         }
         else
             popup.setAlpha(0.85f);
@@ -836,11 +837,11 @@
     }
 
     public void hideUIwhileRecording() {
-        mVideoMenu.hideUI();
+        mCustomVideoMenu.hideUI();
     }
 
     public void showUIafterRecording() {
-        mVideoMenu.showUI();
+        mCustomVideoMenu.showUI();
     }
 
     public void showReviewImage(Bitmap bitmap) {
@@ -893,6 +894,7 @@
 
     public void initializePopup(PreferenceGroup pref) {
         mVideoMenu.initialize(pref);
+        mCustomVideoMenu.initialize(pref);
     }
 
     public void initializeZoom(Parameters param) {
diff --git a/src/com/android/camera/ui/FilmStripView.java b/src/com/android/camera/ui/FilmStripView.java
index 8c29098..7f197ca 100644
--- a/src/com/android/camera/ui/FilmStripView.java
+++ b/src/com/android/camera/ui/FilmStripView.java
@@ -37,8 +37,8 @@
 import android.view.animation.DecelerateInterpolator;
 import android.widget.Scroller;
 
-import com.android.camera.PhotoMenu;
-import com.android.camera.VideoMenu;
+import com.android.camera.CustomPhotoMenu;
+import com.android.camera.CustomVideoMenu;
 import com.android.camera.PreviewGestures;
 import com.android.camera.CameraActivity;
 import com.android.camera.data.LocalData;
@@ -1829,8 +1829,8 @@
     public boolean checkSendToModeView(MotionEvent ev) {
         if (mSendToPreviewMenu || mSendToMenu || mPreviewGestures == null)
             return true;
-        PhotoMenu pMenu = mPreviewGestures.getPhotoMenu();
-        VideoMenu vMenu = mPreviewGestures.getVideoMenu();
+        CustomPhotoMenu pMenu = mPreviewGestures.getCustomPhotoMenu();
+        CustomVideoMenu vMenu = mPreviewGestures.getCustomVideoMenu();
         if (pMenu != null) {
             if (pMenu.isMenuBeingShown()) {
                 if (pMenu.isMenuBeingAnimated()) {
@@ -1882,8 +1882,8 @@
                     || MotionEvent.ACTION_CANCEL == ev.getActionMasked())
                 mReset = true;
         }
-        PhotoMenu pMenu = mPreviewGestures.getPhotoMenu();
-        VideoMenu vMenu = mPreviewGestures.getVideoMenu();
+        CustomPhotoMenu pMenu = mPreviewGestures.getCustomPhotoMenu();
+        CustomVideoMenu vMenu = mPreviewGestures.getCustomVideoMenu();
 
         if (pMenu != null) {
             if (mSendToPreviewMenu)
diff --git a/src/com/android/camera/ui/ListMenu.java b/src/com/android/camera/ui/ListMenu.java
index 64bdc34..53cd48d 100644
--- a/src/com/android/camera/ui/ListMenu.java
+++ b/src/com/android/camera/ui/ListMenu.java
@@ -168,12 +168,8 @@
                     // If the preference is overridden, disable the preference
                     boolean enable = value == null;
                     mEnabled[j] = enable;
-                    int offset = getFirstVisiblePosition();
-                    if (offset >= 0) {
-                        int indexInView = j - offset;
-                        if (getChildCount() > indexInView && indexInView >= 0) {
-                            getChildAt(indexInView).setEnabled(enable);
-                        }
+                    if (getChildCount() > j) {
+                        getChildAt(j).setEnabled(enable);
                     }
                 }
             }