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

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

@ -394,12 +394,10 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
// attached. That's why we instantiate the preview here.
doInstantiatePreview();
}
mOrientationHelper.enable();
}
@Override
protected void onDetachedFromWindow() {
if (!mInEditor) mOrientationHelper.disable();
mLastPreviewStreamSize = null;
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.
* @param requestPermissions - true: auto check permissions enabled, false: auto check permissions disabled.
*/
@SuppressWarnings("unused")
public void setRequestPermissions(boolean 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 durationMillis recording max duration
*/
@SuppressWarnings("unused")
public void takeVideo(@NonNull FileDescriptor fileDescriptor, int durationMillis) {
takeVideo(null, fileDescriptor, durationMillis);
}

@ -7,6 +7,8 @@ import androidx.annotation.VisibleForTesting;
import android.hardware.display.DisplayManager;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.view.Display;
import android.view.OrientationEventListener;
import android.view.Surface;
@ -27,6 +29,7 @@ public class OrientationHelper {
void onDisplayOffsetChanged(int displayOffset, boolean willRecreate);
}
private final Handler mHandler = new Handler(Looper.getMainLooper());
private final Context mContext;
private final Callback mCallback;
@ -99,16 +102,14 @@ public class OrientationHelper {
* Enables this listener.
*/
public void enable() {
if (mEnabled) {
//already enabled, will ignore call
return;
}
if (mEnabled) return;
mEnabled = true;
mDisplayOffset = findDisplayOffset();
if (Build.VERSION.SDK_INT >= 17) {
DisplayManager manager = (DisplayManager)
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();
}

Loading…
Cancel
Save