SlideShare a Scribd company logo
1 of 23
Download to read offline
Building Native Camera Access - Part II
Android Port
© Codename One 2017 all rights reserved
✦Use the include source feature
✦You can implement and debug the code right within the
native IDE
✦This applies to both iOS & Android
import com.wonderkiln.camerakit.*;
import com.codename1.impl.android.AndroidNativeUtil;
import com.codename1.impl.android.AndroidImplementation;
import java.io.File;
CameraNativeAccessImpl
import com.wonderkiln.camerakit.*;
import com.codename1.impl.android.AndroidNativeUtil;
import com.codename1.impl.android.AndroidImplementation;
import java.io.File;
CameraNativeAccessImpl
import com.wonderkiln.camerakit.*;
import com.codename1.impl.android.AndroidNativeUtil;
import com.codename1.impl.android.AndroidImplementation;
import java.io.File;
CameraNativeAccessImpl
public class CameraNativeAccessImpl {
private CameraView view;
private CameraKitEventListener listener =
new CameraKitEventListener() {
public void onEvent(CameraKitEvent event) {}
public void onError(CameraKitError error) {
String errorMessage = "";
if(error.getException() != null) {
errorMessage = error.getException().toString();
com.codename1.io.Log.e(error.getException());
com.codename1.io.Log.sendLogAsync();
}
CameraCallbacks.onError(error.getType(),
error.getMessage(), errorMessage);
}
public void onImage(CameraKitImage image) {
CameraCallbacks.onImage(image.getJpeg());
}
public void onVideo(CameraKitVideo video) {
CameraCallbacks.onVideo("file://" +
video.getVideoFile().getAbsolutePath());
}
};
CameraNativeAccessImpl
public class CameraNativeAccessImpl {
private CameraView view;
private CameraKitEventListener listener =
new CameraKitEventListener() {
public void onEvent(CameraKitEvent event) {}
public void onError(CameraKitError error) {
String errorMessage = "";
if(error.getException() != null) {
errorMessage = error.getException().toString();
com.codename1.io.Log.e(error.getException());
com.codename1.io.Log.sendLogAsync();
}
CameraCallbacks.onError(error.getType(),
error.getMessage(), errorMessage);
}
public void onImage(CameraKitImage image) {
CameraCallbacks.onImage(image.getJpeg());
}
public void onVideo(CameraKitVideo video) {
CameraCallbacks.onVideo("file://" +
video.getVideoFile().getAbsolutePath());
}
};
CameraNativeAccessImpl
public class CameraNativeAccessImpl {
private CameraView view;
private CameraKitEventListener listener =
new CameraKitEventListener() {
public void onEvent(CameraKitEvent event) {}
public void onError(CameraKitError error) {
String errorMessage = "";
if(error.getException() != null) {
errorMessage = error.getException().toString();
com.codename1.io.Log.e(error.getException());
com.codename1.io.Log.sendLogAsync();
}
CameraCallbacks.onError(error.getType(),
error.getMessage(), errorMessage);
}
public void onImage(CameraKitImage image) {
CameraCallbacks.onImage(image.getJpeg());
}
public void onVideo(CameraKitVideo video) {
CameraCallbacks.onVideo("file://" +
video.getVideoFile().getAbsolutePath());
}
};
CameraNativeAccessImpl
public void start() {
AndroidImplementation.runOnUiThreadAndBlock(new Runnable() {
public void run() {
if(view == null) {
view = new CameraView(AndroidNativeUtil.getContext());
view.addCameraKitListener(listener);
}
view.start();
}
});
}
public void stop() {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.stop();
}
});
}
public boolean isStarted() {
if(view == null) {
return false;
}
return view.isStarted();
}
CameraNativeAccessImpl
public void start() {
AndroidImplementation.runOnUiThreadAndBlock(new Runnable() {
public void run() {
if(view == null) {
view = new CameraView(AndroidNativeUtil.getContext());
view.addCameraKitListener(listener);
}
view.start();
}
});
}
public void stop() {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.stop();
}
});
}
public boolean isStarted() {
if(view == null) {
return false;
}
return view.isStarted();
}
CameraNativeAccessImpl
public void start() {
AndroidImplementation.runOnUiThreadAndBlock(new Runnable() {
public void run() {
if(view == null) {
view = new CameraView(AndroidNativeUtil.getContext());
view.addCameraKitListener(listener);
}
view.start();
}
});
}
public void stop() {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.stop();
}
});
}
public boolean isStarted() {
if(view == null) {
return false;
}
return view.isStarted();
}
CameraNativeAccessImpl
public void run() {
view.stop();
}
});
}
public boolean isStarted() {
if(view == null) {
return false;
}
return view.isStarted();
}
public void setMethod(final int param) {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.setMethod(param);
}
});
}
public android.view.View getView() {
return view;
}
public boolean isSupported() {
return true;
}
CameraNativeAccessImpl
public void run() {
view.stop();
}
});
}
public boolean isStarted() {
if(view == null) {
return false;
}
return view.isStarted();
}
public void setMethod(final int param) {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.setMethod(param);
}
});
}
public android.view.View getView() {
return view;
}
public boolean isSupported() {
return true;
}
CameraNativeAccessImpl
public void setPermissions(final int param) {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.setPermissions(param);
}
});
}
public void setZoom(final float param) {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.setZoom(param);
}
});
}
public void setFocus(final int param) {
// ... same runOnUiThread code
}
public void setFlash(final int param) {
// ... same runOnUiThread code
}
public void setFacing(final int param) {
// ... same runOnUiThread code
}
CameraNativeAccessImpl
public void setPermissions(final int param) {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.setPermissions(param);
}
});
}
public void setZoom(final float param) {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.setZoom(param);
}
});
}
public void setFocus(final int param) {
// ... same runOnUiThread code
}
public void setFlash(final int param) {
// ... same runOnUiThread code
}
public void setFacing(final int param) {
// ... same runOnUiThread code
}
CameraNativeAccessImpl
public int getFacing() {
return view.getFacing();
}
public boolean isFacingFront() {
return view.isFacingFront();
}
public boolean isFacingBack() {
return view.isFacingBack();
}
public float getVerticalViewingAngle() {
return view.getCameraProperties().verticalViewingAngle;
}
public float getHorizontalViewingAngle() {
return view.getCameraProperties().horizontalViewingAngle;
}
public int getFlash() {
return view.getFlash();
}
public int getPreviewWidth() {
return view.getPreviewSize().getWidth();
}
public int getPreviewHeight() {
return view.getPreviewSize().getHeight();
CameraNativeAccessImpl
public int getFacing() {
return view.getFacing();
}
public boolean isFacingFront() {
return view.isFacingFront();
}
public boolean isFacingBack() {
return view.isFacingBack();
}
public float getVerticalViewingAngle() {
return view.getCameraProperties().verticalViewingAngle;
}
public float getHorizontalViewingAngle() {
return view.getCameraProperties().horizontalViewingAngle;
}
public int getFlash() {
return view.getFlash();
}
public int getPreviewWidth() {
return view.getPreviewSize().getWidth();
}
public int getPreviewHeight() {
return view.getPreviewSize().getHeight();
CameraNativeAccessImpl
public void captureVideoFile(final String param) {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
String f = param;
if (param.startsWith("file://")) {
f = param.substring(7);
}
view.captureVideo(new File(f));
}
});
}
public void captureImage() {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.captureImage();
}
});
}
public void captureVideo() {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.captureVideo();
}
});
}
public void stopVideo() {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
CameraNativeAccessImpl
public void captureVideoFile(final String param) {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
String f = param;
if (param.startsWith("file://")) {
f = param.substring(7);
}
view.captureVideo(new File(f));
}
});
}
public void captureImage() {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.captureImage();
}
});
}
public void captureVideo() {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.captureVideo();
}
});
}
public void stopVideo() {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
CameraNativeAccessImpl
public void captureVideoFile(final String param) {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
String f = param;
if (param.startsWith("file://")) {
f = param.substring(7);
}
view.captureVideo(new File(f));
}
});
}
public void captureImage() {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.captureImage();
}
});
}
public void captureVideo() {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
view.captureVideo();
}
});
}
public void stopVideo() {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
CameraNativeAccessImpl
Build Hints
© Codename One 2017 all rights reserved
android.gradleDep=compile 'com.wonderkiln:camerakit:0.13.1';
ProGuard
© Codename One 2017 all rights reserved
android.proguardKeep=-dontwarn com.google.android.gms.**
Build Tools 27
© Codename One 2017 all rights reserved
android.buildToolsVersion=27

More Related Content

Similar to Building a Native Camera Access Library - Part II.pdf

Automated%20testing%20with%20Espresso2.x
Automated%20testing%20with%20Espresso2.xAutomated%20testing%20with%20Espresso2.x
Automated%20testing%20with%20Espresso2.xTatsuya Maki
 
Code to DI For - Dependency Injection for Modern Applications
Code to DI For - Dependency Injection for Modern ApplicationsCode to DI For - Dependency Injection for Modern Applications
Code to DI For - Dependency Injection for Modern ApplicationsCaleb Jenkins
 
Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design PatternsGodfrey Nolan
 
Building a Native Camera Access Library - Part V - Transcript.pdf
Building a Native Camera Access Library - Part V - Transcript.pdfBuilding a Native Camera Access Library - Part V - Transcript.pdf
Building a Native Camera Access Library - Part V - Transcript.pdfShaiAlmog1
 
Creating a Facebook Clone - Part XLIII - Transcript.pdf
Creating a Facebook Clone - Part XLIII - Transcript.pdfCreating a Facebook Clone - Part XLIII - Transcript.pdf
Creating a Facebook Clone - Part XLIII - Transcript.pdfShaiAlmog1
 
MobileConf 2015: Desmistificando o Phonegap (Cordova)
MobileConf 2015: Desmistificando o Phonegap (Cordova)MobileConf 2015: Desmistificando o Phonegap (Cordova)
MobileConf 2015: Desmistificando o Phonegap (Cordova)Loiane Groner
 
Skinning Android for Embedded Applications
Skinning Android for Embedded ApplicationsSkinning Android for Embedded Applications
Skinning Android for Embedded ApplicationsVIA Embedded
 
Building a Native Camera Access Library - Part III.pdf
Building a Native Camera Access Library - Part III.pdfBuilding a Native Camera Access Library - Part III.pdf
Building a Native Camera Access Library - Part III.pdfShaiAlmog1
 
Android Lab Test : Using the camera preview (english)
Android Lab Test : Using the camera preview (english)Android Lab Test : Using the camera preview (english)
Android Lab Test : Using the camera preview (english)Bruno Delb
 
Desmistificando o Phonegap (Cordova)
Desmistificando o Phonegap (Cordova)Desmistificando o Phonegap (Cordova)
Desmistificando o Phonegap (Cordova)Loiane Groner
 
I wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdfI wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdffeelinggifts
 
Dagger 2 vs koin
Dagger 2 vs koinDagger 2 vs koin
Dagger 2 vs koinJintin Lin
 
Adapting to Tablets and Desktops - Part 1.pdf
Adapting to Tablets and Desktops - Part 1.pdfAdapting to Tablets and Desktops - Part 1.pdf
Adapting to Tablets and Desktops - Part 1.pdfShaiAlmog1
 
Sharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SFSharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SFPierre-Yves Ricau
 
Android Location-based應用開發分享
Android Location-based應用開發分享Android Location-based應用開發分享
Android Location-based應用開發分享koji lin
 

Similar to Building a Native Camera Access Library - Part II.pdf (20)

Automated%20testing%20with%20Espresso2.x
Automated%20testing%20with%20Espresso2.xAutomated%20testing%20with%20Espresso2.x
Automated%20testing%20with%20Espresso2.x
 
Code to DI For - Dependency Injection for Modern Applications
Code to DI For - Dependency Injection for Modern ApplicationsCode to DI For - Dependency Injection for Modern Applications
Code to DI For - Dependency Injection for Modern Applications
 
NongBeer MVP Demo application
NongBeer MVP Demo applicationNongBeer MVP Demo application
NongBeer MVP Demo application
 
Android Design Patterns
Android Design PatternsAndroid Design Patterns
Android Design Patterns
 
Building a Native Camera Access Library - Part V - Transcript.pdf
Building a Native Camera Access Library - Part V - Transcript.pdfBuilding a Native Camera Access Library - Part V - Transcript.pdf
Building a Native Camera Access Library - Part V - Transcript.pdf
 
Creating a Facebook Clone - Part XLIII - Transcript.pdf
Creating a Facebook Clone - Part XLIII - Transcript.pdfCreating a Facebook Clone - Part XLIII - Transcript.pdf
Creating a Facebook Clone - Part XLIII - Transcript.pdf
 
MobileConf 2015: Desmistificando o Phonegap (Cordova)
MobileConf 2015: Desmistificando o Phonegap (Cordova)MobileConf 2015: Desmistificando o Phonegap (Cordova)
MobileConf 2015: Desmistificando o Phonegap (Cordova)
 
Skinning Android for Embedded Applications
Skinning Android for Embedded ApplicationsSkinning Android for Embedded Applications
Skinning Android for Embedded Applications
 
Rcp by example
Rcp by exampleRcp by example
Rcp by example
 
Building a Native Camera Access Library - Part III.pdf
Building a Native Camera Access Library - Part III.pdfBuilding a Native Camera Access Library - Part III.pdf
Building a Native Camera Access Library - Part III.pdf
 
Android Lab Test : Using the camera preview (english)
Android Lab Test : Using the camera preview (english)Android Lab Test : Using the camera preview (english)
Android Lab Test : Using the camera preview (english)
 
Desmistificando o Phonegap (Cordova)
Desmistificando o Phonegap (Cordova)Desmistificando o Phonegap (Cordova)
Desmistificando o Phonegap (Cordova)
 
I wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdfI wanted to change the cloudsrectangles into an actuall image it do.pdf
I wanted to change the cloudsrectangles into an actuall image it do.pdf
 
Dagger 2 vs koin
Dagger 2 vs koinDagger 2 vs koin
Dagger 2 vs koin
 
Adapting to Tablets and Desktops - Part 1.pdf
Adapting to Tablets and Desktops - Part 1.pdfAdapting to Tablets and Desktops - Part 1.pdf
Adapting to Tablets and Desktops - Part 1.pdf
 
Sharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SFSharper Better Faster Dagger ‡ - Droidcon SF
Sharper Better Faster Dagger ‡ - Droidcon SF
 
Android Location-based應用開發分享
Android Location-based應用開發分享Android Location-based應用開發分享
Android Location-based應用開發分享
 
Dagger for dummies
Dagger for dummiesDagger for dummies
Dagger for dummies
 
Popup view on Mortar
Popup view on MortarPopup view on Mortar
Popup view on Mortar
 
iOS Training Session-3
iOS Training Session-3iOS Training Session-3
iOS Training Session-3
 

More from ShaiAlmog1

The Duck Teaches Learn to debug from the masters. Local to production- kill ...
The Duck Teaches  Learn to debug from the masters. Local to production- kill ...The Duck Teaches  Learn to debug from the masters. Local to production- kill ...
The Duck Teaches Learn to debug from the masters. Local to production- kill ...ShaiAlmog1
 
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfShaiAlmog1
 
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfcreate-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfShaiAlmog1
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfShaiAlmog1
 
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfcreate-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfShaiAlmog1
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfShaiAlmog1
 
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfcreate-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfShaiAlmog1
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfShaiAlmog1
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfShaiAlmog1
 
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfcreate-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfShaiAlmog1
 
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfcreate-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfShaiAlmog1
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfShaiAlmog1
 
create-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfcreate-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfCreating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfCreating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfCreating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfShaiAlmog1
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfCreating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfShaiAlmog1
 

More from ShaiAlmog1 (20)

The Duck Teaches Learn to debug from the masters. Local to production- kill ...
The Duck Teaches  Learn to debug from the masters. Local to production- kill ...The Duck Teaches  Learn to debug from the masters. Local to production- kill ...
The Duck Teaches Learn to debug from the masters. Local to production- kill ...
 
create-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdfcreate-netflix-clone-06-client-ui.pdf
create-netflix-clone-06-client-ui.pdf
 
create-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdfcreate-netflix-clone-01-introduction_transcript.pdf
create-netflix-clone-01-introduction_transcript.pdf
 
create-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdfcreate-netflix-clone-02-server_transcript.pdf
create-netflix-clone-02-server_transcript.pdf
 
create-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdfcreate-netflix-clone-04-server-continued_transcript.pdf
create-netflix-clone-04-server-continued_transcript.pdf
 
create-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdfcreate-netflix-clone-01-introduction.pdf
create-netflix-clone-01-introduction.pdf
 
create-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdfcreate-netflix-clone-06-client-ui_transcript.pdf
create-netflix-clone-06-client-ui_transcript.pdf
 
create-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdfcreate-netflix-clone-03-server.pdf
create-netflix-clone-03-server.pdf
 
create-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdfcreate-netflix-clone-04-server-continued.pdf
create-netflix-clone-04-server-continued.pdf
 
create-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdfcreate-netflix-clone-05-client-model_transcript.pdf
create-netflix-clone-05-client-model_transcript.pdf
 
create-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdfcreate-netflix-clone-03-server_transcript.pdf
create-netflix-clone-03-server_transcript.pdf
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
 
create-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdfcreate-netflix-clone-05-client-model.pdf
create-netflix-clone-05-client-model.pdf
 
Creating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdfCreating a Whatsapp Clone - Part II.pdf
Creating a Whatsapp Clone - Part II.pdf
 
Creating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdfCreating a Whatsapp Clone - Part IX - Transcript.pdf
Creating a Whatsapp Clone - Part IX - Transcript.pdf
 
Creating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdfCreating a Whatsapp Clone - Part II - Transcript.pdf
Creating a Whatsapp Clone - Part II - Transcript.pdf
 
Creating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdfCreating a Whatsapp Clone - Part V - Transcript.pdf
Creating a Whatsapp Clone - Part V - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdfCreating a Whatsapp Clone - Part IV - Transcript.pdf
Creating a Whatsapp Clone - Part IV - Transcript.pdf
 
Creating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdfCreating a Whatsapp Clone - Part IV.pdf
Creating a Whatsapp Clone - Part IV.pdf
 
Creating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdfCreating a Whatsapp Clone - Part I - Transcript.pdf
Creating a Whatsapp Clone - Part I - Transcript.pdf
 

Recently uploaded

Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Skynet Technologies
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...marcuskenyatta275
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch TuesdayIvanti
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptxFIDO Alliance
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimaginedpanagenda
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftshyamraj55
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard37
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...ScyllaDB
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewDianaGray10
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentationyogeshlabana357357
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTopCSSGallery
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxFIDO Alliance
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityVictorSzoltysek
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxFIDO Alliance
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireExakis Nelite
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهMohamed Sweelam
 

Recently uploaded (20)

Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider  Progress from Awareness to Implementation.pptxTales from a Passkey Provider  Progress from Awareness to Implementation.pptx
Tales from a Passkey Provider Progress from Awareness to Implementation.pptx
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
UiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overviewUiPath manufacturing technology benefits and AI overview
UiPath manufacturing technology benefits and AI overview
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
AI mind or machine power point presentation
AI mind or machine power point presentationAI mind or machine power point presentation
AI mind or machine power point presentation
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
ChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps ProductivityChatGPT and Beyond - Elevating DevOps Productivity
ChatGPT and Beyond - Elevating DevOps Productivity
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 

Building a Native Camera Access Library - Part II.pdf

  • 1. Building Native Camera Access - Part II
  • 2. Android Port © Codename One 2017 all rights reserved ✦Use the include source feature ✦You can implement and debug the code right within the native IDE ✦This applies to both iOS & Android
  • 3. import com.wonderkiln.camerakit.*; import com.codename1.impl.android.AndroidNativeUtil; import com.codename1.impl.android.AndroidImplementation; import java.io.File; CameraNativeAccessImpl
  • 4. import com.wonderkiln.camerakit.*; import com.codename1.impl.android.AndroidNativeUtil; import com.codename1.impl.android.AndroidImplementation; import java.io.File; CameraNativeAccessImpl
  • 5. import com.wonderkiln.camerakit.*; import com.codename1.impl.android.AndroidNativeUtil; import com.codename1.impl.android.AndroidImplementation; import java.io.File; CameraNativeAccessImpl
  • 6. public class CameraNativeAccessImpl { private CameraView view; private CameraKitEventListener listener = new CameraKitEventListener() { public void onEvent(CameraKitEvent event) {} public void onError(CameraKitError error) { String errorMessage = ""; if(error.getException() != null) { errorMessage = error.getException().toString(); com.codename1.io.Log.e(error.getException()); com.codename1.io.Log.sendLogAsync(); } CameraCallbacks.onError(error.getType(), error.getMessage(), errorMessage); } public void onImage(CameraKitImage image) { CameraCallbacks.onImage(image.getJpeg()); } public void onVideo(CameraKitVideo video) { CameraCallbacks.onVideo("file://" + video.getVideoFile().getAbsolutePath()); } }; CameraNativeAccessImpl
  • 7. public class CameraNativeAccessImpl { private CameraView view; private CameraKitEventListener listener = new CameraKitEventListener() { public void onEvent(CameraKitEvent event) {} public void onError(CameraKitError error) { String errorMessage = ""; if(error.getException() != null) { errorMessage = error.getException().toString(); com.codename1.io.Log.e(error.getException()); com.codename1.io.Log.sendLogAsync(); } CameraCallbacks.onError(error.getType(), error.getMessage(), errorMessage); } public void onImage(CameraKitImage image) { CameraCallbacks.onImage(image.getJpeg()); } public void onVideo(CameraKitVideo video) { CameraCallbacks.onVideo("file://" + video.getVideoFile().getAbsolutePath()); } }; CameraNativeAccessImpl
  • 8. public class CameraNativeAccessImpl { private CameraView view; private CameraKitEventListener listener = new CameraKitEventListener() { public void onEvent(CameraKitEvent event) {} public void onError(CameraKitError error) { String errorMessage = ""; if(error.getException() != null) { errorMessage = error.getException().toString(); com.codename1.io.Log.e(error.getException()); com.codename1.io.Log.sendLogAsync(); } CameraCallbacks.onError(error.getType(), error.getMessage(), errorMessage); } public void onImage(CameraKitImage image) { CameraCallbacks.onImage(image.getJpeg()); } public void onVideo(CameraKitVideo video) { CameraCallbacks.onVideo("file://" + video.getVideoFile().getAbsolutePath()); } }; CameraNativeAccessImpl
  • 9. public void start() { AndroidImplementation.runOnUiThreadAndBlock(new Runnable() { public void run() { if(view == null) { view = new CameraView(AndroidNativeUtil.getContext()); view.addCameraKitListener(listener); } view.start(); } }); } public void stop() { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.stop(); } }); } public boolean isStarted() { if(view == null) { return false; } return view.isStarted(); } CameraNativeAccessImpl
  • 10. public void start() { AndroidImplementation.runOnUiThreadAndBlock(new Runnable() { public void run() { if(view == null) { view = new CameraView(AndroidNativeUtil.getContext()); view.addCameraKitListener(listener); } view.start(); } }); } public void stop() { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.stop(); } }); } public boolean isStarted() { if(view == null) { return false; } return view.isStarted(); } CameraNativeAccessImpl
  • 11. public void start() { AndroidImplementation.runOnUiThreadAndBlock(new Runnable() { public void run() { if(view == null) { view = new CameraView(AndroidNativeUtil.getContext()); view.addCameraKitListener(listener); } view.start(); } }); } public void stop() { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.stop(); } }); } public boolean isStarted() { if(view == null) { return false; } return view.isStarted(); } CameraNativeAccessImpl
  • 12. public void run() { view.stop(); } }); } public boolean isStarted() { if(view == null) { return false; } return view.isStarted(); } public void setMethod(final int param) { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.setMethod(param); } }); } public android.view.View getView() { return view; } public boolean isSupported() { return true; } CameraNativeAccessImpl
  • 13. public void run() { view.stop(); } }); } public boolean isStarted() { if(view == null) { return false; } return view.isStarted(); } public void setMethod(final int param) { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.setMethod(param); } }); } public android.view.View getView() { return view; } public boolean isSupported() { return true; } CameraNativeAccessImpl
  • 14. public void setPermissions(final int param) { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.setPermissions(param); } }); } public void setZoom(final float param) { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.setZoom(param); } }); } public void setFocus(final int param) { // ... same runOnUiThread code } public void setFlash(final int param) { // ... same runOnUiThread code } public void setFacing(final int param) { // ... same runOnUiThread code } CameraNativeAccessImpl
  • 15. public void setPermissions(final int param) { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.setPermissions(param); } }); } public void setZoom(final float param) { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.setZoom(param); } }); } public void setFocus(final int param) { // ... same runOnUiThread code } public void setFlash(final int param) { // ... same runOnUiThread code } public void setFacing(final int param) { // ... same runOnUiThread code } CameraNativeAccessImpl
  • 16. public int getFacing() { return view.getFacing(); } public boolean isFacingFront() { return view.isFacingFront(); } public boolean isFacingBack() { return view.isFacingBack(); } public float getVerticalViewingAngle() { return view.getCameraProperties().verticalViewingAngle; } public float getHorizontalViewingAngle() { return view.getCameraProperties().horizontalViewingAngle; } public int getFlash() { return view.getFlash(); } public int getPreviewWidth() { return view.getPreviewSize().getWidth(); } public int getPreviewHeight() { return view.getPreviewSize().getHeight(); CameraNativeAccessImpl
  • 17. public int getFacing() { return view.getFacing(); } public boolean isFacingFront() { return view.isFacingFront(); } public boolean isFacingBack() { return view.isFacingBack(); } public float getVerticalViewingAngle() { return view.getCameraProperties().verticalViewingAngle; } public float getHorizontalViewingAngle() { return view.getCameraProperties().horizontalViewingAngle; } public int getFlash() { return view.getFlash(); } public int getPreviewWidth() { return view.getPreviewSize().getWidth(); } public int getPreviewHeight() { return view.getPreviewSize().getHeight(); CameraNativeAccessImpl
  • 18. public void captureVideoFile(final String param) { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { String f = param; if (param.startsWith("file://")) { f = param.substring(7); } view.captureVideo(new File(f)); } }); } public void captureImage() { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.captureImage(); } }); } public void captureVideo() { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.captureVideo(); } }); } public void stopVideo() { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { CameraNativeAccessImpl
  • 19. public void captureVideoFile(final String param) { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { String f = param; if (param.startsWith("file://")) { f = param.substring(7); } view.captureVideo(new File(f)); } }); } public void captureImage() { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.captureImage(); } }); } public void captureVideo() { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.captureVideo(); } }); } public void stopVideo() { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { CameraNativeAccessImpl
  • 20. public void captureVideoFile(final String param) { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { String f = param; if (param.startsWith("file://")) { f = param.substring(7); } view.captureVideo(new File(f)); } }); } public void captureImage() { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.captureImage(); } }); } public void captureVideo() { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { public void run() { view.captureVideo(); } }); } public void stopVideo() { AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() { CameraNativeAccessImpl
  • 21. Build Hints © Codename One 2017 all rights reserved android.gradleDep=compile 'com.wonderkiln:camerakit:0.13.1';
  • 22. ProGuard © Codename One 2017 all rights reserved android.proguardKeep=-dontwarn com.google.android.gms.**
  • 23. Build Tools 27 © Codename One 2017 all rights reserved android.buildToolsVersion=27