Try to fix build

pull/953/head
Mattia Iavarone 5 years ago
parent 518e763142
commit d4e5ad2c06
  1. 4
      .github/workflows/build.yml
  2. 2
      cameraview/build.gradle.kts
  3. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java
  4. 11
      cameraview/src/main/java/com/otaliastudios/cameraview/internal/OrientationHelper.java

@ -18,7 +18,7 @@ jobs:
with: with:
java-version: 1.8 java-version: 1.8
- name: Perform base checks - name: Perform base checks
run: ./gradlew demo:assembleDebug cameraview:publishToDirectory run: ./gradlew demo:assembleDebug cameraview:publishToDirectory --stacktrace
ANDROID_UNIT_TESTS: ANDROID_UNIT_TESTS:
name: Unit Tests name: Unit Tests
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -28,7 +28,7 @@ jobs:
with: with:
java-version: 1.8 java-version: 1.8
- name: Execute unit tests - name: Execute unit tests
run: ./gradlew cameraview:runUnitTests run: ./gradlew cameraview:runUnitTests --stacktrace
- name: Upload unit tests artifact - name: Upload unit tests artifact
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v1
with: with:

@ -93,7 +93,7 @@ tasks.register("runAndroidTests") { // changing name? change github workflow
} }
// Merge the two with a jacoco task. // Merge the two with a jacoco task.
jacoco { toolVersion = "0.8.1" } jacoco { toolVersion = "0.8.5" }
tasks.register("computeCoverage", JacocoReport::class) { tasks.register("computeCoverage", JacocoReport::class) {
dependsOn("compileDebugSources") // Compile sources, needed below dependsOn("compileDebugSources") // Compile sources, needed below
executionData.from(fileTree(coverageInputDir)) executionData.from(fileTree(coverageInputDir))

@ -394,12 +394,10 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
// attached. That's why we instantiate the preview here. // attached. That's why we instantiate the preview here.
doInstantiatePreview(); doInstantiatePreview();
} }
mOrientationHelper.enable();
} }
@Override @Override
protected void onDetachedFromWindow() { protected void onDetachedFromWindow() {
if (!mInEditor) mOrientationHelper.disable();
mLastPreviewStreamSize = null; mLastPreviewStreamSize = null;
super.onDetachedFromWindow(); super.onDetachedFromWindow();
} }
@ -732,6 +730,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
* Sets permissions flag if you want enable auto check permissions or disable it. * Sets permissions flag if you want enable auto check permissions or disable it.
* @param requestPermissions - true: auto check permissions enabled, false: auto check permissions disabled. * @param requestPermissions - true: auto check permissions enabled, false: auto check permissions disabled.
*/ */
@SuppressWarnings("unused")
public void setRequestPermissions(boolean requestPermissions) { public void setRequestPermissions(boolean requestPermissions) {
mRequestPermissions = requestPermissions; mRequestPermissions = requestPermissions;
} }
@ -1810,6 +1809,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
* @param fileDescriptor a file descriptor where the video will be saved * @param fileDescriptor a file descriptor where the video will be saved
* @param durationMillis recording max duration * @param durationMillis recording max duration
*/ */
@SuppressWarnings("unused")
public void takeVideo(@NonNull FileDescriptor fileDescriptor, int durationMillis) { public void takeVideo(@NonNull FileDescriptor fileDescriptor, int durationMillis) {
takeVideo(null, fileDescriptor, durationMillis); takeVideo(null, fileDescriptor, durationMillis);
} }

@ -7,6 +7,8 @@ import androidx.annotation.VisibleForTesting;
import android.hardware.display.DisplayManager; import android.hardware.display.DisplayManager;
import android.os.Build; import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.view.Display; import android.view.Display;
import android.view.OrientationEventListener; import android.view.OrientationEventListener;
import android.view.Surface; import android.view.Surface;
@ -27,6 +29,7 @@ public class OrientationHelper {
void onDisplayOffsetChanged(int displayOffset, boolean willRecreate); void onDisplayOffsetChanged(int displayOffset, boolean willRecreate);
} }
private final Handler mHandler = new Handler(Looper.getMainLooper());
private final Context mContext; private final Context mContext;
private final Callback mCallback; private final Callback mCallback;
@ -99,16 +102,14 @@ public class OrientationHelper {
* Enables this listener. * Enables this listener.
*/ */
public void enable() { public void enable() {
if (mEnabled) { if (mEnabled) return;
//already enabled, will ignore call
return;
}
mEnabled = true; mEnabled = true;
mDisplayOffset = findDisplayOffset(); mDisplayOffset = findDisplayOffset();
if (Build.VERSION.SDK_INT >= 17) { if (Build.VERSION.SDK_INT >= 17) {
DisplayManager manager = (DisplayManager) DisplayManager manager = (DisplayManager)
mContext.getSystemService(Context.DISPLAY_SERVICE); mContext.getSystemService(Context.DISPLAY_SERVICE);
manager.registerDisplayListener(mDisplayOffsetListener, null); // Without the handler, this can crash if called from a thread without a looper
manager.registerDisplayListener(mDisplayOffsetListener, mHandler);
} }
mDeviceOrientationListener.enable(); mDeviceOrientationListener.enable();
} }

Loading…
Cancel
Save