Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a8981cf8 authored by Kerong Sui's avatar Kerong Sui Committed by Steve Kondik
Browse files

Gallery2: camera: disable all camera controls ASAP when swtich the camera

Camera switch button is a pieItem, there is a fadeInOut animation for these
kinds of menus. And the onClick event deliver to upper layer happens after
the end of the animation which lasts 600ms. We should add another event
callback before the animation to disalbe all camera controls as soon as
possible.

Change-Id: Iddcb9e9452aa0ff6ea8485c08c9c56b067995fb5
parent cf82d8cf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ public abstract class CameraPreference {
        public void onRestorePreferencesClicked();
        public void onOverriddenPreferencesClicked();
        public void onCameraPickerClicked(int cameraId);
        public void onCameraPickerSuperClicked();
    }

    public CameraPreference(Context context, AttributeSet attrs) {
+4 −0
Original line number Diff line number Diff line
@@ -2084,6 +2084,10 @@ public class PhotoModule
        }
    }

    @Override
    public void onCameraPickerSuperClicked() {
    }

    // Preview texture has been copied. Now camera can be released and the
    // animation can be started.
    @Override
+7 −0
Original line number Diff line number Diff line
@@ -93,6 +93,13 @@ public class VideoMenu extends PieController
                    [lpref.findIndexOfValue(lpref.getValue())]);

            final PieItem fitem = item;
            item.setOnSuperClickListener(new OnClickListener() {

                @Override
                public void onClick(PieItem item) {
                    mListener.onCameraPickerSuperClicked();
                }
            });
            item.setOnClickListener(new OnClickListener() {

                @Override
+8 −2
Original line number Diff line number Diff line
@@ -2333,13 +2333,19 @@ public class VideoModule implements CameraModule,
            // We need to keep a preview frame for the animation before
            // releasing the camera. This will trigger onPreviewTextureCopied.
            ((CameraScreenNail) mActivity.mCameraScreenNail).copyTexture();
            // Disable all camera controls.
            mSwitchingCamera = true;
        } else {
            switchCamera();
        }
    }

    @Override
    public void onCameraPickerSuperClicked() {
        if (mPaused || mPendingSwitchCameraId != -1) return;

        // Disable all camera controls.
        mSwitchingCamera = true;
    }

    @Override
    public boolean needsSwitcher() {
        return !mIsVideoCaptureIntent;
+11 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ public class PieItem {
    private List<PieItem> mItems;
    private Path mPath;
    private OnClickListener mOnClickListener;
    private OnClickListener mOnSuperClickListener;
    private float mAlpha;
    private CharSequence mLabel;

@@ -138,12 +139,22 @@ public class PieItem {
        mOnClickListener = listener;
    }

    public void setOnSuperClickListener(OnClickListener listener) {
        mOnSuperClickListener = listener;
    }

    public void performClick() {
        if (mOnClickListener != null) {
            mOnClickListener.onClick(this);
        }
    }

    public void performSuperClick() {
        if (mOnSuperClickListener != null) {
            mOnSuperClickListener.onClick(this);
        }
    }

    public int getIntrinsicWidth() {
        return mDrawable.getIntrinsicWidth();
    }
Loading