11package kr .co .bootpay .bio .activity ;
22
33import android .app .AlertDialog ;
4+ import android .app .ProgressDialog ;
45import android .content .Context ;
56import android .content .DialogInterface ;
67import android .content .Intent ;
8+ import android .graphics .PorterDuff ;
79import android .graphics .Typeface ;
10+ import android .graphics .drawable .Drawable ;
11+ import android .os .Build ;
812import android .os .Bundle ;
913import android .os .Handler ;
1014import android .os .Looper ;
1115import android .os .PersistableBundle ;
1216import android .os .Vibrator ;
1317import android .util .Log ;
1418import android .util .TypedValue ;
19+ import android .view .Gravity ;
1520import android .view .View ;
1621import android .widget .HorizontalScrollView ;
1722import android .widget .LinearLayout ;
23+ import android .widget .ProgressBar ;
1824import android .widget .TextView ;
1925import android .widget .Toast ;
2026
5965import kr .co .bootpay .pref .UserInfo ;
6066import kr .co .bootpay .rest .BootpayBioRestImplement ;
6167
62- import static android .view .View .TEXT_ALIGNMENT_TEXT_END ;
6368
6469public class BootpayBioActivity extends FragmentActivity implements BootpayBioRestImplement {
6570
@@ -91,6 +96,8 @@ public class BootpayBioActivity extends FragmentActivity implements BootpayBioRe
9196 View quota_line ;
9297 int currentIndex = 0 ;
9398
99+ ProgressDialog progress ;
100+
94101 @ Override
95102 protected void onCreate (@ Nullable Bundle savedInstanceState ) {
96103 super .onCreate (savedInstanceState );
@@ -101,6 +108,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
101108 this .presenter = new BioApiPresenter (new ApiService (this .context ), this );
102109 request = CurrentBioRequest .getInstance ().request ;
103110 if (request != null ) bioPayload = request .getBioPayload ();
111+ initProgressCircle ();
104112
105113 CurrentBioRequest .getInstance ().bioActivity = this ;
106114
@@ -112,6 +120,20 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
112120 setQuotaValue ();
113121 }
114122
123+ void initProgressCircle () {
124+ progress = new ProgressDialog (context , R .style .BootpayDialogStyle );
125+
126+ progress .setIndeterminate (true );
127+ progress .setCancelable (false );
128+
129+ if (Build .VERSION .SDK_INT < Build .VERSION_CODES .LOLLIPOP ) {
130+ Drawable drawable = new ProgressBar (this ).getIndeterminateDrawable ().mutate ();
131+ drawable .setColorFilter (ContextCompat .getColor (this , R .color .colorAccent ),
132+ PorterDuff .Mode .SRC_IN );
133+ progress .setIndeterminateDrawable (drawable );
134+ }
135+ }
136+
115137 void setQuotaValue () {
116138 if (request == null ) return ;
117139 quota_layout .setVisibility (request .getPrice () < 50000 ? View .GONE : View .VISIBLE );
@@ -216,7 +238,8 @@ private void setNameViews() {
216238 for (String name : bioPayload .getNames ()) {
217239 TextView text = new TextView (context );
218240 LinearLayout .LayoutParams params = new LinearLayout .LayoutParams (LinearLayout .LayoutParams .MATCH_PARENT , LinearLayout .LayoutParams .WRAP_CONTENT );
219- text .setTextAlignment (TEXT_ALIGNMENT_TEXT_END );
241+ // text.setTextAlignment(TEXT_ALIGNMENT_TEXT_END);
242+ text .setGravity (Gravity .RIGHT );
220243 text .setLayoutParams (params );
221244 text .setText (name );
222245 text .setTextColor (getResources ().getColor (R .color .black , null ));
@@ -244,7 +267,8 @@ private void setPriceViews() {
244267 TextView right = new TextView (context );
245268 LinearLayout .LayoutParams params2 = new LinearLayout .LayoutParams (0 , LinearLayout .LayoutParams .WRAP_CONTENT , 1.0f );
246269 right .setLayoutParams (params2 );
247- right .setTextAlignment (TEXT_ALIGNMENT_TEXT_END );
270+ right .setGravity (Gravity .RIGHT );
271+ // right.setTextAlignment(TEXT_ALIGNMENT_TEXT_END);
248272 right .setTextSize (TypedValue .COMPLEX_UNIT_SP , 14 );
249273 right .setText (getComma (bioPrice .getPrice ()));
250274 right .setTextColor (getResources ().getColor (R .color .black , null ));
@@ -270,7 +294,8 @@ private void setPriceViews() {
270294 TextView right = new TextView (context );
271295 LinearLayout .LayoutParams params2 = new LinearLayout .LayoutParams (0 , LinearLayout .LayoutParams .WRAP_CONTENT , 1.0f );
272296 right .setLayoutParams (params2 );
273- right .setTextAlignment (TEXT_ALIGNMENT_TEXT_END );
297+ right .setGravity (Gravity .RIGHT );
298+ // right.setTextAlignment(TEXT_ALIGNMENT_TEXT_END);
274299 right .setTextSize (TypedValue .COMPLEX_UNIT_SP , 16 );
275300 right .setTypeface (left .getTypeface (), Typeface .BOLD );
276301 right .setText (getComma (request .getPrice ()));
@@ -336,9 +361,22 @@ void goBioPayRequest(String passwordToken) {
336361 }
337362 otp = getOTPValue (key );
338363 }
364+
365+ showProgress ("결제 요청중" );
339366 presenter .postEasyCardRequest (uuid , userToken , otp , passwordToken , bioWallet .wallet_id , "" , CurrentBioRequest .getInstance ().request .getPayload ());
340367 }
341368
369+ void showProgress (final String msg ) {
370+ Handler handler = new Handler (Looper .getMainLooper ());
371+ handler .post (new Runnable () {
372+ @ Override
373+ public void run () {
374+ progress .setMessage (msg );
375+ progress .show ();
376+ }
377+ });
378+ }
379+
342380 String getOTPValue (String key ) {
343381 CodeGenerator generator = new DefaultCodeGenerator (HashingAlgorithm .SHA512 , 8 );
344382 long time = Long .valueOf (server_unixtime ) / 30 ;
@@ -359,6 +397,7 @@ void goRegisterBiometricRequest() {
359397 if (uuid == null || "" .equals (uuid )) { Log .d ("bootpay" , "uuid 값이 없습니다" ); return ; }
360398 if (userToken == null || "" .equals (userToken )) { Log .d ("bootpay" , "userToken 값이 없습니다" ); return ; }
361399
400+ showProgress ("결제권한 추가중" );
362401 presenter .postEasyBiometric (uuid , userToken , passwordToken );
363402 }
364403
@@ -373,17 +412,21 @@ void goAuthRegisterBiometricOTP() {
373412 if ("" .equals (otp )) return ;
374413 String uuid = UserInfo .getInstance (context ).getBootpayUuid ();
375414 String userToken = request .getEasyPayUserToken ();
415+
416+ showProgress ("결제 요청중" );
376417 presenter .postEasyBiometricRegister (uuid , userToken , otp );
377418 }
378419
379420
380421
381422 @ Override
382423 public void callbackEasyBiometric (ResEasyBiometric res ) {
424+ progress .dismiss ();
383425 if (res .code != 0 ) {
384426 goPopUpError (res .message );
385427 return ;
386428 }
429+
387430 easyBiometric = res ;
388431 server_unixtime = res .data .server_unixtime ;
389432 saveBiometricKey ();
@@ -415,6 +458,8 @@ public void transactionConfirm(String data) {
415458
416459 String uuid = UserInfo .getInstance (context ).getBootpayUuid ();
417460 String userToken = request .getEasyPayUserToken ();
461+
462+ showProgress ("결제 승인중" );
418463 presenter .postEasyConfirm (uuid , userToken , res .data .receipt_id );
419464 } catch (Exception e ) {
420465 e .printStackTrace ();
@@ -423,6 +468,7 @@ public void transactionConfirm(String data) {
423468
424469 @ Override
425470 public void callbacktEasyBiometricRegister (ResEasyBiometric res ) {
471+ progress .dismiss ();
426472 if (res .code != 0 ) {
427473 goPopUpError (res .message );
428474 return ;
@@ -442,13 +488,14 @@ public void callbackEasyCardWallet(ResWalletList res) {
442488 server_unixtime = res .data .user .server_unixtime ;
443489 setCardPager (res .data );
444490 if (CurrentBioRequest .getInstance ().type == CurrentBioRequest .REQUEST_TYPE_REGISTER_CARD ) {
445- goBiometricAuth ( );
491+ goPopup ( "이 기기에서 결제할 수 있도록 설정합니다. (최초 1회)" );
446492 }
447493 }
448494
449495
450496 @ Override
451497 public void callbackEasyCardRequest (ResReceiptID res ) {
498+ progress .dismiss ();
452499 if (res .code != 0 ) {
453500 goPopUpError (res .message );
454501 return ;
@@ -460,6 +507,7 @@ public void callbackEasyCardRequest(ResReceiptID res) {
460507
461508 @ Override
462509 public void callbackEasyTransaction (String data ) {
510+ progress .dismiss ();
463511 DoneListener done = CurrentBioRequest .getInstance ().done ;
464512 if (done != null ) done .onDone (data );
465513 }
@@ -513,7 +561,13 @@ public void onAuthenticationFailed() {
513561 }
514562
515563 void goBiometricAuth () {
516- biometricPrompt .authenticate (promptInfo );
564+ Handler handler = new Handler (Looper .getMainLooper ());
565+ handler .post (new Runnable () {
566+ @ Override
567+ public void run () {
568+ biometricPrompt .authenticate (promptInfo );
569+ }
570+ });
517571 }
518572
519573 void goPopUpVerifyForPay () {
@@ -522,7 +576,6 @@ void goPopUpVerifyForPay() {
522576 handler .post (new Runnable () {
523577 @ Override
524578 public void run () {
525-
526579 isBioFailPopUp = true ;
527580 AlertDialog .Builder builder = new AlertDialog .Builder (context , R .style .AlertDialogStyle );
528581 builder .setMessage ("지문인식에 여러 번 실패하여, 비밀번호로 결제합니다." );
@@ -575,23 +628,58 @@ public void startBioPay(BioDeviceUse user, BioWallet bioWallet) {
575628 }
576629
577630
578- void goPopup (String msg ) {
579- AlertDialog .Builder builder = new AlertDialog .Builder (context , R .style .AlertDialogStyle );
580- // builder.se
581- builder .setMessage (msg );
582- builder .setPositiveButton ("확인" , new DialogInterface .OnClickListener () {
583- @ Override
584- public void onClick (DialogInterface dialogInterface , int i ) {
585- CurrentBioRequest .getInstance ().type = CurrentBioRequest .REQUEST_TYPE_ENABLE_DEVICE ;
586- goVeiryPassword ();
587- }
588- }).setNegativeButton ("취소" , new DialogInterface .OnClickListener () {
631+ void goPopup (final String msg ) {
632+ Handler handler = new Handler (Looper .getMainLooper ());
633+ handler .post (new Runnable () {
589634 @ Override
590- public void onClick (DialogInterface dialogInterface , int i ) {
591- dialogInterface .dismiss ();
635+ public void run () {
636+ AlertDialog .Builder builder = new AlertDialog .Builder (context , R .style .AlertDialogStyle );
637+ builder .setMessage (msg );
638+ builder .setPositiveButton ("확인" , new DialogInterface .OnClickListener () {
639+ @ Override
640+ public void onClick (DialogInterface dialogInterface , int i ) {
641+ CurrentBioRequest .getInstance ().type = CurrentBioRequest .REQUEST_TYPE_ENABLE_DEVICE ;
642+ goVeiryPassword ();
643+ }
644+ }).setNegativeButton ("취소" , new DialogInterface .OnClickListener () {
645+ @ Override
646+ public void onClick (DialogInterface dialogInterface , int i ) {
647+ dialogInterface .dismiss ();
648+ }
649+ });
650+ AlertDialog alertDialog = builder .create ();
651+ alertDialog .show ();
592652 }
593653 });
594- AlertDialog alertDialog = builder .create ();
595- alertDialog .show ();
654+ }
655+
656+ @ Override
657+ public void onActivityResult (int requestCode , int resultCode , Intent data ) {
658+ super .onActivityResult (requestCode , resultCode , data );
659+
660+ if (requestCode == 9999 && resultCode > 0 ) {
661+ //wallet 재갱신
662+ if (CurrentBioRequest .getInstance ().type == CurrentBioRequest .REQUEST_TYPE_VERIFY_PASSWORD ) {
663+ //지문인식 후
664+ goRegisterBiometricRequest ();
665+ } else if (CurrentBioRequest .getInstance ().type == CurrentBioRequest .REQUEST_TYPE_ENABLE_DEVICE ) {
666+ //지문인식 후
667+ goRegisterBiometricRequest ();
668+ //otp 등록해야함
669+ } else if (CurrentBioRequest .getInstance ().type == CurrentBioRequest .REQUEST_TYPE_VERIFY_PASSWORD_FOR_PAY ) {
670+ //비밀번호로 결제
671+ if (CurrentBioRequest .getInstance ().token != null ) goBioPayRequest (CurrentBioRequest .getInstance ().token );
672+ } else if (CurrentBioRequest .getInstance ().type == CurrentBioRequest .REQUEST_TYPE_REGISTER_CARD ) {
673+ //카드를 등록 했음
674+ getEasyCardWalletList ();
675+ } else if (CurrentBioRequest .getInstance ().type == CurrentBioRequest .REQUEST_TYPE_PASSWORD_CHANGE ) {
676+ //카드를 등록 했음
677+ getEasyCardWalletList ();
678+ } else if (CurrentBioRequest .getInstance ().type == CurrentBioRequest .REQUEST_TYPE_OTHER ) {
679+ Vibrator vibrator = (Vibrator ) context .getSystemService (Context .VIBRATOR_SERVICE );
680+ vibrator .vibrate (10 );
681+ finish ();
682+ }
683+ }
596684 }
597685}
0 commit comments