@ -51,11 +51,11 @@ public class FingerPrintAuthPromptDialog extends android.support.v4.app.DialogFr
public Dialog onCreateDialog ( Bundle savedInstanceState ) {
public Dialog onCreateDialog ( Bundle savedInstanceState ) {
AlertDialog . Builder builder = new AlertDialog . Builder ( getActivity ( ) ) ;
AlertDialog . Builder builder = new AlertDialog . Builder ( getActivity ( ) ) ;
View view = getActivity ( ) . getLayoutInflater ( ) . inflate ( R . layout . dialog_fingerprint_auth_prompt , null ) ;
View view = getActivity ( ) . getLayoutInflater ( ) . inflate ( R . layout . dialog_fingerprint_auth_prompt , null ) ;
fingerprintScannerImgView = view . findViewById ( R . id . fingerprintScannerImgView ) ;
cancelView = view . findViewById ( R . id . btnCancel ) ;
fingerprintScannerImgView = view . findViewById ( R . id . fingerprintScannerImgView ) ;
cancelView = view . findViewById ( R . id . btnCancel ) ;
builder . setView ( view ) ;
builder . setView ( view ) ;
initialize ( ) ;
initialize ( ) ;
Dialog dialog = builder . create ( ) ;
Dialog dialog = builder . create ( ) ;
try {
try {
this . window = dialog . getWindow ( ) ;
this . window = dialog . getWindow ( ) ;
window . setBackgroundDrawableResource ( R . drawable . ic_rounded_white ) ;
window . setBackgroundDrawableResource ( R . drawable . ic_rounded_white ) ;
@ -73,10 +73,9 @@ public class FingerPrintAuthPromptDialog extends android.support.v4.app.DialogFr
}
}
public void setFingerprintAuthListener ( boolean userAction , FingerprintAuthListener listener )
{
this . userAction = userAction ;
this . listener = listener ;
public void setFingerprintAuthListener ( boolean userAction , FingerprintAuthListener listener ) {
this . userAction = userAction ;
this . listener = listener ;
}
}
@Override
@Override
@ -85,10 +84,10 @@ public class FingerPrintAuthPromptDialog extends android.support.v4.app.DialogFr
cancelView . setOnClickListener ( new View . OnClickListener ( ) {
cancelView . setOnClickListener ( new View . OnClickListener ( ) {
@Override
@Override
public void onClick ( View v ) {
public void onClick ( View v ) {
dismiss ( ) ;
dismiss ( ) ;
}
}
} ) ;
} ) ;
if ( fingerPrintReaderSubs = = null | | fingerPrintReaderSubs . isDisposed ( ) )
if ( fingerPrintReaderSubs = = null | | fingerPrintReaderSubs . isDisposed ( ) )
fingerPrintReaderSubs = startObservingFingerPrintScanner ( ) ;
fingerPrintReaderSubs = startObservingFingerPrintScanner ( ) ;
}
}
@ -122,7 +121,7 @@ public class FingerPrintAuthPromptDialog extends android.support.v4.app.DialogFr
fingerPrintAVDCompat . start ( ) ;
fingerPrintAVDCompat . start ( ) ;
}
}
} , 200 ) ;
} , 200 ) ;
} else {
} else {
new Handler ( ) . postDelayed ( ( ) - > {
new Handler ( ) . postDelayed ( ( ) - > {
fingerprintScannerImgView . setImageDrawable ( null ) ;
fingerprintScannerImgView . setImageDrawable ( null ) ;
@ -147,12 +146,11 @@ public class FingerPrintAuthPromptDialog extends android.support.v4.app.DialogFr
} )
} )
. observeOn ( AndroidSchedulers . mainThread ( ) )
. observeOn ( AndroidSchedulers . mainThread ( ) )
. retryWhen ( errors - > errors . flatMap (
error - > {
if ( error instanceof SecurityUtils . FailedFingerPrintException | | error instanceof SecurityUtils . SensorNotReadyException )
{
. retryWhen ( errors - > errors . flatMap (
error - > {
if ( error instanceof SecurityUtils . FailedFingerPrintException | | error instanceof SecurityUtils . SensorNotReadyException ) {
showToastMessage ( error . getMessage ( ) ) ;
showToastMessage ( error . getMessage ( ) ) ;
return Observable . timer ( 100 , TimeUnit . MILLISECONDS ) ;
return Observable . timer ( 100 , TimeUnit . MILLISECONDS ) ;
}
}
return Observable . error ( error ) ;
return Observable . error ( error ) ;
}
}
@ -161,9 +159,9 @@ public class FingerPrintAuthPromptDialog extends android.support.v4.app.DialogFr
}
}
private void showToastMessage ( String message ) {
private void showToastMessage ( String message ) {
Toast toast = Toast . makeText ( getActivity ( ) , message , Toast . LENGTH_SHORT ) ;
Toast toast = Toast . makeText ( getActivity ( ) , message , Toast . LENGTH_SHORT ) ;
TextView v = ( TextView ) toast . getView ( ) . findViewById ( android . R . id . message ) ;
TextView v = ( TextView ) toast . getView ( ) . findViewById ( android . R . id . message ) ;
if ( v ! = null ) v . setGravity ( Gravity . CENTER ) ;
if ( v ! = null ) v . setGravity ( Gravity . CENTER ) ;
toast . show ( ) ;
toast . show ( ) ;
}
}
@ -173,16 +171,16 @@ public class FingerPrintAuthPromptDialog extends android.support.v4.app.DialogFr
@Override
@Override
public void onNext ( FingerprintAuthenticationResult fingerprintAuthenticationResult ) {
public void onNext ( FingerprintAuthenticationResult fingerprintAuthenticationResult ) {
if ( listener ! = null )
listener . onFingerPrintAuthenticated ( userAction ) ;
if ( listener ! = null )
listener . onFingerPrintAuthenticated ( userAction ) ;
}
}
@Override
@Override
public void onError ( Throwable e ) {
public void onError ( Throwable e ) {
if ( Build . VERSION . SDK_INT > = Build . VERSION_CODES . M & & e instanceof KeyPermanentlyInvalidatedException ) {
if ( Build . VERSION . SDK_INT > = Build . VERSION_CODES . M & & e instanceof KeyPermanentlyInvalidatedException ) {
listener . onFingerPrintInvalidatedBySystem ( ) ;
listener . onFingerPrintInvalidatedBySystem ( ) ;
}
showToastMessage ( e . getMessage ( ) ) ;
} else
showToastMessage ( e . getMessage ( ) ) ;
}
}
@Override
@Override
@ -192,9 +190,9 @@ public class FingerPrintAuthPromptDialog extends android.support.v4.app.DialogFr
}
}
public interface FingerprintAuthListener
{
public interface FingerprintAuthListener {
void onFingerPrintAuthenticated ( boolean userAction ) ;
void onFingerPrintAuthenticated ( boolean userAction ) ;
void onFingerPrintInvalidatedBySystem ( ) ;
void onFingerPrintInvalidatedBySystem ( ) ;
}
}
}
}