Search in sources :

Example 1 with RotateLayout

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

the class CaptureUI method setOrientation.

public void setOrientation(int orientation, boolean animation) {
    mOrientation = orientation;
    mCameraControls.setOrientation(orientation, animation);
    if (mFilterLayout != null) {
        ViewGroup vg = (ViewGroup) mFilterLayout.getChildAt(0);
        if (vg != null)
            vg = (ViewGroup) vg.getChildAt(0);
        if (vg != null) {
            for (int i = vg.getChildCount() - 1; i >= 0; --i) {
                RotateLayout l = (RotateLayout) vg.getChildAt(i);
                l.setOrientation(orientation, animation);
            }
        }
    }
    if (mRecordingTimeRect != null) {
        mRecordingTimeView.setRotation(-orientation);
    }
    if (mFaceView != null) {
        mFaceView.setDisplayRotation(orientation);
    }
    if (mCountDownView != null)
        mCountDownView.setOrientation(orientation);
    RotateTextToast.setOrientation(orientation);
    if (mZoomRenderer != null) {
        mZoomRenderer.setOrientation(orientation);
    }
    if (mSceneModeLabelRect != null) {
        if (orientation == 180) {
            mSceneModeName.setRotation(180);
            mSceneModeLabelCloseIcon.setRotation(180);
            mSceneModeLabelRect.setOrientation(0, false);
        } else {
            mSceneModeName.setRotation(0);
            mSceneModeLabelCloseIcon.setRotation(0);
            mSceneModeLabelRect.setOrientation(orientation, false);
        }
    }
    if (mSceneModeInstructionalDialog != null && mSceneModeInstructionalDialog.isShowing()) {
        mSceneModeInstructionalDialog.dismiss();
        mSceneModeInstructionalDialog = null;
        showSceneInstructionalDialog(orientation);
    }
}
Also used : ViewGroup(android.view.ViewGroup) RotateLayout(com.android.camera.ui.RotateLayout) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 2 with RotateLayout

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

the class VideoMenu method addFilterMode.

public void addFilterMode() {
    final IconListPreference pref = (IconListPreference) mPreferenceGroup.findPreference(CameraSettings.KEY_VIDEOCAMERA_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++) {
        RotateLayout layout2 = (RotateLayout) 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);
                        changeFilterModeControlIcon(pref.getValue());
                        for (View v1 : views) {
                            v1.setActivated(v1 == v);
                        }
                        onSettingChanged(pref);
                    }
                }
                return true;
            }
        });
        views[j] = layout2;
        layout2.setActivated(i == init);
        TextView label = (TextView) layout2.findViewById(R.id.label);
        imageView.setImageResource(thumbnails[i]);
        label.setText(entries[i]);
        layout.addView(layout2);
    }
    previewMenuLayout.addView(basic);
    mPreviewMenu = basic;
}
Also used : ViewGroup(android.view.ViewGroup) RotateLayout(com.android.camera.ui.RotateLayout) GridView(android.widget.GridView) RotateImageView(com.android.camera.ui.RotateImageView) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) WindowManager(android.view.WindowManager) MotionEvent(android.view.MotionEvent) LayoutParams(android.widget.FrameLayout.LayoutParams) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) Resources(android.content.res.Resources) RotateImageView(com.android.camera.ui.RotateImageView) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout) Display(android.view.Display)

Example 3 with RotateLayout

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

the class VideoUI method setOrientation.

public void setOrientation(int orientation, boolean animation) {
    mCameraControls.setOrientation(orientation, animation);
    if (mMenuLayout != null)
        mMenuLayout.setOrientation(orientation, animation);
    if (mSubMenuLayout != null)
        mSubMenuLayout.setOrientation(orientation, animation);
    if (mRecordingTimeRect != null) {
        if (orientation == 180) {
            mRecordingTimeRect.setOrientation(0, false);
            mRecordingTimeView.setRotation(180);
        } else {
            mRecordingTimeView.setRotation(0);
            mRecordingTimeRect.setOrientation(orientation, false);
        }
    }
    if (mPreviewMenuLayout != null) {
        ViewGroup vg = (ViewGroup) mPreviewMenuLayout.getChildAt(0);
        if (vg != null)
            vg = (ViewGroup) vg.getChildAt(0);
        if (vg != null) {
            for (int i = vg.getChildCount() - 1; i >= 0; --i) {
                RotateLayout l = (RotateLayout) vg.getChildAt(i);
                l.setOrientation(orientation, animation);
            }
        }
    }
    if (mZoomRenderer != null) {
        mZoomRenderer.setOrientation(orientation);
    }
    RotateTextToast.setOrientation(orientation);
    mOrientation = orientation;
}
Also used : ViewGroup(android.view.ViewGroup) RotateLayout(com.android.camera.ui.RotateLayout) Point(android.graphics.Point)

Example 4 with RotateLayout

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

the class PhotoUI method setOrientation.

