Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MYID Public Code
MyID Sample Android
Commits
e2b54af8
Commit
e2b54af8
authored
Feb 21, 2023
by
Javokhir Savriev
Browse files
New 2.1.4 version
parent
8f400af7
Changes
86
Hide whitespace changes
Inline
Side-by-side
flutter-sample/android/app/libs/myid-sdk-2.1.4-release.aar
0 → 100644
View file @
e2b54af8
File added
flutter-sample/android/app/src/main/AndroidManifest.xml
0 → 100644
View file @
e2b54af8
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.example.example"
>
<application
android:name=
"${applicationName}"
android:icon=
"@mipmap/ic_launcher"
android:label=
"example"
android:theme=
"@style/Theme.MaterialComponents.Light.NoActionBar"
>
<activity
android:name=
".MainActivity"
android:configChanges=
"orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:exported=
"true"
android:hardwareAccelerated=
"true"
android:launchMode=
"singleTop"
android:windowSoftInputMode=
"adjustResize"
>
<meta-data
android:name=
"io.flutter.embedding.android.NormalTheme"
android:resource=
"@style/NormalTheme"
/>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
<meta-data
android:name=
"flutterEmbedding"
android:value=
"2"
/>
</application>
</manifest>
\ No newline at end of file
flutter-sample/android/app/src/main/kotlin/com/example/example/Keys.kt
0 → 100644
View file @
e2b54af8
package
com.example.example
object
Keys
{
const
val
PHONE_NUMBER
=
"KEY_PHONE_NUMBER"
const
val
CLIENT_ID
=
"KEY_CLIENT_ID"
const
val
PASSPORT_DATA
=
"KEY_PASSPORT_DATA"
const
val
DATE_OF_BIRTH
=
"KEY_DATE_OF_BIRTH"
const
val
SDK_HASH
=
"KEY_SDK_HASH"
const
val
EXTERNAL_ID
=
"KEY_EXTERNAL_ID"
const
val
THRESHOLD
=
"KEY_THRESHOLD"
const
val
BUILD_MODE
=
"KEY_BUILD_MODE"
const
val
ENTRY_TYPE
=
"KEY_ENTRY_TYPE"
const
val
RESIDENT_TYPE
=
"KEY_RESIDENT_TYPE"
const
val
LOCALE
=
"KEY_LOCALE"
const
val
CAMERA_SHAPE
=
"KEY_CAMERA_SHAPE"
const
val
WITH_PHOTO
=
"KEY_WITH_PHOTO"
}
\ No newline at end of file
flutter-sample/android/app/src/main/kotlin/com/example/example/MainActivity.kt
0 → 100644
View file @
e2b54af8
package
com.example.example
import
android.content.Intent
import
com.google.gson.Gson
import
io.flutter.embedding.android.FlutterActivity
import
io.flutter.embedding.engine.FlutterEngine
import
io.flutter.plugin.common.MethodCall
import
io.flutter.plugin.common.MethodChannel
import
uz.myid.android.sdk.capture.*
import
uz.myid.android.sdk.capture.model.OrganizationDetails
import
java.util.*
class
MainActivity
:
FlutterActivity
(),
MyIdResultListener
{
private
var
flutterResult
:
MethodChannel
.
Result
?
=
null
private
val
myIdClient
=
MyIdClient
()
override
fun
configureFlutterEngine
(
flutterEngine
:
FlutterEngine
)
{
super
.
configureFlutterEngine
(
flutterEngine
)
MethodChannel
(
flutterEngine
.
dartExecutor
.
binaryMessenger
,
CHANNEL
)
.
setMethodCallHandler
{
call
,
result
->
if
(
call
.
method
==
"runSDK"
)
{
flutterResult
=
result
startMyId
(
call
)
}
}
}
override
fun
onActivityResult
(
requestCode
:
Int
,
resultCode
:
Int
,
data
:
Intent
?)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
)
if
(
requestCode
==
MYID_REQUEST_CODE
)
{
myIdClient
.
handleActivityResult
(
resultCode
,
this
)
}
}
override
fun
onSuccess
(
result
:
MyIdResult
)
{
val
resultData
=
ResultData
(
resultCode
=
result
.
code
,
comparison
=
result
.
comparison
)
flutterResult
?.
success
(
Gson
().
toJson
(
resultData
))
}
override
fun
onError
(
e
:
MyIdException
)
{
val
resultData
=
ResultData
(
errorMessage
=
e
.
message
,
errorCode
=
e
.
code
)
flutterResult
?.
success
(
Gson
().
toJson
(
resultData
))
}
override
fun
onUserExited
()
{
val
resultData
=
ResultData
(
errorMessage
=
"User exited"
,
errorCode
=
400
)
flutterResult
?.
success
(
Gson
().
toJson
(
resultData
))
}
private
fun
startMyId
(
call
:
MethodCall
)
{
val
phoneNumber
=
call
.
argument
<
String
>(
Keys
.
PHONE_NUMBER
).
orEmpty
()
val
clientId
=
call
.
argument
<
String
>(
Keys
.
CLIENT_ID
).
orEmpty
()
val
passportData
=
call
.
argument
<
String
>(
Keys
.
PASSPORT_DATA
).
orEmpty
()
val
dateOfBirth
=
call
.
argument
<
String
>(
Keys
.
DATE_OF_BIRTH
).
orEmpty
()
val
sdkHash
=
call
.
argument
<
String
>(
Keys
.
SDK_HASH
).
orEmpty
()
val
externalId
=
call
.
argument
<
String
>(
Keys
.
EXTERNAL_ID
).
orEmpty
()
val
threshold
=
call
.
argument
<
Double
>(
Keys
.
THRESHOLD
)
?:
0.5f
val
buildMode
=
when
(
call
.
argument
<
String
>(
Keys
.
BUILD_MODE
)
?.
uppercase
())
{
MyIdBuildMode
.
DEBUG
.
name
->
MyIdBuildMode
.
DEBUG
else
->
MyIdBuildMode
.
PRODUCTION
}
val
entryType
=
when
(
call
.
argument
<
String
>(
Keys
.
ENTRY_TYPE
)
?.
uppercase
())
{
MyIdEntryType
.
FACE
.
name
->
MyIdEntryType
.
FACE
else
->
MyIdEntryType
.
AUTH
}
val
residentType
=
when
(
call
.
argument
<
String
>(
Keys
.
RESIDENT_TYPE
)
?.
uppercase
())
{
MyIdResidentType
.
USER_DEFINED
.
name
->
MyIdResidentType
.
USER_DEFINED
MyIdResidentType
.
NON_RESIDENT
.
name
->
MyIdResidentType
.
NON_RESIDENT
else
->
MyIdResidentType
.
RESIDENT
}
val
cameraShape
=
when
(
call
.
argument
<
String
>(
Keys
.
CAMERA_SHAPE
)
?.
uppercase
())
{
MyIdCameraShape
.
ELLIPSE
.
name
->
MyIdCameraShape
.
ELLIPSE
else
->
MyIdCameraShape
.
CIRCLE
}
val
locale
=
call
.
argument
<
String
>(
Keys
.
LOCALE
)
?:
"en"
val
withPhoto
=
call
.
argument
<
Boolean
>(
Keys
.
WITH_PHOTO
)
?:
false
val
organizationDetails
=
OrganizationDetails
(
phoneNumber
=
phoneNumber
)
val
myIdConfig
=
MyIdConfig
.
builder
(
clientId
=
clientId
)
.
withPassportData
(
passportData
)
.
withBirthDate
(
dateOfBirth
)
.
withSdkHash
(
sdkHash
)
.
withExternalId
(
externalId
)
.
withThreshold
(
threshold
.
toFloat
())
.
withBuildMode
(
buildMode
)
.
withEntryType
(
entryType
)
.
withResidency
(
residentType
)
.
withLocale
(
Locale
(
locale
))
.
withCameraShape
(
cameraShape
)
.
withOrganizationDetails
(
organizationDetails
)
.
withPhoto
(
withPhoto
)
.
build
()
myIdClient
.
startActivityForResult
(
this
,
MYID_REQUEST_CODE
,
myIdConfig
)
}
companion
object
{
private
const
val
CHANNEL
=
"flutter.native/myid"
private
const
val
MYID_REQUEST_CODE
=
999
}
}
flutter-sample/android/app/src/main/kotlin/com/example/example/ResultData.kt
0 → 100644
View file @
e2b54af8
package
com.example.example
import
androidx.annotation.Keep
import
com.google.gson.annotations.SerializedName
@Keep
data class
ResultData
(
@SerializedName
(
"result_code"
)
val
resultCode
:
String
?
=
null
,
@SerializedName
(
"comparison"
)
val
comparison
:
Double
?
=
null
,
@SerializedName
(
"error_message"
)
val
errorMessage
:
String
?
=
null
,
@SerializedName
(
"error_code"
)
val
errorCode
:
Int
?
=
null
)
flutter-sample/android/app/src/main/res/drawable-v21/launch_background.xml
0 → 100644
View file @
e2b54af8
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:drawable=
"?android:colorBackground"
/>
</layer-list>
flutter-sample/android/app/src/main/res/drawable/launch_background.xml
0 → 100644
View file @
e2b54af8
<?xml version="1.0" encoding="utf-8"?>
<layer-list
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:drawable=
"@android:color/white"
/>
</layer-list>
flutter-sample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
0 → 100644
View file @
e2b54af8
544 Bytes
flutter-sample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
0 → 100644
View file @
e2b54af8
442 Bytes
flutter-sample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
0 → 100644
View file @
e2b54af8
721 Bytes
flutter-sample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
0 → 100644
View file @
e2b54af8
1.01 KB
flutter-sample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
0 → 100644
View file @
e2b54af8
1.41 KB
flutter-sample/android/app/src/main/res/values-night/styles.xml
0 → 100644
View file @
e2b54af8
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style
name=
"LaunchTheme"
parent=
"@android:style/Theme.Black.NoTitleBar"
>
<item
name=
"android:windowBackground"
>
@drawable/launch_background
</item>
</style>
<style
name=
"NormalTheme"
parent=
"@android:style/Theme.Black.NoTitleBar"
>
<item
name=
"android:windowBackground"
>
?android:colorBackground
</item>
</style>
</resources>
flutter-sample/android/app/src/main/res/values/strings.xml
0 → 100644
View file @
e2b54af8
<resources></resources>
\ No newline at end of file
flutter-sample/android/app/src/main/res/values/styles.xml
0 → 100644
View file @
e2b54af8
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style
name=
"LaunchTheme"
parent=
"@android:style/Theme.Light.NoTitleBar"
>
<item
name=
"android:windowBackground"
>
@drawable/launch_background
</item>
</style>
<style
name=
"NormalTheme"
parent=
"@android:style/Theme.Light.NoTitleBar"
>
<item
name=
"android:windowBackground"
>
?android:colorBackground
</item>
</style>
</resources>
flutter-sample/android/build.gradle
0 → 100644
View file @
e2b54af8
buildscript
{
repositories
{
google
()
mavenCentral
()
}
dependencies
{
classpath
"com.android.tools.build:gradle:7.3.1"
classpath
"org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.21"
}
}
allprojects
{
repositories
{
google
()
mavenCentral
()
}
}
rootProject
.
buildDir
=
"../build"
subprojects
{
project
.
buildDir
=
"${rootProject.buildDir}/${project.name}"
}
subprojects
{
project
.
evaluationDependsOn
(
":app"
)
}
task
clean
(
type:
Delete
)
{
delete
rootProject
.
buildDir
}
flutter-sample/android/gradle.properties
0 → 100644
View file @
e2b54af8
org.gradle.jvmargs
=
-Xmx1536M
android.useAndroidX
=
true
android.enableJetifier
=
true
flutter-sample/android/gradle/wrapper/gradle-wrapper.properties
0 → 100644
View file @
e2b54af8
#Fri Jun 23 08:50:38 CEST 2017
distributionBase
=
GRADLE_USER_HOME
distributionPath
=
wrapper/dists
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-7.4-bin.zip
flutter-sample/android/settings.gradle
0 → 100644
View file @
e2b54af8
include
":app"
def
localPropertiesFile
=
new
File
(
rootProject
.
projectDir
,
"local.properties"
)
def
properties
=
new
Properties
()
assert
localPropertiesFile
.
exists
()
localPropertiesFile
.
withReader
(
"UTF-8"
)
{
reader
->
properties
.
load
(
reader
)
}
def
flutterSdkPath
=
properties
.
getProperty
(
"flutter.sdk"
)
assert
flutterSdkPath
!=
null
,
"flutter.sdk not set in local.properties"
apply
from:
"$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
flutter-sample/lib/main.dart
0 → 100644
View file @
e2b54af8
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
void
main
(
)
{
runApp
(
const
App
());
}
class
App
extends
StatelessWidget
{
const
App
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
const
MaterialApp
(
title:
'AppName'
,
debugShowCheckedModeBanner:
false
,
themeMode:
ThemeMode
.
light
,
home:
View
(),
);
}
}
class
View
extends
StatefulWidget
{
const
View
({
Key
?
key
})
:
super
(
key:
key
);
static
const
platform
=
MethodChannel
(
'flutter.native/myid'
);
@override
State
<
View
>
createState
()
=>
_ViewState
();
}
class
_ViewState
extends
State
<
View
>
{
var
result
=
""
;
@override
Widget
build
(
BuildContext
context
)
{
return
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
TextButton
(
onPressed:
()
{
View
.
platform
.
invokeMethod
(
'runSDK'
,
<
String
,
dynamic
>{
'KEY_PHONE_NUMBER'
:
"1234567"
,
// Organization phone number
'KEY_CLIENT_ID'
:
""
,
'KEY_PASSPORT_DATA'
:
"AB1234567"
,
'KEY_DATE_OF_BIRTH'
:
"01.09.1999"
,
// Format: dd.MM.yyyy
'KEY_SDK_HASH'
:
""
,
// Optional
'KEY_EXTERNAL_ID'
:
""
,
// Optional
'KEY_THRESHOLD'
:
0.5
,
// 0.5 until 1.0
'KEY_BUILD_MODE'
:
"PRODUCTION"
,
// PRODUCTION or DEBUG
'KEY_ENTRY_TYPE'
:
"AUTH"
,
// AUTH or FACE
'KEY_RESIDENT_TYPE'
:
"AUTH"
,
// USER_DEFINED, RESIDENT and NON_RESIDENT
'KEY_LOCALE'
:
"uz"
,
// uz, en, ru
'KEY_CAMERA_SHAPE'
:
"CIRCLE"
,
// CIRCLE or ELLIPSE
'KEY_WITH_PHOTO'
:
false
}).
then
((
value
)
=>
setState
(()
=>
result
=
value
));
},
child:
const
Text
(
"Run myID SDK"
),
),
Text
(
"Result is: "
+
result
,
style:
const
TextStyle
(
fontSize:
26
),
),
],
),
);
}
}
Prev
1
2
3
4
5
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment