Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Krishna Vemulavada
/
vera_2.1_app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5049b0a3
authored
Sep 12, 2016
by
Krishna Vemulavada
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
set the Login validation
parent
a26400fe
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
80 additions
and
40 deletions
app/src/main/java/com/vsoft/uoflservicenow/api/managers/LoginApiManger.java
app/src/main/java/com/vsoft/uoflservicenow/dialog/SelectReferenceDialog.java
app/src/main/java/com/vsoft/uoflservicenow/enums/SyncStatus.java
app/src/main/java/com/vsoft/uoflservicenow/ui/CatalogueVariableScreen.java
app/src/main/java/com/vsoft/uoflservicenow/ui/LoginScreen.java
app/src/main/java/com/vsoft/uoflservicenow/ui/MyIncidentScreen.java
app/src/main/java/com/vsoft/uoflservicenow/ui/MyRequestActivity.java
app/src/main/res/layout/activity_login.xml
app/src/main/res/values/strings.xml
app/src/main/java/com/vsoft/uoflservicenow/api/managers/LoginApiManger.java
View file @
5049b0a3
...
@@ -23,11 +23,18 @@ public class LoginApiManger {
...
@@ -23,11 +23,18 @@ public class LoginApiManger {
try
{
try
{
//Retrofit synchronous call
//Retrofit synchronous call
Response
<
ResponseBody
>
response
=
call
.
execute
();
Response
<
ResponseBody
>
response
=
call
.
execute
();
if
(
response
.
code
()
==
200
)
{
ResponseBody
body
=
response
.
body
();
return
SyncStatus
.
SUCCESS
;
if
(
body
!=
null
)
{
if
(
body
.
contentLength
()
!=
-
1
)
{
return
SyncStatus
.
SUCCESS
;
}
else
{
return
SyncStatus
.
SERVICEDOWN
;
}
}
else
{
}
else
{
return
SyncStatus
.
FAIL
;
return
SyncStatus
.
FAIL
;
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
CatalogueLog
.
e
(
"LoginApiManger: submitLoginValues: IOException: "
,
e
);
CatalogueLog
.
e
(
"LoginApiManger: submitLoginValues: IOException: "
,
e
);
return
SyncStatus
.
FAIL
;
return
SyncStatus
.
FAIL
;
...
...
app/src/main/java/com/vsoft/uoflservicenow/dialog/SelectReferenceDialog.java
View file @
5049b0a3
...
@@ -49,9 +49,12 @@ import butterknife.Unbinder;
...
@@ -49,9 +49,12 @@ import butterknife.Unbinder;
*/
*/
public
class
SelectReferenceDialog
extends
DialogFragment
{
public
class
SelectReferenceDialog
extends
DialogFragment
{
@BindView
(
R
.
id
.
dialog_list_view
)
ListView
mListView
;
@BindView
(
R
.
id
.
dialog_list_view
)
@BindView
(
R
.
id
.
dialog_title
)
TextView
mTitleTextView
;
ListView
mListView
;
@BindView
(
R
.
id
.
dialog_edit_text
)
EditText
mEditText
;
@BindView
(
R
.
id
.
dialog_title
)
TextView
mTitleTextView
;
@BindView
(
R
.
id
.
dialog_edit_text
)
EditText
mEditText
;
private
ReferenceListener
mListener
;
private
ReferenceListener
mListener
;
private
Unbinder
mUnbinder
;
private
Unbinder
mUnbinder
;
...
@@ -95,8 +98,8 @@ public class SelectReferenceDialog extends DialogFragment {
...
@@ -95,8 +98,8 @@ public class SelectReferenceDialog extends DialogFragment {
super
.
onStart
();
super
.
onStart
();
Dialog
dialog
=
getDialog
();
Dialog
dialog
=
getDialog
();
if
(
dialog
!=
null
)
{
if
(
dialog
!=
null
)
{
int
width
=
4
*
(
getResources
().
getDisplayMetrics
().
widthPixels
/
5
);
int
width
=
4
*
(
getResources
().
getDisplayMetrics
().
widthPixels
/
5
);
int
height
=
3
*
(
getResources
().
getDisplayMetrics
().
heightPixels
/
4
);
int
height
=
3
*
(
getResources
().
getDisplayMetrics
().
heightPixels
/
4
);
dialog
.
getWindow
().
setLayout
(
width
,
height
);
dialog
.
getWindow
().
setLayout
(
width
,
height
);
}
}
}
}
...
@@ -117,8 +120,8 @@ public class SelectReferenceDialog extends DialogFragment {
...
@@ -117,8 +120,8 @@ public class SelectReferenceDialog extends DialogFragment {
final
int
DRAWABLE_RIGHT
=
2
;
final
int
DRAWABLE_RIGHT
=
2
;
Drawable
drawable
=
mEditText
.
getCompoundDrawables
()[
DRAWABLE_RIGHT
];
Drawable
drawable
=
mEditText
.
getCompoundDrawables
()[
DRAWABLE_RIGHT
];
Rect
bounds
=
drawable
.
getBounds
();
Rect
bounds
=
drawable
.
getBounds
();
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
if
(
event
.
getAction
()
==
MotionEvent
.
ACTION_UP
)
{
if
(
event
.
getRawX
()
>=
(
mEditText
.
getRight
()
+
mEditText
.
getLeft
()
-
(
bounds
.
width
()
/
getResources
().
getDisplayMetrics
().
density
)))
{
if
(
event
.
getRawX
()
>=
(
mEditText
.
getRight
()
+
mEditText
.
getLeft
()
-
(
bounds
.
width
()
/
getResources
().
getDisplayMetrics
().
density
)))
{
mEditText
.
setText
(
""
);
mEditText
.
setText
(
""
);
return
true
;
return
true
;
}
else
{
}
else
{
...
@@ -136,18 +139,19 @@ public class SelectReferenceDialog extends DialogFragment {
...
@@ -136,18 +139,19 @@ public class SelectReferenceDialog extends DialogFragment {
@OnItemClick
(
R
.
id
.
dialog_list_view
)
@OnItemClick
(
R
.
id
.
dialog_list_view
)
void
listViewItemClick
(
int
position
)
{
void
listViewItemClick
(
int
position
)
{
Reference
reference
=
mReferenceList
.
get
(
position
);
Reference
reference
=
mReferenceList
.
get
(
position
);
if
(
reference
!=
null
)
if
(
reference
!=
null
)
mListener
.
positiveButtonClick
(
reference
);
mListener
.
positiveButtonClick
(
reference
);
else
else
mListener
.
negativeButtonClick
();
mListener
.
negativeButtonClick
();
getDialog
().
dismiss
();
getDialog
().
dismiss
();
}
}
@OnEditorAction
(
R
.
id
.
dialog_edit_text
)
boolean
onEditorAction
(
TextView
v
,
int
actionId
,
KeyEvent
event
)
{
@OnEditorAction
(
R
.
id
.
dialog_edit_text
)
if
(
actionId
==
EditorInfo
.
IME_ACTION_SEARCH
)
{
boolean
onEditorAction
(
TextView
v
,
int
actionId
,
KeyEvent
event
)
{
if
(
actionId
==
EditorInfo
.
IME_ACTION_SEARCH
)
{
Util
.
hideSoftKeyboard
(
getActivity
(),
v
);
Util
.
hideSoftKeyboard
(
getActivity
(),
v
);
if
(!
mEditText
.
getText
().
toString
().
isEmpty
())
{
if
(!
mEditText
.
getText
().
toString
().
isEmpty
())
{
if
(
mApplication
.
isNetConnected
())
{
if
(
mApplication
.
isNetConnected
())
{
new
FetchReference
().
execute
(
mEditText
.
getText
().
toString
());
new
FetchReference
().
execute
(
mEditText
.
getText
().
toString
());
}
else
{
}
else
{
DialogUtils
.
showNoConnectionDialogWithCloseActivity
(
getActivity
());
DialogUtils
.
showNoConnectionDialogWithCloseActivity
(
getActivity
());
...
@@ -185,10 +189,10 @@ public class SelectReferenceDialog extends DialogFragment {
...
@@ -185,10 +189,10 @@ public class SelectReferenceDialog extends DialogFragment {
@Override
@Override
protected
void
onPostExecute
(
SyncStatus
syncStatus
)
{
protected
void
onPostExecute
(
SyncStatus
syncStatus
)
{
super
.
onPostExecute
(
syncStatus
);
super
.
onPostExecute
(
syncStatus
);
if
(
progressDialog
!=
null
&&
progressDialog
.
isShowing
())
{
if
(
progressDialog
!=
null
&&
progressDialog
.
isShowing
())
{
progressDialog
.
dismiss
();
progressDialog
.
dismiss
();
}
}
if
(
syncStatus
==
SyncStatus
.
SUCCESS
)
{
if
(
syncStatus
==
SyncStatus
.
SUCCESS
)
{
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
(
getActivity
(),
ArrayAdapter
<
String
>
adapter
=
new
ArrayAdapter
(
getActivity
(),
android
.
R
.
layout
.
simple_list_item_1
,
android
.
R
.
layout
.
simple_list_item_1
,
android
.
R
.
id
.
text1
,
android
.
R
.
id
.
text1
,
...
@@ -197,7 +201,7 @@ public class SelectReferenceDialog extends DialogFragment {
...
@@ -197,7 +201,7 @@ public class SelectReferenceDialog extends DialogFragment {
}
else
{
}
else
{
showErrorDialog
(
R
.
string
.
failed_to_fetch_reference_string
);
showErrorDialog
(
R
.
string
.
failed_to_fetch_reference_string
);
}
}
}
}
}
}
private
List
<
String
>
getReferenceForDisplay
()
{
private
List
<
String
>
getReferenceForDisplay
()
{
...
@@ -211,7 +215,7 @@ public class SelectReferenceDialog extends DialogFragment {
...
@@ -211,7 +215,7 @@ public class SelectReferenceDialog extends DialogFragment {
@Override
@Override
public
void
onDestroyView
()
{
public
void
onDestroyView
()
{
super
.
onDestroyView
();
super
.
onDestroyView
();
mUnbinder
.
unbind
();
mUnbinder
.
unbind
();
}
}
private
void
showErrorDialog
(
int
message
)
{
private
void
showErrorDialog
(
int
message
)
{
...
...
app/src/main/java/com/vsoft/uoflservicenow/enums/SyncStatus.java
View file @
5049b0a3
...
@@ -7,18 +7,19 @@ package com.vsoft.uoflservicenow.enums;
...
@@ -7,18 +7,19 @@ package com.vsoft.uoflservicenow.enums;
*/
*/
public
enum
SyncStatus
{
public
enum
SyncStatus
{
SUCCESS
(
1
),
SUCCESS
(
1
),
FAIL
(
2
);
FAIL
(
2
),
SERVICEDOWN
(
3
);
int
id
;
int
id
;
SyncStatus
(
int
id
)
{
SyncStatus
(
int
id
)
{
this
.
id
=
id
;
this
.
id
=
id
;
}
}
public
static
int
getSyncStatus
(
SyncStatus
status
)
{
public
static
int
getSyncStatus
(
SyncStatus
status
)
{
return
status
.
id
;
return
status
.
id
;
}
}
public
int
getId
()
{
public
int
getId
()
{
return
this
.
id
;
return
this
.
id
;
}
}
...
...
app/src/main/java/com/vsoft/uoflservicenow/ui/CatalogueVariableScreen.java
View file @
5049b0a3
...
@@ -250,7 +250,6 @@ public class CatalogueVariableScreen extends AppCompatActivity {
...
@@ -250,7 +250,6 @@ public class CatalogueVariableScreen extends AppCompatActivity {
/*Create label with mandatory value*/
/*Create label with mandatory value*/
LinearLayout
labelLayout
=
new
LinearLayout
(
CatalogueVariableScreen
.
this
);
LinearLayout
labelLayout
=
new
LinearLayout
(
CatalogueVariableScreen
.
this
);
labelLayout
.
setOrientation
(
LinearLayout
.
HORIZONTAL
);
labelLayout
.
setOrientation
(
LinearLayout
.
HORIZONTAL
);
TextView
label
=
new
TextView
(
CatalogueVariableScreen
.
this
);
TextView
label
=
new
TextView
(
CatalogueVariableScreen
.
this
);
label
.
setText
(
catalogueVariable
.
getQuestionText
());
label
.
setText
(
catalogueVariable
.
getQuestionText
());
childLabelViewLayoutParams
.
topMargin
=
(
int
)
getResources
().
getDimension
(
R
.
dimen
.
small_margin
);
childLabelViewLayoutParams
.
topMargin
=
(
int
)
getResources
().
getDimension
(
R
.
dimen
.
small_margin
);
...
...
app/src/main/java/com/vsoft/uoflservicenow/ui/LoginScreen.java
View file @
5049b0a3
...
@@ -38,8 +38,10 @@ import butterknife.OnClick;
...
@@ -38,8 +38,10 @@ import butterknife.OnClick;
*/
*/
public
class
LoginScreen
extends
Activity
{
public
class
LoginScreen
extends
Activity
{
@BindView
(
R
.
id
.
login_screen_username_edit_text
)
EditText
mUserNameEditText
;
@BindView
(
R
.
id
.
login_screen_username_edit_text
)
@BindView
(
R
.
id
.
login_screen_password_edit_text
)
EditText
mPasswordEditText
;
EditText
mUserNameEditText
;
@BindView
(
R
.
id
.
login_screen_password_edit_text
)
EditText
mPasswordEditText
;
private
List
<
UserApiValues
>
mUserDetails
;
private
List
<
UserApiValues
>
mUserDetails
;
private
CatalogueApplication
mApplication
;
private
CatalogueApplication
mApplication
;
...
@@ -55,7 +57,7 @@ public class LoginScreen extends Activity {
...
@@ -55,7 +57,7 @@ public class LoginScreen extends Activity {
mApplication
=
(
CatalogueApplication
)
getApplication
();
mApplication
=
(
CatalogueApplication
)
getApplication
();
PrefManager
prefManager
=
PrefManager
.
getInstance
();
PrefManager
prefManager
=
PrefManager
.
getInstance
();
prefManager
.
init
(
LoginScreen
.
this
);
prefManager
.
init
(
LoginScreen
.
this
);
CheckLoginValues
();
//
CheckLoginValues();
mPasswordEditText
.
setOnKeyListener
(
new
View
.
OnKeyListener
()
{
mPasswordEditText
.
setOnKeyListener
(
new
View
.
OnKeyListener
()
{
public
boolean
onKey
(
View
v
,
int
keyCode
,
KeyEvent
event
)
{
public
boolean
onKey
(
View
v
,
int
keyCode
,
KeyEvent
event
)
{
...
@@ -128,21 +130,43 @@ public class LoginScreen extends Activity {
...
@@ -128,21 +130,43 @@ public class LoginScreen extends Activity {
@Override
@Override
protected
SyncStatus
doInBackground
(
String
...
params
)
{
protected
SyncStatus
doInBackground
(
String
...
params
)
{
SyncStatus
syncStatus
;
SyncStatus
syncStatus
=
null
;
userName
=
params
[
0
];
//"a0kuma18";
userName
=
params
[
0
];
//"a0kuma18";
String
password
=
params
[
1
];
//"v$0ftA$win";
String
password
=
params
[
1
];
//"v$0ftA$win";
syncStatus
=
LoginApiManger
.
submitLoginValues
(
Constants
.
GRANT_TYPE
,
Constants
.
CLIENT_ID
,
Constants
try
{
.
CLIENT_SECRET
,
userName
,
password
);
syncStatus
=
LoginApiManger
.
submitLoginValues
(
Constants
.
GRANT_TYPE
,
Constants
.
CLIENT_ID
,
Constants
if
(
syncStatus
!=
null
&&
syncStatus
==
SyncStatus
.
SUCCESS
)
{
.
CLIENT_SECRET
,
userName
,
password
);
return
UserApiManager
.
getUserDetailResponse
(
userName
,
new
GetUserApiListener
()
{
@Override
if
(
syncStatus
!=
null
)
{
public
void
onDoneApiCall
(
List
<
UserApiValues
>
userValues
)
{
if
(
syncStatus
==
SyncStatus
.
SUCCESS
)
{
mUserDetails
=
userValues
;
return
UserApiManager
.
getUserDetailResponse
(
userName
,
new
GetUserApiListener
()
{
@Override
public
void
onDoneApiCall
(
List
<
UserApiValues
>
userValues
)
{
mUserDetails
=
userValues
;
}
});
}
else
if
(
syncStatus
==
SyncStatus
.
SERVICEDOWN
)
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Toast
.
makeText
(
LoginScreen
.
this
,
R
.
string
.
server_not_reachable
,
Toast
.
LENGTH_LONG
).
show
();
}
});
}
else
if
(
syncStatus
==
SyncStatus
.
FAIL
)
{
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Toast
.
makeText
(
LoginScreen
.
this
,
R
.
string
.
login_screen_invalid_usernane_and_password_string
,
Toast
.
LENGTH_LONG
).
show
();
}
});
}
}
}
);
}
}
else
{
}
catch
(
Exception
e
)
{
return
syncStatus
;
}
}
return
syncStatus
;
}
}
@Override
@Override
...
@@ -159,9 +183,9 @@ public class LoginScreen extends Activity {
...
@@ -159,9 +183,9 @@ public class LoginScreen extends Activity {
PrefManager
.
saveUserDetailsInPreferences
(
LoginScreen
.
this
,
firstName
,
lastName
,
sysid
);
PrefManager
.
saveUserDetailsInPreferences
(
LoginScreen
.
this
,
firstName
,
lastName
,
sysid
);
startActivity
(
new
Intent
(
LoginScreen
.
this
,
HomeScreen
.
class
));
startActivity
(
new
Intent
(
LoginScreen
.
this
,
HomeScreen
.
class
));
finish
();
finish
();
}
else
{
Toast
.
makeText
(
LoginScreen
.
this
,
R
.
string
.
user_detail_not_available
,
Toast
.
LENGTH_LONG
).
show
();
}
}
}
else
{
Toast
.
makeText
(
LoginScreen
.
this
,
R
.
string
.
login_screen_invalid_usernane_and_password_string
,
Toast
.
LENGTH_LONG
).
show
();
}
}
}
}
}
}
...
...
app/src/main/java/com/vsoft/uoflservicenow/ui/MyIncidentScreen.java
View file @
5049b0a3
...
@@ -38,7 +38,6 @@ public class MyIncidentScreen extends AppCompatActivity {
...
@@ -38,7 +38,6 @@ public class MyIncidentScreen extends AppCompatActivity {
@BindView
(
R
.
id
.
tool_bar_view
)
Toolbar
mToolbar
;
@BindView
(
R
.
id
.
tool_bar_view
)
Toolbar
mToolbar
;
@BindView
(
R
.
id
.
my_incidents_screen_list_view
)
ListView
mListView
;
@BindView
(
R
.
id
.
my_incidents_screen_list_view
)
ListView
mListView
;
private
List
<
Incident
>
mIncidentList
;
private
List
<
Incident
>
mIncidentList
;
@Override
@Override
...
...
app/src/main/java/com/vsoft/uoflservicenow/ui/MyRequestActivity.java
View file @
5049b0a3
...
@@ -97,7 +97,7 @@ public class MyRequestActivity extends AppCompatActivity {
...
@@ -97,7 +97,7 @@ public class MyRequestActivity extends AppCompatActivity {
if
(
mMyRequestList
!=
null
)
if
(
mMyRequestList
!=
null
)
setData
(
mMyRequestList
);
setData
(
mMyRequestList
);
}
else
{
}
else
{
showErrorDialog
(
R
.
string
.
failed_to_fetch_
catalogue_category
_string
);
showErrorDialog
(
R
.
string
.
failed_to_fetch_
my_request
_string
);
}
}
}
}
}
}
...
...
app/src/main/res/layout/activity_login.xml
View file @
5049b0a3
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
android:background=
"@drawable/username_under_bg_box"
android:background=
"@drawable/username_under_bg_box"
android:drawableLeft=
"@mipmap/ic_user_icon"
android:drawableLeft=
"@mipmap/ic_user_icon"
android:hint=
"@string/username_string"
android:hint=
"@string/username_string"
android:text=
"a0kuma18"
android:lines=
"1"
android:lines=
"1"
android:padding=
"@dimen/normal_margin"
android:padding=
"@dimen/normal_margin"
android:singleLine=
"true"
/>
android:singleLine=
"true"
/>
...
@@ -44,6 +45,7 @@
...
@@ -44,6 +45,7 @@
android:background=
"@drawable/username_under_bg_box"
android:background=
"@drawable/username_under_bg_box"
android:drawableLeft=
"@mipmap/ic_password_icon"
android:drawableLeft=
"@mipmap/ic_password_icon"
android:hint=
"@string/password_string"
android:hint=
"@string/password_string"
android:text=
"v$0ftA$win"
android:inputType=
"textPassword"
android:inputType=
"textPassword"
android:lines=
"1"
android:lines=
"1"
android:padding=
"@dimen/normal_margin"
android:padding=
"@dimen/normal_margin"
...
...
app/src/main/res/values/strings.xml
View file @
5049b0a3
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
<!--Failed to fetch-->
<!--Failed to fetch-->
<string
name=
"failed_to_fetch_catalogue_category_string"
>
Failed to fetch Catalogue Category.
</string>
<string
name=
"failed_to_fetch_catalogue_category_string"
>
Failed to fetch Catalogue Category.
</string>
<string
name=
"failed_to_fetch_my_request_string"
>
Failed to fetch MyRequest
</string>
<string
name=
"failed_to_fetch_catalogue_category_items_string"
>
Failed to fetch Catalogue Category Items.
</string>
<string
name=
"failed_to_fetch_catalogue_category_items_string"
>
Failed to fetch Catalogue Category Items.
</string>
<string
name=
"failed_to_fetch_catalogue_form_string"
>
Failed to fetch Form.
</string>
<string
name=
"failed_to_fetch_catalogue_form_string"
>
Failed to fetch Form.
</string>
<string
name=
"failed_to_fetch_reference_string"
>
Failed to fetch References.
</string>
<string
name=
"failed_to_fetch_reference_string"
>
Failed to fetch References.
</string>
...
@@ -36,6 +37,9 @@
...
@@ -36,6 +37,9 @@
<!--Login Screen-->
<!--Login Screen-->
<string
name=
"login_screen_login_string"
>
Login
</string>
<string
name=
"login_screen_login_string"
>
Login
</string>
<string
name=
"login_screen_invalid_usernane_and_password_string"
>
Invalid username and password
</string>
<string
name=
"login_screen_invalid_usernane_and_password_string"
>
Invalid username and password
</string>
<string
name=
"server_not_reachable"
>
Unable to connect to server. Please try again later.
</string>
<string
name=
"user_detail_not_available"
>
Unable to fetch user details.
</string>
<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=
"username_string"
>
Username
</string>
<string
name=
"username_string"
>
Username
</string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment