Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ public void run() {

@Override
boolean shouldFlipSizes() {
return mSensorOffset % 180 != 0;
return (mDeviceOrientation + mSensorOffset) % 180 != 0;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.Display;
import android.view.MotionEvent;
import android.view.ViewGroup;
import android.view.WindowManager;
Expand Down Expand Up @@ -169,8 +170,7 @@ protected CameraController instantiateCameraController(CameraCallbacks callbacks
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (!isInEditMode()) {
WindowManager manager = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
mOrientationHelper.enable(manager.getDefaultDisplay());
mOrientationHelper.enable(getContext());
}
}

Expand Down Expand Up @@ -487,6 +487,8 @@ public void start() {

if (checkPermissions(getSessionType())) {
mIsStarted = true;
// Update display orientation for current CameraController
mOrientationHelper.enable(getContext());
mCameraController.start();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.view.Display;
import android.view.OrientationEventListener;
import android.view.Surface;
import android.view.WindowManager;

class OrientationHelper {

Expand Down Expand Up @@ -67,10 +68,10 @@ public void onOrientationChanged(int orientation) {
};
}

void enable(Display display) {
mDisplay = display;
void enable(Context context) {
mDisplay = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
mListener.enable();
mLastKnownDisplayOffset = DISPLAY_ORIENTATIONS.get(display.getRotation());
mLastKnownDisplayOffset = DISPLAY_ORIENTATIONS.get(mDisplay.getRotation());
mCallbacks.onDisplayOffsetChanged(mLastKnownDisplayOffset);
}

Expand Down