Skip to content

Commit

Permalink
feat(android): camerax, preview config, photo size, whitebalance, zoom (
Browse files Browse the repository at this point in the history
  • Loading branch information
triniwiz authored Dec 1, 2020
1 parent 55667d2 commit b24997c
Show file tree
Hide file tree
Showing 12 changed files with 1,134 additions and 482 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@
tns plugin add @nstudio/nativescript-camera-plus
```

**Note :- Android**
Please add the following to your app.gradle

```gradle
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
```

## Sample

_Yes the camera is rotated because it's a webcam to an emulator and it's just the way life works_
Expand Down
10 changes: 9 additions & 1 deletion demo/app/App_Resources/Android/app.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@
android {
defaultConfig {
generatedDensities = []
applicationId = "org.nativescript.demo"
}
aaptOptions {
additionalParameters "--no-version-vectors"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

project.ext {
kotlinVersion = "1.4.20"
}
35 changes: 23 additions & 12 deletions demo/app/main-page.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
import * as observable from '@nativescript/core/data/observable';
import * as pages from '@nativescript/core/ui/page';
import { HelloWorldModel } from './main-view-model';
import {CameraPlus} from '@nstudio/nativescript-camera-plus';
import {HelloWorldModel} from './main-view-model';

// Event handler for Page 'loaded' event attached in main-page.xml
export function pageLoaded(args: observable.EventData) {
// Get the event sender
const page = <pages.Page>args.object;
page.bindingContext = new HelloWorldModel(page);
// Get the event sender
const page = <pages.Page>args.object;
page.bindingContext = new HelloWorldModel(page);
}

export function camLoaded(args: any) {
console.log(`cam loaded event`);

try {
const flashMode = args.object.getFlashMode();
console.log(`flashMode in loaded event = ${flashMode}`);
} catch (e) {
console.log(e);
}
const cam = args.object as CameraPlus;
console.log(`cam loaded event`);
const handle = () => {
console.log('sizes', cam.getAvailablePictureSizes('16:9'));
cam.autoFocus = true;
try {
const flashMode = args.object.getFlashMode();
console.log(`flashMode in loaded event = ${flashMode}`);
} catch (e) {
console.log(e);
}
};
if (!cam.hasCameraPermission()) {
cam.requestCameraPermissions()
.then(() => handle());
} else {
handle();
}
}
Loading

0 comments on commit b24997c

Please sign in to comment.