This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[camera_platform_interface] Add platform interface methods for locking capture orientation. #3389
Merged
mvanbeusekom
merged 17 commits into
flutter:master
from
Baseflow:fix/video-photo-preview-rotation-platform-interface
Jan 7, 2021
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9c4d4ca
Expand platform interface to support reporting device orientation
BeMacized ed56fac
Switch to flutter DeviceOrientation enum
BeMacized eab58fe
Add interface methods for (un)locking the capture orientation.
BeMacized 27bba29
Update capture orientation interfaces and add unit tests.
BeMacized 859076f
Made device orientation mandatory for locking capture orientation in …
BeMacized 118bd00
Update comment
BeMacized 0aba73a
Merge branch 'master' into fix/video-photo-preview-rotation-platform-…
BeMacized 0bb07be
Update comment.
BeMacized a2c3fbf
Update changelog and pubspec version
BeMacized 1d409b9
Update packages/camera/camera_platform_interface/lib/src/events/devic…
BeMacized 96a739a
Merge branch 'master' into fix/video-photo-preview-rotation-platform-…
mvanbeusekom 8c1aa01
Update packages/camera/camera_platform_interface/lib/src/events/devic…
BeMacized 0c6da4b
Update packages/camera/camera_platform_interface/lib/src/events/devic…
BeMacized 16b9b42
Update packages/camera/camera_platform_interface/lib/src/events/devic…
BeMacized 3c79c34
Update packages/camera/camera_platform_interface/lib/src/method_chann…
BeMacized d2838f6
Update packages/camera/camera_platform_interface/lib/src/method_chann…
BeMacized 7f9896c
Update version number
mvanbeusekom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
52 changes: 52 additions & 0 deletions
52
packages/camera/camera_platform_interface/lib/src/events/device_event.dart
This file contains hidden or 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,52 @@ | ||
// Copyright 2019 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'package:camera_platform_interface/src/utils/utils.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
/// Generic Event coming from the native side of Camera, | ||
/// not related to a specific camera module. | ||
/// | ||
/// This class is used as a base class for all the events that might be | ||
/// triggered from a device, but it is never used directly as an event type. | ||
/// | ||
/// Do NOT instantiate new events like `DeviceEvent()` directly, | ||
/// use a specific class instead: | ||
/// | ||
/// Do `class NewEvent extend DeviceEvent` when creating your own events. | ||
/// See below for examples: `DeviceOrientationChangedEvent`... | ||
/// These events are more semantic and more pleasant to use than raw generics. | ||
/// They can be (and in fact, are) filtered by the `instanceof`-operator. | ||
abstract class DeviceEvent {} | ||
|
||
/// The [DeviceOrientationChangedEvent] is fired every time the user changes the | ||
/// physical orientation of the device. | ||
class DeviceOrientationChangedEvent extends DeviceEvent { | ||
/// The new orientation of the device | ||
final DeviceOrientation orientation; | ||
|
||
/// Build a new orientation changed event. | ||
DeviceOrientationChangedEvent(this.orientation); | ||
|
||
/// Converts the supplied [Map] to an instance of the [DeviceOrientationChangedEvent] | ||
/// class. | ||
DeviceOrientationChangedEvent.fromJson(Map<String, dynamic> json) | ||
: orientation = deserializeDeviceOrientation(json['orientation']); | ||
|
||
/// Converts the [DeviceOrientationChangedEvent] instance into a [Map] instance that | ||
/// can be serialized to JSON. | ||
Map<String, dynamic> toJson() => { | ||
'orientation': serializeDeviceOrientation(orientation), | ||
}; | ||
|
||
@override | ||
bool operator ==(Object other) => | ||
identical(this, other) || | ||
other is DeviceOrientationChangedEvent && | ||
runtimeType == other.runtimeType && | ||
orientation == other.orientation; | ||
|
||
@override | ||
int get hashCode => orientation.hashCode; | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.