@capgo/camera-preview 3.2.4 → 3.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p>
2
2
  <h3 align="center">Capacitor Camera Preview</h3>
3
- <p align="center"><strong><code>@capacitor-community/camera-preview</code></strong></p>
3
+ <p align="center"><strong><code>@capgo/camera-preview</code></strong></p>
4
4
  <br>
5
5
  <p align="center"><strong>CAPACITOR 3</strong></p><br>
6
6
 
@@ -33,11 +33,11 @@ Version 2+ of this plugin is compatible with Ionic 5+ and Capacitor 3. If your p
33
33
  # Installation
34
34
 
35
35
  ```
36
- yarn add @capacitor-community/camera-preview
36
+ yarn add @capgo/camera-preview
37
37
 
38
38
  or
39
39
 
40
- npm install @capacitor-community/camera-preview
40
+ npm install @capgo/camera-preview
41
41
  ```
42
42
  Then run
43
43
  ```
@@ -57,7 +57,7 @@ For more help consult the [Capacitor docs](https://capacitorjs.com/docs/android/
57
57
  You will need to add two permissions to `Info.plist`. Follow the [Capacitor docs](https://capacitorjs.com/docs/ios/configuration#configuring-infoplist) and add permissions with the raw keys `NSCameraUsageDescription` and `NSMicrophoneUsageDescription`. `NSMicrophoneUsageDescription` is only required, if audio will be used. Otherwise set the `disableAudio` option to `true`, which also disables the microphone permission request.
58
58
 
59
59
  ## Extra Web installation steps
60
- Add `import '@capacitor-community/camera-preview'` to you entry script in ionic on `app.module.ts`, so capacitor can register the web platform from the plugin
60
+ Add `import '@capgo/camera-preview'` to you entry script in ionic on `app.module.ts`, so capacitor can register the web platform from the plugin
61
61
 
62
62
 
63
63
  # Methods
@@ -101,7 +101,7 @@ All options stated are optional and will default to values here
101
101
  * `disableExifHeaderStripping` - Defaults to false - **Android Only** - Disable automatic rotation of the image, and let the browser deal with it (keep reading on how to achieve it) -->
102
102
 
103
103
  ```javascript
104
- import { CameraPreview, CameraPreviewOptions } from '@capacitor-community/camera-preview';
104
+ import { CameraPreview, CameraPreviewOptions } from '@capgo/camera-preview';
105
105
 
106
106
  const cameraPreviewOptions: CameraPreviewOptions = {
107
107
  position: 'rear',
@@ -193,7 +193,7 @@ CameraPreview.hide();
193
193
  <!-- <info>Take the picture. If width and height are not specified or are 0 it will use the defaults. If width and height are specified, it will choose a supported photo size that is closest to width and height specified and has closest aspect ratio to the preview. The argument `quality` defaults to `85` and specifies the quality/compression value: `0=max compression`, `100=max quality`.</info><br/> -->
194
194
 
195
195
  ```javascript
196
- import { CameraPreviewPictureOptions } from '@capacitor-community/camera-preview';
196
+ import { CameraPreviewPictureOptions } from '@capgo/camera-preview';
197
197
 
198
198
  const cameraPreviewPictureOptions: CameraPreviewPictureOptions = {
199
199
  quality: 50
@@ -215,7 +215,7 @@ const base64PictureData = result.value;
215
215
  <info>Captures a sample image from the video stream. Only for Android and iOS, web implementation falls back to `capture` method. This can be used to perform real-time analysis on the current frame in the video. The argument `quality` defaults to `85` and specifies the quality/compression value: `0=max compression`, `100=max quality`.</info><br/>
216
216
 
217
217
  ```javascript
218
- import { CameraSampleOptions } from '@capacitor-community/camera-preview';
218
+ import { CameraSampleOptions } from '@capgo/camera-preview';
219
219
 
220
220
  const cameraSampleOptions: CameraSampleOptions = {
221
221
  quality: 50
@@ -233,7 +233,7 @@ const base64PictureData = result.value;
233
233
  <info>Get the flash modes supported by the camera device currently started. Returns an array containing supported flash modes. See <code>[FLASH_MODE](#camera_Settings.FlashMode)</code> for possible values that can be returned</info><br/>
234
234
 
235
235
  ```javascript
236
- import { CameraPreviewFlashMode } from '@capacitor-community/camera-preview';
236
+ import { CameraPreviewFlashMode } from '@capgo/camera-preview';
237
237
 
238
238
  const flashModes = await CameraPreview.getSupportedFlashModes();
239
239
  const supportedFlashModes: CameraPreviewFlashMode[] = flashModes.result;
@@ -4,6 +4,7 @@ import android.app.Activity;
4
4
  import android.app.Fragment;
5
5
  import android.content.Context;
6
6
  import android.content.pm.PackageManager;
7
+ import android.content.res.Configuration;
7
8
  import android.graphics.Bitmap;
8
9
  import android.graphics.Bitmap.CompressFormat;
9
10
  import android.graphics.BitmapFactory;
@@ -390,6 +391,40 @@ public class CameraActivity extends Fragment {
390
391
  }
391
392
  }
392
393
 
394
+ @Override
395
+ public void onConfigurationChanged(Configuration newConfig) {
396
+ super.onConfigurationChanged(newConfig);
397
+
398
+ final FrameLayout frameContainerLayout = (FrameLayout) view.findViewById(
399
+ getResources().getIdentifier("frame_container", "id", appResourcesPackage)
400
+ );
401
+
402
+ final int previousOrientation = frameContainerLayout.getHeight() > frameContainerLayout.getWidth() ? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE;
403
+ // Checks if the orientation of the screen has changed
404
+ if (newConfig.orientation != previousOrientation) {
405
+
406
+ final RelativeLayout frameCamContainerLayout = (RelativeLayout) view.findViewById(
407
+ getResources().getIdentifier("frame_camera_cont", "id", appResourcesPackage)
408
+ );
409
+
410
+ frameContainerLayout.getLayoutParams().width = frameCamContainerLayout.getHeight();
411
+ frameContainerLayout.getLayoutParams().height = frameCamContainerLayout.getWidth();
412
+
413
+ frameCamContainerLayout.getLayoutParams().width = frameCamContainerLayout.getHeight();
414
+ frameCamContainerLayout.getLayoutParams().height = frameCamContainerLayout.getWidth();
415
+
416
+ frameContainerLayout.invalidate();
417
+ frameContainerLayout.requestLayout();
418
+
419
+ frameCamContainerLayout.forceLayout();
420
+
421
+ mPreview.setCameraDisplayOrientation();
422
+
423
+ }
424
+
425
+ }
426
+
427
+
393
428
  public Camera getCamera() {
394
429
  return mCamera;
395
430
  }
@@ -102,7 +102,7 @@ class Preview extends RelativeLayout implements SurfaceHolder.Callback, TextureV
102
102
  }
103
103
  }
104
104
 
105
- private void setCameraDisplayOrientation() {
105
+ public void setCameraDisplayOrientation() {
106
106
  Camera.CameraInfo info = new Camera.CameraInfo();
107
107
  int rotation = ((Activity) getContext()).getWindowManager().getDefaultDisplay().getRotation();
108
108
  int degrees = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capgo/camera-preview",
3
- "version": "3.2.4",
3
+ "version": "3.2.6",
4
4
  "description": "Camera preview",
5
5
  "main": "dist/esm/index.js",
6
6
  "types": "dist/esm/index.d.ts",