forked from flutter/flutter
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[camerax] Wrap classes to implement resolution configuration for imag…
…e capture, image analysis, and preview (flutter#4523) Wraps classes to implement resolution configuration for image capture, image analysis, and preview. Also bumps CameraX version to latest and removes the deprecated classes used previously. No functionality changes. Also thanks to @bparrishMines who did majority of the work here! Part of flutter#120462
- Loading branch information
Showing
40 changed files
with
2,158 additions
and
369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...erax/android/src/main/java/io/flutter/plugins/camerax/AspectRatioStrategyHostApiImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.plugins.camerax; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.VisibleForTesting; | ||
import androidx.camera.core.resolutionselector.AspectRatioStrategy; | ||
import io.flutter.plugins.camerax.GeneratedCameraXLibrary.AspectRatioStrategyHostApi; | ||
|
||
/** | ||
* Host API implementation for {@link AspectRatioStrategy}. | ||
* | ||
* <p>This class handles instantiating and adding native object instances that are attached to a | ||
* Dart instance or handle method calls on the associated native class or an instance of the class. | ||
*/ | ||
public class AspectRatioStrategyHostApiImpl implements AspectRatioStrategyHostApi { | ||
private final InstanceManager instanceManager; | ||
private final AspectRatioStrategyProxy proxy; | ||
|
||
/** Proxy for constructors and static method of {@link AspectRatioStrategy}. */ | ||
@VisibleForTesting | ||
public static class AspectRatioStrategyProxy { | ||
/** Creates an instance of {@link AspectRatioStrategy}. */ | ||
@NonNull | ||
public AspectRatioStrategy create( | ||
@NonNull Long preferredAspectRatio, @NonNull Long fallbackRule) { | ||
return new AspectRatioStrategy(preferredAspectRatio.intValue(), fallbackRule.intValue()); | ||
} | ||
} | ||
|
||
/** | ||
* Constructs an {@link AspectRatioStrategyHostApiImpl}. | ||
* | ||
* @param instanceManager maintains instances stored to communicate with attached Dart objects | ||
*/ | ||
public AspectRatioStrategyHostApiImpl(@NonNull InstanceManager instanceManager) { | ||
this(instanceManager, new AspectRatioStrategyProxy()); | ||
} | ||
|
||
/** | ||
* Constructs an {@link AspectRatioStrategyHostApiImpl}. | ||
* | ||
* @param instanceManager maintains instances stored to communicate with attached Dart objects | ||
* @param proxy proxy for constructors and static method of {@link AspectRatioStrategy} | ||
*/ | ||
@VisibleForTesting | ||
AspectRatioStrategyHostApiImpl( | ||
@NonNull InstanceManager instanceManager, @NonNull AspectRatioStrategyProxy proxy) { | ||
this.instanceManager = instanceManager; | ||
this.proxy = proxy; | ||
} | ||
|
||
/** | ||
* Creates an {@link AspectRatioStrategy} instance with the preferred aspect ratio and fallback | ||
* rule specified. | ||
*/ | ||
@Override | ||
public void create( | ||
@NonNull Long identifier, @NonNull Long preferredAspectRatio, @NonNull Long fallbackRule) { | ||
instanceManager.addDartCreatedInstance( | ||
proxy.create(preferredAspectRatio, fallbackRule), identifier); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.