Browse Source

Register Screen ui revamped

master
Preyea Regmi 5 years ago
parent
commit
2df9872b6b
  1. 1228
      app/src/main/assets/nativecountrylist.json
  2. 21
      app/src/main/java/com/gmeremit/online/gmeremittance_native/base/BaseGateway.java
  3. 2
      app/src/main/java/com/gmeremit/online/gmeremittance_native/base/PrivilegedGateway.java
  4. 55
      app/src/main/java/com/gmeremit/online/gmeremittance_native/registerV2/gateway/RegisterV2Gateway.java
  5. 8
      app/src/main/java/com/gmeremit/online/gmeremittance_native/registerV2/presenter/RegisterV2InteractorInterface.java
  6. 158
      app/src/main/java/com/gmeremit/online/gmeremittance_native/registerV2/presenter/RegisterV2Presenter.java
  7. 25
      app/src/main/java/com/gmeremit/online/gmeremittance_native/registerV2/presenter/RegisterV2PresenterInterface.java
  8. 214
      app/src/main/java/com/gmeremit/online/gmeremittance_native/registerV2/view/RegisterV2Activity.java
  9. 6
      app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/security/SecurityUtils.java
  10. 8
      app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/security/securitykeypad/SecurityKeyboardManager.java
  11. 72
      app/src/main/res/layout/activity_register_v2.xml
  12. 2
      app/src/main/res/values/strings.xml

1228
app/src/main/assets/nativecountrylist.json
File diff suppressed because it is too large
View File

21
app/src/main/java/com/gmeremit/online/gmeremittance_native/base/BaseGateway.java

@ -1,4 +1,25 @@
package com.gmeremit.online.gmeremittance_native.base;
import android.content.Context;
import java.io.IOException;
import java.io.InputStream;
public class BaseGateway implements BaseGatewayInterface {
public String loadJSONFromAsset(Context context,String filePath) {
String json = null;
try {
InputStream is = context.getAssets().open(filePath);
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
json = new String(buffer, "UTF-8");
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
return json;
}
}

2
app/src/main/java/com/gmeremit/online/gmeremittance_native/base/PrivilegedGateway.java

@ -12,7 +12,7 @@ import static com.gmeremit.online.gmeremittance_native.base.PrefKeys.USER_PREFER
@SuppressWarnings("HardCodedStringLiteral")
public abstract class PrivilegedGateway implements PrivilegedGatewayInterface {
public abstract class PrivilegedGateway extends BaseGateway implements PrivilegedGatewayInterface {
private static PrivilegedGatewayDataObserverManager privilegedGatewayDataObserverManager = null;

55
app/src/main/java/com/gmeremit/online/gmeremittance_native/registerV2/gateway/RegisterV2Gateway.java

@ -1,56 +1,63 @@
package com.gmeremit.online.gmeremittance_native.registerV2.gateway;
import android.annotation.SuppressLint;
import android.content.Context;
import com.gmeremit.online.gmeremittance_native.GmeApplication;
import com.gmeremit.online.gmeremittance_native.base.PrefKeys;
import com.gmeremit.online.gmeremittance_native.base.PrivilegedGateway;
import com.gmeremit.online.gmeremittance_native.loginV2.presenter.LoginV2InteractorInterface;
import com.gmeremit.online.gmeremittance_native.recipientV2.model.recipientadd.AddRecipientApiResponse;
import com.gmeremit.online.gmeremittance_native.recipientV2.model.recipientlisting.GetAllRecipientApiResponse;
import com.gmeremit.online.gmeremittance_native.recipientV2.presenter.recipientlisting.RecipientListingV2InteractorInterface;
import com.gmeremit.online.gmeremittance_native.kycV2.model.kyc.NativeCountry;
import com.gmeremit.online.gmeremittance_native.registerV2.model.RegisterApiResponse;
import com.gmeremit.online.gmeremittance_native.registerV2.presenter.RegisterV2InteractorInterface;
import com.gmeremit.online.gmeremittance_native.utils.https.HttpClientV2;
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import java.util.List;
import io.reactivex.Observable;
import okhttp3.ResponseBody;
public class RegisterV2Gateway extends PrivilegedGateway implements RegisterV2InteractorInterface.Register2GatewayInterface {
private final RegisterV2InteractorInterface interactor;
public RegisterV2Gateway(RegisterV2InteractorInterface agentListV2InteractorInterface) {
this.interactor=agentListV2InteractorInterface;
this.interactor = agentListV2InteractorInterface;
}
@Override
public Observable<RegisterApiResponse> registerUser(String auth, String userName, String password,String confirmPassword, String dob, String clientId, String fcmId, String appVersion, String phoneBrand, String phoneOs, String deviceId, String osVersion) {
public Observable<RegisterApiResponse> registerUser(String auth, String userName, String password, String confirmPassword, String dob, String clientId, String fcmId, String appVersion, String phoneBrand, String phoneOs, String deviceId, String osVersion) {
JsonObject jsonObject=new JsonObject();
jsonObject.addProperty("username",userName);
jsonObject.addProperty("password",password);
jsonObject.addProperty("confirmPassword",confirmPassword);
jsonObject.addProperty("dob",dob);
jsonObject.addProperty("clientId",clientId);
jsonObject.addProperty("uuid",deviceId);
jsonObject.addProperty("appVersion",appVersion);
jsonObject.addProperty("phoneBrand",phoneBrand);
jsonObject.addProperty("phoneOS",phoneOs);
jsonObject.addProperty("fcmId",fcmId);
jsonObject.addProperty("osVersion",osVersion);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("username", userName);
jsonObject.addProperty("password", password);
jsonObject.addProperty("confirmPassword", confirmPassword);
jsonObject.addProperty("dob", dob);
jsonObject.addProperty("clientId", clientId);
jsonObject.addProperty("uuid", deviceId);
jsonObject.addProperty("appVersion", appVersion);
jsonObject.addProperty("phoneBrand", phoneBrand);
jsonObject.addProperty("phoneOS", phoneOs);
jsonObject.addProperty("fcmId", fcmId);
jsonObject.addProperty("osVersion", osVersion);
return HttpClientV2.getInstance().signUpV2(auth,jsonObject);
return HttpClientV2.getInstance().signUpV2(auth, jsonObject);
}
@SuppressLint("ApplySharedPref")
@Override
public void updateUserId(String userId) {
GmeApplication.getStorage().edit().putString(PrefKeys.USER_ID,userId).commit();
GmeApplication.getStorage().edit().putString(PrefKeys.USER_LOGGED_IN_STATUS,"HOME").apply();
GmeApplication.getStorage().edit().putString(PrefKeys.USER_ID, userId).commit();
GmeApplication.getStorage().edit().putString(PrefKeys.USER_LOGGED_IN_STATUS, "HOME").apply();
}
@Override
public Observable<List<NativeCountry>> getNativeCountryList(Context context) {
return Observable.fromCallable(() -> loadJSONFromAsset(context, "nativecountrylist.json"))
.map(nativeCountryJson -> HttpClientV2.getDeserializer().fromJson(nativeCountryJson, TypeToken.getParameterized(List.class, NativeCountry.class).getType()));
}
}

8
app/src/main/java/com/gmeremit/online/gmeremittance_native/registerV2/presenter/RegisterV2InteractorInterface.java

@ -1,11 +1,16 @@
package com.gmeremit.online.gmeremittance_native.registerV2.presenter;
import android.content.Context;
import com.gmeremit.online.gmeremittance_native.base.BaseInteractorInterface;
import com.gmeremit.online.gmeremittance_native.base.PrivilegedGatewayInterface;
import com.gmeremit.online.gmeremittance_native.kycV2.model.kyc.NativeCountry;
import com.gmeremit.online.gmeremittance_native.recipientV2.model.recipientadd.AddRecipientApiResponse;
import com.gmeremit.online.gmeremittance_native.recipientV2.model.recipientadd.RecipientRelatedDataApiResponse;
import com.gmeremit.online.gmeremittance_native.registerV2.model.RegisterApiResponse;
import java.util.List;
import io.reactivex.Observable;
import okhttp3.ResponseBody;
@ -15,8 +20,11 @@ public interface RegisterV2InteractorInterface extends BaseInteractorInterface {
interface Register2GatewayInterface extends PrivilegedGatewayInterface
{
Observable<RegisterApiResponse> registerUser(String auth, String userName, String password,String confirmPassword, String dob, String clientId, String fcmId, String appVersion, String phoneBrand, String phoneOs, String deviceId, String osVersion);
void updateUserId(String userId);
Observable<List<NativeCountry>> getNativeCountryList(Context context);
}
}

158
app/src/main/java/com/gmeremit/online/gmeremittance_native/registerV2/presenter/RegisterV2Presenter.java

@ -4,6 +4,7 @@ import com.gmeremit.online.gmeremittance_native.GmeApplication;
import com.gmeremit.online.gmeremittance_native.R;
import com.gmeremit.online.gmeremittance_native.base.BasePresenter;
import com.gmeremit.online.gmeremittance_native.customwidgets.CustomAlertDialog;
import com.gmeremit.online.gmeremittance_native.kycV2.model.kyc.NativeCountry;
import com.gmeremit.online.gmeremittance_native.registerV2.gateway.RegisterV2Gateway;
import com.gmeremit.online.gmeremittance_native.registerV2.model.RegisterApiResponse;
import com.gmeremit.online.gmeremittance_native.utils.Constants;
@ -11,110 +12,42 @@ import com.gmeremit.online.gmeremittance_native.utils.Utils;
import com.gmeremit.online.gmeremittance_native.utils.https.GenericApiObserverResponse;
import com.google.firebase.iid.FirebaseInstanceId;
import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers;
public class RegisterV2Presenter extends BasePresenter implements RegisterV2PresenterInterface, RegisterV2InteractorInterface {
private final RegisterV2Gateway gateway;
private final Register2GatewayInterface gateway;
private final RegisterV2ContractInterface view;
private CompositeDisposable compositeDisposable;
private List<NativeCountry> nativeCountryList;
private NativeCountry selectedNativeCountry;
private String encPassword;
private String encConfirmPassword;
private String selectedUserId;
private String selectedMobileNumber;
private boolean isSelectedNativeCountryValid;
public RegisterV2Presenter(RegisterV2PresenterInterface.RegisterV2ContractInterface view) {
this.view = view;
compositeDisposable=new CompositeDisposable();
this.gateway = new RegisterV2Gateway(this);
encPassword="";
encConfirmPassword="";
getDefaultData();
}
private void getDefaultData() {
this.compositeDisposable.add(
this.gateway.getNativeCountryList(view.getContext()).subscribe(nativeCountryList-> this.nativeCountryList=nativeCountryList));
@Deprecated
@Override
public boolean validatePasswords(String pwdString, String pwdConfrimString) {
boolean pwdValidation=true;
boolean confirmPwdValidation=true;
if (!Utils.hasSpecialCharacters(pwdString)) {
this.view.setPasswordError("Password should have at least one symbol");
pwdValidation= false;
}
if (!Utils.hasNumbers(pwdString)) {
this.view.setPasswordError("Password should have at least one number");
pwdValidation= false;
}
if (pwdString.length()>1&&pwdString.length()<9) {
this.view.setPasswordError("Password should have at least 9 characters");
pwdValidation= false;
}
if (!Utils.hasAtleastOnCapitalLetter(pwdString)) {
this.view.setPasswordError("Password should have at least one capital letter");
pwdValidation= false;
}
if(pwdString.trim().length()<1)
{
this.view.setPasswordError("Password cannot be empty");
pwdValidation= false;
}
if (!pwdString.equals(pwdConfrimString)) {
this.view.setConfirmPasswordError("Passwords does not match");
confirmPwdValidation= false;
}
if(pwdConfrimString==null||pwdConfrimString.trim().length()<1)
{
this.view.setConfirmPasswordError("Confirm password cannot be empty");
confirmPwdValidation= false;
}
if(pwdValidation) {
view.setPasswordError(null);
}
if(confirmPwdValidation)
{
view.setConfirmPasswordError(null);
}
return pwdValidation&&confirmPwdValidation;
}
/**
* Validation removed after implementing security keypad
* @return
*/
@Override
public boolean validatePasswords()
{
boolean pwdValidation=true;
boolean confirmPwdValidation=true;
if(encPassword==null||encPassword.trim().length()<1)
{
this.view.setPasswordError(getStringfromStringId(R.string.password_empty_error));
pwdValidation= false;
}
if(encConfirmPassword==null||encConfirmPassword.trim().length()<1)
{
this.view.setConfirmPasswordError(getStringfromStringId(R.string.confirm_passowrd_empty_error));
confirmPwdValidation= false;
}
if(pwdValidation) {
view.setPasswordError(null);
}
if(confirmPwdValidation)
{
view.setConfirmPasswordError(null);
}
return pwdValidation&&confirmPwdValidation;
}
@Override
public void registerUser(String userId, String password, String dob) {
@ -137,7 +70,7 @@ public class RegisterV2Presenter extends BasePresenter implements RegisterV2Pres
auth,
userId,
this.encPassword,
this.encConfirmPassword,
"",
dob,
"172017F9EC11222E8107142733",
fcmID,
@ -154,43 +87,47 @@ public class RegisterV2Presenter extends BasePresenter implements RegisterV2Pres
);
}
@Override
public boolean validateDob(String dobString) {
if(dobString==null||dobString.trim().length()<1)
{
this.view.setDobError(getStringfromStringId(R.string.dob_valid_error));
private boolean returnFalseIfMobileNoIsNotValid(String mobile) {
if (mobile == null || mobile.length() < 1) {
this.view.setMobileError(getStringfromStringId(R.string.kyc_mobile_empty_error));
return false;
}
if (!Utils.hasNumbersOnly(mobile) || mobile.length() != 11) {
this.view.setMobileError(getStringfromStringId(R.string.kyc_mobile_invalid_number_error));
return false;
}
view.setDobError(null);
this.view.setMobileError(null);
return true;
}
@Override
public void updateSelectedNativeCountry(NativeCountry seletedNativeCountry) {
this.selectedNativeCountry=seletedNativeCountry;
isSelectedNativeCountryValid=seletedNativeCountry!=null;
if(!isSelectedNativeCountryValid)
view.setNativeCountryError(getStringfromStringId(R.string.kyc_native_country_error));
else
view.setNativeCountryError(null);
validateAll();
}
@Override
public boolean validateEmail(String emailId) {
if(!Utils.isValidEmail(emailId))
{
this.view.setUserIdError(getStringfromStringId(R.string.email_valid_error));
return false;
}
this.view.setUserIdError(null);
return true;
public void updateMobileNumber(String mobileNumber) {
}
@Deprecated
@Override
public boolean validateAll(String emailId, String pwdString, String pwdConfirmString, String dobString) {
boolean emailIdValidation=validateEmail(emailId);
boolean pwdValidation=validatePasswords(pwdString,pwdConfirmString);
boolean dobValidation=validateDob(dobString);
return (emailIdValidation&&pwdValidation&&dobValidation);
public List<NativeCountry> getNativeCountryList() {
return nativeCountryList;
}
@Override
public boolean validateAll(String emailId, String dobString) {
boolean emailIdValidation=validateEmail(emailId);
boolean pwdValidation=validatePasswords();
boolean dobValidation=validateDob(dobString);
return (emailIdValidation&&pwdValidation&&dobValidation);
public void updateId(String id) {
}
@Override
@ -198,9 +135,8 @@ public class RegisterV2Presenter extends BasePresenter implements RegisterV2Pres
this.encPassword=encUpdatedPassword;
}
@Override
public void updateConfirmPassword(String encConfirmPassword) {
this.encConfirmPassword=encConfirmPassword;
private void validateAll() {
}
@Override

25
app/src/main/java/com/gmeremit/online/gmeremittance_native/registerV2/presenter/RegisterV2PresenterInterface.java

@ -4,38 +4,47 @@ import android.content.Context;
import com.gmeremit.online.gmeremittance_native.base.BaseContractInterface;
import com.gmeremit.online.gmeremittance_native.base.BasePresenterInterface;
import com.gmeremit.online.gmeremittance_native.kycV2.model.kyc.NativeCountry;
import java.util.List;
public interface RegisterV2PresenterInterface extends BasePresenterInterface {
boolean validatePasswords(String pwdString, String pwdConfrimString);
void registerUser(String userId, String password, String dob);
boolean validateDob(String dobString);
boolean validateEmail(String emailId);
boolean validateAll(String emailId,String pwdString, String pwdConfirmString,String dobString);
boolean validateAll(String emailId,String dobString);
void updateId(String id);
void updatePassword(String encUpdatedPassword);
void updateConfirmPassword(String encConfirmPassword);
void updateSelectedNativeCountry(NativeCountry selectedNativeCountry);
void updateMobileNumber(String mobileNumber);
List<NativeCountry> getNativeCountryList();
boolean validatePasswords();
interface RegisterV2ContractInterface extends BaseContractInterface {
void setConfirmPasswordError(String error);
void setPasswordError(String error);
void setDobError(String error);
void setNativeCountryError(String error);
void setUserIdError(String error);
void setMobileError(String error);
void redirectToLogin();
void enableSubmitButton(boolean action);
void redirectToDashboard();
Context getContext();

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

@ -19,21 +19,17 @@ import android.widget.TextView;
import com.gmeremit.online.gmeremittance_native.R;
import com.gmeremit.online.gmeremittance_native.base.BaseActivity;
import com.gmeremit.online.gmeremittance_native.customwidgets.GenericTextListingDialog;
import com.gmeremit.online.gmeremittance_native.customwidgets.GmeErrorTextView;
import com.gmeremit.online.gmeremittance_native.homeV2.view.HomeActivityV2;
import com.gmeremit.online.gmeremittance_native.kycV2.model.kyc.NativeCountry;
import com.gmeremit.online.gmeremittance_native.loginV2.view.LoginV2Activity;
import com.gmeremit.online.gmeremittance_native.registerV2.presenter.RegisterV2Presenter;
import com.gmeremit.online.gmeremittance_native.registerV2.presenter.RegisterV2PresenterInterface;
import com.gmeremit.online.gmeremittance_native.utils.Utils;
import com.gmeremit.online.gmeremittance_native.utils.security.securitykeypad.SecurityKeyboardManager;
import com.gmeremit.online.gmeremittance_native.utils.security.securitykeypad.SecurityKeyboardView;
import com.gmeremit.online.gmeremittance_native.utils.security.securitykeypad.SecurityKeypadRequestParamBuilder;
import com.softsecurity.transkey.TransKeyActivity;
import com.tsongkha.spinnerdatepicker.SpinnerDatePickerDialogBuilder;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Locale;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -41,38 +37,39 @@ import butterknife.ButterKnife;
public class RegisterV2Activity extends BaseActivity implements RegisterV2PresenterInterface.RegisterV2ContractInterface, View.OnClickListener, View.OnTouchListener {
@BindView(R.id.email_mobile)
EditText emailMobileTextView;
@BindView(R.id.ed_userId)
EditText ed_userId;
@BindView(R.id.ed_mobile)
EditText ed_mobile;
@BindView(R.id.securityKeyboardPassword)
SecurityKeyboardView securityKeyboardPasswordView;
@BindView(R.id.securityKeyboardConfirmPassword)
SecurityKeyboardView securityKeyboardConfirmPasswordView;
@BindView(R.id.ed_dob)
EditText ed_dob;
@BindView(R.id.ed_native_country)
EditText ed_native_country;
@BindView(R.id.btn_submit)
Button btn_submit;
@BindView(R.id.emailErrorTxt)
GmeErrorTextView emailErrorTxt;
@BindView(R.id.userIdErrorTxt)
GmeErrorTextView userIdErrorTxt;
@BindView(R.id.mobileErrorTxt)
GmeErrorTextView mobileErrorTxt;
@BindView(R.id.passwordErrorTxt)
GmeErrorTextView passwordErrorTxt;
@BindView(R.id.confirmPwdErrorTxt)
GmeErrorTextView confirmPwdErrorTxt;
@BindView(R.id.dateErrorTxt)
GmeErrorTextView dateErrorTxt;
@BindView(R.id.nativeCountryErrorTxt)
GmeErrorTextView nativeCountryErrorTxt;
@BindView(R.id.tv_login)
TextView tv_login;
@BindView(R.id.ed_dob_container)
FrameLayout ed_dob_container;
@BindView(R.id.ed_native_country_container)
FrameLayout ed_native_country_container;
@BindView(R.id.keypadContainer)
FrameLayout keypadContainer;
@ -86,8 +83,6 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
@BindView(R.id.passwordText)
TextView passwordTextView;
@BindView(R.id.confirmPasswordText)
TextView confirmPasswordTextView;
@BindView(R.id.rootViewRegister)
View rootView;
@ -99,10 +94,9 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
private RegisterDobClickGestureDetector dobContainerOnClickGestureDetector;
SecurityKeyboardManager securityKeyboardPasswordManager;
SecurityKeyboardManager securityKeyboardConfirmPasswordManager;
SecurityKeypadPasswordListener securityKeyboardPasswordListener;
SecurityKeypadConfirmPasswordListener securityKeyboardConfirmPasswordListener;
private GenericTextListingDialog<NativeCountry> nativeCountrylListDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -126,7 +120,7 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
try {
securityKeyboardPasswordManager = new SecurityKeyboardManager(this);
SecurityKeypadRequestParamBuilder request = new SecurityKeypadRequestParamBuilder(this);
request.setHintString(getString(R.string.create_password_text));
request.setHintString(getString(R.string.password_policy_text));
request.disableKeyPadEffect(false);
@ -142,26 +136,7 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
Log.d("GMESecurityKeyboard", e.getMessage());
}
securityKeyboardConfirmPasswordListener = new SecurityKeypadConfirmPasswordListener();
securityKeyboardConfirmPasswordView.setKeyboardContainerView(keypadContainer);
securityKeyboardConfirmPasswordView.setKeyboardBallonView(ballonView);
try {
securityKeyboardConfirmPasswordManager = new SecurityKeyboardManager(this);
SecurityKeypadRequestParamBuilder request = new SecurityKeypadRequestParamBuilder(this);
request.setHintString(getString(R.string.confirm_password_text));
request.disableKeyPadEffect(false);
securityKeyboardConfirmPasswordManager.bindWithSecurityWidgetView(securityKeyboardConfirmPasswordView)
.setBallonView(ballonView)
.setKeyboardContainer(keypadContainer)
.setRequestParams(request)
.setActionListener(securityKeyboardConfirmPasswordListener)
.build();
} catch (Exception e) {
e.printStackTrace();
Log.d("GMESecurityKeyboard", e.getMessage());
}
}
private void performDefaultAction(Bundle savedInstanceState) {
@ -175,7 +150,6 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
tv_login.setOnClickListener(this);
btn_submit.setOnClickListener(this);
securityKeyboardPasswordView.setSecurityKeyboardFocusStateListener(securityKeyboardPasswordListener);
securityKeyboardConfirmPasswordView.setSecurityKeyboardFocusStateListener(securityKeyboardConfirmPasswordListener);
}
@ -186,14 +160,13 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
tv_login.setOnClickListener(null);
btn_submit.setOnClickListener(null);
securityKeyboardPasswordView.setSecurityKeyboardFocusStateListener(null);
securityKeyboardConfirmPasswordView.setSecurityKeyboardFocusStateListener(null);
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
return (securityKeyboardPasswordView.checkIfTouchIntersectKeypadLayout(ev) || securityKeyboardConfirmPasswordView.checkIfTouchIntersectKeypadLayout(ev) || dobConatinerClickGestureDetector.onTouchEvent(ev) || super.dispatchTouchEvent(ev));
return (securityKeyboardPasswordView.checkIfTouchIntersectKeypadLayout(ev) || dobConatinerClickGestureDetector.onTouchEvent(ev) || super.dispatchTouchEvent(ev));
}
@ -205,44 +178,38 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
break;
case R.id.btn_submit:
if (presenter.validateAll(emailMobileTextView.getText().toString().trim(), ed_dob.getText().toString())) {
if (btn_submit.isEnabled()) {
hideKeyBoard();
presenter.registerUser(emailMobileTextView.getText().toString().trim(), null, ed_dob.getText().toString());
presenter.registerUser(ed_userId.getText().toString().trim(), null, ed_native_country.getText().toString());
}
break;
}
}
public void promptDatePicker() {
public void promptNativeCountrySelection() {
hideKeyBoard();
SpinnerDatePickerDialogBuilder builder = new SpinnerDatePickerDialogBuilder();
builder.context(RegisterV2Activity.this)
.spinnerTheme(R.style.NumberPickerStyle)
.showTitle(true)
.showDaySpinner(true)
.dialogTheme(R.style.DatePickerTheme)
.setTitle(getString(R.string.select_dob_text))
.setPositiveButtonText(getString(R.string.ok_text))
.setNegativeButtonText(getString(R.string.cancel_text))
.setCurrentDateAsMaxDate()
.defaultDate(1990, 1, 1)
.callback(new com.tsongkha.spinnerdatepicker.DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(com.tsongkha.spinnerdatepicker.DatePicker datePicker, int year, int monthOfYear, int dayOfMonth) {
Calendar newDate = Calendar.getInstance();
newDate.set(year, monthOfYear, dayOfMonth);
ed_dob.setText(new SimpleDateFormat(Utils.getDefaultDateFormat(), Locale.US).format(newDate.getTime()));
}
})
.build().show();
if (nativeCountrylListDialog == null)
nativeCountrylListDialog = new GenericTextListingDialog<>();
nativeCountrylListDialog.setData(this.presenter.getNativeCountryList());
nativeCountrylListDialog.setListener(selectedNativeCountry ->
{
presenter.updateSelectedNativeCountry(selectedNativeCountry);
nativeCountrylListDialog.dismiss();
});
nativeCountrylListDialog.setHintAndTitle(getString(R.string.search_country_text), getString(R.string.select_country_text), getString(R.string.no_country_found_text));
nativeCountrylListDialog.disableSearch(false);
if (!nativeCountrylListDialog.isAdded())
nativeCountrylListDialog.show(getSupportFragmentManager(), "NATIVECOUNTRYDIALOG");
presenter.updateSelectedNativeCountry(null);
}
@Override
public void setConfirmPasswordError(String error) {
confirmPwdErrorTxt.setErrorText(error);
}
@Override
@ -251,13 +218,18 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
}
@Override
public void setDobError(String error) {
dateErrorTxt.setErrorText(error);
public void setNativeCountryError(String error) {
nativeCountryErrorTxt.setErrorText(error);
}
@Override
public void setUserIdError(String error) {
emailErrorTxt.setErrorText(error);
userIdErrorTxt.setErrorText(error);
}
@Override
public void setMobileError(String error) {
}
@Override
@ -268,6 +240,11 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
finish();
}
@Override
public void enableSubmitButton(boolean action) {
btn_submit.setEnabled(action);
}
@Override
public void redirectToDashboard() {
Intent redirectIntent = new Intent(this, HomeActivityV2.class);
@ -285,7 +262,7 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
@Override
public boolean onTouch(View v, MotionEvent event) {
if (v.getId() == R.id.ed_dob_container) {
promptDatePicker();
promptNativeCountrySelection();
return true;
}
return false;
@ -295,8 +272,6 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
public void onBackPressed() {
if (securityKeyboardPasswordManager != null && securityKeyboardPasswordManager.isKeyboardVisible())
securityKeyboardPasswordManager.hideKeyboard();
else if (securityKeyboardConfirmPasswordManager != null && securityKeyboardConfirmPasswordManager.isKeyboardVisible())
securityKeyboardConfirmPasswordManager.hideKeyboard();
else
super.onBackPressed();
}
@ -305,26 +280,26 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
@Override
public boolean onSingleTapUp(MotionEvent e) {
if (e.getAction() == MotionEvent.ACTION_UP) {
boolean isDobContainerClicked = checkIfDateContainerIsClicked(e.getX(), e.getY());
if (isDobContainerClicked)
promptDatePicker();
return isDobContainerClicked;
boolean isNativeCountryContainerClicked = checkIfNativeContainerIsClicked(e.getX(), e.getY());
if (isNativeCountryContainerClicked)
promptNativeCountrySelection();
return isNativeCountryContainerClicked;
}
return super.onSingleTapUp(e);
}
private boolean checkIfDateContainerIsClicked(float x, float y) {
private boolean checkIfNativeContainerIsClicked(float x, float y) {
int posX = (int) x;
int posY = (int) y;
int[] dobConatinerLeftAndTopCoordinates = new int[2];
ed_dob_container.getLocationOnScreen(dobConatinerLeftAndTopCoordinates);
ed_native_country_container.getLocationOnScreen(dobConatinerLeftAndTopCoordinates);
Rect dobContainerBoundRect = new Rect(dobConatinerLeftAndTopCoordinates[0], dobConatinerLeftAndTopCoordinates[1],
dobConatinerLeftAndTopCoordinates[0] + ed_dob_container.getMeasuredWidth(),
dobConatinerLeftAndTopCoordinates[1] + ed_dob_container.getMeasuredHeight());
dobConatinerLeftAndTopCoordinates[0] + ed_native_country_container.getMeasuredWidth(),
dobConatinerLeftAndTopCoordinates[1] + ed_native_country_container.getMeasuredHeight());
return dobContainerBoundRect.contains(posX, posY);
}
@ -362,7 +337,6 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
@Override
public void onSecurityViewRecievedFocus() {
hideKeyboardFromRemainingWidget();
if (securityKeyboardPasswordManager != null && !securityKeyboardPasswordManager.isKeyboardVisible()) {
hideKeyBoard();
securityKeyboardPasswordManager.showKeyboard();
@ -383,69 +357,7 @@ public class RegisterV2Activity extends BaseActivity implements RegisterV2Presen
}
//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())
securityKeyboardConfirmPasswordManager.hideKeyboard();
}
}
class SecurityKeypadConfirmPasswordListener implements SecurityKeyboardManager.SecurityKeyboardActionListenerFacade, SecurityKeyboardView.SecurityKeyboardFocusStateListener {
@Override
public void done(Intent intent) {
String encryptedText = intent.getStringExtra(TransKeyActivity.mTK_PARAM_SECURE_DATA);
presenter.updateConfirmPassword(encryptedText);
}
@Override
public void cancel(Intent intent) {
String encryptedText = intent.getStringExtra(TransKeyActivity.mTK_PARAM_SECURE_DATA);
presenter.updateConfirmPassword(encryptedText);
}
@Override
public void input(int i) {
}
@Override
public void minTextSizeCallback() {
}
@Override
public void maxTextSizeCallback() {
}
@Override
public void onSecurityViewRecievedFocus() {
hideKeyboardFromRemainingWidget();
if (securityKeyboardConfirmPasswordManager != null && !securityKeyboardConfirmPasswordManager.isKeyboardVisible()) {
hideKeyBoard();
securityKeyboardConfirmPasswordManager.showKeyboard();
scrollView.postDelayed(() -> {
scrollView.smoothScrollTo(0, confirmPasswordTextView.getTop());
}, 250);
}
}
@Override
public void onSecurityViewLostFocus() {
if (securityKeyboardConfirmPasswordManager != null && securityKeyboardConfirmPasswordManager.isKeyboardVisible()) {
securityKeyboardConfirmPasswordManager.hideKeyboard();
} 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())
securityKeyboardPasswordManager.hideKeyboard();
}
}
}

6
app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/security/SecurityUtils.java

@ -11,9 +11,13 @@ import com.mtramin.rxfingerprint.data.FingerprintEncryptionResult;
import io.reactivex.Observable;
/**
* @author Preyea R. Regmi
* @version 1.0
* <h1>Security Utils Helper Class For Biometric Auth</h1>
* <p>
* Since we are using security keypad with Symmetric Key Encryption, we can only obtain encrypted text as password but not plain text.
* So the length of the encrypted text exceeds 256 bit and we cannot use Public/Private Encryption Algorithm i.e. RSA encryption offfered by Android's KeyStore.
* Therefore inorder to persist password and encryption key in same storage using Android's Keystore mechanism, we follow the following steps
* Therefore inorder to persist password and encryption key in same storage using Android's Keystore mechanism, we follow the following steps</p>
* 1) We generate AES key seperately using "AESEncryptionHelper" class if not already generated intially.
* 2) Encrypt the confidential content with the AES Algorithm using the generated AES key and persist it.
* 3) That AES key is then encrypted using RSA key provided by Keystore and persist it to prevent from being exploited.

8
app/src/main/java/com/gmeremit/online/gmeremittance_native/utils/security/securitykeypad/SecurityKeyboardManager.java

@ -15,8 +15,12 @@ import com.softsecurity.transkey.ITransKeyCallbackListener;
import com.softsecurity.transkey.TransKeyCtrl;
/**
* Created by Preyea
* Helper class to interact with security virtual keypad.
* @author Preyea R. Regmi
* <h1>Helper class to interact with virtual security keypad SDK.</h1>
* <p>
* The used virtual security keypad is just a view that can be inflated in any ViewGroup. This class provides overall encapsulation of all the related element provided by
* the Virtual Keypad SDK in order to mimick OS like keyboard behavior. This allows us to show/hide keypad in the same Activity from where it is invoked thus providing better UX.
*</p>
*/
public class SecurityKeyboardManager {

72
app/src/main/res/layout/activity_register_v2.xml

@ -76,12 +76,12 @@
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="2dp"
android:text="@string/email_text"
android:text="@string/login_user_id_text"
android:textSize="14sp"
app:txtfontName="@string/regular" />
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeEditText
style="@style/editetxtsinglelineDone"
android:id="@+id/email_mobile"
android:id="@+id/ed_userId"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
@ -91,13 +91,13 @@
android:paddingEnd="8dp"
android:textSize="16sp"
android:minHeight="40dp"
android:hint="@string/email_text"
android:hint="@string/login_user_id_text"
android:imeOptions="actionDone"
android:background="@drawable/curve_rectangle_edit_text"
/>
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeErrorTextView
android:layout_marginStart="3dp"
android:id="@+id/emailErrorTxt"
android:id="@+id/userIdErrorTxt"
android:paddingTop="2dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -126,39 +126,17 @@
/>
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView
android:id="@+id/confirmPasswordText"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="2dp"
android:text="@string/confirm_password_text"
android:textSize="14sp"
app:txtfontName="@string/regular" />
<com.gmeremit.online.gmeremittance_native.utils.security.securitykeypad.SecurityKeyboardView
android:id="@+id/securityKeyboardConfirmPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeErrorTextView
android:layout_marginStart="3dp"
android:id="@+id/confirmPwdErrorTxt"
android:paddingTop="2dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="2dp"
android:text="@string/dob_text"
android:text="@string/native_country_text"
android:textSize="14sp"
app:txtfontName="@string/regular" />
<FrameLayout
android:id="@+id/ed_dob_container"
android:id="@+id/ed_native_country_container"
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -170,7 +148,7 @@
android:focusableInTouchMode="false"
android:cursorVisible="false"
style="@style/editetxtsinglelineDone"
android:id="@+id/ed_dob"
android:id="@+id/ed_native_country"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
@ -181,7 +159,7 @@
android:paddingEnd="8dp"
android:textSize="16sp"
android:minHeight="40dp"
android:hint="@string/dob_text"
android:hint="@string/native_country_placeholder_text"
android:imeOptions="actionDone"
/>
<ImageView
@ -193,12 +171,43 @@
/>
</FrameLayout>
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeErrorTextView
android:id="@+id/dateErrorTxt"
android:id="@+id/nativeCountryErrorTxt"
android:paddingTop="2dp"
android:layout_marginStart="3dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="8dp"
android:paddingBottom="2dp"
android:text="@string/mobile_text"
android:textSize="14sp"
app:txtfontName="@string/regular" />
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeEditText
style="@style/editetxtsinglelineDone"
android:id="@+id/ed_mobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:textSize="16sp"
android:minHeight="40dp"
android:hint="@string/mobile_number_text"
android:imeOptions="actionDone"
android:background="@drawable/curve_rectangle_edit_text"
/>
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeErrorTextView
android:layout_marginStart="3dp"
android:id="@+id/mobileErrorTxt"
android:paddingTop="2dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:layout_gravity="center_horizontal"
@ -233,6 +242,7 @@
<com.gmeremit.online.gmeremittance_native.customwidgets.GmeButton
android:id="@+id/btn_submit"
android:enabled="false"
android:layout_width="200dp"
android:layout_height="50dp"
android:layout_gravity="center"

2
app/src/main/res/values/strings.xml

@ -278,7 +278,7 @@
<string name="new_password_placeholder_text">Enter Your New Password</string>
<string name="confirm_new_password_placeholder_text">Confirm Your Password</string>
<string name="save_password_text">Save</string>
<string name="password_policy_text">Password should be At least one sumbol, At least one capital letter, At leset one number and be at least 9 characters</string>
<string name="password_policy_text">Password should be at least 6 characters</string>
<string name="confirm_password_mismatch_error">Confirm password does not match with new password</string>
<string name="success_text">Success</string>
<string name="confirm_passowrd_empty_error">Confirm password cannot be empty</string>

Loading…
Cancel
Save