Commit e2b54af8 authored by Javokhir Savriev's avatar Javokhir Savriev
Browse files

New 2.1.4 version

parent 8f400af7
# Changelog
All notable changes to this project will be documented in this file.
## [2.1.4] - 21 Feb, 2023
### New features
- Added new `withResidency(value: MyIdResidentType)` method for residency.
- Added new translations to texts in MyID SDK.
## [2.1.3] - 30 Jan, 2023
### New features
- Added an option to handle result on `onActivityResult` method. For more information, please visit our [README](README.md#with-onactivityresult-method).
- Added Content-Language for every request.
### Changed features
- UI: Increased image compression quality parameter.
- UI: Improved Auth screen ui components
## [2.1.2] - 25 Nov, 2022
### New features
- 📝 Added new identification recommendations.
- 🌟 Updated ID Card detection frame.
- 🔥 Added new `withCameraShape(value: MyIdCameraShape)` method to change camera shape.
- 🌟 Added new `withSdkHash(value: String)` method for identification.
### Changed features
- Update `targetSdkVersion` from `31` to `33`
- Update `androidx.core:core-ktx` from `1.8.0` to `1.9.0`
- Update `androidx.appcompat:appcompat` from `1.4.2` to `1.5.1`
- Update `cameraVersion` from `1.2.0-alpha01` to `1.3.0-alpha01`
- Update `mlkit-face-detection` from `17.0.1` to `17.1.0`
- Update `mlkit-text-recognition` from `18.0.0` to `18.0.2`
- Update `mlkit-barcode-scanning` from `18.0.0` to `18.1.0`
## [2.1.1] - 31 Oct, 2022
### Changed features
- Update `withLocale(value: MyIdLocale)` from `MyIdLocale` to `Locale`
## [2.1.0] - 16 Sep, 2022
### New features
- 🔥 Added new `withOrganizationDetails(value: OrganizationDetails)` method. You can customize the
SDK, for it to match your organization's brand
book. [Usage](README.md#custom-organization-details)
- 🌟 Added `comparison` value to the `MyIdResult` object on successful identification.
### Fixes
- 🔨 First April bug fixed.
## [2.0.9] - 30 Aug, 2022
### New features
- 🌟 Added new `withThreshold(value: Float)` method for identification.
- 🔥 Added Ban user feature.
- 🔥 Added Liveness fail and Bad or blurry recommendations.
### Fixes
- 🔨 `Image's size must be lower than 1600 kb`. This bug fixed.
# MyID Android SDK
## Table of contents
- [Important](#important)
- [Getting started](#getting-started)
- [Before you begin](#11-before-you-begin)
- [Setup MyID Android SDK](#12-setup-myid-android-sdk)
- [Permissions](#13-permissions)
- [Usage](#usage)
- [Methods](#11-methods)
- [Handling callbacks](#12-handling-callbacks)
- [SDK error codes](#sdk-error-codes)
- [Localization](#localization)
- [Custom Organization Details](#custom-organization-details)
## Important
**Note:** When you update the version of MyID SDK in your application, check the version of the
libraries in [dependencies](#12-setup-myid-android-sdk) and update them too!
## Getting started
### 1.1 Before you begin
Install or update Android Studio to its latest version.
The SDK supports API level 21 and above
Make sure that your app meets the following requirements:
- `minSdkVersion = 21`
- `targetSdkVersion = 33`
- `android.useAndroidX = true`
``` gradle
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
```
- myid-sdk-***.aar, has been provided to you, it contains SDK public interface and implementation.
Archive name contains ever increasing release version number.
### 1.2 Setup MyID Android SDK
Create new project in AndroidStudio. Inside mobile application folder create new folder to store SDK
libraries (For example libs) and copy MyID SDK provided libraries.
Add reference to library to module **_build.gradle_**:
``` gradle
implementation(files("libs/myid-sdk-2.1.4-release.aar"))
```
**Note:** You can get `myid-sdk-2.1.4-release.aar` file
from [here](android-sample/app/libs/myid-sdk-2.1.4-release.aar)
After synchronization, You should be able to access to SDK classes from your source code.
MyID Android SDK also requires following libraries to be added:
``` gradle
dependencies {
implementation(files("libs/myid-sdk-2.1.4-release.aar"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4")
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.5.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.5.1")
def cameraVersion = "1.3.0-alpha01"
implementation("androidx.camera:camera-camera2:$cameraVersion")
implementation("androidx.camera:camera-lifecycle:$cameraVersion")
implementation("androidx.camera:camera-view:$cameraVersion")
implementation("io.ktor:ktor-client-android:2.1.2")
implementation("io.sentry:sentry-android:6.7.0-alpha.1")
// Use these dependencies if your app supports Google Play Services
implementation("com.google.android.gms:play-services-mlkit-face-detection:17.1.0")
implementation("com.google.android.gms:play-services-mlkit-text-recognition:18.0.2")
implementation("com.google.android.gms:play-services-mlkit-barcode-scanning:18.1.0")
// Use these dependencies if your app doesn't support Google Play Services
implementation("com.google.mlkit:face-detection:16.1.5")
implementation("com.google.mlkit:text-recognition:16.0.0-beta6")
implementation("com.google.mlkit:barcode-scanning:17.0.2")
}
```
### 1.3 Permissions
Add following lines to the **_AndroidManifest.xml_**:
``` xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
```
## Usage
### With Activity Result API
``` kotlin
class ExampleActivity : AppCompatActivity(), MyIdResultListener {
private val myIdClient = MyIdClient()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
startMyId()
}
private fun startMyId() {
val organizationDetails = OrganizationDetails(
phoneNumber = "1234567",
logo = R.drawable.image_logo
)
val myIdConfig = MyIdConfig.builder(clientId = /* Your client id */)
.withPassportData(passportData)
.withBirthDate(dateOfBirth)
.withSdkHash(sdkHash)
.withExternalId(externalId)
.withThreshold(threshold)
.withBuildMode(MyIdBuildMode.PRODUCTION)
.withEntryType(MyIdEntryType.AUTH)
.withResidency(MyIdResidentType.RESIDENT)
.withLocale(Locale("en"))
.withCameraShape(MyIdCameraShape.CIRCLE)
.withOrganizationDetails(organizationDetails)
.withPhoto(false)
.build()
val intent = client.createIntent(activity = this, myIdConfig = myIdConfig)
result.launch(intent)
}
private val result = takeUserResult(listener = this)
}
```
### With `onActivityResult` method
``` kotlin
class ExampleActivity : AppCompatActivity(), MyIdResultListener {
private val myIdClient = MyIdClient()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
startMyId()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
myIdClient.handleActivityResult(resultCode, this)
}
private fun startMyId() {
val organizationDetails = OrganizationDetails(
phoneNumber = "1234567",
logo = R.drawable.image_logo
)
val myIdConfig = MyIdConfig.builder(clientId = /* Your client id */)
.withPassportData(passportData)
.withBirthDate(dateOfBirth)
.withSdkHash(sdkHash)
.withExternalId(externalId)
.withThreshold(threshold)
.withBuildMode(MyIdBuildMode.PRODUCTION)
.withEntryType(MyIdEntryType.AUTH)
.withResidency(MyIdResidentType.RESIDENT)
.withLocale(Locale("en"))
.withCameraShape(MyIdCameraShape.CIRCLE)
.withOrganizationDetails(organizationDetails)
.withPhoto(false)
.build()
/*
Start the flow. 1 should be your request code (customize as needed).
Must be an Activity or Fragment (support library).
This request code will be important for you on onActivityResult() to identify the MyIdResultListener.
*/
myIdClient.startActivityForResult(this, 1, myIdConfig)
}
}
```
### 1.1 Methods
Method | Notes | Default
--- | --- | ---
`withPassportData(value: String)` | Passport serial number or PINFL data | Optional
`withBirthDate(value: String)` | Date of birth in. Format: `dd.MM.yyyy` | Optional
`withSdkHash(value: String)` | 32 characters long string | Optional
`withExternalId(value: String)` | 36 characters long. Should match with UUID4 regex | Optional
`withThreshold(value: Float)` | The value can be in the range of `0.50` - `0.99` | 0.50
`withBuildMode(value: MyIdBuildMode)` | Build mode | MyIdBuildMode.PRODUCTION
`withEntryType(value: MyIdEntryType)` | Customizing the SDK Entry types | MyIdEntryType.AUTH
`withResidency(value: MyIdResidentType)` | To set a specific resident type | MyIdResidentType.RESIDENT
`withLocale(value: Locale)` | To set a specific locale | Locale("uz")
`withCameraShape(value: MyIdCameraShape)` | To set a specific camera shape | MyIdCameraShape.CIRCLE
`withOrganizationDetails(value: OrganizationDetails)` | Custom Organization Details | Optional
`withPhoto(value: Boolean)` | Return SDK face bitmap | false
**Note 1.1.** You can customize the screen for entering passport data and date of birth in your
application, in which case you can pass these parameters during initialization to the SDK, otherwise
the SDK requires the input of passport data and date of birth for user identification.
**Note 1.2.** If the `sdk_hash` is empty, blank or string with length other than 32 has been
provided, we will continue showing the credentials screen.
**Note 1.3.** If the `externalId` is not empty, has a length of 36 characters and corresponds to the
regular expression UUID4, we will display a [recommendation](images/screen01.jpg) screen in case the
sdk detects a blurry photo.
**Note 1.4.** `MyIdBuildMode` contains **DEBUG** and **PRODUCTION** modes.
- **DEBUG** is used to sandbox.
- **PRODUCTION** is used to production.
**Note 1.5.** `MyIdEntryType` contains **AUTH** and **FACE** types.
- **AUTH** is used to identify the user through the MyID services.
- **FACE** is used to detect a face and returns a picture (bitmap).
**Note 1.6.** `MyIdCameraShape` contains **[CIRCLE](images/screen03.jpg)**
and **[ELLIPSE](images/screen04.jpg)** types.
### 1.2 Handling callbacks
```kotlin
val myIdResultListener: MyIdResultListener = object : MyIdResultListener {
override fun onSuccess(result: MyIdResult) {
// Get face bitmap and result code
val bitmap = result.bitmap
val code = result.code
val comparison = result.comparison
}
override fun onUserExited() {
// User left the SDK
}
override fun onError(e: MyIdException) {
// Get error message and code:
val message = e.message
val code = e.code
}
}
```
| Attribute | Notes |
| -----|-------|
| `onSuccess` | `MyIdResult` contains information about the face captures made during the flow, result code and comparison value. |
| `onUserExited` | User left the SDK flow without completing it. |
| `onError` | Some error happened. `MyIdException` contains information about the error message and code |
## SDK error codes
The error code in the following list may appear during the call of SDK. The list below is for your
reference.
| Code | Error message
|:----:|:-------------
| 2 | Паспортные данные введены неправильно
| 3 | Не удалось подтвердить жизненность
| 4 | Не удалось распознать
| 5 | Внешний сервис недоступен или работает некорректно
| 6 | Запрашиваемый пользовател скончался
| 7 | Фото с ресурсов не получено
| 8 | Внутренняя ошибка MyID
| 9 | Срок выполнения задачи истек
| 10 | Срок ожидания задачи в очереди истек
| 11 | Сервис MyID не может обработать запрос. Попробуйте повторить позже
| 12 | Сервис MyID не может обработать запрос. Попробуйте повторить позже
| 13 | Сервис MyID не может обработать запрос. Попробуйте повторить позже
| 14 | Не удалось подтвердить жизненность. Некорректная фотография
| 15 | Сервис MyID не может обработать запрос. Попробуйте повторить позже
| 16 | Сервис MyID не может обработать запрос. Попробуйте повторить позже
| 17 | Не удалось распознать. Некорректная фотография
| 18 | Сервис проверки жизненности не может обработать запрос
| 19 | Сервис распознования не может обработать запрос
| 20 | Размытая фотография
| 21 | Лицо не полностью изображено
| 22 | Обнаружено несколько лиц
| 23 | Представленное изображение в градациях серого, требуется цветное изображение
| 24 | Обнаружены затемненные очки
| 25 | Тип фотографии не поддерживается
| 26 | Глаза закрыты либо не видны
| 27 | Обнаружено вращение головы
| 28 | Не удалось обнаружить все ориентиры
| 101 | Непредвиденная ошибка
| 102 | Доступ к камере запрещен
| 103 | Ошибка при получении данных с сервера
| 120 | Размытое фото обнаружено в SDK
## Localization
The MyID Android SDK supports translations for the following languages:
- Uzbek (uz) 🇺🇿
- English (en) 🇬🇧
- Russian (ru) 🇷🇺
By default, the Uzbek language is used. However, you can also call the `withLocale(Locale)`
method of the `MyIdConfig.Builder` configuration to set the language.
## Custom Organization Details
You can customize the SDK, for it to match your organization's brand book, by
providing `OrganizationDetails` object to `withOrganizationDetails` method. The object allows you to
customize following fields:
- *phoneNumber* - by default 712022202, which is MyID's call center. If you would like the customer
to call your own call center, you can display your own phone number on the error screen, by
providing it in this field ([sample](images/screen01.jpg)).
- *logo* - the drawable asset, that will be displayed on the input screen. If you would like to
display your own logo on the top of the screen, this is the place to provide it. Make sure it fits
the imageView element, which has the *240x60* size.
plugins {
id "com.android.application"
id "org.jetbrains.kotlin.android"
}
android {
compileSdk 33
defaultConfig {
applicationId "uz.myid.sdk.sample"
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0.0"
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation(files("libs/myid-sdk-2.1.4-release.aar"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4")
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.5.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.5.1")
def cameraVersion = "1.3.0-alpha01"
implementation("androidx.camera:camera-camera2:$cameraVersion")
implementation("androidx.camera:camera-lifecycle:$cameraVersion")
implementation("androidx.camera:camera-view:$cameraVersion")
implementation("io.ktor:ktor-client-android:2.1.2")
implementation("io.sentry:sentry-android:6.7.0-alpha.1")
implementation("com.google.android.gms:play-services-mlkit-face-detection:17.1.0")
implementation("com.google.android.gms:play-services-mlkit-text-recognition:18.0.2")
implementation("com.google.android.gms:play-services-mlkit-barcode-scanning:18.1.0")
implementation("com.google.android.material:material:1.8.0")
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uz.myid.sdk.sample">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyIdSample">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
package uz.myid.sdk.sample;
import static uz.myid.android.sdk.capture.MyIdResultKt.takeUserResult;
import android.content.Intent;
import android.os.Bundle;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import java.util.Locale;
import uz.myid.android.sdk.capture.MyIdBuildMode;
import uz.myid.android.sdk.capture.MyIdCameraShape;
import uz.myid.android.sdk.capture.MyIdClient;
import uz.myid.android.sdk.capture.MyIdConfig;
import uz.myid.android.sdk.capture.MyIdEntryType;
import uz.myid.android.sdk.capture.MyIdException;
import uz.myid.android.sdk.capture.MyIdResidentType;
import uz.myid.android.sdk.capture.MyIdResult;
import uz.myid.android.sdk.capture.MyIdResultListener;
public class ExampleJavaActivity extends AppCompatActivity implements MyIdResultListener {
private final MyIdClient myIdClient = new MyIdClient();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startMyId();
}
@Override
public void onSuccess(@NonNull MyIdResult result) {
// Get face bitmap, result code, comparison value
}
@Override
public void onError(@NonNull MyIdException e) {
// Get error message and code
}
@Override
public void onUserExited() {
// User exited sdk
}
private void startMyId() {
String clientId = "client_id";
String passportData = "passport_data";
String dateOfBirth = "date_of_birth";
String sdkHash = "sdk_hash";
String externalId = "external_id";
float threshold = 0.5f;
MyIdConfig myIdConfig = new MyIdConfig.Builder(clientId)
.withPassportData(passportData)
.withBirthDate(dateOfBirth)
.withSdkHash(sdkHash)
.withExternalId(externalId)
.withThreshold(threshold)
.withBuildMode(MyIdBuildMode.PRODUCTION)
.withEntryType(MyIdEntryType.AUTH)
.withResidency(MyIdResidentType.RESIDENT)
.withLocale(new Locale("en"))
.withCameraShape(MyIdCameraShape.CIRCLE)
.withPhoto(false)
.build();
Intent intent = myIdClient.createIntent(this, myIdConfig);
result.launch(intent);
}
private final ActivityResultLauncher<Intent> result = takeUserResult(this, this);
}
\ No newline at end of file
package uz.myid.sdk.sample;
import static uz.myid.android.sdk.capture.MyIdResultKt.takeUserResult;
import android.content.Intent;
import android.os.Bundle;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import java.util.Locale;
import uz.myid.android.sdk.capture.MyIdBuildMode;
import uz.myid.android.sdk.capture.MyIdCameraShape;
import uz.myid.android.sdk.capture.MyIdClient;
import uz.myid.android.sdk.capture.MyIdConfig;
import uz.myid.android.sdk.capture.MyIdEntryType;
import uz.myid.android.sdk.capture.MyIdException;
import uz.myid.android.sdk.capture.MyIdResidentType;
import uz.myid.android.sdk.capture.MyIdResult;
import uz.myid.android.sdk.capture.MyIdResultListener;
public class ExampleJavaFragment extends Fragment implements MyIdResultListener {
private final MyIdClient myIdClient = new MyIdClient();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startMyId();
}
@Override
public void onSuccess(@NonNull MyIdResult result) {
// Get face bitmap, result code, comparison value
}
@Override
public void onError(@NonNull MyIdException e) {
// Get error message and code
}
@Override
public void onUserExited() {
// User exited sdk
}
private void startMyId() {
String clientId = "client_id";
String passportData = "passport_data";
String dateOfBirth = "date_of_birth";
String sdkHash = "sdk_hash";
String externalId = "external_id";
float threshold = 0.5f;
MyIdConfig myIdConfig = new MyIdConfig.Builder(clientId)
.withPassportData(passportData)
.withBirthDate(dateOfBirth)
.withSdkHash(sdkHash)
.withExternalId(externalId)
.withThreshold(threshold)
.withBuildMode(MyIdBuildMode.PRODUCTION)
.withEntryType(MyIdEntryType.AUTH)
.withResidency(MyIdResidentType.RESIDENT)
.withLocale(new Locale("en"))
.withCameraShape(MyIdCameraShape.CIRCLE)
.withPhoto(false)
.build();
Intent intent = myIdClient.createIntent(requireActivity(), myIdConfig);
result.launch(intent);
}
private final ActivityResultLauncher<Intent> result = takeUserResult(this, this);
}
package uz.myid.sdk.sample
import android.os.Bundle
import androidx.fragment.app.Fragment
import uz.myid.android.sdk.capture.*
import uz.myid.android.sdk.capture.model.OrganizationDetails
import java.util.*
class ExampleKotlinFragment : Fragment(), MyIdResultListener {
private val myIdClient = MyIdClient()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
startMyId()
}
override fun onSuccess(result: MyIdResult) {
// Get face bitmap and result code
}
override fun onError(e: MyIdException) {
// Get error message and code
}
override fun onUserExited() {
// User exited sdk
}
private fun startMyId() {
val clientId = "client_id"
val passportData = "passport_data"
val dateOfBirth = "date_of_birth"
val sdkHash = "sdk_hash"
val externalId = "external_id"
val threshold = 0.50f
val organizationDetails = OrganizationDetails(
phoneNumber = "1234567",
)
val myIdConfig = MyIdConfig.Builder(clientId)
.withPassportData(passportData)
.withBirthDate(dateOfBirth)
.withSdkHash(sdkHash)
.withExternalId(externalId)
.withThreshold(threshold)
.withBuildMode(MyIdBuildMode.PRODUCTION)
.withEntryType(MyIdEntryType.AUTH)
.withResidency(MyIdResidentType.RESIDENT)
.withLocale(Locale("en"))
.withCameraShape(MyIdCameraShape.CIRCLE)
.withOrganizationDetails(organizationDetails)
.withPhoto(false)
.build()
val intent = myIdClient.createIntent(requireActivity(), myIdConfig)
result.launch(intent)
}
private val result = takeUserResult(this)
}
\ No newline at end of file
package uz.myid.sdk.sample
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import uz.myid.android.sdk.capture.*
import uz.myid.android.sdk.capture.model.OrganizationDetails
import java.util.*
class ExampleWithOnActivityResultActivity : AppCompatActivity(), MyIdResultListener {
private val myIdClient = MyIdClient()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
startMyId()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
myIdClient.handleActivityResult(resultCode, this)
}
override fun onSuccess(result: MyIdResult) {
// Get face bitmap and result code
}
override fun onError(e: MyIdException) {
// Get error message and code
}
override fun onUserExited() {
// User exited sdk
}
private fun startMyId() {
val clientId = "client_id"
val passportData = "passport_data"
val dateOfBirth = "date_of_birth"
val sdkHash = "sdk_hash"
val externalId = "external_id"
val threshold = 0.50f
val organizationDetails = OrganizationDetails(
phoneNumber = "1234567",
)
val myIdConfig = MyIdConfig.Builder(clientId)
.withPassportData(passportData)
.withBirthDate(dateOfBirth)
.withSdkHash(sdkHash)
.withExternalId(externalId)
.withThreshold(threshold)
.withBuildMode(MyIdBuildMode.PRODUCTION)
.withEntryType(MyIdEntryType.AUTH)
.withResidency(MyIdResidentType.RESIDENT)
.withLocale(Locale("en"))
.withCameraShape(MyIdCameraShape.CIRCLE)
.withOrganizationDetails(organizationDetails)
.withPhoto(false)
.build()
/*
Start the flow. 1 should be your request code (customize as needed).
Must be an Activity or Fragment (support library).
This request code will be important for you on onActivityResult() to identify the MyIdResultListener.
*/
myIdClient.startActivityForResult(this, 1, myIdConfig)
}
}
\ No newline at end of file
package uz.myid.sdk.sample
import android.os.Bundle
import android.widget.EditText
import androidx.appcompat.app.AppCompatActivity
import uz.myid.android.sdk.capture.*
import uz.myid.android.sdk.capture.model.OrganizationDetails
import uz.myid.sdk.sample.databinding.ActivityMainBinding
import java.util.*
class MainActivity : AppCompatActivity(), MyIdResultListener {
private val binding by lazy { ActivityMainBinding.inflate(layoutInflater) }
private val myIdClient = MyIdClient()
private var clientId = ""
private var buildMode = MyIdBuildMode.PRODUCTION
private var entryType = MyIdEntryType.AUTH
private var residency = MyIdResidentType.RESIDENT
private var locale = Locale("en")
private var shape = MyIdCameraShape.CIRCLE
private var code = ""
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
with(binding) {
inputClientId.setText(clientId)
radioGroupLang.setOnCheckedChangeListener { _, checkedId ->
locale = when (checkedId) {
R.id.radioUz -> Locale("uz")
R.id.radioEn -> Locale("en")
else -> Locale("ru")
}
}
radioGroupEntryType.setOnCheckedChangeListener { _, checkedId ->
entryType = if (checkedId == R.id.radioFace) {
MyIdEntryType.FACE
} else {
MyIdEntryType.AUTH
}
}
radioGroupResidentType.setOnCheckedChangeListener { _, checkedId ->
residency = when (checkedId) {
R.id.radioManual -> MyIdResidentType.USER_DEFINED
R.id.radioNonResident -> MyIdResidentType.NON_RESIDENT
else -> MyIdResidentType.RESIDENT
}
}
radioGroupBuildMode.setOnCheckedChangeListener { _, checkedId ->
buildMode = if (checkedId == R.id.radioProd) {
MyIdBuildMode.PRODUCTION
} else {
MyIdBuildMode.DEBUG
}
inputClientId.setText(clientId)
}
radioGroupShape.setOnCheckedChangeListener { _, checkedId ->
shape = if (checkedId == R.id.radioCircle) {
MyIdCameraShape.CIRCLE
} else {
MyIdCameraShape.ELLIPSE
}
}
buttonStart.setOnClickListener { startMyId() }
}
}
override fun onSuccess(result: MyIdResult) {
code = result.code.orEmpty()
with(binding) {
imageResult.setImageBitmap(result.bitmap)
"""
Result code: ${result.code}
Comparison value: ${result.comparison}
""".trimIndent().also { textResult.text = it }
}
}
override fun onError(e: MyIdException) {
code = ""
with(binding) {
imageResult.setImageBitmap(null)
"""
Result error: ${e.message}
Result error code: ${e.code}
""".trimIndent().also { textResult.text = it }
}
}
override fun onUserExited() {
code = ""
with(binding) {
imageResult.setImageBitmap(null)
"User exited sdk".also { textResult.text = it }
}
}
private fun startMyId() {
val organizationDetails = OrganizationDetails(
phoneNumber = binding.inputPhoneNumber.value
)
val myIdConfig = MyIdConfig.builder(binding.inputClientId.value)
.withPassportData(binding.inputPassportData.value)
.withBirthDate(binding.inputDate.value)
.withSdkHash(binding.inputSdkHash.value)
.withExternalId(binding.inputExternalId.value)
.withThreshold(binding.thresholdSlider.value)
.withBuildMode(buildMode)
.withEntryType(entryType)
.withResidency(residency)
.withLocale(locale)
.withCameraShape(shape)
.withOrganizationDetails(organizationDetails)
.withPhoto(binding.checkboxWithPhoto.isChecked)
.build()
val intent = myIdClient.createIntent(this, myIdConfig)
result.launch(intent)
}
private val result = takeUserResult(this)
private inline val EditText.value: String get() = text.toString().trim()
}
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp">
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/client_id"
app:helperText="* Required"
app:helperTextEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputClientId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:inputType="textMultiLine"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:hint="@string/passport"
app:helperText="* Optional"
app:helperTextEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputPassportData"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:hint="@string/birth_date"
app:helperText="* Optional"
app:helperTextEnabled="true"
app:placeholderText="дд.мм.гггг">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:hint="@string/sdk_hash"
app:helperText="* Optional"
app:helperTextEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputSdkHash"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:inputType="textMultiLine"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:hint="@string/external_id"
app:helperText="* Optional"
app:helperTextEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputExternalId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:inputType="textMultiLine"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.Material3.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:hint="@string/organization_phone_number"
app:helperText="* Optional"
app:helperTextEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputPhoneNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="no"
android:inputType="phone"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/threshold"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
<com.google.android.material.slider.Slider
android:id="@+id/thresholdSlider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stepSize="0.01"
android:valueFrom="0.50"
android:valueTo="0.99"
app:labelBehavior="floating" />
<RadioGroup
android:id="@+id/radioGroupBuildMode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:checkedButton="@id/radioProd"
android:orientation="horizontal">
<RadioButton
android:id="@+id/radioProd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/prod"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
<RadioButton
android:id="@+id/radioDev"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="@string/dev"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
</RadioGroup>
<RadioGroup
android:id="@+id/radioGroupEntryType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:checkedButton="@id/radioAuth"
android:orientation="horizontal">
<RadioButton
android:id="@+id/radioAuth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/auth"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
<RadioButton
android:id="@+id/radioFace"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:text="@string/face"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
</RadioGroup>
<RadioGroup
android:id="@+id/radioGroupResidentType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:checkedButton="@id/radioResident"
android:orientation="horizontal">
<RadioButton
android:id="@+id/radioManual"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/manual"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
<RadioButton
android:id="@+id/radioResident"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:text="@string/resident"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
<RadioButton
android:id="@+id/radioNonResident"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:text="@string/non_resident"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
</RadioGroup>
<RadioGroup
android:id="@+id/radioGroupLang"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:checkedButton="@id/radioEn"
android:orientation="horizontal">
<RadioButton
android:id="@+id/radioUz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/uzbek"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
<RadioButton
android:id="@+id/radioEn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:text="@string/english"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
<RadioButton
android:id="@+id/radioRu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:text="@string/russian"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
</RadioGroup>
<RadioGroup
android:id="@+id/radioGroupShape"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:checkedButton="@id/radioCircle"
android:orientation="horizontal">
<RadioButton
android:id="@+id/radioCircle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/circle"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
<RadioButton
android:id="@+id/radioEllipse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:text="@string/ellipse"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
</RadioGroup>
<CheckBox
android:id="@+id/checkboxWithPhoto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:checked="false"
android:text="@string/with_photo"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
<com.google.android.material.button.MaterialButton
android:id="@+id/buttonStart"
style="@style/Widget.Material3.Button.UnelevatedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="20dp"
android:text="@string/scan_face_data"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
<TextView
android:id="@+id/textResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:text="@string/result_image"
android:textAppearance="@style/TextAppearance.Material3.BodyLarge" />
<ImageView
android:id="@+id/imageResult"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_marginTop="16dp"
android:contentDescription="@string/image" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
\ No newline at end of file
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