Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
475f4ab
Replicated existing code and migrated references to new embedding, ad…
matthew-carroll Sep 24, 2019
8cde03b
Introduced CameraPreviewDisplay and CameraImageStream to remove Flutt…
matthew-carroll Sep 24, 2019
2081f42
Introduced a CameraEventListener to completely decouple Camera from E…
matthew-carroll Sep 24, 2019
b78bfcb
Removed all references of Result from Camera by introducing a combina…
matthew-carroll Sep 24, 2019
b45ae68
Refactored Camera such that getFlutterTexture() no longer needs to ex…
matthew-carroll Sep 24, 2019
6780abf
Moved ResolutionPreset to standalone class and made Camera package pr…
matthew-carroll Sep 24, 2019
8b93f68
Re-organized Camera code order to clearly separate preview images, fr…
matthew-carroll Sep 24, 2019
c85fcc2
Removed Activity reference from Camera.
matthew-carroll Sep 24, 2019
e04653b
Refactored CameraPermissions to eliminate Activity, ActivityCompat, C…
matthew-carroll Sep 24, 2019
60c1d20
Refactored CameraPermissions into an Interface and AndroidCameraPermi…
matthew-carroll Sep 25, 2019
13e4303
Separated the CameraPlugin class from the concept of the comms Camera…
matthew-carroll Sep 25, 2019
d5da9ce
Introduced CameraDetails data structure & wrote unit tests for Camera…
matthew-carroll Sep 25, 2019
436d9ca
Added unit tests for CameraPluginProtocol and reached 100% coverage f…
matthew-carroll Sep 25, 2019
3dcc0ab
Moved CameraPreviewDisplay and CameraImageStream implementations into…
matthew-carroll Sep 26, 2019
02ab397
Extracted per-camera channel construction out into CameraPlugin for t…
matthew-carroll Sep 26, 2019
e5408d9
Refactored so that CameraSystem and AndroidCameraSystem could be redu…
matthew-carroll Sep 26, 2019
6ea1b4f
Deleted CameraUtils, and continued to cleanup relationships.
matthew-carroll Sep 26, 2019
4669cb4
Added tests for CameraSystem - at 93% line coverage.
matthew-carroll Sep 26, 2019
410d0ac
Added tests to ensure that CameraPlugin does nothing without an Activ…
matthew-carroll Sep 26, 2019
0bd6522
Added tests for ChannelCameraEventHandler - now at CameraSystem (93%)…
matthew-carroll Sep 26, 2019
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
Prev Previous commit
Next Next commit
Refactored so that CameraSystem and AndroidCameraSystem could be redu…
…ced to just a CameraSystem that doesn't know about Android stuff.
  • Loading branch information
matthew-carroll committed Sep 26, 2019
commit e5408d91e3a92bd02bb10ee2a8042b40406b44f0
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package dev.flutter.plugins.camera;

import android.content.Context;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraManager;

import androidx.annotation.NonNull;

import io.flutter.embedding.engine.plugins.FlutterPlugin;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.view.TextureRegistry;

/* package */ class AndroidCameraFactory implements CameraFactory {
@NonNull
private final FlutterPlugin.FlutterPluginBinding pluginBinding;
@NonNull
private final ActivityPluginBinding activityBinding;

/* package */ AndroidCameraFactory(
@NonNull FlutterPlugin.FlutterPluginBinding pluginBinding,
@NonNull ActivityPluginBinding activityBinding
) {
this.pluginBinding = pluginBinding;
this.activityBinding = activityBinding;
}

@NonNull
@Override
public Camera createCamera(
@NonNull String cameraName,
@NonNull String resolutionPreset,
boolean enableAudio
) throws CameraAccessException {
TextureRegistry.SurfaceTextureEntry textureEntry = pluginBinding
.getFlutterEngine()
.getRenderer()
.createSurfaceTexture();

return new Camera(
activityBinding.getActivity(),
(CameraManager) activityBinding.getActivity().getSystemService(Context.CAMERA_SERVICE),
textureEntry,
cameraName,
resolutionPreset,
enableAudio
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package dev.flutter.plugins.camera;

import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraManager;

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/* package */ class AndroidCameraHardware implements CameraHardware {
@NonNull
private final CameraManager cameraManager;

/* package */ AndroidCameraHardware(@NonNull CameraManager cameraManager) {
this.cameraManager = cameraManager;
}

@NonNull
@Override
public List<CameraDetails> getAvailableCameras() throws CameraAccessException {
List<Map<String, Object>> allCameraDetailsSerialized = CameraUtils.getAvailableCameras(cameraManager);
List<CameraDetails> allCameraDetails = new ArrayList<>();
for (Map<String, Object> serializedDetails : allCameraDetailsSerialized) {
allCameraDetails.add(new CameraDetails(
(String) serializedDetails.get("name"),
(Integer) serializedDetails.get("sensorOrientation"),
(String) serializedDetails.get("lensFacing")
));
}
return allCameraDetails;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ public void onOrientationChanged(int orientation) {
previewSize = computeBestPreviewSize(cameraName, preset);
}

public long getTextureId() {
return flutterTexture.id();
}

public void setCameraEventHandler(@Nullable CameraEventHandler handler) {
this.cameraEventHandler = handler;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package dev.flutter.plugins.camera;

import android.hardware.camera2.CameraAccessException;

import androidx.annotation.NonNull;

public interface CameraFactory {
@NonNull
Camera createCamera(
@NonNull String cameraName,
@NonNull String resolutionPreset,
boolean enableAudio
) throws CameraAccessException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package dev.flutter.plugins.camera;

import android.hardware.camera2.CameraAccessException;

import androidx.annotation.NonNull;

import java.util.List;

public interface CameraHardware {
@NonNull
List<CameraDetails> getAvailableCameras() throws CameraAccessException;
}
Loading