Commit e187aa8b by Krishna Vemulawada

login sso and otp

parents 29cd325e 47ff318d
Showing with 1395 additions and 68 deletions
......@@ -72,7 +72,7 @@ android {
vportal {
applicationId "com.vsoft.vera.vportal"
versionCode 1
versionName "0.0.9"
versionName "0.1.2"
}
}
}
......
......@@ -43,12 +43,18 @@
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name=".ui.OtpValidationActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize|stateHidden" />
<activity
android:name=".ui.LoginChooseActivity"
android:screenOrientation="portrait"
/> <activity
android:name=".ui.ADALActivity"
android:screenOrientation="portrait"
/>
<activity android:name=".ui.ResetPasswordActivity"
android:screenOrientation="portrait"
android:fitsSystemWindows="true"
......

36.2 KB | W: | H:

127 KB | W: | H:

app/src/main/ic_launcher-web.png
app/src/main/ic_launcher-web.png
app/src/main/ic_launcher-web.png
app/src/main/ic_launcher-web.png
  • 2-up
  • Swipe
  • Onion skin
package com.vsoft.vera.api.interfaces;
import com.vsoft.vera.api.pojos.OtpPostData;
import com.vsoft.vera.utils.Constants;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
public interface OtpApi {
@POST(Constants.URL_PHONE_NUMBER_VERIFICATION)
Call<ResponseBody> getOtp(@Body OtpPostData otpPostData);
@GET(Constants.URL_PHONE_NUMBER_VALIDATION)
Call<ResponseBody> validateOtp(@Query(value = Constants.PHONE_NUMBER,encoded = true) String phone_number,
@Query(value = Constants.COUNTRY_CODE, encoded = true) String country_code,
@Query(Constants.VERIFICATION_CODE) String verification_code,
@Query(Constants.LANGUAGE) String language);
}
package com.vsoft.vera.api.listeners.get;
import com.vsoft.vera.api.pojos.LoginApiResponse;
public interface GetValidateOtpApiListener {
void onDoneApiCall(String message);
void onFailApiCall(String message);
}
package com.vsoft.vera.api.listeners.post;
public interface PostOtpApiListener {
void onDoneApiCall(String message);
void onFailApiCall(String message);
}
package com.vsoft.vera.api.managers;
import com.google.gson.JsonObject;
import com.vsoft.vera.api.RestClient;
import com.vsoft.vera.api.interfaces.LoginApi;
import com.vsoft.vera.api.interfaces.OtpApi;
import com.vsoft.vera.api.listeners.get.GetValidateOtpApiListener;
import com.vsoft.vera.api.listeners.post.PostOtpApiListener;
import com.vsoft.vera.api.pojos.OtpPostData;
import com.vsoft.vera.db.models.Reference;
import com.vsoft.vera.utils.CatalogueLog;
import com.vsoft.vera.utils.Constants;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
public class OtpApiManager {
private static String error = "Something went Wrong";
public static void getOTP(String mobileNumber, PostOtpApiListener listener){
final Retrofit retrofit = RestClient.getInitializedRestAdapterWithOutAuthorizationHeader();
OtpPostData otpPostData = new OtpPostData();
otpPostData.setPhone_number(mobileNumber);
otpPostData.setVia("sms");
otpPostData.setCountry_code("+1");
otpPostData.setLn("en");
Call<ResponseBody> call = retrofit.create(OtpApi.class).getOtp(otpPostData);
try {
//Retrofit synchronous call
Response<ResponseBody> response = call.execute();
if(response.isSuccessful()){
try{
JSONObject jsonObject = new JSONObject(response.body().string());
if(jsonObject.has(Constants.RESPONSE_SUCCESS)){
boolean success = jsonObject.getBoolean(Constants.RESPONSE_SUCCESS);
if(success){
listener.onDoneApiCall(jsonObject.getString(Constants.RESPONSE_MESSAGE));
}else{
if(jsonObject.has(Constants.RESPONSE_ERRORS)){
JSONObject errors = jsonObject.getJSONObject(Constants.RESPONSE_ERRORS);
if(errors.has(Constants.RESPONSE_MESSAGE)) {
listener.onFailApiCall(jsonObject.getString(Constants.RESPONSE_MESSAGE));
}else{
listener.onFailApiCall(error);
}
}else{
listener.onFailApiCall(error);
}
}
}else{
listener.onFailApiCall(error);
}
}catch (JSONException e) {
CatalogueLog.e("LoginApiManager: submitLoginValues: onResponse: ", e);
listener.onFailApiCall(error);
} catch (IOException e) {
CatalogueLog.e("LoginApiManager: submitLoginValues: onResponse: ", e);
listener.onFailApiCall(error);
}
}else {
JSONObject errorObject = new JSONObject(response.errorBody().string());
if(errorObject.has(Constants.RESPONSE_MESSAGE)){
listener.onFailApiCall(errorObject.getString(Constants.RESPONSE_MESSAGE));
}else{
listener.onFailApiCall(error);
}
}
}catch (IOException e) {
CatalogueLog.e("OtpApiManager: IOException: ", e);
listener.onFailApiCall(error);
} catch (NullPointerException e) {
CatalogueLog.e("OtpApiManager: NullPointerException: ", e);
listener.onFailApiCall(error);
} catch (JSONException e) {
CatalogueLog.e("OtpApiManager: JSONException: ", e);
listener.onFailApiCall(error);
}
}
public static void validateOTP(String mobileNumber,String verificationCode, GetValidateOtpApiListener listener){
final Retrofit retrofit = RestClient.getInitializedRestAdapterWithOutAuthorizationHeader();
Call<ResponseBody> call = retrofit.create(OtpApi.class).validateOtp(mobileNumber,"+1",verificationCode,"en");
try {
//Retrofit synchronous call
Response<ResponseBody> response = call.execute();
if(response.isSuccessful()){
try{
JSONObject jsonObject = new JSONObject(response.body().string());
if(jsonObject.has(Constants.RESPONSE_SUCCESS)){
boolean success = jsonObject.getBoolean(Constants.RESPONSE_SUCCESS);
if(success){
listener.onDoneApiCall(jsonObject.getString(Constants.RESPONSE_MESSAGE));
}else{
if(jsonObject.has(Constants.RESPONSE_ERRORS)){
JSONObject errors = jsonObject.getJSONObject(Constants.RESPONSE_ERRORS);
if(errors.has(Constants.RESPONSE_MESSAGE)) {
listener.onFailApiCall(jsonObject.getString(Constants.RESPONSE_MESSAGE));
}else{
listener.onFailApiCall(error);
}
}else{
listener.onFailApiCall(error);
}
}
}else{
listener.onFailApiCall(error);
}
}catch (JSONException e) {
CatalogueLog.e("LoginApiManager: submitLoginValues: onResponse: ", e);
listener.onFailApiCall(error);
} catch (IOException e) {
CatalogueLog.e("LoginApiManager: submitLoginValues: onResponse: ", e);
listener.onFailApiCall(error);
}
}else {
JSONObject errorObject = new JSONObject(response.errorBody().string());
if(errorObject.has(Constants.RESPONSE_MESSAGE)){
listener.onFailApiCall(errorObject.getString(Constants.RESPONSE_MESSAGE));
}else{
listener.onFailApiCall(error);
}
}
}catch (IOException e) {
CatalogueLog.e("OtpApiManager: IOException: ", e);
listener.onFailApiCall(error);
} catch (NullPointerException e) {
CatalogueLog.e("OtpApiManager: NullPointerException: ", e);
listener.onFailApiCall(error);
} catch (JSONException e) {
CatalogueLog.e("OtpApiManager: JSONException: ", e);
listener.onFailApiCall(error);
}
}
}
package com.vsoft.vera.api.pojos;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class OtpPostData {
@SerializedName("via")
@Expose
private String via;
@SerializedName("phone_number")
@Expose
private String phone_number;
@SerializedName("country_code")
@Expose
private String country_code;
@SerializedName("ln")
@Expose
private String ln;
public String getVia() {
return via;
}
public void setVia(String via) {
this.via = via;
}
public String getPhone_number() {
return phone_number;
}
public void setPhone_number(String phone_number) {
this.phone_number = phone_number;
}
public String getCountry_code() {
return country_code;
}
public void setCountry_code(String country_code) {
this.country_code = country_code;
}
public String getLn() {
return ln;
}
public void setLn(String ln) {
this.ln = ln;
}
}
......@@ -2,18 +2,22 @@ package com.vsoft.vera.ui;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.preference.PreferenceManager;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.volley.DefaultRetryPolicy;
......@@ -32,7 +36,23 @@ import com.microsoft.aad.adal.IDispatcher;
import com.microsoft.aad.adal.Logger;
import com.microsoft.aad.adal.PromptBehavior;
import com.microsoft.aad.adal.Telemetry;
import com.vsoft.vera.CatalogueApplication;
import com.vsoft.vera.R;
import com.vsoft.vera.api.listeners.get.GetUserDetailApiListener;
import com.vsoft.vera.api.listeners.get.GetUserLoginApiListener;
import com.vsoft.vera.api.listeners.put.PutDeviceRegistrationApiListener;
import com.vsoft.vera.api.managers.LoginApiManager;
import com.vsoft.vera.api.managers.UserApiManager;
import com.vsoft.vera.api.pojos.LoginApiResponse;
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.utils.Constants;
import com.vsoft.vera.utils.DialogUtils;
import com.vsoft.vera.utils.GenerateRandomString;
import com.vsoft.vera.utils.PrefManager;
import com.vsoft.vera.utils.Util;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -49,6 +69,13 @@ public class ADALActivity extends AppCompatActivity {
private static final String TAG = ADALActivity.class.getSimpleName();
Button callGraphButton;
Button signOutButton;
Button login_with_otp;
ImageView logo_banner;
private static final int API_SUCCESS_USER_LOGIN = 1;
private static final int API_FAIL_USER_LOGIN = 2;
private static final int API_SUCCESS_USER_DETAIL = 3;
private static final int API_FAIL_USER_DETAIL = 4;
private List<UserApiValues> mUserDetails;
/* Azure AD Constants */
/* Authority is in the form of https://login.microsoftonline.com/yourtenant.onmicrosoft.com */
......@@ -64,7 +91,7 @@ public class ADALActivity extends AppCompatActivity {
private final static String MSGRAPH_URL = "https://graph.microsoft.com/v1.0/me";
/* Azure AD Variables */
private AuthenticationContext mAuthContext;
private AuthenticationContext mAuthContext;
private AuthenticationResult mAuthResult;
/* Handler to do an interactive sign in and acquire token */
......@@ -79,10 +106,13 @@ public class ADALActivity extends AppCompatActivity {
/* Constant to store user id in shared preferences */
private static final String USER_ID = "user_id";
private boolean isLogin= false;
private boolean sspLogin= false;
/* Telemetry variables */
// Flag to turn event aggregation on/off
private static final boolean sTelemetryAggregationIsRequired = true;
/* Telemetry dispatcher registration */
static {
Telemetry.getInstance().registerDispatcher(new IDispatcher() {
......@@ -100,19 +130,31 @@ public class ADALActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.adal_main);
CheckLoginValues();
callGraphButton = (Button) findViewById(R.id.callGraph);
signOutButton = (Button) findViewById(R.id.clearCache);
login_with_otp = (Button) findViewById(R.id.login_with_otp);
logo_banner = findViewById(R.id.logo_banner);
callGraphButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mAuthContext.getCache().removeAll();
sIntSignInInvoked.set(false);
onCallGraphClicked();
}
});
signOutButton.setOnClickListener(new View.OnClickListener() {
login_with_otp.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
onSignOutClicked();
// onSignOutClicked();
Intent intent = new Intent(ADALActivity.this,OtpValidationActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
}
});
......@@ -149,6 +191,32 @@ public class ADALActivity extends AppCompatActivity {
String userId = preferences.getString(USER_ID, "");
if(!TextUtils.isEmpty(userId)){
mAuthContext.acquireTokenSilentAsync(RESOURCE_ID, CLIENT_ID, userId, getAuthSilentCallback());
}else {
mAuthContext.getCache().removeAll();
}
}
private void CheckLoginValues() {
String sysId = PrefManager.getSharedPref(ADALActivity.this, PrefManager.PREFERENCE_USER_SYS_ID);
if (!TextUtils.isEmpty(sysId)) {
/*Send broadcast to start SyncService*/
Intent intent = new Intent(Constants.APPLICATION_BROADCAST_INTENT);
intent.putExtra(Constants.APPLICATION_BROADCAST_DATA_ACTION, Constants.ACTION_SYNC);
LocalBroadcastManager.getInstance(ADALActivity.this).sendBroadcast(intent);
Bundle bundle = getIntent().getExtras();
if(bundle != null) {
int requestCode = bundle.getInt(Constants.DATA_KEY_LOGIN_REQUEST_CODE);
if (requestCode == Constants.LOGIN_SCREEN_REQUEST_CODE) {
setResult(Constants.LOGIN_SCREEN_REQUEST_CODE, new Intent());
} else {
startActivity(new Intent(ADALActivity.this, HomeScreen.class));
}
} else {
startActivity(new Intent(ADALActivity.this, HomeScreen.class));
}
isLogin = true;
finish();
}
}
......@@ -165,6 +233,7 @@ public class ADALActivity extends AppCompatActivity {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
mAuthContext.onActivityResult(requestCode, resultCode, data);
}
/*
......@@ -195,8 +264,23 @@ public class ADALActivity extends AppCompatActivity {
public void onResponse(JSONObject response) {
/* Successfully called graph, process data and send to UI */
Log.d(TAG, "Response: " + response.toString());
JSONObject root = null;
try {
root = new JSONObject(response.toString());
String userLoginName = root.getString("givenName");
PrefManager.setSharedPref(ADALActivity.this, PrefManager.PREFERENCE_USER_FULL_NAME, userLoginName);
/*Send broadcast to start SyncService*/
if(!isLogin){
callGraphButton.setVisibility(View.GONE);
login_with_otp.setVisibility(View.GONE);
logo_banner.setVisibility(View.GONE);
new LoginDetailsSendToServer().execute();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
......@@ -222,12 +306,12 @@ public class ADALActivity extends AppCompatActivity {
queue.add(request);
}
private void onSignOutClicked() {
private void onSignOutClicked() {
// End user has clicked the Sign Out button
// Kill the token cache
// Optionally call the signout endpoint to fully sign out the user account
mAuthContext.getCache().removeAll();
updateSignedOutUI();
// updateSignedOutUI();
}
//
......@@ -249,18 +333,28 @@ public class ADALActivity extends AppCompatActivity {
private void updateSuccessUI() {
// Called on success from /me endpoint
// Removed call Graph API button and paint Sign out
callGraphButton.setVisibility(View.VISIBLE);
callGraphButton.setVisibility(View.GONE);
signOutButton.setVisibility(View.GONE);
login_with_otp.setVisibility(View.GONE);
logo_banner.setVisibility(View.GONE);
findViewById(R.id.welcome).setVisibility(View.GONE);
((TextView) findViewById(R.id.welcome)).setText("Welcome, " +
mAuthResult.getUserInfo().getGivenName());
findViewById(R.id.graphData).setVisibility(View.GONE);
}
@SuppressLint("SetTextI18n")
private void updateSignedOutUI() {
callGraphButton.setVisibility(View.VISIBLE);
signOutButton.setVisibility(View.GONE);
findViewById(R.id.welcome).setVisibility(View.INVISIBLE);
findViewById(R.id.graphData).setVisibility(View.INVISIBLE);
......@@ -306,6 +400,7 @@ public class ADALActivity extends AppCompatActivity {
@Override
public void run() {
updateSuccessUI();
}
});
}
......@@ -416,4 +511,165 @@ public class ADALActivity extends AppCompatActivity {
};
}
private class LoginDetailsSendToServer extends AsyncTask<Void, Integer, Integer> {
private ProgressDialog progressDialog;
private static final int USER_DETAIL = 1;
private int apiStatus;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(ADALActivity.this);
progressDialog.setMessage(getString(R.string.loading_string));
progressDialog.show();
progressDialog.setCancelable(false);
}
@Override
protected Integer doInBackground(Void... params) {
final String userName = "bkovi";
String password = "123";
LoginApiManager.submitLoginValues(LoginApiResponse.Json.PASSWORD, Constants.LOGIN_CLIENT_ID, Constants
.LOGIN_CLIENT_SECRET, userName, password, new GetUserLoginApiListener() {
@Override
public void onDoneApiCall(LoginApiResponse loginApiResponse) {
apiStatus = API_SUCCESS_USER_LOGIN;
publishProgress(USER_DETAIL);
/*Save access token in Preference*/
PrefManager.setSharedPref(ADALActivity.this, PrefManager.PREFERENCE_ACCESS_TOKEN, loginApiResponse.getAccessToken());
PrefManager.setSharedPref(ADALActivity.this, PrefManager.PREFERENCE_REFRESH_TOKEN, loginApiResponse.getRefreshToken());
UserApiManager.getUserDetailResponse(ADALActivity.this, userName, new GetUserDetailApiListener() {
@Override
public void onDoneApiCall(List<UserApiValues> userValues) {
mUserDetails = userValues;
if(Util.isNotificationsItemEnabled()) {
UserApiManager.putDeviceRegistration(ADALActivity.this, userValues.get(0).getSysId(), new PutDeviceRegistrationApiListener() {
@Override
public void onDoneApiCall() {
apiStatus = API_SUCCESS_USER_DETAIL;
}
@Override
public void onFailApiCall() {
apiStatus = API_FAIL_USER_DETAIL;
}
});
} else {
apiStatus = API_SUCCESS_USER_DETAIL;
}
}
@Override
public void onFailApiCall() {
apiStatus = API_FAIL_USER_DETAIL;
}
});
}
@Override
public void onFailApiCall() {
apiStatus = API_FAIL_USER_LOGIN;
}
});
return apiStatus;
}
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
if(values[0] == USER_DETAIL) {
// progressDialog.setMessage(getString(R.string.login_screen_getting_user_detail_loading_string));
}
}
@Override
protected void onPostExecute(Integer syncStatus) {
super.onPostExecute(syncStatus);
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
if (syncStatus == API_SUCCESS_USER_DETAIL) {
if (mUserDetails != null) {
isLogin = true;
if (((CatalogueApplication) getApplication()).isNetConnected()) {
ChatBotHistoryManager.delete();
String generateRandomStrPharma = GenerateRandomString.randomString(30);
PrefManager.setSharedPref(ADALActivity.this, PrefManager.SESSION_ID, generateRandomStrPharma);
} else {
DialogUtils.showNoConnectionDialog(ADALActivity.this);
}
String generateRandoStrPharma = GenerateRandomString.randomString(30);
PrefManager.setSharedPref(ADALActivity.this, PrefManager.SESSION_ID, generateRandoStrPharma);
String firstName = mUserDetails.get(0).getFirstName();
String lastName = mUserDetails.get(0).getLastName();
String sysid = mUserDetails.get(0).getSysId();
String userFullName = mUserDetails.get(0).getFullName();
String userId = mUserDetails.get(0).getUserId();
String userEmailId = mUserDetails.get(0).getUserEmailId();
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);
if (localChatBotUser == null) {
/*Clears all data from CHAT_BOT_HISTORY and CHAT_BOT_USER tables*/
ChatBotHistoryManager.deleteAllRows();
ChatBotUserManager.deleteAllRows();
/*Save Logged in user in local db for chat screen*/
ChatBotUser chatBotUser = ChatBotUser.ChatBotUserBuilder.aChatBotUser()
.setUserSysId(sysid)
.setName(firstName)
.build();
ChatBotUserManager.save(chatBotUser);
} else {//Update the name of user
localChatBotUser.setName(firstName);
ChatBotUserManager.update(localChatBotUser);
}
}
/*End Chat Local DB Part*/
PrefManager.setSharedPref(ADALActivity.this, PrefManager.PREFERENCE_USER_FIRST_NAME, firstName);
PrefManager.setSharedPref(ADALActivity.this, PrefManager.PREFERENCE_USER_LAST_NAME, lastName);
PrefManager.setSharedPref(ADALActivity.this, PrefManager.PREFERENCE_USER_SYS_ID, sysid);
/*For pre fill value in variable form*/
PrefManager.setSharedPref(ADALActivity.this, PrefManager.PREFERENCE_USER_ID, userId);
PrefManager.setSharedPref(ADALActivity.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);
LocalBroadcastManager.getInstance(ADALActivity.this).sendBroadcast(intent);
Bundle bundle = getIntent().getExtras();
if(bundle != null) {
int requestCode = bundle.getInt(Constants.DATA_KEY_LOGIN_REQUEST_CODE);
if (requestCode == Constants.LOGIN_SCREEN_REQUEST_CODE) {
startActivity(new Intent(ADALActivity.this, ChatActivity.class));
} else {
startActivity(new Intent(ADALActivity.this, HomeScreen.class));
}
} else {
startActivity(new Intent(ADALActivity.this, HomeScreen.class));
}
//
} else {
Util.simpleAlert(ADALActivity.this,getResources().getString(R.string.user_detail_not_available));
}
} else if (syncStatus == API_FAIL_USER_LOGIN) {
Util.simpleAlert(ADALActivity.this,getResources().getString(R.string.login_screen_invalid_username_and_password_string));
} else if (syncStatus == API_FAIL_USER_DETAIL) {
Util.simpleAlert(ADALActivity.this,getResources().getString(R.string.failed_to_fetch_user_detail_string));
}
}
}
}
......@@ -4,10 +4,15 @@ import android.Manifest;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AlertDialog;
......@@ -15,6 +20,9 @@ import android.support.v7.widget.Toolbar;
import android.widget.GridView;
import com.google.android.gms.analytics.Tracker;
import com.microsoft.aad.adal.AuthenticationContext;
import com.microsoft.aad.adal.AuthenticationResult;
import com.microsoft.aad.adal.PromptBehavior;
import com.vsoft.vera.BuildConfig;
import com.vsoft.vera.CatalogueApplication;
import com.vsoft.vera.MenuProvider;
......@@ -29,6 +37,8 @@ import com.vsoft.vera.utils.DialogUtils;
import com.vsoft.vera.utils.PrefManager;
import com.vsoft.vera.utils.Util;
import java.util.concurrent.atomic.AtomicBoolean;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
......@@ -43,6 +53,29 @@ public class HomeScreen extends HandleNotificationActivity {
@BindView(R.id.home_screen_grid_view)
GridView mGridView;
private int pos;
private AuthenticationContext mAuthContext;
/* Azure AD Constants */
/* Authority is in the form of https://login.microsoftonline.com/yourtenant.onmicrosoft.com */
private static final String AUTHORITY = "https://login.microsoftonline.com/common";
/* The clientID of your application is a unique identifier which can be obtained from the app registration portal */
private static final String CLIENT_ID = "b9808fea-11a7-4ed5-aab0-baae8688adb4";
/* Resource URI of the endpoint which will be accessed */
private static final String RESOURCE_ID = "https://graph.microsoft.com/";
/* The Redirect URI of the application (Optional) */
private static final String REDIRECT_URI = "x-msauth-com.com.vsoft.vmetrics://com.vsoft.vmetrics";
/* Microsoft Graph Constants */
private final static String MSGRAPH_URL = "https://graph.microsoft.com/v1.0/me";
private AuthenticationResult mAuthResult;
/* Handler to do an interactive sign in and acquire token */
private Handler mAcquireTokenHandler;
/* Boolean variable to ensure invocation of interactive sign-in only once in case of multiple acquireTokenSilent call failures */
private static AtomicBoolean sIntSignInInvoked = new AtomicBoolean();
/* Constant to send message to the mAcquireTokenHandler to do acquire token with Prompt.Auto*/
private static final int MSG_INTERACTIVE_SIGN_IN_PROMPT_AUTO = 1;
/* Constant to send message to the mAcquireTokenHandler to do acquire token with Prompt.Always */
private static final int MSG_INTERACTIVE_SIGN_IN_PROMPT_ALWAYS = 2;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -58,6 +91,20 @@ public class HomeScreen extends HandleNotificationActivity {
HomeScreenAdapter adapter = new HomeScreenAdapter(this, MenuProvider.MENU_ITEMS);
mGridView.setAdapter(adapter);
mAuthContext = new AuthenticationContext(getApplicationContext(), AUTHORITY, false);
// mAcquireTokenHandler = new Handler(Looper.getMainLooper()){
// @Override
// public void handleMessage(Message msg) {
// if( sIntSignInInvoked.compareAndSet(false, true)) {
// if (msg.what == MSG_INTERACTIVE_SIGN_IN_PROMPT_AUTO){
// mAuthContext.acquireToken(HomeScreen.this, RESOURCE_ID, CLIENT_ID, REDIRECT_URI, PromptBehavior.Auto, getAuthInteractiveCallback());
// }else if(msg.what == MSG_INTERACTIVE_SIGN_IN_PROMPT_ALWAYS){
// mAuthContext.acquireToken(HomeScreen.this, RESOURCE_ID, CLIENT_ID, REDIRECT_URI, PromptBehavior.Always, getAuthInteractiveCallback());
// }
// }
// }
// };
}
@OnItemClick(R.id.home_screen_grid_view)
......@@ -79,34 +126,86 @@ public class HomeScreen extends HandleNotificationActivity {
@OnClick(R.id.nav_back)
void homeIconClicked() {
//Below dialog will appear in only debug mode.
// if(BuildConfig.BUILD_TYPE_INT == 1 ||BuildConfig.BUILD_TYPE_INT == 3 ) {
// AlertDialog.Builder builder = new AlertDialog.Builder(this);
// StringBuilder stringBuilder = new StringBuilder();
// stringBuilder.append("ServiceNow Instance: ");
// stringBuilder.append(Constants.DOMAIN);
// stringBuilder.append("\n");
// stringBuilder.append("Socket URL: ");
// stringBuilder.append(Constants.CHAT_SERVER_URL);
// stringBuilder.append("\n");
// stringBuilder.append("Flavor: ");
// stringBuilder.append(BuildConfig.FLAVOR);
// stringBuilder.append("\n");
// stringBuilder.append("Build Type: ");
// stringBuilder.append(BuildConfig.BUILD_TYPE);
// stringBuilder.append("\n");
// stringBuilder.append("\n");
// stringBuilder.append("Version: "+BuildConfig.VERSION_NAME);
// builder.setMessage(stringBuilder.toString())
// .setTitle("App Info")
// .setCancelable(false)
// .setPositiveButton(R.string.ok_string, new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int id) {
// dialog.dismiss();
// }
// });
// AlertDialog alert = builder.create();
// alert.show();
// }
// if(BuildConfig.BUILD_TYPE_INT == 1 ||BuildConfig.BUILD_TYPE_INT == 3 ) {
// AlertDialog.Builder builder = new AlertDialog.Builder(this);
// StringBuilder stringBuilder = new StringBuilder();
// stringBuilder.append("ServiceNow Instance: ");
// stringBuilder.append(Constants.DOMAIN);
// stringBuilder.append("\n");
// stringBuilder.append("Socket URL: ");
// stringBuilder.append(Constants.CHAT_SERVER_URL);
// stringBuilder.append("\n");
// stringBuilder.append("Flavor: ");
// stringBuilder.append(BuildConfig.FLAVOR);
// stringBuilder.append("\n");
// stringBuilder.append("Build Type: ");
// stringBuilder.append(BuildConfig.BUILD_TYPE);
// stringBuilder.append("\n");
// stringBuilder.append("\n");
// stringBuilder.append("Version: "+BuildConfig.VERSION_NAME);
// builder.setMessage(stringBuilder.toString())
// .setTitle("App Info")
// .setCancelable(false)
// .setPositiveButton(R.string.ok_string, new DialogInterface.OnClickListener() {
// public void onClick(DialogInterface dialog, int id) {
// dialog.dismiss();
// }
// });
// AlertDialog alert = builder.create();
// alert.show();
// }
if(BuildConfig.BUILD_TYPE_INT == 1 ||BuildConfig.BUILD_TYPE_INT == 3 ) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("ServiceNow Instance: ");
stringBuilder.append(Constants.DOMAIN);
stringBuilder.append("\n");
stringBuilder.append("Socket URL: ");
stringBuilder.append(Constants.CHAT_SERVER_URL);
stringBuilder.append("\n");
stringBuilder.append("Flavor: ");
stringBuilder.append(BuildConfig.FLAVOR);
stringBuilder.append("\n");
stringBuilder.append("Build Type: ");
stringBuilder.append(BuildConfig.BUILD_TYPE);
stringBuilder.append("\n");
stringBuilder.append("\n");
stringBuilder.append("Version: "+BuildConfig.VERSION_NAME);
builder.setMessage(stringBuilder.toString())
.setTitle("App Info")
.setCancelable(false)
.setPositiveButton(R.string.ok_string, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
String userFullName = PrefManager.getSharedPref(HomeScreen.this, PrefManager.PREFERENCE_USER_FULL_NAME);
if(userFullName!= null){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Username: ");
stringBuilder.append(userFullName);
builder.setMessage(stringBuilder.toString())
.setTitle("User Details")
.setCancelable(false)
.setPositiveButton(R.string.ok_string, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
}
@OnClick(R.id.home_screen_logout_image_view)
......@@ -117,7 +216,16 @@ public class HomeScreen extends HandleNotificationActivity {
.setPositiveButton(R.string.ok_string, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
if(((CatalogueApplication)getApplication()).isNetConnected()) {
new LogoutTask().execute();
String userFullName = PrefManager.getSharedPref(HomeScreen.this, PrefManager.PREFERENCE_USER_FULL_NAME);
if(userFullName != null){
mAuthContext.getCache().removeAll();
new LogoutTask().execute();
}else {
new LogoutTask().execute();
}
} else {
DialogUtils.showNoConnectionDialog(HomeScreen.this);
}
......@@ -191,6 +299,8 @@ public class HomeScreen extends HandleNotificationActivity {
}
if (syncStatus == SyncStatus.SUCCESS) {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
preferences.edit().putString("user_id", "").apply();
PrefManager.setSharedPref(HomeScreen.this, PrefManager.PREFERENCE_ACCESS_TOKEN, "");
PrefManager.setSharedPref(HomeScreen.this, PrefManager.PREFERENCE_REFRESH_TOKEN, "");
PrefManager.setSharedPref(HomeScreen.this, PrefManager.PREFERENCE_USER_LAST_NAME, "");
......@@ -200,7 +310,8 @@ public class HomeScreen extends HandleNotificationActivity {
PrefManager.setSharedPref(HomeScreen.this, PrefManager.PREFERENCE_USER_FULL_NAME, "");
PrefManager.setSharedPref(HomeScreen.this, PrefManager.PREFERENCE_USER_EMAIL_ID, "");
PrefManager.setSharedPref(HomeScreen.this, PrefManager.SESSION_ID, "");
Intent loginIntent = new Intent(HomeScreen.this, LoginScreen.class);
Intent loginIntent = new Intent(HomeScreen.this, ADALActivity.class);
loginIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(loginIntent);
} else {
......
......@@ -13,6 +13,7 @@ import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import com.google.android.gms.analytics.Tracker;
import com.vsoft.vera.CatalogueApplication;
......@@ -77,7 +78,7 @@ public class LoginScreen extends Activity {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
callLoginAPI();
callLoginAPI(false);
return true;
default:
break;
......@@ -113,6 +114,22 @@ public class LoginScreen extends Activity {
Util.sendScreenName(tracker, getString(R.string.login_screen_string));
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == Constants.LOGIN_SCREEN_OTP_REQUEST_CODE){
if(data!=null && data.getExtras()!=null){
String message = data.getExtras().getString(Constants.MESSAGE);
if(message.equalsIgnoreCase(Constants.RESPONSE_SUCCESS)){
callLoginAPI(false);
}else{
Toast.makeText(this,"Something went Wrong",Toast.LENGTH_LONG).show();
}
}
}
}
private void CheckLoginValues() {
String sysId = PrefManager.getSharedPref(LoginScreen.this, PrefManager.PREFERENCE_USER_SYS_ID);
if (!TextUtils.isEmpty(sysId)) {
......@@ -136,7 +153,7 @@ public class LoginScreen extends Activity {
}
}
private void callLoginAPI() {
private void callLoginAPI(boolean withOtp) {
String userNameString = mUserNameEditText.getText().toString().trim();
String passwordString = mPasswordEditText.getText().toString().trim();
......@@ -149,19 +166,38 @@ public class LoginScreen extends Activity {
if (!TextUtils.isEmpty(userNameString) && !TextUtils.isEmpty(passwordString)) {
KeyboardUtil.hideKeyboard(LoginScreen.this);
if (mApplication.isNetConnected()) {
new LoginDetailsSendToServer().execute(mUserNameEditText.getText().toString().trim(), mPasswordEditText.getText().toString().trim());
if(withOtp){
launchOptValidationScreen();
}else{
new LoginDetailsSendToServer().execute(mUserNameEditText.getText().toString().trim(), mPasswordEditText.getText().toString().trim());
}
} else {
DialogUtils.showNoConnectionDialog(LoginScreen.this);
}
}
}
@OnClick(R.id.login_screen_login_text_view)
void onLoginClicked() {
callLoginAPI();
@OnClick({R.id.login_screen_login_text_view,R.id.login_screen_login_text_view_twillio})
void onLoginClicked(View mView) {
if(mView.getId()==R.id.login_screen_login_text_view){
callLoginAPI(false);
}else if(mView.getId()==R.id.login_screen_login_text_view_twillio){
callLoginAPI(true);
}
}
private void launchOptValidationScreen(){
Intent intent = new Intent(LoginScreen.this,OtpValidationActivity.class);
startActivityForResult(intent,Constants.LOGIN_SCREEN_OTP_REQUEST_CODE);
}
private class LoginDetailsSendToServer extends AsyncTask<String, Integer, Integer> {
private ProgressDialog progressDialog;
private static final int USER_DETAIL = 1;
......
package com.vsoft.vera.ui;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.LocalBroadcastManager;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.vsoft.vera.CatalogueApplication;
import com.vsoft.vera.R;
import com.vsoft.vera.api.listeners.get.GetUserDetailApiListener;
import com.vsoft.vera.api.listeners.get.GetUserLoginApiListener;
import com.vsoft.vera.api.listeners.get.GetValidateOtpApiListener;
import com.vsoft.vera.api.listeners.post.PostOtpApiListener;
import com.vsoft.vera.api.listeners.put.PutDeviceRegistrationApiListener;
import com.vsoft.vera.api.managers.LoginApiManager;
import com.vsoft.vera.api.managers.OtpApiManager;
import com.vsoft.vera.api.managers.UserApiManager;
import com.vsoft.vera.api.pojos.LoginApiResponse;
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.utils.Constants;
import com.vsoft.vera.utils.DialogUtils;
import com.vsoft.vera.utils.GenerateRandomString;
import com.vsoft.vera.utils.KeyboardUtil;
import com.vsoft.vera.utils.PrefManager;
import com.vsoft.vera.utils.Util;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class OtpValidationActivity extends Activity {
@BindView(R.id.otp_screen_phone_edit_text) EditText mPhoneEditText;
@BindView(R.id.otp_screen_otp_edit_text) EditText mOTPEditText;
@BindView(R.id.phone_validate_layout) RelativeLayout phone_layout;
@BindView(R.id.otp_validate_layout) RelativeLayout otp_validate_layout;
private CatalogueApplication mApplication;
private String phoneString = null;
private static final int API_SUCCESS_USER_LOGIN = 1;
private static final int API_FAIL_USER_LOGIN = 2;
private static final int API_SUCCESS_USER_DETAIL = 3;
private static final int API_FAIL_USER_DETAIL = 4;
private List<UserApiValues> mUserDetails;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_otp_validation);
ButterKnife.bind(this);
mApplication = (CatalogueApplication) getApplication();
}
@OnClick(R.id.otp_screen_text_view)
void onLoginClicked() {
callOtpAPI();
}
@OnClick(R.id.otp_screen_validate_text_view)
void onValidateClicked(){
callValidateOtpAPI();
}
private void callOtpAPI() {
phoneString = mPhoneEditText.getText().toString().trim();
if (TextUtils.isEmpty(phoneString)) {
mPhoneEditText.setError(getResources().getString(R.string.phone_error));
}
if (!TextUtils.isEmpty(phoneString) ) {
KeyboardUtil.hideKeyboard(OtpValidationActivity.this);
if (mApplication.isNetConnected()) {
new generateOtp().execute(phoneString);
} else {
DialogUtils.showNoConnectionDialog(OtpValidationActivity.this);
}
}
}
private void callValidateOtpAPI() {
String optCode = mOTPEditText.getText().toString().trim();
if (TextUtils.isEmpty(optCode)) {
mOTPEditText.setError(getResources().getString(R.string.otp_error));
}
if (!TextUtils.isEmpty(phoneString) ) {
KeyboardUtil.hideKeyboard(OtpValidationActivity.this);
if (mApplication.isNetConnected()) {
new validateOtp().execute(phoneString,optCode);
} else {
DialogUtils.showNoConnectionDialog(OtpValidationActivity.this);
}
}
}
private class generateOtp extends AsyncTask<String, Integer, Integer> {
private ProgressDialog progressDialog;
private String apiMessage="Something went Wrong";
private int apiStatus=0;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(OtpValidationActivity.this);
progressDialog.setMessage(getString(R.string.generating_otp));
progressDialog.show();
progressDialog.setCancelable(false);
}
@Override
protected Integer doInBackground(String... params) {
String phoneString = params[0];
OtpApiManager.getOTP(phoneString, new PostOtpApiListener() {
@Override
public void onDoneApiCall(String message) {
apiMessage = message;
apiStatus = 1;
}
@Override
public void onFailApiCall(String message) {
apiMessage = message;
apiStatus = 0;
}
});
return apiStatus;
}
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(Integer status) {
super.onPostExecute(status);
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
if(apiStatus==1){ // success
showPhoneLayout(false);
}else{
showPhoneLayout(true);
}
Toast.makeText(OtpValidationActivity.this,apiMessage,Toast.LENGTH_LONG).show();
}
}
private class validateOtp extends AsyncTask<String, Integer, String>{
private ProgressDialog progressDialog;
private String apiMessage="Something went Wrong";
private int apiStatus=0;
@Override
protected void onPreExecute() {
super.onPreExecute();
progressDialog = new ProgressDialog(OtpValidationActivity.this);
progressDialog.setMessage(getString(R.string.validating_otp));
progressDialog.show();
progressDialog.setCancelable(false);
}
@Override
protected String doInBackground(String... params) {
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;
}
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(String message) {
super.onPostExecute(message);
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
if(apiStatus==1){
new LoginDetailsSendToServer().execute();
}else{
Toast.makeText(OtpValidationActivity.this,apiMessage,Toast.LENGTH_LONG).show();
}
}
}
private void showPhoneLayout(boolean show){
if(show){
phone_layout.setVisibility(View.VISIBLE);
otp_validate_layout.setVisibility(View.GONE);
}else{
phone_layout.setVisibility(View.GONE);
otp_validate_layout.setVisibility(View.VISIBLE);
}
}
private class LoginDetailsSendToServer extends AsyncTask<Void, Integer, Integer> {
private ProgressDialog progressDialog;
private static final int USER_DETAIL = 1;
private int apiStatus;
@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);
}
@Override
protected Integer doInBackground(Void... params) {
final String userName = "bkovi";
String password = "123";
LoginApiManager.submitLoginValues(LoginApiResponse.Json.PASSWORD, Constants.LOGIN_CLIENT_ID, Constants
.LOGIN_CLIENT_SECRET, userName, password, new GetUserLoginApiListener() {
@Override
public void onDoneApiCall(LoginApiResponse loginApiResponse) {
apiStatus = API_SUCCESS_USER_LOGIN;
publishProgress(USER_DETAIL);
/*Save access token in Preference*/
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_ACCESS_TOKEN, loginApiResponse.getAccessToken());
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.PREFERENCE_REFRESH_TOKEN, loginApiResponse.getRefreshToken());
UserApiManager.getUserDetailResponse(OtpValidationActivity.this, userName, new GetUserDetailApiListener() {
@Override
public void onDoneApiCall(List<UserApiValues> userValues) {
mUserDetails = userValues;
if(Util.isNotificationsItemEnabled()) {
UserApiManager.putDeviceRegistration(OtpValidationActivity.this, userValues.get(0).getSysId(), new PutDeviceRegistrationApiListener() {
@Override
public void onDoneApiCall() {
apiStatus = API_SUCCESS_USER_DETAIL;
}
@Override
public void onFailApiCall() {
apiStatus = API_FAIL_USER_DETAIL;
}
});
} else {
apiStatus = API_SUCCESS_USER_DETAIL;
}
}
@Override
public void onFailApiCall() {
apiStatus = API_FAIL_USER_DETAIL;
}
});
}
@Override
public void onFailApiCall() {
apiStatus = API_FAIL_USER_LOGIN;
}
});
return apiStatus;
}
@Override
protected void onProgressUpdate(Integer... values) {
super.onProgressUpdate(values);
if(values[0] == USER_DETAIL) {
// progressDialog.setMessage(getString(R.string.login_screen_getting_user_detail_loading_string));
}
}
@Override
protected void onPostExecute(Integer syncStatus) {
super.onPostExecute(syncStatus);
if (progressDialog != null && progressDialog.isShowing()) {
progressDialog.dismiss();
}
if (syncStatus == API_SUCCESS_USER_DETAIL) {
if (mUserDetails != null) {
if (((CatalogueApplication) getApplication()).isNetConnected()) {
ChatBotHistoryManager.delete();
String generateRandomStrPharma = GenerateRandomString.randomString(30);
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.SESSION_ID, generateRandomStrPharma);
} else {
DialogUtils.showNoConnectionDialog(OtpValidationActivity.this);
}
String generateRandoStrPharma = GenerateRandomString.randomString(30);
PrefManager.setSharedPref(OtpValidationActivity.this, PrefManager.SESSION_ID, generateRandoStrPharma);
String firstName = mUserDetails.get(0).getFirstName();
String lastName = mUserDetails.get(0).getLastName();
String sysid = mUserDetails.get(0).getSysId();
String userFullName = mUserDetails.get(0).getFullName();
String userId = mUserDetails.get(0).getUserId();
String userEmailId = mUserDetails.get(0).getUserEmailId();
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);
if (localChatBotUser == null) {
/*Clears all data from CHAT_BOT_HISTORY and CHAT_BOT_USER tables*/
ChatBotHistoryManager.deleteAllRows();
ChatBotUserManager.deleteAllRows();
/*Save Logged in user in local db for chat screen*/
ChatBotUser chatBotUser = ChatBotUser.ChatBotUserBuilder.aChatBotUser()
.setUserSysId(sysid)
.setName(firstName)
.build();
ChatBotUserManager.save(chatBotUser);
} else {//Update the name of user
localChatBotUser.setName(firstName);
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);
LocalBroadcastManager.getInstance(OtpValidationActivity.this).sendBroadcast(intent);
Bundle bundle = getIntent().getExtras();
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 {
startActivity(new Intent(OtpValidationActivity.this, HomeScreen.class));
}
} else {
startActivity(new Intent(OtpValidationActivity.this, HomeScreen.class));
}
finish();
} 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));
}
}
}
}
......@@ -53,6 +53,13 @@ public class Constants {
public static final String MESSAGE = "Message";
public static final String PHONE_NUMBER = "phone_number";
public static final String COUNTRY_CODE = "country_code";
public static final String VERIFICATION_CODE = "verification_code";
public static final String LANGUAGE = "ln";
public static final String VIA = "via";
/**
* Broadcast custom intent
*/
......@@ -78,13 +85,14 @@ public class Constants {
public static final String URL_PARAM_FILE_NAME = "file_name";
public static final String URL_PARAM_SYS_ID = "sys_id";
public static final String URL_PARAM_OPENED_BY = "opened_by";
public static String URL_PHONE_NUMBER_VERIFICATION = "https://api.authy.com/protected/json/phones/verification/start?api_key=" + Constants.TWILIO_VALIDATION_KEY;
public static String URL_PHONE_NUMBER_VALIDATION = "https://api.authy.com/protected/json/phones/verification/check?api_key=" + Constants.TWILIO_VALIDATION_KEY;
public static final String URL_PHONE_NUMBER_VERIFICATION = "https://api.authy.com/protected/json/phones/verification/start?api_key=" + Constants.TWILIO_VALIDATION_KEY;
public static final String URL_PHONE_NUMBER_VALIDATION = "https://api.authy.com/protected/json/phones/verification/check?api_key=" + Constants.TWILIO_VALIDATION_KEY;
/**
* Request Code
* */
public static final int LOGIN_SCREEN_REQUEST_CODE = 105;
public static final int LOGIN_SCREEN_OTP_REQUEST_CODE = 112;
/**
* Preference Notification token.
......@@ -158,6 +166,9 @@ public class Constants {
public static final String RESPONSE_VARIABLES_OBJECT_NAME = "variables";
public static final String RESPONSE_CATEGORY_OBJECT_NAME = "Category";
public static final String RESPONSE_VARIABLES_UI_POLICY_ACTIONS = "ui_policy_actions";
public static final String RESPONSE_SUCCESS = "success";
public static final String RESPONSE_MESSAGE = "message";
public static final String RESPONSE_ERRORS = "errors";
/**
* Web services urls
......
......@@ -2,12 +2,35 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/login_screen_login_button_background_color" />
<!-- <solid android:color="@color/button_bg" />-->
<corners android:radius="10dip" />
<!-- <corners android:radius="10dip" />-->
<stroke
android:width="1dp"
android:color="@color/login_screen_login_button_background_color" />
<!-- <stroke-->
<!-- android:width="1dp"-->
<!-- android:color="@color/button_bg" />-->
</shape>
\ No newline at end of file
<corners
android:radius="10dp"
/>
<gradient
android:angle="45"
android:centerX="35%"
android:centerColor="#6699c8"
android:startColor="#7faad1"
android:endColor="#1966ad"
android:type="linear"
/>
<padding
android:left="0dp"
android:top="0dp"
android:right="0dp"
android:bottom="0dp"
/>
<size
android:width="270dp"
android:height="60dp"
/>
</shape>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/fulton_bg"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/tool_bar_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/button_bg_two"
android:minHeight="?attr/actionBarSize"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
app:titleTextColor="@color/tool_bar_title_color">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/small_margin"
android:layout_marginRight="@dimen/small_margin">
<TextView
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="FULTON COUNTY"
android:textColor="@color/screen_bg_color_white" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<RelativeLayout
android:id="@+id/phone_validate_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TextInputLayout
android:id="@+id/phone_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:layout_centerVertical="true">
<EditText
android:id="@+id/otp_screen_phone_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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 phone number"
android:lines="1"
android:inputType="number"
android:padding="@dimen/normal_margin"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/otp_screen_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/normal_margin"
android:layout_marginLeft="@dimen/extra_large_margin"
android:layout_marginRight="@dimen/extra_large_margin"
android:layout_marginTop="30dp"
android:layout_below="@+id/phone_layout"
android:background="@drawable/login_bg"
android:gravity="center"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:text="@string/generate_otp"
android:textColor="@android:color/white"
android:textSize="@dimen/large_text_size" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/otp_validate_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
<android.support.design.widget.TextInputLayout
android:id="@+id/otp_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:layout_marginBottom="0dp"
android:layout_centerVertical="true">
<EditText
android:id="@+id/otp_screen_otp_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/extra_large_margin"
android:layout_marginRight="@dimen/extra_large_margin"
android:background="@drawable/username_under_bg_box"
android:hint="@string/enter_otp"
android:lines="1"
android:inputType="number"
android:padding="@dimen/normal_margin"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/otp_screen_validate_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/normal_margin"
android:layout_marginLeft="@dimen/extra_large_margin"
android:layout_marginRight="@dimen/extra_large_margin"
android:layout_marginTop="30dp"
android:layout_below="@+id/otp_layout"
android:background="@drawable/login_bg"
android:gravity="center"
android:paddingBottom="@dimen/normal_margin"
android:paddingTop="@dimen/normal_margin"
android:text="@string/validate_otp"
android:textColor="@android:color/white"
android:textSize="@dimen/large_text_size" />
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF"
android:background="@drawable/fulton_bg"
android:orientation="vertical"
tools:context="com.vsoft.vera.ui.ADALActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/tool_bar_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/button_bg_two"
android:minHeight="?attr/actionBarSize"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
app:contentInsetRight="0dp"
app:contentInsetStart="0dp"
app:titleTextColor="@color/tool_bar_title_color">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/small_margin"
android:layout_marginRight="@dimen/small_margin">
<TextView
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="FULTON COUNTY"
android:textColor="@color/screen_bg_color_white" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<TextView
android:text="WelCome"
......@@ -19,12 +49,14 @@
android:id="@+id/welcome"
android:visibility="gone"/>
<ImageView
android:id="@+id/logo_banner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
android:layout_marginTop="50dp"
android:alpha="0.8"
android:layout_gravity="center_horizontal"
android:background="@drawable/ic_login_banner" />
android:background="@drawable/fulton_app_logo" />
<Button
android:id="@+id/callGraph"
......@@ -33,7 +65,7 @@
android:layout_marginBottom="@dimen/normal_margin"
android:layout_marginLeft="@dimen/extra_large_margin"
android:layout_marginRight="@dimen/extra_large_margin"
android:layout_marginTop="30dp"
android:layout_marginTop="50dp"
android:background="@drawable/login_bg"
android:gravity="center"
android:paddingBottom="@dimen/normal_margin"
......
......@@ -3,14 +3,14 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#EBEAEA"
android:background="@drawable/fulton_bg"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/tool_bar_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#303030"
android:background="@color/button_bg_two"
android:minHeight="?attr/actionBarSize"
app:contentInsetEnd="0dp"
app:contentInsetLeft="0dp"
......@@ -39,7 +39,7 @@
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="@string/app_name"
android:text="FULTON COUNTY"
android:textColor="@color/screen_bg_color_white" />
<ImageView
......
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
</adaptive-icon>
\ No newline at end of file

3.22 KB | W: | H:

6.88 KB | W: | H:

app/src/main/res/mipmap-hdpi/ic_launcher.png
app/src/main/res/mipmap-hdpi/ic_launcher.png
app/src/main/res/mipmap-hdpi/ic_launcher.png
app/src/main/res/mipmap-hdpi/ic_launcher.png
  • 2-up
  • Swipe
  • Onion skin

4.61 KB | W: | H:

10.5 KB | W: | H:

app/src/main/res/mipmap-xhdpi/ic_launcher.png
app/src/main/res/mipmap-xhdpi/ic_launcher.png
app/src/main/res/mipmap-xhdpi/ic_launcher.png
app/src/main/res/mipmap-xhdpi/ic_launcher.png
  • 2-up
  • Swipe
  • Onion skin

7.52 KB | W: | H:

18.7 KB | W: | H:

app/src/main/res/mipmap-xxhdpi/ic_launcher.png
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -30,6 +30,10 @@
<!--Notification screen-->
<color name="list_divider_color">@color/light_gray</color>
<color name="button_bg">#0055A4</color>
<color name="button_bg_two">#002a52</color>
<!--Chatbot Screen-->
<color name="username0">#e21400</color>
<color name="username1">#91580f</color>
......
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>
\ No newline at end of file
<resources>
<color name="ic_launcher_background">#FFFFFF</color>
</resources>
\ No newline at end of file
<resources>
<string name="app_name">V-Portal</string>
<string name="app_name">Fulton-County</string>
<string name="set_string">Set</string>
<string name="submit_string">Submit</string>
......@@ -47,19 +47,30 @@
<!--Login Screen-->
<string name="prompt_relogin_login_expired">Login expired, please login again&#8230;</string>
<string name="login_screen_login_string">Login</string>
<string name="login_screen_login_string_twillio">Login With Twillio</string>
<string name="login_screen_login_string_twillio">Login With OTP</string>
<string name="login_screen_submit_string">Submit</string>
<string name="login_screen_logging_in_loading_string">Logging in&#8230;</string>
<string name="login_screen_getting_user_detail_loading_string">Getting user details&#8230;</string>
<string name="login_screen_invalid_username_and_password_string">Invalid username and password</string>
<string name="user_detail_not_available">Unable to fetch user details.</string>
<string name="generate_otp">Generate OTP</string>
<string name="generating_otp">Generating OTP</string>
<string name="sending_otp">Sending OTP</string>
<string name="validate_otp">Validate OTP</string>
<string name="validating_otp">Validating OTP</string>
<string name="enter_otp">Enter OTP</string>
<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="otp_error">Please enter OTP</string>
<string name="username_string">Username</string>
<string name="password_string">Password</string>
<string name="confirm_password_string">Confirm Password</string>
<string name="home_screen_logout_string">Ver: %1$s</string>
<string name="phone">Phone </string>
<!--Variable Screen-->
<string name="variable_form_mandatory_toast_string">Fields marked with an asterisk(*) are mandatory.</string>
......
......@@ -3,13 +3,14 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:background="#000"
android:background="@drawable/fulton_splash_screen"
android:orientation="vertical">
<ImageView
android:layout_gravity="center"
android:layout_width="200dp"
android:layout_height="150dp"
android:background="@drawable/logo_splash"
android:visibility="gone"
android:background="@drawable/fulton_splash_screen"
/>
</FrameLayout>
\ No newline at end of file
<resources>
<string name="app_name">VERA 2.1</string>
<string name="app_name">Fulton-County</string>
<!--home Screen Option-->
<!--Start-->
......
The file could not be displayed because it is too large.
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"0.0.9","enabled":true,"outputFile":"app-vportal-staging.apk","fullName":"vportalStaging","baseName":"vportal-staging"},"path":"app-vportal-staging.apk","properties":{}}]
\ No newline at end of file
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"0.1.2","enabled":true,"outputFile":"app-vportal-staging.apk","fullName":"vportalStaging","baseName":"vportal-staging"},"path":"app-vportal-staging.apk","properties":{}}]
\ No newline at end of file
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