Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
I
Implementation Partner Connect
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gandha Ryanto
Implementation Partner Connect
Commits
7496aa08
Commit
7496aa08
authored
Feb 08, 2021
by
ganda@mdd.co.id
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dev env
parent
09961c26
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
405 additions
and
63 deletions
+405
-63
gradle.xml
.idea/gradle.xml
+0
-1
build.gradle
app/build.gradle
+31
-24
ExampleInstrumentedTest.java
...implementationpartnerconnect/ExampleInstrumentedTest.java
+0
-26
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+2
-2
MainActivity.java
...ava/id/mdd/implementationpartnerconnect/MainActivity.java
+8
-8
NewMainActivity.java
.../id/mdd/implementationpartnerconnect/NewMainActivity.java
+359
-0
activity_main.xml
app/src/main/res/layout/activity_main.xml
+5
-2
No files found.
.idea/gradle.xml
View file @
7496aa08
...
...
@@ -16,7 +16,6 @@
</set>
</option>
<option
name=
"resolveModulePerSourceSet"
value=
"false"
/>
<option
name=
"useQualifiedModuleNames"
value=
"true"
/>
</GradleProjectSettings>
</option>
</component>
...
...
app/build.gradle
View file @
7496aa08
...
...
@@ -31,42 +31,49 @@ android {
dependencies
{
implementation
fileTree
(
include:
[
'*.jar'
],
dir:
'libs'
)
implementation
'androidx.appcompat:appcompat:1.2.0'
implementation
'com.android.support.constraint:constraint-layout:
1.1.3
'
implementation
'androidx.appcompat:appcompat:1.
1
.0'
implementation
'androidx.constraintlayout:constraintlayout:
1.1.3
'
implementation
"androidx.preference:preference:1.1.
0
"
implementation
'com.google.android.material:material:1.
1.0
'
testImplementation
'junit:junit:4.1
2
'
implementation
'com.android.support.constraint:constraint-layout:
2.0.4
'
implementation
'androidx.appcompat:appcompat:1.
2
.0'
implementation
'androidx.constraintlayout:constraintlayout:
2.0.4
'
implementation
"androidx.preference:preference:1.1.
1
"
implementation
'com.google.android.material:material:1.
2.1
'
testImplementation
'junit:junit:4.1
3.1
'
androidTestImplementation
'com.android.support.test:runner:1.0.2'
androidTestImplementation
'com.android.support.test.espresso:espresso-core:3.0.2'
implementation
fileTree
(
include:
[
'*.aar'
],
dir:
'libs'
)
implementation
'com.squareup.okhttp3:okhttp:
3.10.0
'
implementation
'com.squareup.okhttp3:logging-interceptor:
3.10.0
'
implementation
'com.squareup.okhttp3:okhttp:
4.1.1
'
implementation
'com.squareup.okhttp3:logging-interceptor:
4.1.1
'
implementation
'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
implementation
'com.squareup.retrofit2:converter-gson:2.
4
.0'
implementation
'com.squareup.retrofit2:converter-gson:2.
9
.0'
//retrofit
implementation
'com.squareup.retrofit2:retrofit:2.
5
.0'
implementation
'com.squareup.retrofit2:converter-gson:2.
4
.0'
implementation
'com.squareup.okhttp3:logging-interceptor:
3.12
.1'
implementation
'com.squareup.retrofit2:retrofit:2.
9
.0'
implementation
'com.squareup.retrofit2:converter-gson:2.
9
.0'
implementation
'com.squareup.okhttp3:logging-interceptor:
4.1
.1'
implementation
'com.squareup.retrofit2:converter-scalars:2.3.0'
// implementation project(path: ':mdd-service-release')
implementation
'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation
'io.reactivex.rxjava2:rxjava:2.2.1
0
'
implementation
'io.reactivex.rxjava2:rxjava:2.2.1
9
'
implementation
'com.jakewharton:butterknife:10.2.0'
implementation
'com.bugfender.sdk:android:3.
+
'
implementation
'com.bugfender.sdk:android:3.
0.8
'
annotationProcessor
'com.jakewharton:butterknife-compiler:10.1.0'
implementation
(
group:
'com.mdd.payment'
,
name:
'brizzilib-release'
,
version:
'1.1.1'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.library'
,
name:
'brizzi-release-sbox'
,
version:
'1.3'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'aar-deviceid-release'
,
version:
'2.0.5'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.service'
,
name:
'partner-connect'
,
version:
'2.5.0'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'mybanklibrary-release'
,
version:
'3.7.0'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.topup'
,
name:
'update-balance'
,
version:
'3.0.4'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'z91library-release'
,
version:
'2.1.2'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'organicdrv-release'
,
version:
'2.1.2'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'wepoylibrary-release'
,
version:
'2.2.6'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'paxlibrary-release'
,
version:
'2.1.3'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'nativecripto-release'
,
version:
'2.0.1'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'isodeplibrary-release'
,
version:
'2.1.2'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.service'
,
name:
'partner-connect'
,
version:
'2.3.4'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'mybanklibrary-release'
,
version:
'3.6.7'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.topup'
,
name:
'update-balance'
,
version:
'2.8.6'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'z91library-release'
,
version:
'2.1.0'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'organicdrv-release'
,
version:
'2.1.0'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'wepoylibrary-release'
,
version:
'2.2.0'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'paxlibrary-release'
,
version:
'2.1.1'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'nativecripto-release'
,
version:
'2.0.0'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'isodeplibrary-release'
,
version:
'2.1.1'
,
ext:
'aar'
)
implementation
(
group:
'com.mdd.payment'
,
name:
'sunmilibrary-release'
,
version:
'2.2.1'
,
ext:
'aar'
)
implementation
'com.sunmi:printerlibrary:1.0.9'
implementation
'com.sunmi:sunmiui:1.1.27'
implementation
(
group:
'com.mdd.payment'
,
name:
'paylib-release'
,
version:
'1.0.1'
,
ext:
'aar'
)
}
\ No newline at end of file
app/src/androidTest/java/id/mdd/implementationpartnerconnect/ExampleInstrumentedTest.java
deleted
100644 → 0
View file @
09961c26
package
id
.
mdd
.
implementationpartnerconnect
;
import
android.content.Context
;
import
androidx.test.platform.app.InstrumentationRegistry
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
static
org
.
junit
.
Assert
.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith
(
AndroidJUnit4
.
class
)
public
class
ExampleInstrumentedTest
{
@Test
public
void
useAppContext
()
{
// Context of the app under test.
Context
appContext
=
InstrumentationRegistry
.
getInstrumentation
().
getTargetContext
();
assertEquals
(
"id.mdd.implementationpartnerconnect"
,
appContext
.
getPackageName
());
}
}
\ No newline at end of file
app/src/main/AndroidManifest.xml
View file @
7496aa08
...
...
@@ -18,11 +18,11 @@
android:allowBackup=
"true"
android:icon=
"@mipmap/ic_launcher"
android:label=
"@string/app_name"
android:roundIcon=
"@mipmap/ic_launcher_round"
android:networkSecurityConfig=
"@xml/network_security_config"
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:theme=
"@style/AppTheme"
>
<activity
android:name=
".MainActivity"
>
<activity
android:name=
".
New
MainActivity"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
...
...
app/src/main/java/id/mdd/implementationpartnerconnect/MainActivity.java
View file @
7496aa08
...
...
@@ -237,7 +237,7 @@ public class MainActivity extends AppCompatActivity implements MDDUpdateBalanceV
@Override
public
void
onRequestPermissionsResult
(
int
requestCode
,
@NonNull
String
[]
permissions
,
@NonNull
int
[]
grantResults
)
{
super
.
onRequestPermissionsResult
(
requestCode
,
permissions
,
grantResults
);
Log
.
e
(
"requestPermissionResult"
,
"reqCode "
+
requestCode
+
" permission "
+
permissions
+
" grantResults "
+
grantResults
);
Log
.
e
(
"requestPermissionResult"
,
"reqCode "
+
requestCode
+
" permission "
+
permissions
+
" grantResults "
+
grantResults
);
((
MyApp
)
getApplication
()).
initAar
(
this
);
}
...
...
@@ -457,7 +457,7 @@ public class MainActivity extends AppCompatActivity implements MDDUpdateBalanceV
private
void
execute
(
Tag
tag
)
{
Log
.
d
(
"Execute"
,
"--> execute"
);
if
(
reader
!=
null
){
if
(
reader
!=
null
)
{
cardProcessor
=
new
MainCardProcessor
(
MainActivity
.
this
,
reader
,
new
UpdateBalanceView
()
{
@Override
public
void
onUpdateBalanceSuccess
(
SuccessUpdateBalance
successUpdateBalance
)
{
...
...
@@ -488,26 +488,26 @@ public class MainActivity extends AppCompatActivity implements MDDUpdateBalanceV
runOnUiThread
(
this
::
onNfcCardFound
);
CardInfoCommand
command
=
new
CardInfoCommand
(
reader
.
myReader
);
Log
.
e
(
"myReader"
,
"Myreader : "
+
reader
.
myReader
);
Log
.
e
(
"myReader"
,
"Myreader : "
+
reader
.
myReader
);
final
CommandResult
<
CardInfo
>
execute
=
command
.
execute
(
cardUid
);
CardInfo
detectedCardInfo
=
execute
.
getResult
();
Log
.
d
(
"executeSuccess"
,
"executeIsSuccess = "
+
execute
.
isSuccess
());
if
(
execute
.
isSuccess
())
{
if
(
detectedCardInfo
.
getBankType
().
toLowerCase
().
contains
(
"dki"
)
||
detectedCardInfo
.
getBankType
().
toLowerCase
().
contains
(
"bca"
)){
||
detectedCardInfo
.
getBankType
().
toLowerCase
().
contains
(
"bca"
))
{
runOnUiThread
(()
->
{
MainActivity
.
this
.
onBalanceInfoAvailable
(
detectedCardInfo
);
mProgress
.
setVisibility
(
View
.
GONE
);
mOpsResult
.
setText
(
R
.
string
.
tap_card
);
});
}
else
{
cardProcessor
.
getBalance
(
detectedCardInfo
);
cardProcessor
.
updateBalance
(
detectedCardInfo
,
1
);
}
else
{
cardProcessor
.
getBalance
(
detectedCardInfo
,
null
);
cardProcessor
.
updateBalance
(
detectedCardInfo
,
1
,
null
);
}
}
else
{
runOnUiThread
(()
->
{
Log
.
e
(
"error"
,
"Messagenya : "
+
execute
.
getMessage
());
Log
.
e
(
"error"
,
"Messagenya : "
+
execute
.
getMessage
());
MainActivity
.
this
.
onUpdateBalanceError
(
"Kartu tidak terdeteksi"
);
cardProcessor
.
unlockIsoDepCard
();
});
...
...
app/src/main/java/id/mdd/implementationpartnerconnect/NewMainActivity.java
0 → 100644
View file @
7496aa08
package
id
.
mdd
.
implementationpartnerconnect
;
import
android.Manifest
;
import
android.content.Context
;
import
android.content.pm.PackageManager
;
import
android.graphics.Color
;
import
android.graphics.PorterDuff
;
import
android.media.MediaPlayer
;
import
android.nfc.NfcAdapter
;
import
android.nfc.NfcManager
;
import
android.nfc.Tag
;
import
android.os.AsyncTask
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.os.StrictMode
;
import
android.provider.Settings
;
import
android.util.Log
;
import
android.view.View
;
import
android.view.WindowManager
;
import
android.widget.Button
;
import
android.widget.ImageButton
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
android.widget.ProgressBar
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.app.AppCompatActivity
;
import
androidx.core.app.ActivityCompat
;
import
androidx.core.content.ContextCompat
;
import
com.mdd.topupUnik.ubal.ApiUtils
;
import
com.mdd.topupUnik.ubal.InitDebugCertificate
;
import
com.mdd.topupUnik.ubal.InitReader
;
import
com.mdd.topupUnik.ubal.MainCardProcessor
;
import
com.mdd.topupUnik.ubal.SuccessUpdateBalance
;
import
com.mdd.topupUnik.ubal.UpdateBalanceView
;
import
com.mdd.topupUnik.ubal.http.response.CardBalanceAPDUResponse
;
import
com.mdd.topupUnik.ubal.lib.CardInfo
;
import
com.mdd.topupUnik.ubal.lib.CardInfoCommand
;
import
com.mdd.topupUnik.ubal.lib.CommandResult
;
import
com.medicom.dudikov.mybanklibrary.nativeLib
;
import
java.text.DecimalFormat
;
import
java.text.NumberFormat
;
import
java.util.Locale
;
import
butterknife.BindView
;
import
butterknife.ButterKnife
;
import
id.emhusnan.mdd.service.ConfigService
;
import
id.emhusnan.mdd.service.LibraryConfig
;
import
id.emhusnan.mdd.service.MDDUpdateBalanceView
;
import
static
com
.
medicom
.
organicdrv
.
utilsLib
.
ByteArrayToHexString
;
public
class
NewMainActivity
extends
AppCompatActivity
implements
MDDUpdateBalanceView
,
InitListener
,
NfcAdapter
.
ReaderCallback
{
private
static
final
int
MY_PERMISSIONS_REQUEST_READ_CONTACTS
=
1
;
private
static
final
String
TAG
=
"NewMainActivity"
;
@BindView
(
R
.
id
.
logoCard
)
ImageView
logoCard
;
@BindView
(
R
.
id
.
textCardBalance
)
TextView
textCardBalance
;
@BindView
(
R
.
id
.
textCardNumber
)
TextView
textCardNumber
;
@BindView
(
R
.
id
.
btnGantiKartu
)
ImageButton
btnGantiKartu
;
@BindView
(
R
.
id
.
bgCard
)
LinearLayout
bgCard
;
@BindView
(
R
.
id
.
pgProcess
)
ProgressBar
pgProcess
;
@BindView
(
R
.
id
.
txtStatus
)
TextView
txtStatus
;
@BindView
(
R
.
id
.
btnUpdateBalance
)
Button
btnUpdateBalance
;
@BindView
(
R
.
id
.
txtAmount
)
TextView
txtAmount
;
@BindView
(
R
.
id
.
textCardBalanceNew
)
TextView
textCardBalanceNew
;
@BindView
(
R
.
id
.
lyUpdateBalance
)
LinearLayout
lyUpdateBalance
;
@BindView
(
R
.
id
.
btnAktivasiAar
)
Button
btnAktivasiAar
;
@BindView
(
R
.
id
.
about
)
TextView
about
;
@BindView
(
R
.
id
.
version
)
TextView
version
;
@BindView
(
R
.
id
.
pbloading
)
ProgressBar
pbloading
;
DecimalFormat
formatter
=
(
DecimalFormat
)
NumberFormat
.
getInstance
(
Locale
.
US
);
private
int
idDriver
=
nativeLib
.
USE_SunMi_ENGGINE
;
private
InitReader
reader
;
private
MainCardProcessor
cardProcessor
;
private
boolean
hasPendingOperation
;
private
int
oldBalance
=
0
;
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
ButterKnife
.
bind
(
this
);
validateHasPermissions
();
}
private
void
validateHasPermissions
()
{
StrictMode
.
ThreadPolicy
policy
=
new
StrictMode
.
ThreadPolicy
.
Builder
().
permitAll
().
build
();
StrictMode
.
setThreadPolicy
(
policy
);
// permission READ_PHONE_STATE
if
(
ContextCompat
.
checkSelfPermission
(
this
,
Manifest
.
permission
.
READ_PHONE_STATE
)
!=
PackageManager
.
PERMISSION_GRANTED
)
{
Toast
.
makeText
(
this
,
"Please grant permission"
,
Toast
.
LENGTH_SHORT
).
show
();
if
(
ActivityCompat
.
shouldShowRequestPermissionRationale
(
this
,
Manifest
.
permission
.
READ_PHONE_STATE
))
{
}
else
{
ActivityCompat
.
requestPermissions
(
this
,
new
String
[]{
Manifest
.
permission
.
READ_PHONE_STATE
,
Manifest
.
permission
.
INTERNET
,
Manifest
.
permission
.
READ_EXTERNAL_STORAGE
},
MY_PERMISSIONS_REQUEST_READ_CONTACTS
);
}
}
else
{
Log
.
d
(
"Init"
,
"--> Init"
);
// ((MyApp) getApplication()).initAar(this);
ConfigService
configService
=
new
ConfigService
();
configService
.
setMid
(
"1234567abc"
);
configService
.
setToken
(
"165eea86947a4e9483d1902f93495fc6"
);
String
accessToken
=
"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJhdXRoLXNlcnZpY2U6MS4wLjAiLCJzdWIiOnsibmFtZSI6IlRlc3RTdGFnIiwidXNlcm5hbWUiOiJUZXN0U3RhZyIsImF1dGhfbGV2ZWwiOiJNRVJDSEFOVCIsIm1pZCI6IjIwZjFmMTNmODA1MGFjY2QxYjNjNzFlOWUyYTQ0NzU3In0sImlhdCI6MTU5MzQxMzM5MCwiZXhwIjoxNzUxMTk4MTUwLCJuYmYiOjE1OTM0MTMzOTJ9.E6UJMKha5YCbri4KRExDV4zeA1ZBfabpW-O6SInxxvfyTTYnUZCEu58STBGrOCL0RuxTFp5Y-XEyoa932fQcTpMBMsKkvDmGeftJ0hmjzAxAjHTfUxUyEa-HHF1whsM4YQUG9CesEBjU9IUcE6Rs-jykYxuryvvqqop5BoEIwO71qQBrq6DtpwjwFk9hbNt0EKs_HmCpySfXQxorfLMbAVJCHBYoo4UVymUfwUbps7hW6eQwNoBnt11O59CRPf6uUVIfCrsaaBMcJI-mc214-EMyl3RmMbqNl_f_0ITEJhMtK2zbUFZ8dMrGdZZgWJxiHdmzxqdaEPDVshYi9Uo31w"
;
LibraryConfig
mConfig
=
new
LibraryConfig
(
configService
.
getMid
(),
Settings
.
Secure
.
ANDROID_ID
,
configService
.
getToken
(),
accessToken
,
ApiUtils
.
dev_environment
);
final
nativeLib
[]
nativeLibrary
=
new
nativeLib
[
1
];
InitDebugCertificate
initDebugCertificate
=
new
InitDebugCertificate
();
AsyncTask
.
execute
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
nativeLibrary
[
0
]
=
new
nativeLib
(
getApplicationContext
(),
idDriver
);
reader
=
initDebugCertificate
.
getDebug
(
nativeLibrary
[
0
],
getApplicationContext
(),
idDriver
,
mConfig
,
true
);
// Log.e("reader", new Gson().toJson(reader));
pbloading
.
setVisibility
(
View
.
GONE
);
execute
(
null
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
});
}
}
@Override
public
void
onTagDiscovered
(
Tag
tag
)
{
execute
(
tag
);
}
@Override
public
void
onNFcCardNotSupported
(
int
i
)
{
hasPendingOperation
=
false
;
Toast
.
makeText
(
this
,
R
.
string
.
nfc_not_found
,
Toast
.
LENGTH_SHORT
).
show
();
NfcManager
manager
=
(
NfcManager
)
getSystemService
(
Context
.
NFC_SERVICE
);
NfcAdapter
adapter
=
manager
.
getDefaultAdapter
();
Log
.
d
(
TAG
,
"adapter:"
+
adapter
+
","
+
Build
.
MODEL
+
","
+
Build
.
BRAND
);
if
(
adapter
==
null
||
!
adapter
.
isEnabled
())
{
txtStatus
.
setTextColor
(
getResources
().
getColor
(
R
.
color
.
text_error
));
txtStatus
.
setText
(
R
.
string
.
nfc_not_found
);
}
// showProgressBar();
displayResult
(
R
.
color
.
text_normal
,
R
.
string
.
nfc_not_found
);
findViewById
(
R
.
id
.
lyUpdateBalance
).
setVisibility
(
View
.
GONE
);
}
@Override
public
void
onNfcCardFound
()
{
hasPendingOperation
=
true
;
Toast
.
makeText
(
this
,
"Mohon Tunggu..."
,
Toast
.
LENGTH_LONG
).
show
();
// showProgressBar();
displayResult
(
R
.
color
.
text_normal
,
R
.
string
.
keep_tap
);
findViewById
(
R
.
id
.
lyUpdateBalance
).
setVisibility
(
View
.
GONE
);
}
@Override
public
void
onFinishOperation
()
{
hasPendingOperation
=
false
;
Toast
.
makeText
(
this
,
"On Finishoperation"
,
Toast
.
LENGTH_SHORT
).
show
();
}
@Override
public
void
onBalanceInfoAvailable
(
CardInfo
cardInfo
)
{
hasPendingOperation
=
false
;
Log
.
d
(
TAG
,
"onBalanceInfoAvailable: "
+
cardInfo
.
getBalance
());
runOnUiThread
(()
->
{
// pgProcess.setVisibility(View.VISIBLE);
if
(
cardInfo
.
getBankType
().
equals
(
"BNI"
))
{
bgCard
.
getBackground
().
setColorFilter
(
Color
.
parseColor
(
"#F6630E"
),
PorterDuff
.
Mode
.
SRC_ATOP
);
logoCard
.
setImageResource
(
R
.
drawable
.
tapcash_logo
);
}
else
{
bgCard
.
getBackground
().
setColorFilter
(
Color
.
parseColor
(
"#013C76"
),
PorterDuff
.
Mode
.
SRC_ATOP
);
logoCard
.
setImageResource
(
R
.
drawable
.
logo_emoney
);
}
oldBalance
=
cardInfo
.
getBalance
();
txtAmount
.
setText
(
"Rp "
+
cardInfo
.
getBalance
());
textCardNumber
.
setText
(
cardInfo
.
getCardNumber
());
txtStatus
.
setTextColor
(
getColorRes
(
R
.
color
.
text_normal
));
});
beep
();
}
private
void
beep
()
{
MediaPlayer
mp
=
MediaPlayer
.
create
(
this
,
R
.
raw
.
beep
);
mp
.
start
();
}
@Override
public
void
onUpdateBalaceSuccess
(
SuccessUpdateBalance
successUpdateBalance
)
{
}
@Override
public
void
onUpdateBalanceError
(
String
s
)
{
}
@Override
public
void
onBeginOperation
()
{
hasPendingOperation
=
true
;
Toast
.
makeText
(
this
,
"Begin Transaction"
,
Toast
.
LENGTH_SHORT
).
show
();
Log
.
d
(
TAG
,
"onBeginOperation: "
);
getWindow
().
addFlags
(
WindowManager
.
LayoutParams
.
FLAG_KEEP_SCREEN_ON
);
displayResult
(
R
.
color
.
text_normal
,
R
.
string
.
keep_tap
);
// showProgressBar();
findViewById
(
R
.
id
.
lyUpdateBalance
).
setVisibility
(
View
.
GONE
);
}
@Override
public
void
onInitReaderComplete
(
InitReader
reader
)
{
}
private
void
displayResult
(
int
p
,
int
p2
)
{
txtStatus
.
setTextColor
(
getColorRes
(
p
));
txtStatus
.
setText
(
p2
);
}
private
int
getColorRes
(
int
res
)
{
if
(
Build
.
VERSION
.
SDK_INT
<
23
)
{
return
getResources
().
getColor
(
res
);
}
return
getColor
(
res
);
}
// private void showProgressBar() {
// pgProcess.setVisibility(View.VISIBLE);
// }
private
void
execute
(
Tag
tag
)
{
Log
.
d
(
"Execute"
,
"--> execute"
);
if
(
reader
!=
null
)
{
cardProcessor
=
new
MainCardProcessor
(
this
,
reader
,
new
UpdateBalanceView
()
{
@Override
public
void
onUpdateBalanceSuccess
(
SuccessUpdateBalance
successUpdateBalance
)
{
runOnUiThread
(()
->
onUpdateBalaceSuccess
(
successUpdateBalance
));
}
@Override
public
void
onUpdateBalanceError
(
String
reason
)
{
runOnUiThread
(()
->
onUpdateBalanceError
(
reason
));
}
@Override
public
void
onCardDetected
(
CardInfo
cardInfo
)
{
runOnUiThread
(()
->
onBalanceInfoAvailable
(
cardInfo
));
}
@Override
public
void
onErrorNfcCardMsg
(
int
errorCode
)
{
runOnUiThread
(()
->
onUpdateBalanceError
(
""
));
}
},
ApiUtils
.
dev_environment
);
if
(
tag
!=
null
)
{
cardProcessor
.
lockIsoDepCard
(
tag
);
String
cardUid
=
ByteArrayToHexString
(
tag
.
getId
());
Log
.
d
(
"TagFromIntent"
,
cardUid
);
boolean
hasCardUid
=
!
cardUid
.
isEmpty
();
if
(
hasCardUid
)
{
Log
.
d
(
TAG
,
"---> Send to UI Card Found"
);
runOnUiThread
(
this
::
onNfcCardFound
);
CardInfoCommand
command
=
new
CardInfoCommand
(
reader
.
myReader
);
Log
.
e
(
"myReader"
,
"Myreader : "
+
reader
.
myReader
);
final
CommandResult
<
CardInfo
>
execute
=
command
.
execute
(
cardUid
);
CardInfo
detectedCardInfo
=
execute
.
getResult
();
Log
.
d
(
"executeSuccess"
,
"executeIsSuccess = "
+
execute
.
isSuccess
());
if
(
execute
.
isSuccess
())
{
if
(
detectedCardInfo
.
getBankType
().
toLowerCase
().
contains
(
"dki"
)
||
detectedCardInfo
.
getBankType
().
toLowerCase
().
contains
(
"bca"
))
{
runOnUiThread
(()
->
{
onBalanceInfoAvailable
(
detectedCardInfo
);
pgProcess
.
setVisibility
(
View
.
GONE
);
txtStatus
.
setText
(
R
.
string
.
tap_card
);
});
}
else
{
// cardProcessor.getBalance(detectedCardInfo, null);
cardProcessor
.
updateBalance
(
detectedCardInfo
,
1
,
null
);
}
}
else
{
runOnUiThread
(()
->
{
Log
.
e
(
"error"
,
"Messagenya : "
+
execute
.
getMessage
());
onUpdateBalanceError
(
"Kartu tidak terdeteksi"
);
cardProcessor
.
unlockIsoDepCard
();
});
}
cardProcessor
.
unlockIsoDepCard
();
}
else
{
//wrong card type
cardProcessor
.
unlockIsoDepCard
();
}
}
else
{
CardInfoCommand
command
=
new
CardInfoCommand
(
reader
.
myReader
);
Log
.
e
(
"myReader"
,
"Myreader : "
+
reader
.
myReader
);
String
cardUID
=
cardProcessor
.
findCardUid
();
final
CommandResult
<
CardInfo
>
execute
=
command
.
execute
(
cardUID
);
CardInfo
detectedCardInfo
=
execute
.
getResult
();
Log
.
d
(
"executeSuccess"
,
"executeIsSuccess = "
+
execute
.
isSuccess
());
if
(
execute
.
isSuccess
())
{
if
(
detectedCardInfo
.
getBankType
().
toLowerCase
().
contains
(
"dki"
)
||
detectedCardInfo
.
getBankType
().
toLowerCase
().
contains
(
"bca"
))
{
runOnUiThread
(()
->
{
onBalanceInfoAvailable
(
detectedCardInfo
);
pgProcess
.
setVisibility
(
View
.
GONE
);
txtStatus
.
setText
(
R
.
string
.
tap_card
);
});
}
else
{
// cardProcessor.getBalance(detectedCardInfo, null);
cardProcessor
.
updateBalance
(
detectedCardInfo
,
1
,
null
);
}
}
else
{
CardBalanceAPDUResponse
cardBalanceAPDUResponse
=
cardProcessor
.
getBalance
();
CardInfo
cardInfo
=
new
CardInfo
(
cardBalanceAPDUResponse
.
getBalance
(),
cardBalanceAPDUResponse
.
getCardNumber
(),
"Mandiri"
,
cardBalanceAPDUResponse
.
getCardUid
());
onBalanceInfoAvailable
(
cardInfo
);
}
}
}
}
}
app/src/main/res/layout/activity_main.xml
View file @
7496aa08
...
...
@@ -101,13 +101,15 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:paddingLeft=
"16dp"
android:paddingRight=
"16dp"
>
<ProgressBar
android:id=
"@+id/pgProcess"
android:layout_width=
"28dp"
android:layout_height=
"28dp"
android:layout_marginRight=
"4dp"
/>
android:layout_marginRight=
"4dp"
android:visibility=
"gone"
/>
<TextView
android:id=
"@+id/txtStatus"
...
...
@@ -233,10 +235,11 @@
android:text=
"1.0.1"
android:textColor=
"#dcdcdc"
/>
</LinearLayout>
<ProgressBar
android:id=
"@+id/pbloading"
android:layout_width=
"75dp"
android:layout_height=
"match_parent"
android:layout_gravity=
"center"
android:visibility=
"
visible"
/>
android:visibility=
"
gone"
/>
</LinearLayout>
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