public void setOrientation(int orientation, boolean animation) {
    mOrientation = orientation;
    mCameraControls.setOrientation(orientation, animation);
    if (mMenuLayout != null)
        mMenuLayout.setOrientation(orientation, animation);
    if (mSubMenuLayout != null)
        mSubMenuLayout.setOrientation(orientation, animation);
    if (mPreviewMenuLayout != null) {
        ViewGroup vg = (ViewGroup) mPreviewMenuLayout.getChildAt(0);
        if (vg != null)
            vg = (ViewGroup) vg.getChildAt(0);
        if (vg != null) {
            for (int i = vg.getChildCount() - 1; i >= 0; --i) {
                RotateLayout l = (RotateLayout) vg.getChildAt(i);
                l.setOrientation(orientation, animation);
            }
        }
    }
    if (mMakeupMenuLayout != null) {
        View view = mMakeupMenuLayout.getChildAt(0);
        if (view instanceof RotateLayout) {
            for (int i = mMakeupMenuLayout.getChildCount() - 1; i >= 0; --i) {
                RotateLayout l = (RotateLayout) mMakeupMenuLayout.getChildAt(i);
                l.setOrientation(orientation, animation);
            }
        } else {
            ViewGroup vg = (ViewGroup) mMakeupMenuLayout.getChildAt(1);
            if (vg != null) {
                for (int i = vg.getChildCount() - 1; i >= 0; --i) {
                    ViewGroup vewiGroup = (ViewGroup) vg.getChildAt(i);
                    if (vewiGroup instanceof RotateLayout) {
                        RotateLayout l = (RotateLayout) vewiGroup;
                        l.setOrientation(orientation, animation);
                    }
                }
            }
        }
    }
    if (mCountDownView != null)
        mCountDownView.setOrientation(orientation);
    RotateTextToast.setOrientation(orientation);
    if (mFaceView != null) {
        mFaceView.setDisplayRotation(orientation);
    }
    if (mZoomRenderer != null) {
        mZoomRenderer.setOrientation(orientation);
    }
    if (mReviewImage != null) {
        RotateImageView v = (RotateImageView) mReviewImage;
        v.setOrientation(orientation, animation);
    }
    mOrientation = orientation;
}
Also used : RotateImageView(com.android.camera.ui.RotateImageView) ViewGroup(android.view.ViewGroup) RotateLayout(com.android.camera.ui.RotateLayout) SurfaceView(android.view.SurfaceView) ImageView(android.widget.ImageView) CameraRootView(com.android.camera.ui.CameraRootView) View(android.view.View) ListView(android.widget.ListView) RotateImageView(com.android.camera.ui.RotateImageView) CountDownView(com.android.camera.ui.CountDownView) SelfieFlashView(com.android.camera.ui.SelfieFlashView) FaceView(com.android.camera.ui.FaceView) Point(android.graphics.Point)

Example 5 with RotateLayout

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

the class PhotoMenu method 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++) {
        RotateLayout layout2 = (RotateLayout) 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);
                        changeFilterModeControlIcon(pref.getValue());
                        onSettingChanged(pref);
                        for (View v1 : views) {
                            v1.setActivated(v1 == v);
                        }
                    }
                }
                return true;
            }
        });
        views[j] = layout2;
        layout2.setActivated(i == init);
        TextView label = (TextView) layout2.findViewById(R.id.label);
        imageView.setImageResource(thumbnails[i]);
        label.setText(entries[i]);
        layout.addView(layout2);
    }
    previewMenuLayout.addView(basic);
    mPreviewMenu = basic;
}
Also used : ViewGroup(android.view.ViewGroup) RotateLayout(com.android.camera.ui.RotateLayout) GridView(android.widget.GridView) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) RotateImageView(com.android.camera.ui.RotateImageView) WindowManager(android.view.WindowManager) MotionEvent(android.view.MotionEvent) LayoutParams(android.widget.FrameLayout.LayoutParams) LayoutInflater(android.view.LayoutInflater) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) Resources(android.content.res.Resources) ImageView(android.widget.ImageView) RotateImageView(com.android.camera.ui.RotateImageView) LinearLayout(android.widget.LinearLayout) Display(android.view.Display)

Aggregations

RotateLayout (com.android.camera.ui.RotateLayout)11 ViewGroup (android.view.ViewGroup)9 Point (android.graphics.Point)6 View (android.view.View)6 FrameLayout (android.widget.FrameLayout)6 ImageView (android.widget.ImageView)6 Resources (android.content.res.Resources)5 Display (android.view.Display)5 LayoutInflater (android.view.LayoutInflater)5 MotionEvent (android.view.MotionEvent)5 WindowManager (android.view.WindowManager)5 LayoutParams (android.widget.FrameLayout.LayoutParams)5 LinearLayout (android.widget.LinearLayout)5 TextView (android.widget.TextView)5 RotateImageView (com.android.camera.ui.RotateImageView)5 ListView (android.widget.ListView)4 GridView (android.widget.GridView)3 HorizontalScrollView (android.widget.HorizontalScrollView)3 Paint (android.graphics.Paint)2 CountDownView (com.android.camera.ui.CountDownView)2