Commit 65149409 authored by Samuel RIVALS's avatar Samuel RIVALS
Browse files

Add readme, install and developer documentation

parent 859428f5
# GUI SDK Developer Guide
Welcome to the ONprint developer guide.<br/><br/>
This document lists all the main ONprint GUI SDK functions to explain you how
to build an Android application using ONprint picture recognition.
## Fundamentals
All the basic function calls (like SDK init) are detailed in [light SDK developer guide][1].
## GUI functions
Here are the functions which are specifics to the SDK GUI:
### > Start ONprint Activity
To launch the camera view activity (the main screen) call the MainScreen class:
``` java
startActivityForResult(new Intent(Class.this, MainScreen.class), 0);
```
If you use "startActivity" your application will be stucked inside ONprint application.
### > CameraPreview class
The camera preview class allows you to customize your customized camera view class.
You need CameraPreview layout:
``` java
<com.onprint.sdk.core.camera.CameraPreview
android:id="@+id/camera_preview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
```
and a cameraPreview object :
``` java
CameraPreview cameraPreview = findViewById(R.id.camera_preview);
```
### > Trigger a Recogition Action
You can trigger a picuter with takePicture() function. This function is also called when the button with ID R.id.buttonTakePicture is triggered:
``` java
cameraPreview.takePicture();
```
### > Active the camera flash light
To activate the camera flash light use this function with flash_actived set to true:
``` java
camera.set_flash(boolean flash_actived);
```
### > Release the camera
To release the camera use this function:
``` java
cameraPreview.releaseCamera();
```
## Image treatment
Parse image obtains from callback:
``` java
private void searchEnrichedImage(byte[] data) {
new EnrichedImage(new ONprintBMP(view, data), "image/jpeg", new DeviceInformation().getSystemLanguage(),
null, new IEnrichedImage() {
@Override
public void enriched(JSONObject object) {
//Log.i(TAG, "JSON: " + object);
ONprintEnrichedImage imageJson = new ONprintEnrichedImage(object);
if (imageJson == null) {
imageDetected = false;
onScanCompleted(null);
Log.e(TAG, "JSON is null");
return;
}
imageDetected = true;
onScanCompleted(imageJson);
}
@Override
public void notEnriched() {
onScanCompleted(null);
}
@Override
public void failed(String error) {
Log.e(TAG, error);
onScanCompleted(null);
}
});
}
```
ONprintEnrichedImage has getters for each of the following attributes:
``` java
public class ONprintEnrichedImage extends RealmObject {
@PrimaryKey
protected long id;
private String ONprintImageId;
private String pathONprintImageFile;
private String bigThumbnailUrl;
private String languageCode;
protected String title;
private String documentId;
protected String sessionId;
protected String theme;
private String dateOfScan;
private String hourOfScan;
private boolean isFavorite;
private boolean isSent;
private int order;
private boolean autoTrigger;
private Style titleStyle;
protected RealmList<Action> actions;
protected String source;
```
## ONprint Image Database
Insert/Update:
``` java
Image.insertOrUpdateInDatabase(image);
```
Delete:
``` java
Image.delete(image);
```
Get an image from an ONprintImage ID:
``` java
Image.getImageById(imageID)
```
Get all ONprintImage images:
``` java
Image.getAll()
```
### > Image search
This function allows to treat Enriched Image callback:
``` java
public EnrichedImage(File file, String contentType, String languageCode,
HashMap<String, String> headers, IEnrichedImage callback);
```
Example:
``` java
new EnrichedImage(imageFile, "image/jpeg", FR-fr, null, new IEnrichedImage() {
@Override
public void enriched(JSONObject object) {
// Pour parser image
Image image = Parse.jsonImage(object);
}
@Override
public void notEnriched() {
// not Enriched
}
@Override
public void failed(String error) {
// error
}
});
```
### > Click
Here is the function allowing to manage click:
``` java
public Click(String sessionId, String actionId, IClick callback)
```
Example:
``` java
new Click(sessionId, actionId, new IClick() {
@Override
public void succes() {
Log.i(LOG_TAG, "SendClick [ OK ]");
}
@Override
public void failed(String error) {
Log.e(LOG_TAG, "SendClick [ ERROR ] \n" + error);
}
});
```
### > Layouts Customization
Set no boot splash screen :
``` java
SDKLayouts.no_splash_screen();
```
Set no tuorial launched at first start:
``` java
SDKLayouts.no_first_start_tuto();
```
Inside SplashScreen.java, we can see Camera customization:
``` java
SDKLayouts.set_camera_layout(R.layout.custom_camera_view);
```
Here we're defining our layout for own layout camera design.
Note that layout's ID names have to be respected.
Custom the camera layout:
``` java
- public static void set_camera_layout (int cl)
- public static int get_camera_layout()
```
Custom the "Picture not recognized" layout:
``` java
- public static void set_no_result_dialog(Class cl, int no_result_layout, Activity a)
- public static Class get_no_result_dialog()
```
Custom actions list layout:
``` java
- public static void set_action_layout (int cl)
- public static int get_action_layout()
```
Cutom WebView layout:
``` java
- public static void set_web_layout (int cl)
- public static int get_web_layout()
```
Custom favorite view layout:
``` java
- public static void set_favorite_layout (int cl)
- public static int get_favorite_layout()
```
Custom tutorial 4 pages layout:
``` java
- public static void set_tutorial_layouts (int tut_1, int tut_2, int tut_3, int tut_4)
- public static int get_tuto_1()
- public static int get_tuto_2()
- public static int get_tuto_3()
- public static int get_tuto_4()
```
Activate animation on tutos:
``` java
- public static void active_anim()
- public static boolean is_with_anim()
```
[1]: https://gitlab.com/onprint_public/Android_ONprint_Light_SDK_Sample/tree/master/DEV.md
# GUI SDK Installation Guide
Here are the steps to use the GUI SDK.
## Build Installation
### Add Light and GUI SDK packages
First download [Android light SDK][1] and [Android GUI SDK][1] from the developer resources page,
then put them inside your root project and unzip them.
Inside "settings.gradle" add:
``` java
'your_project', ':ONprint_Light', ':ONprint_GUI'
```
### Gradle intitialization
Then add inside your main build.gradle:
``` java
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath "io.realm:realm-gradle-plugin:5.7.0"
}
}
```
Then add inside your application/build.gradle:
``` java
apply plugin: 'realm-android'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependencies {
...
implementation 'com.android.support:design:28.0.0'
implementation 'com.github.bumptech.glide:glide:4.1.1'
implementation 'com.github.clans:fab:1.6.4'
implementation 'com.ritesh:ratiolayout:1.0.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'org.apache.commons:commons-text:1.6'
implementation project(':ONprint_GUI')
implementation project(':ONprint_Light')
}
```
### Manifest permissions and requirements
Add inside the AndroidManifest.xml the following permissions:
``` java
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
```
Note: telephony requirement is important because without it
Google Play prevents tablet installation.
## Java Initialization
### Data Base initialization
``` java
Realm.init(getApplicationContext());
RealmConfiguration config = new RealmConfiguration.Builder()
.name("database.realm")
.schemaVersion(1)
.deleteRealmIfMigrationNeeded()
.build();
Realm.setDefaultConfiguration(config);
```
### SDK intialization
To init ONprint SDK you need a apiKey which is a character chain allowing you to use ONprint API services with your dedicating data.
``` java
ONprint.init(context, apiKey);
```
To obtain your personal API Key, please contact mobile@onprint.com
### Launch camera
Final step is to launch main ONprint activity:
``` java
Intent camera_view = new Intent(SplashScreen.this, MainScreen.class);
startActivity(camera_view);
```
## Dev
Now it's time... to code!
Please follow -> the [developer guide][3]
[1]: https://gitlab.com/onprint_public/Android_ONprint_GUI_SDK_Sample/tree/master/ONprintWS
[2]: https://gitlab.com/onprint_public/Android_ONprint_GUI_SDK_Sample/tree/master/OnprintSDK
[3]: https://gitlab.com/onprint_public/Android_ONprint_GUI_SDK_Sample/tree/master/DEV.md
# Android ONprint SDK Light Sample
Android ONprint GUI SDK Sample
===================================
In no time, create an application to get information of enriched images by taking picture.
An Android sample to show how simple it is to use ONprint light SDK from a Google Camera Sample.
This sample demonstrates how to use basic functionalities of
ONprint SDK GUI API.
## Introduction
You can learn through patches how to enhance your code.
This [Sample API][1] shows you how to use basic functionalities of ONprint GUI SDK.
By using [ONprint API][2] and [ONprint Light SDK][3], it provides you an interface for individual camera
connected to an iOS device in order
to get informations from picture.
GUI will use ONprint interface used especially in [ONprint Generic Application][4].
So if you flash an enriched image, associated image actions will poped up!
An historic is also available.
Furthermore, it allows you to record usage stats.
## Pre-requisites
- Android SDK 21
- Android Build Tools v27.0.3
- Android Support Repository
- Java 1.8
## Screenshots
<img src="screenshots/main.jpg" height="400" alt="Screenshot"/>
## Getting Started with the Sample
This sample uses the Gradle build system. To build this project, run the SplashScreen class in Android Studio.
## SDK Integration
To start, install the SDK for your own project by following the [install doc][5].
<br/><br/>
Then, to integrate ONprint functions, please consult the [developer guide][6].
### Support
If you've found an error in this sample or if you have any question,
please send us an email to: mobile@onprint.com
### License
© 2019 by LTU Tech. All Rights Reserved.
[1]: https://gitlab.com/onprint_public/Android_ONprint_GUI_SDK_Sample
[2]: http://developer.onprint.com/api.html
[3]: https://gitlab.com/onprint_public/Android_ONprint_Light_SDK_Sample
[4]: https://play.google.com/store/apps/details?id=com.onprint.generic
[5]: https://gitlab.com/onprint_public/Android_ONprint_GUI_SDK_Sample/blob/master/INSTALL.md
[6]: https://gitlab.com/onprint_public/Android_ONprint_GUI_SDK_Sample/blob/master/DEV.md
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment