Skip to content

Commit

Permalink
Merge pull request #46 from BlinkID/sample/android-custom-ui
Browse files Browse the repository at this point in the history
Sample/android custom ui
  • Loading branch information
i1E authored Apr 1, 2020
2 parents 56ec700 + 5dd5ba9 commit ba4bca8
Show file tree
Hide file tree
Showing 101 changed files with 12,074 additions and 2 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,22 @@ If you do not wish to use BlinkID NuGet packages, you can directly reference bin
- all projects will be built and their respective NuGet packages will be created in their `bin/Release` folder
5. Upload packages to [NuGet](https://www.nuget.org/)
## Android custom integration
This section describes how to create your scan activity with BlinkID SDK, natively in Android and wrap it to Xamarin. For that purpose, we have prepared [AndroidCustomUI](./Samples/AndroidCustomUI) sample.
Steps to wrap custom functionality to Xamarin:
1. Implement it natively for Android - create Android library:
- make sure that you are not using any resources from the BlinkID Android SDK in resource files inside your library, otherwise, you will get compile errors while generating Xamarin bindings from Android library
- we have created [BlinkIDWrapper](./Samples/AndroidCustomUI/BindingSource/BlinkIDWrapper) Android Studio project which contains [LibBlinkIDWrapper](./Samples/AndroidCustomUI/BindingSource/BlinkIDWrapper/LibBlinkIDWrapper) Android library module with custom scan activity
2. Build .aar archive from the library module:
- we have built `LibBlinkIDWrapper-release.aar` from our Android library module
3. Create a new Xamarin Bindings Library for Android:
- add a dependency to `BlinkID.Android.Binding` nuget package
- add `.aar` to `Jars` folder and set the *Build Action* for `.aar` to *LibraryProjectZip*
- we have prepared [CustomUIBinding](./Samples/AndroidCustomUI/CustomUISample/CustomUIBinding) project inside [CustomUISample](./Samples/AndroidCustomUI/CustomUISample) solution
4. You can use the Bindings Library in the application project:
- first, add a reference to the created Bindings Library
- add a dependency to `BlinkID.Android.Binding`
- we have prepared sample application project [CustomUIApp](./Samples/AndroidCustomUI/CustomUISample/CustomUIApp) inside [CustomUISample](./Samples/AndroidCustomUI/CustomUISample) solution
6 changes: 6 additions & 0 deletions Samples/AndroidCustomUI/BindingSource/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.gradle
local.properties
.DS_Store
build
*.iml
.idea
14 changes: 14 additions & 0 deletions Samples/AndroidCustomUI/BindingSource/BlinkIDWrapper/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"

defaultConfig {
minSdkVersion 16
targetSdkVersion 29
versionCode 1
versionName "1.0"
consumerProguardFiles 'consumer-rules.pro'
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

}

dependencies {
api("com.microblink:blinkid:${rootProject.ext.blinkIdVersion}@aar") {
transitive = true
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.microblink.blinkid.wrapper">

<application>
<activity android:name=".MyScanActivity"/>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.microblink.blinkid.wrapper;

import android.app.Activity;
import android.content.Intent;

import com.microblink.entities.recognizers.RecognizerBundle;

public final class BlinkIDWrapper {

public static void startMyScanActivityForResult(Activity parentActivity, int requestCode, RecognizerBundle recognizerBundle) {
Intent intent = new Intent(parentActivity, MyScanActivity.class);
recognizerBundle.saveToIntent(intent);
parentActivity.startActivityForResult(intent, requestCode);
}

}
Loading

0 comments on commit ba4bca8

Please sign in to comment.