Commit 35ad6637 by Krishna Vemulawada

mail added for sysid

parents 420ba7ac f70f4a8b
......@@ -72,7 +72,7 @@ android {
vportal {
applicationId "com.vsoft.vera.vportal"
versionCode 1
versionName "0.1.8"
versionName "1.1.0"
}
}
}
......
......@@ -15,8 +15,10 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AppCompatActivity;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
......@@ -72,6 +74,7 @@ import org.json.JSONObject;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
......@@ -169,6 +172,8 @@ public class ADALActivity extends AppCompatActivity {
}
});
getCountryCode();
// CheckLoginValues();
callGraphButton = (Button) findViewById(R.id.callGraph);
signOutButton = (Button) findViewById(R.id.clearCache);
......@@ -189,7 +194,6 @@ public class ADALActivity extends AppCompatActivity {
});
login_with_otp.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// onSignOutClicked();
......@@ -804,4 +808,28 @@ public class ADALActivity extends AppCompatActivity {
}
}
}
/*
* getCountryCode - To get the Country mobile code dynamically.
*
* @return void
* */
public void getCountryCode() {
try {
TelephonyManager telephonyManager =
(TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE);
if (telephonyManager != null) {
String countryName = telephonyManager.getNetworkCountryIso();
if(countryName.equalsIgnoreCase("us")) {
Constants.TWILIO_COUNTRY_CODE = "+1";
}
if(countryName.equalsIgnoreCase("in")) {
Constants.TWILIO_COUNTRY_CODE = "+91";
}
}
} catch (Exception e) {
Constants.TWILIO_COUNTRY_CODE = "+1";
}
}
}
......@@ -14,7 +14,6 @@ import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.bumptech.glide.Glide;
......@@ -22,6 +21,7 @@ import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.vsoft.vera.CatalogueApplication;
import com.vsoft.vera.R;
import com.vsoft.vera.api.listeners.get.GetLiveAgentApiListener;
import com.vsoft.vera.api.listeners.get.GetUserDetailApiListener;
import com.vsoft.vera.api.listeners.get.GetUserLoginApiListener;
import com.vsoft.vera.api.listeners.get.GetValidateOtpApiListener;
......@@ -35,6 +35,7 @@ import com.vsoft.vera.db.managers.ChatBotHistoryManager;
import com.vsoft.vera.db.managers.ChatBotUserManager;
import com.vsoft.vera.db.models.ChatBotUser;
import com.vsoft.vera.db.models.UserApiValues;
import com.vsoft.vera.enums.SyncStatus;
import com.vsoft.vera.utils.Constants;
import com.vsoft.vera.utils.DialogUtils;
import com.vsoft.vera.utils.GenerateRandomString;
......@@ -63,6 +64,7 @@ public class OtpValidationActivity extends Activity {
private static final int API_FAIL_USER_DETAIL = 4;
private List<UserApiValues> mUserDetails;
private LinearLayout mainLayt;
String userFullName;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
......@@ -82,18 +84,16 @@ public class OtpValidationActivity extends Activity {
ButterKnife.bind(this);
mApplication = (CatalogueApplication) getApplication();
// new LoginDetailsSendToServer().execute();
}
@OnClick(R.id.otp_screen_text_view)
void onLoginClicked() {
callOtpAPI();
}
@OnClick(R.id.otp_screen_validate_text_view)
void onValidateClicked(){
callValidateOtpAPI();
}
......@@ -102,16 +102,11 @@ public class OtpValidationActivity extends Activity {
phoneString = mPhoneEditText.getText().toString().trim();
if (TextUtils.isEmpty(phoneString)) {
mPhoneEditText.setError(getResources().getString(R.string.phone_error));
}
if (!TextUtils.isEmpty(phoneString) && phoneString.length() >= 10) {
mPhoneEditText.setError(getResources().getString(R.string.phone_no_error));
} else if (!TextUtils.isEmpty(phoneString) && phoneString.length() >= 10 && phoneString.length() <=20) {
KeyboardUtil.hideKeyboard(OtpValidationActivity.this);
if (mApplication.isNetConnected()) {
new generateOtp().execute(phoneString);
} else {
DialogUtils.showNoConnectionDialog(OtpValidationActivity.this);
}
......@@ -120,21 +115,18 @@ public class OtpValidationActivity extends Activity {
private void callValidateOtpAPI() {
String optCode = mOTPEditText.getText().toString().trim();
if (TextUtils.isEmpty(optCode)) {
String otpCode = mOTPEditText.getText().toString().trim();
if (TextUtils.isEmpty(otpCode)) {
mOTPEditText.setError(getResources().getString(R.string.otp_error));
}else{
} else if(!TextUtils.isEmpty(otpCode) && otpCode.length() <=8) {
KeyboardUtil.hideKeyboard(OtpValidationActivity.this);
if (mApplication.isNetConnected()) {
new validateOtp().execute(phoneString,optCode);
if (mApplication.isNetConnected()) {
new validateOtp().execute(phoneString, otpCode);
} else {
DialogUtils.showNoConnectionDialog(OtpValidationActivity.this);
}
}
}
......@@ -162,12 +154,10 @@ public class OtpValidationActivity extends Activity {
public void onDoneApiCall(String message) {
apiMessage = message;
apiStatus = 1;
}
@Override
public void onFailApiCall(String message) {
apiMessage = message;
apiStatus = 0;
}
......@@ -189,7 +179,6 @@ public class OtpValidationActivity extends Activity {
}
if(apiStatus==1){ // success
showPhoneLayout(false);
}else{
showPhoneLayout(true);
......@@ -227,23 +216,17 @@ public class OtpValidationActivity extends Activity {
String phoneString = params[0];
String otpCode = params[1];
OtpApiManager.validateOTP(phoneString, otpCode,new GetValidateOtpApiListener() {
@Override
public void onDoneApiCall(String message) {
apiMessage = message;
apiStatus = 1;
}
@Override
public void onFailApiCall(String message) {
apiMessage = message;
apiStatus = 0;
}
});
return apiMessage;
......@@ -289,6 +272,7 @@ public class OtpValidationActivity extends Activity {
private static final int USER_DETAIL = 1;
private int apiStatus;
@Override
protected void onPreExecute() {
super.onPreExecute();
......@@ -378,14 +362,93 @@ public class OtpValidationActivity extends Activity {
String lastName = mUserDetails.get(0).getLastName();
String sysid = mUserDetails.get(0).getSysId();
String userFullName = mUserDetails.get(0).getFullName();
userFullName = mUserDetails.get(0).getFullName();
String userId = mUserDetails.get(0).getUserId();
String userEmailId = mUserDetails.get(0).getUserEmailId();
/*End Chat Local DB Part*/
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_USER_FIRST_NAME, firstName);
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_USER_LAST_NAME, lastName);
/*For pre fill value in variable form*/
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_USER_FULL_NAME, "");
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_USER_ID, userId);
new GetyUserSysIDAsync().execute();
} else {
Util.simpleAlert(OtpValidationActivity.this,getResources().getString(R.string.user_detail_not_available));
}
} else if (syncStatus == API_FAIL_USER_LOGIN) {
Util.simpleAlert(OtpValidationActivity.this,getResources().getString(R.string.login_screen_invalid_username_and_password_string));
} else if (syncStatus == API_FAIL_USER_DETAIL) {
Util.simpleAlert(OtpValidationActivity.this,getResources().getString(R.string.failed_to_fetch_user_detail_string));
}
}
}
private class GetyUserSysIDAsync extends AsyncTask<Void, Void, SyncStatus> {
private ProgressDialog progressDialog;
private SyncStatus syncStatus = SyncStatus.FAIL;
String userSysId;
String accessToken;
String email;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(OtpValidationActivity.this);
progressDialog.setMessage(getString(R.string.login_screen_logging_in_loading_string));
progressDialog.show();
progressDialog.setCancelable(false);
accessToken = PrefManager.getSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_ACCESS_TOKEN);
email = "kkonarski@vsoftconsulting.com";
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_USER_EMAIL_ID, email);
}
@Override
protected SyncStatus doInBackground(Void... params) {
UserApiManager.getUserSysId(OtpValidationActivity.this,accessToken,email,new GetLiveAgentApiListener() {
@Override
public void onDoneApiCall(String url) {
userSysId = url;
syncStatus = SyncStatus.SUCCESS;
}
@Override
public void onFailApiCall() {
syncStatus = SyncStatus.FAIL;
}
});
return syncStatus;
}
@Override
protected void onPostExecute(SyncStatus syncStatus) {
super.onPostExecute(syncStatus);
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
if (syncStatus == SyncStatus.SUCCESS) {
if(userSysId != null){
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_USER_SYS_ID, userSysId);
if(Util.isChatItemEnabled()) {
/*Start Chat Local DB Part*/
//Here we'll save logged in user detail in local DB for chat history.
ChatBotUser localChatBotUser = ChatBotUserManager.getChatBotUsersByUserSysId(sysid);
ChatBotUser localChatBotUser = ChatBotUserManager.getChatBotUsersByUserSysId(userSysId);
if (localChatBotUser == null) {
/*Clears all data from CHAT_BOT_HISTORY and CHAT_BOT_USER tables*/
ChatBotHistoryManager.deleteAllRows();
......@@ -393,26 +456,15 @@ public class OtpValidationActivity extends Activity {
/*Save Logged in user in local db for chat screen*/
ChatBotUser chatBotUser = ChatBotUser.ChatBotUserBuilder.aChatBotUser()
.setUserSysId(sysid)
.setName(firstName)
.setUserSysId(userSysId)
.setName(userFullName)
.build();
ChatBotUserManager.save(chatBotUser);
} else {//Update the name of user
localChatBotUser.setName(firstName);
localChatBotUser.setName(userFullName);
ChatBotUserManager.update(localChatBotUser);
}
}
/*End Chat Local DB Part*/
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_USER_FIRST_NAME, firstName);
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_USER_LAST_NAME, lastName);
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_USER_SYS_ID, sysid);
/*For pre fill value in variable form*/
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_USER_FULL_NAME, "");
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_USER_ID, userId);
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_USER_EMAIL_ID, userEmailId);
/*Send broadcast to start SyncService*/
Intent intent = new Intent(Constants.APPLICATION_BROADCAST_INTENT);
intent.putExtra(Constants.APPLICATION_BROADCAST_DATA_ACTION, Constants.ACTION_SYNC);
......@@ -422,6 +474,7 @@ public class OtpValidationActivity extends Activity {
if(bundle != null) {
int requestCode = bundle.getInt(Constants.DATA_KEY_LOGIN_REQUEST_CODE);
if (requestCode == Constants.LOGIN_SCREEN_REQUEST_CODE) {
startActivity(new Intent(OtpValidationActivity.this, ChatActivity.class));
} else {
Intent homeIntent = new Intent(OtpValidationActivity.this, HomeScreen.class);
......@@ -433,17 +486,16 @@ public class OtpValidationActivity extends Activity {
homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(homeIntent);
}
finish();
} else {
}else {
Util.simpleAlert(OtpValidationActivity.this,getResources().getString(R.string.user_detail_not_available));
}
} else if (syncStatus == API_FAIL_USER_LOGIN) {
Util.simpleAlert(OtpValidationActivity.this,getResources().getString(R.string.login_screen_invalid_username_and_password_string));
} else if (syncStatus == API_FAIL_USER_DETAIL) {
} else if (syncStatus == SyncStatus.FAIL) {
Util.simpleAlert(OtpValidationActivity.this,getResources().getString(R.string.failed_to_fetch_user_detail_string));
}
}
}
}
......@@ -11,7 +11,7 @@ import com.vsoft.vera.api.interfaces.PendingApprovalsApi;
public class Constants {
public static final String TAG = AppConfig.APP_INTERNAL_NAME;
public static final String TWILIO_COUNTRY_CODE = "+91";
public static String TWILIO_COUNTRY_CODE;// = "+91";
public static final String[] month = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
/**
......
......@@ -59,9 +59,10 @@
android:layout_marginLeft="@dimen/extra_large_margin"
android:layout_marginRight="@dimen/extra_large_margin"
android:background="@drawable/username_under_bg_box"
android:hint="Please enter mobile number"
android:hint="@string/phone_number"
android:lines="1"
android:inputType="number"
android:maxLength="20"
android:inputType="phone"
android:padding="@dimen/normal_margin"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
......@@ -109,6 +110,7 @@
android:background="@drawable/username_under_bg_box"
android:hint="@string/enter_otp"
android:lines="1"
android:maxLength="8"
android:inputType="number"
android:padding="@dimen/normal_margin"
android:singleLine="true" />
......
......@@ -64,7 +64,8 @@
<string name="user_error">Please enter username</string>
<string name="pasw_error">Please enter password</string>
<string name="phone_error">Please enter mobile number</string>
<string name="phone_number">Please enter mobile number</string>
<string name="phone_no_error">Please enter valid mobile number</string>
<string name="otp_error">Please enter OTP</string>
<string name="username_string">Username</string>
<string name="password_string">Password</string>
......@@ -144,7 +145,7 @@
<!-- messages -->
<string name="message_welcome">Chat with VERA</string>
<string name="reset_password">RESET PASSWORD</string>
<string name="view_all_str"><u>View ALL</u></string>
<string name="view_all_str"><u>View all</u></string>
<!--Speech Recognizer-->
<string name="ds_listening">Listening…</string>
......
The file could not be displayed because it is too large.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment