Search in sources :

Example 1 with ListSubMenu

use of com.android.camera.ui.ListSubMenu in project android_packages_apps_Snap by LineageOS.

the class VideoMenu method onPreferenceClicked.

@Override
public // the second-level popup
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;
    // Developer menu
    if (pref.getKey().equals(CameraSettings.KEY_MAX_BRIGHTNESS)) {
        mPrivateCounter++;
        if (mPrivateCounter >= DEVELOPER_MENU_TOUCH_COUNT) {
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivity);
            if (!mActivity.isDeveloperMenuEnabled()) {
                mActivity.enableDeveloperMenu();
                prefs.edit().putBoolean(CameraSettings.KEY_DEVELOPER_MENU, true).apply();
                closeAllView();
                RotateTextToast.makeText(mActivity, R.string.developer_menu_enabled, Toast.LENGTH_SHORT).show();
            } else {
                mActivity.disableDeveloperMenu();
                prefs.edit().putBoolean(CameraSettings.KEY_DEVELOPER_MENU, false).apply();
                closeAllView();
                RotateTextToast.makeText(mActivity, R.string.developer_menu_disabled, Toast.LENGTH_SHORT).show();
            }
            mPrivateCounter = 0;
        }
    } else {
        mPrivateCounter = 0;
    }
}
Also used : ListSubMenu(com.android.camera.ui.ListSubMenu) SharedPreferences(android.content.SharedPreferences) LayoutInflater(android.view.LayoutInflater)

Example 2 with ListSubMenu

use of com.android.camera.ui.ListSubMenu in project android_packages_apps_Snap by LineageOS.

the class PhotoMenu method onPreferenceClicked.

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);
    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;
    // Developer menu
    if (pref.getKey().equals(CameraSettings.KEY_MAX_BRIGHTNESS)) {
        mPrivateCounter++;
        if (mPrivateCounter >= DEVELOPER_MENU_TOUCH_COUNT) {
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mActivity);
            if (!mActivity.isDeveloperMenuEnabled()) {
                mActivity.enableDeveloperMenu();
                prefs.edit().putBoolean(CameraSettings.KEY_DEVELOPER_MENU, true).apply();
                closeAllView();
                RotateTextToast.makeText(mActivity, R.string.developer_menu_enabled, Toast.LENGTH_SHORT).show();
            } else {
                mActivity.disableDeveloperMenu();
                prefs.edit().putBoolean(CameraSettings.KEY_DEVELOPER_MENU, false).apply();
                closeAllView();
                RotateTextToast.makeText(mActivity, R.string.developer_menu_disabled, Toast.LENGTH_SHORT).show();
            }
            mPrivateCounter = 0;
        }
    } else {
        mPrivateCounter = 0;
    }
}
Also used : ListSubMenu(com.android.camera.ui.ListSubMenu) SharedPreferences(android.content.SharedPreferences) LayoutInflater(android.view.LayoutInflater)

Example 3 with ListSubMenu

use of com.android.camera.ui.ListSubMenu in project android_packages_apps_Snap by LineageOS.

the class VideoUI method showPopup.

public void showPopup(ListView popup, int level, boolean animate) {
    FrameLayout.LayoutParams layoutParams;
    hideUI();
    popup.setVisibility(View.VISIBLE);
    if (level == 1) {
        if (mMenuLayout == null) {
            mMenuLayout = new RotateLayout(mActivity, null);
            if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
                layoutParams = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP);
            } else {
                layoutParams = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.TOP);
            }
            mMenuLayout.setLayoutParams(layoutParams);
            ((ViewGroup) mRootView).addView(mMenuLayout);
        }
        mMenuLayout.setOrientation(mOrientation, true);
        mMenuLayout.addView(popup);
    }
    if (level == 2) {
        if (mSubMenuLayout == null) {
            mSubMenuLayout = new RotateLayout(mActivity, null);
            ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT);
            mSubMenuLayout.setLayoutParams(params);
            ((ViewGroup) mRootView).addView(mSubMenuLayout);
        }
        if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
            layoutParams = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP);
        } else {
            layoutParams = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.TOP);
        }
        int screenHeight = (mOrientation == 0 || mOrientation == 180) ? mRootView.getHeight() : mRootView.getWidth();
        int height = ((ListSubMenu) popup).getPreCalculatedHeight();
        int yBase = ((ListSubMenu) popup).getYBase();
        int y = Math.max(0, yBase);
        if (yBase + height > screenHeight)
            y = Math.max(0, screenHeight - height);
        if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
            layoutParams.setMargins(CameraActivity.SETTING_LIST_WIDTH_1, y, 0, 0);
        } else {
            layoutParams.setMargins(0, y, CameraActivity.SETTING_LIST_WIDTH_1, 0);
        }
        mSubMenuLayout.setLayoutParams(layoutParams);
        mSubMenuLayout.addView(popup);
        mSubMenuLayout.setOrientation(mOrientation, true);
    }
    if (animate) {
        if (level == 1)
            mVideoMenu.animateSlideIn(mMenuLayout, CameraActivity.SETTING_LIST_WIDTH_1, true);
        if (level == 2)
            mVideoMenu.animateFadeIn(popup);
    } else {
        popup.setAlpha(1f);
    }
}
Also used : ListSubMenu(com.android.camera.ui.ListSubMenu) LayoutParams(android.widget.FrameLayout.LayoutParams) LayoutParams(android.widget.FrameLayout.LayoutParams) RotateLayout(com.android.camera.ui.RotateLayout) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) Point(android.graphics.Point)

Example 4 with ListSubMenu

use of com.android.camera.ui.ListSubMenu in project android_packages_apps_Snap by LineageOS.

the class PhotoUI method showPopup.

public void showPopup(ListView popup, int level, boolean animate) {
    FrameLayout.LayoutParams params;
    hideUI();
    popup.setVisibility(View.VISIBLE);
    if (level == 1) {
        if (mMenuLayout == null) {
            mMenuLayout = new RotateLayout(mActivity, null);
            if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
                params = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP);
            } else {
                params = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_1, LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.TOP);
            }
            mMenuLayout.setLayoutParams(params);
            ((ViewGroup) mRootView).addView(mMenuLayout);
        }
        mMenuLayout.setOrientation(mOrientation, true);
        mMenuLayout.addView(popup);
    }
    if (level == 2) {
        if (mSubMenuLayout == null) {
            mSubMenuLayout = new RotateLayout(mActivity, null);
            ((ViewGroup) mRootView).addView(mSubMenuLayout);
        }
        if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
            params = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP);
        } else {
            params = new FrameLayout.LayoutParams(CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.TOP);
        }
        int screenHeight = (mOrientation == 0 || mOrientation == 180) ? mRootView.getHeight() : mRootView.getWidth();
        int height = ((ListSubMenu) popup).getPreCalculatedHeight();
        int yBase = ((ListSubMenu) popup).getYBase();
        int y = Math.max(0, yBase);
        if (yBase + height > screenHeight)
            y = Math.max(0, screenHeight - height);
        if (mRootView.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL) {
            params.setMargins(CameraActivity.SETTING_LIST_WIDTH_1, y, 0, 0);
        } else {
            params.setMargins(0, y, CameraActivity.SETTING_LIST_WIDTH_1, 0);
        }
        mSubMenuLayout.setLayoutParams(params);
        mSubMenuLayout.addView(popup);
        mSubMenuLayout.setOrientation(mOrientation, true);
    }
    if (animate) {
        if (level == 1)
            mMenu.animateSlideIn(mMenuLayout, CameraActivity.SETTING_LIST_WIDTH_1, true);
        if (level == 2)
            mMenu.animateFadeIn(popup);
    } else {
        popup.setAlpha(1f);
    }
}
Also used : ListSubMenu(com.android.camera.ui.ListSubMenu) LayoutParams(android.widget.FrameLayout.LayoutParams) RotateLayout(com.android.camera.ui.RotateLayout) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) Point(android.graphics.Point)

Aggregations

ListSubMenu (com.android.camera.ui.ListSubMenu)4 SharedPreferences (android.content.SharedPreferences)2 Point (android.graphics.Point)2 LayoutInflater (android.view.LayoutInflater)2 ViewGroup (android.view.ViewGroup)2 FrameLayout (android.widget.FrameLayout)2 LayoutParams (android.widget.FrameLayout.LayoutParams)2 RotateLayout (com.android.camera.ui.RotateLayout)2