Merge branch 'master' into fix-third-party-use-of-camera-error

pull/324/head
Okafor Ezewuzie 7 years ago committed by GitHub
commit f666bb84c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/OrientationHelperTest.java
  2. 5
      cameraview/src/main/res/layout/cameraview_texture_view.xml
  3. 2
      cameraview/src/main/utils/com/otaliastudios/cameraview/OrientationHelper.java

@ -90,5 +90,10 @@ public class OrientationHelperTest extends BaseTest {
helper.mListener.onOrientationChanged(270); helper.mListener.onOrientationChanged(270);
assertEquals(helper.getDeviceOrientation(), 270); assertEquals(helper.getDeviceOrientation(), 270);
verify(callback, times(1)).onDeviceOrientationChanged(270); verify(callback, times(1)).onDeviceOrientationChanged(270);
// It is still 270 after ORIENTATION_UNKNOWN
helper.mListener.onOrientationChanged(OrientationEventListener.ORIENTATION_UNKNOWN);
assertEquals(helper.getDeviceOrientation(), 270);
verify(callback, times(1)).onDeviceOrientationChanged(270);
} }
} }

@ -4,5 +4,6 @@
android:id="@+id/texture_view" android:id="@+id/texture_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:layout_gravity="center"
android:layout_gravity="center" /> android:background="@null"
android:gravity="center" />

@ -28,7 +28,7 @@ class OrientationHelper {
public void onOrientationChanged(int orientation) { public void onOrientationChanged(int orientation) {
int or = 0; int or = 0;
if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) { if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN) {
or = 0; or = mDeviceOrientation != -1 ? mDeviceOrientation : 0;
} else if (orientation >= 315 || orientation < 45) { } else if (orientation >= 315 || orientation < 45) {
or = 0; or = 0;
} else if (orientation >= 45 && orientation < 135) { } else if (orientation >= 45 && orientation < 135) {

Loading…
Cancel
Save