Skip to content

Commit dac6561

Browse files
authored
*Added Kotlin version of the sample app used to implement DeviceRisk SDK (#22)
* *Added Kotlin version of the sample app used to implement DeviceRisk SDK * *Fixed issues found in pull request
1 parent 5312268 commit dac6561

31 files changed

+477
-7
lines changed

android-studio-sample-app/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
applicationId "com.iovation.mobile.android.sample.sampleapp"
88
minSdkVersion 21
99
targetSdkVersion 31
10-
versionCode 4
11-
versionName "5.0.0"
10+
versionCode 9
11+
versionName "5.0.1"
1212
}
1313
buildTypes {
1414
release {

android-studio-sample-app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ buildscript {
77
google()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:4.0.2'
10+
classpath 'com.android.tools.build:gradle:7.0.3'
11+
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
1112

1213
// NOTE: Do not place your application dependencies here; they belong
1314
// in the individual module build.gradle files

android-studio-sample-app/gradle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@
1515
# When configured, Gradle will run in incubating parallel mode.
1616
# This option should only be used with decoupled projects. More details, visit
1717
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18-
# org.gradle.parallel=true
18+
# org.gradle.parallel=true
19+
android.enableJetifier=true
20+
android.useAndroidX=true
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Nov 09 08:29:48 PST 2020
1+
#Thu Mar 30 14:27:27 EDT 2023
22
distributionBase=GRADLE_USER_HOME
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
34
distributionPath=wrapper/dists
4-
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
6+
zipStoreBase=GRADLE_USER_HOME
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
plugins {
2+
id 'com.android.application'
3+
id 'org.jetbrains.kotlin.android'
4+
}
5+
6+
android {
7+
compileSdk 32
8+
9+
defaultConfig {
10+
applicationId "com.iovation.mobile.android.sample.kotlinApp"
11+
minSdk 21
12+
targetSdk 32
13+
versionCode 10
14+
versionName "5.0.1"
15+
}
16+
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21+
}
22+
}
23+
compileOptions {
24+
sourceCompatibility JavaVersion.VERSION_1_8
25+
targetCompatibility JavaVersion.VERSION_1_8
26+
}
27+
kotlinOptions {
28+
jvmTarget = '1.8'
29+
}
30+
31+
buildFeatures {
32+
viewBinding true
33+
}
34+
}
35+
36+
dependencies {
37+
implementation 'androidx.appcompat:appcompat:1.0.0'
38+
implementation files('libs/fraudforce-lib-release-5.0.0.aar')
39+
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
40+
}
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.iovation.mobile.android.sample.kotlinApp">
4+
5+
<application
6+
android:name=".MainApplication"
7+
android:allowBackup="true"
8+
android:icon="@mipmap/ic_launcher"
9+
android:label="@string/app_name"
10+
android:roundIcon="@mipmap/ic_launcher_round"
11+
android:supportsRtl="true"
12+
android:theme="@style/Theme.Androidstudiosampleapp">
13+
<activity
14+
android:name=".MainActivity"
15+
android:exported="true">
16+
<intent-filter>
17+
<action android:name="android.intent.action.MAIN" />
18+
19+
<category android:name="android.intent.category.LAUNCHER" />
20+
</intent-filter>
21+
</activity>
22+
</application>
23+
24+
</manifest>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.iovation.mobile.android.sample.kotlinApp
2+
3+
import androidx.appcompat.app.AppCompatActivity
4+
import android.os.Bundle
5+
import android.view.View
6+
import com.iovation.mobile.android.FraudForceManager
7+
import com.iovation.mobile.android.sample.kotlinApp.databinding.ActivityMainBinding
8+
import kotlinx.coroutines.CoroutineScope
9+
import kotlinx.coroutines.Dispatchers
10+
import kotlinx.coroutines.launch
11+
import kotlinx.coroutines.withContext
12+
13+
class MainActivity : AppCompatActivity() {
14+
private lateinit var binding: ActivityMainBinding
15+
16+
private val uiScope = CoroutineScope(Dispatchers.IO)
17+
18+
override fun onCreate(savedInstanceState: Bundle?) {
19+
super.onCreate(savedInstanceState)
20+
21+
FraudForceManager.refresh(applicationContext)
22+
23+
binding = ActivityMainBinding.inflate(layoutInflater)
24+
setContentView(binding.root)
25+
26+
binding.button.setOnClickListener{
27+
blackboxRequestHandler()
28+
}
29+
}
30+
31+
private fun blackboxRequestHandler() {
32+
binding.blackboxResult.text = ""
33+
binding.blackboxResult.visibility = View.GONE
34+
35+
binding.blackboxResultLine.visibility = View.GONE
36+
37+
binding.blackboxLabel.text = getString(R.string.printing_wait_msg)
38+
binding.blackboxLabel.visibility = View.VISIBLE
39+
40+
uiScope.launch {
41+
val blackbox : String = getBlackbox()
42+
withContext(Dispatchers.Main) {
43+
printBlackbox(blackbox)
44+
}
45+
}
46+
}
47+
48+
private fun getBlackbox() : String {
49+
return FraudForceManager.getBlackbox(applicationContext)
50+
}
51+
52+
private fun printBlackbox(blackbox : String){
53+
binding.blackboxLabel.text = getString(R.string.blackbox_label)
54+
binding.blackboxLabel.visibility = View.VISIBLE
55+
56+
binding.blackboxResultLine.visibility = View.VISIBLE
57+
58+
binding.blackboxResult.text = blackbox
59+
binding.blackboxResult.visibility = View.VISIBLE
60+
61+
FraudForceManager.refresh(applicationContext)
62+
}
63+
}

0 commit comments

Comments
 (0)