Commit 35ad6637 by Krishna Vemulawada

mail added for sysid

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