Browse Source

Back button handled

master
preyearegmi 6 years ago
parent
commit
267f8cd20d
  1. 84
      app/src/main/java/com/gmeremit/online/gmeremittance_native/registerV2/view/RegisterV2Activity.java

84
app/src/main/java/com/gmeremit/online/gmeremittance_native/registerV2/view/RegisterV2Activity.java

@ -119,7 +119,7 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
dobContainerOnClickGestureDetector = new RegisterDobClickGestureDetector();
dobConatinerClickGestureDetector = new GestureDetectorCompat(this, dobContainerOnClickGestureDetector);
securityKeyboardPasswordListener=new SecurityKeypadPasswordListener();
securityKeyboardPasswordListener = new SecurityKeypadPasswordListener();
securityKeyboardPasswordView.setKeyboardContainerView(keypadContainer);
securityKeyboardPasswordView.setKeyboardBallonView(ballonView);
try {
@ -141,7 +141,7 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
Log.d("GMESecurityKeyboard", e.getMessage());
}
securityKeyboardConfirmPasswordListener=new SecurityKeypadConfirmPasswordListener();
securityKeyboardConfirmPasswordListener = new SecurityKeypadConfirmPasswordListener();
securityKeyboardConfirmPasswordView.setKeyboardContainerView(keypadContainer);
securityKeyboardConfirmPasswordView.setKeyboardBallonView(ballonView);
try {
@ -192,7 +192,7 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
return (securityKeyboardPasswordView.checkIfTouchIntersectKeypadLayout(ev)||securityKeyboardConfirmPasswordView.checkIfTouchIntersectKeypadLayout(ev)||dobConatinerClickGestureDetector.onTouchEvent(ev)|| super.dispatchTouchEvent(ev));
return (securityKeyboardPasswordView.checkIfTouchIntersectKeypadLayout(ev) || securityKeyboardConfirmPasswordView.checkIfTouchIntersectKeypadLayout(ev) || dobConatinerClickGestureDetector.onTouchEvent(ev) || super.dispatchTouchEvent(ev));
}
@ -283,6 +283,15 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
return false;
}
@Override
public void onBackPressed() {
if (securityKeyboardPasswordManager != null && securityKeyboardPasswordManager.isKeyboardVisible())
securityKeyboardPasswordManager.hideKeyboard();
else if (securityKeyboardConfirmPasswordManager != null && securityKeyboardConfirmPasswordManager.isKeyboardVisible())
securityKeyboardConfirmPasswordManager.hideKeyboard();
else
super.onBackPressed();
}
class RegisterDobClickGestureDetector extends GestureDetector.SimpleOnGestureListener {
@Override
@ -315,24 +324,23 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
}
class SecurityKeypadPasswordListener implements SecurityKeyboardManager.SecurityKeyboardActionListenerFacade,SecurityKeyboardView.SecurityKeyboardFocusStateListener {
class SecurityKeypadPasswordListener implements SecurityKeyboardManager.SecurityKeyboardActionListenerFacade, SecurityKeyboardView.SecurityKeyboardFocusStateListener {
@Override
public void done(Intent intent) {
String encryptedText=intent.getStringExtra(TransKeyActivity.mTK_PARAM_SECURE_DATA);
Log.d("RegisterScreen",encryptedText);
presenter.updatePassword(intent.getStringExtra(encryptedText),getDecryptedDataFromIntent(intent));
String encryptedText = intent.getStringExtra(TransKeyActivity.mTK_PARAM_SECURE_DATA);
Log.d("RegisterScreen", encryptedText);
presenter.updatePassword(intent.getStringExtra(encryptedText), getDecryptedDataFromIntent(intent));
}
@Override
public void cancel(Intent intent) {
String encryptedText=intent.getStringExtra(TransKeyActivity.mTK_PARAM_SECURE_DATA);
Log.d("RegisterScreen",encryptedText);
presenter.updatePassword(encryptedText,getDecryptedDataFromIntent(intent));
String encryptedText = intent.getStringExtra(TransKeyActivity.mTK_PARAM_SECURE_DATA);
Log.d("RegisterScreen", encryptedText);
presenter.updatePassword(encryptedText, getDecryptedDataFromIntent(intent));
}
private String getDecryptedDataFromIntent(Intent intent)
{
private String getDecryptedDataFromIntent(Intent intent) {
if (intent == null)
return "";
@ -340,8 +348,8 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
byte[] secureKey = intent.getByteArrayExtra(TransKeyActivity.mTK_PARAM_SECURE_KEY);
int iRealDataLength = intent.getIntExtra(TransKeyActivity.mTK_PARAM_DATA_LENGTH, 0);
Log.d("EncryptedData",cipherData);
return EncryptionManager.decryptCipherText(cipherData,secureKey,iRealDataLength);
Log.d("EncryptedData", cipherData);
return EncryptionManager.decryptCipherText(cipherData, secureKey, iRealDataLength);
}
@ -366,9 +374,9 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
if (securityKeyboardPasswordManager != null && !securityKeyboardPasswordManager.isKeyboardVisible()) {
hideKeyBoard();
securityKeyboardPasswordManager.showKeyboard();
scrollView.postDelayed(()->{
scrollView.postDelayed(() -> {
scrollView.smoothScrollTo(0, passwordTextView.getTop());
},250);
}, 250);
}
}
@ -377,39 +385,37 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
public void onSecurityViewLostFocus() {
if (securityKeyboardPasswordManager != null && securityKeyboardPasswordManager.isKeyboardVisible()) {
securityKeyboardPasswordManager.hideKeyboard();
Log.d("RegisterScreen","PasswordKeyboard Hide");
}
else
Log.d("RegisterScreen", "PasswordKeyboard Hide");
} else
hideKeyBoard();
}
//In some cases remaining keyboard widget may still be focusable as our layout can be scrolled for which the on screen location of remaining widget may be false
private void hideKeyboardFromRemainingWidget()
{
if(securityKeyboardConfirmPasswordManager!=null&&securityKeyboardConfirmPasswordManager.isKeyboardVisible())
private void hideKeyboardFromRemainingWidget() {
if (securityKeyboardConfirmPasswordManager != null && securityKeyboardConfirmPasswordManager.isKeyboardVisible())
securityKeyboardConfirmPasswordManager.hideKeyboard();
}
}
class SecurityKeypadConfirmPasswordListener implements SecurityKeyboardManager.SecurityKeyboardActionListenerFacade,SecurityKeyboardView.SecurityKeyboardFocusStateListener {
class SecurityKeypadConfirmPasswordListener implements SecurityKeyboardManager.SecurityKeyboardActionListenerFacade, SecurityKeyboardView.SecurityKeyboardFocusStateListener {
@Override
public void done(Intent intent) {
String encryptedText=intent.getStringExtra(TransKeyActivity.mTK_PARAM_SECURE_DATA);
Log.d("RegisterScreen",encryptedText);
presenter.updateConfirmPassword(encryptedText,getDecryptedDataFromIntent(intent));
String encryptedText = intent.getStringExtra(TransKeyActivity.mTK_PARAM_SECURE_DATA);
Log.d("RegisterScreen", encryptedText);
presenter.updateConfirmPassword(encryptedText, getDecryptedDataFromIntent(intent));
}
@Override
public void cancel(Intent intent) {
String encryptedText=intent.getStringExtra(TransKeyActivity.mTK_PARAM_SECURE_DATA);
Log.d("RegisterScreen",encryptedText);
presenter.updateConfirmPassword(encryptedText,getDecryptedDataFromIntent(intent));
String encryptedText = intent.getStringExtra(TransKeyActivity.mTK_PARAM_SECURE_DATA);
Log.d("RegisterScreen", encryptedText);
presenter.updateConfirmPassword(encryptedText, getDecryptedDataFromIntent(intent));
}
private String getDecryptedDataFromIntent(Intent intent)
{
private String getDecryptedDataFromIntent(Intent intent) {
if (intent == null)
return "";
@ -417,7 +423,7 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
byte[] secureKey = intent.getByteArrayExtra(TransKeyActivity.mTK_PARAM_SECURE_KEY);
int iRealDataLength = intent.getIntExtra(TransKeyActivity.mTK_PARAM_DATA_LENGTH, 0);
return EncryptionManager.decryptCipherText(cipherData,secureKey,iRealDataLength);
return EncryptionManager.decryptCipherText(cipherData, secureKey, iRealDataLength);
}
@ -443,9 +449,9 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
hideKeyBoard();
securityKeyboardConfirmPasswordManager.showKeyboard();
scrollView.postDelayed(()->{
scrollView.postDelayed(() -> {
scrollView.smoothScrollTo(0, confirmPasswordTextView.getTop());
},250);
}, 250);
}
}
@ -454,16 +460,14 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
public void onSecurityViewLostFocus() {
if (securityKeyboardConfirmPasswordManager != null && securityKeyboardConfirmPasswordManager.isKeyboardVisible()) {
securityKeyboardConfirmPasswordManager.hideKeyboard();
Log.d("RegisterScreen","PasswordConfirmKeyboard Hide");
}
else
Log.d("RegisterScreen", "PasswordConfirmKeyboard Hide");
} else
hideKeyBoard();
}
//In some cases remaining keyboard widget may still be focusable as our layout can be scrolled for which the on screen location of remaining widget may be false
private void hideKeyboardFromRemainingWidget()
{
if(securityKeyboardPasswordManager!=null&&securityKeyboardPasswordManager.isKeyboardVisible())
private void hideKeyboardFromRemainingWidget() {
if (securityKeyboardPasswordManager != null && securityKeyboardPasswordManager.isKeyboardVisible())
securityKeyboardPasswordManager.hideKeyboard();
}
}

Loading…
Cancel
Save