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
816fab51
authored
Nov 24, 2016
by
Kunj Gupta
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fixed - Pre fill user detail in variable from screen.
parent
df26a011
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
27 deletions
app/src/main/java/com/vsoft/uoflservicenow/db/models/UserApiValues.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/utils/PrefManager.java
app/src/main/res/values/strings.xml
app/src/main/java/com/vsoft/uoflservicenow/db/models/UserApiValues.java
View file @
816fab51
...
...
@@ -20,6 +20,14 @@ public class UserApiValues {
@Expose
private
String
sysId
;
@SerializedName
(
"name"
)
@Expose
private
String
fullName
;
@SerializedName
(
"user_name"
)
@Expose
private
String
userId
;
public
String
getFirstName
()
{
return
firstName
;
}
...
...
@@ -43,4 +51,20 @@ public class UserApiValues {
public
void
setSysId
(
String
sysId
)
{
this
.
sysId
=
sysId
;
}
public
String
getFullName
()
{
return
fullName
;
}
public
void
setFullName
(
String
fullName
)
{
this
.
fullName
=
fullName
;
}
public
String
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
String
userId
)
{
this
.
userId
=
userId
;
}
}
app/src/main/java/com/vsoft/uoflservicenow/ui/CatalogueVariableScreen.java
View file @
816fab51
...
...
@@ -9,6 +9,7 @@ import android.content.ContentUris;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.content.pm.PackageManager
;
import
android.database.Cursor
;
import
android.graphics.Typeface
;
...
...
@@ -76,6 +77,7 @@ import com.vsoft.uoflservicenow.utils.CatalogueLog;
import
com.vsoft.uoflservicenow.utils.Constants
;
import
com.vsoft.uoflservicenow.utils.DialogUtils
;
import
com.vsoft.uoflservicenow.utils.PartialCondition
;
import
com.vsoft.uoflservicenow.utils.PrefManager
;
import
com.vsoft.uoflservicenow.utils.Util
;
import
org.json.JSONArray
;
...
...
@@ -118,7 +120,6 @@ public class CatalogueVariableScreen extends AppCompatActivity {
private
File
mAttachmentFile
;
private
Uri
mAttachmentUri
;
private
HashMap
<
CatalogueVariable
,
VariableViewContainer
>
mVariableViewMap
;
private
HashMap
<
String
,
ArrayList
<
CatalogueVariable
>>
mContainerViewMap
;
private
static
final
int
WRITE_EXTERNAL_STORAGE
=
1
;
private
static
final
int
FILE_SELECT_CODE
=
0
;
...
...
@@ -364,7 +365,11 @@ public class CatalogueVariableScreen extends AppCompatActivity {
if
(!
mCatalogueVariableList
.
isEmpty
())
{
VariableViewContainer
container
;
SharedPreferences
sharedPreferences
=
null
;
for
(
int
i
=
0
;
i
<
mCatalogueVariableList
.
size
();
i
++)
{
if
(
sharedPreferences
==
null
)
{
sharedPreferences
=
getSharedPreferences
(
PrefManager
.
PREFERENCES_USER_VALUES_KEY
,
Context
.
MODE_PRIVATE
);
}
CatalogueVariable
catalogueVariable
=
mCatalogueVariableList
.
get
(
i
);
/*If API return active false for a variable, there is no need show that variable*/
if
(
catalogueVariable
.
isActive
())
{
...
...
@@ -402,6 +407,14 @@ public class CatalogueVariableScreen extends AppCompatActivity {
View
controlView
=
container
.
getInputView
();
if
(
controlView
!=
null
)
{
/*For set default text in full_name and user_id textView.*/
if
(
catalogueVariable
.
getName
().
equals
(
getString
(
R
.
string
.
catalogue_user_full_name
)))
{
String
userFullName
=
sharedPreferences
.
getString
(
PrefManager
.
PREFERENCE_USER_FULL_NAME
,
""
);
((
EditText
)
controlView
).
setText
(
userFullName
);
}
else
if
(
catalogueVariable
.
getName
().
equals
(
getString
(
R
.
string
.
catalogue_user_id
)))
{
String
userId
=
sharedPreferences
.
getString
(
PrefManager
.
PREFERENCE_USER_ID
,
""
);
((
EditText
)
controlView
).
setText
(
userId
);
}
if
(
viewType
==
ViewType
.
DATE
)
{
controlView
.
setOnClickListener
(
dateListener
);
}
else
if
(
viewType
==
ViewType
.
DATE_AND_TIME
)
{
...
...
app/src/main/java/com/vsoft/uoflservicenow/ui/LoginScreen.java
View file @
816fab51
...
...
@@ -181,8 +181,10 @@ public class LoginScreen extends Activity {
if
(
mUserDetails
!=
null
)
{
String
firstName
=
mUserDetails
.
get
(
0
).
getFirstName
();
String
lastName
=
mUserDetails
.
get
(
0
).
getLastName
();
String
sysid
=
mUserDetails
.
get
(
0
).
getSysId
();
PrefManager
.
saveUserDetailsInPreferences
(
LoginScreen
.
this
,
firstName
,
lastName
,
sysid
);
String
sysId
=
mUserDetails
.
get
(
0
).
getSysId
();
String
userFullName
=
mUserDetails
.
get
(
0
).
getFullName
();
String
userId
=
mUserDetails
.
get
(
0
).
getUserId
();
PrefManager
.
saveUserDetailsInPreferences
(
LoginScreen
.
this
,
userFullName
,
userId
,
firstName
,
lastName
,
sysId
);
startActivity
(
new
Intent
(
LoginScreen
.
this
,
HomeScreen
.
class
));
finish
();
}
else
{
...
...
app/src/main/java/com/vsoft/uoflservicenow/utils/PrefManager.java
View file @
816fab51
...
...
@@ -10,21 +10,22 @@ import android.preference.PreferenceManager;
public
class
PrefManager
{
private
static
volatile
PrefManager
pSelf
=
null
;
String
TAG
=
PrefManager
.
class
.
getSimpleName
();
private
SharedPreferences
sharedPref
=
null
;
private
SharedPreferences
.
Editor
editor
=
null
;
//Login Preferences
public
static
final
String
PREFERENCES_USER_VALUES_KEY
=
"UserPrefs"
;
p
ublic
static
final
String
PREFERENCES_FIRST_NAME
=
"firstName"
;
p
ublic
static
final
String
PREFERENCE_LAST_NAME
=
"lastName"
;
p
rivate
static
final
String
PREFERENCES_FIRST_NAME
=
"firstName"
;
p
rivate
static
final
String
PREFERENCE_LAST_NAME
=
"lastName"
;
public
static
final
String
PREFERENCE_SYS_ID
=
"sysId"
;
public
static
final
String
PREFERENCE_USER_FULL_NAME
=
"full_name"
;
public
static
final
String
PREFERENCE_USER_ID
=
"user_id"
;
public
static
PrefManager
getInstance
(){
if
(
pSelf
==
null
){
synchronized
(
PrefManager
.
class
){
if
(
pSelf
==
null
){
public
static
PrefManager
getInstance
()
{
if
(
pSelf
==
null
)
{
synchronized
(
PrefManager
.
class
)
{
if
(
pSelf
==
null
)
{
pSelf
=
new
PrefManager
();
}
}
...
...
@@ -36,65 +37,66 @@ public class PrefManager {
/**
* save username and password in shared preferences
* @param context
* @param first
n
ame
* @param last
n
ame
* @param sys
i
d
* @param first
N
ame
* @param last
N
ame
* @param sys
I
d
*/
public
static
void
saveUserDetailsInPreferences
(
Context
context
,
String
firstname
,
String
lastname
,
String
sysid
)
{
public
static
void
saveUserDetailsInPreferences
(
Context
context
,
String
userFullName
,
String
userId
,
String
firstName
,
String
lastName
,
String
sysId
)
{
SharedPreferences
sharedPreferences
=
context
.
getSharedPreferences
(
PREFERENCES_USER_VALUES_KEY
,
Context
.
MODE_PRIVATE
);
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
/**
* some times we are getting a username with white space
* so we just removed here
*/
editor
.
putString
(
PREFERENCES_FIRST_NAME
,
firstname
);
editor
.
putString
(
PREFERENCE_LAST_NAME
,
lastname
);
editor
.
putString
(
PREFERENCE_SYS_ID
,
sysid
);
editor
.
putString
(
PREFERENCES_FIRST_NAME
,
firstName
);
editor
.
putString
(
PREFERENCE_LAST_NAME
,
lastName
);
editor
.
putString
(
PREFERENCE_SYS_ID
,
sysId
);
editor
.
putString
(
PREFERENCE_USER_FULL_NAME
,
userFullName
);
editor
.
putString
(
PREFERENCE_USER_ID
,
userId
);
editor
.
apply
();
}
public
void
init
(
Context
context
){
public
void
init
(
Context
context
)
{
sharedPref
=
PreferenceManager
.
getDefaultSharedPreferences
(
context
);
editor
=
sharedPref
.
edit
();
}
//! Generic function to get boolean value for specified key.
public
boolean
getPrefValueBoolean
(
String
mKey
,
boolean
defValue
){
public
boolean
getPrefValueBoolean
(
String
mKey
,
boolean
defValue
)
{
return
sharedPref
.
getBoolean
(
mKey
,
defValue
);
}
//! Generic function to get int value for specified key.
public
int
getPrefValueInt
(
String
mKey
,
int
defValue
){
public
int
getPrefValueInt
(
String
mKey
,
int
defValue
)
{
return
sharedPref
.
getInt
(
mKey
,
defValue
);
}
//! Generic function to string value for specified key.
public
String
getPrefValueString
(
String
mKey
,
String
defValue
){
public
String
getPrefValueString
(
String
mKey
,
String
defValue
)
{
return
sharedPref
.
getString
(
mKey
,
defValue
);
}
public
Long
getPrefValueLong
(
String
mKey
,
Long
defValue
){
public
Long
getPrefValueLong
(
String
mKey
,
Long
defValue
)
{
return
sharedPref
.
getLong
(
mKey
,
defValue
);
}
public
void
putPrefValueBoolean
(
String
mKey
,
boolean
mValue
){
public
void
putPrefValueBoolean
(
String
mKey
,
boolean
mValue
)
{
editor
.
putBoolean
(
mKey
,
mValue
);
editor
.
commit
();
}
public
void
putPrefValueInt
(
String
mKey
,
int
mValue
){
public
void
putPrefValueInt
(
String
mKey
,
int
mValue
)
{
editor
.
putInt
(
mKey
,
mValue
);
editor
.
commit
();
}
public
void
putPrefValueString
(
String
mKey
,
String
mValue
){
public
void
putPrefValueString
(
String
mKey
,
String
mValue
)
{
editor
.
putString
(
mKey
,
mValue
);
editor
.
commit
();
}
public
void
putLong
(
String
mKey
,
long
mValue
){
public
void
putLong
(
String
mKey
,
long
mValue
)
{
editor
.
putLong
(
mKey
,
mValue
);
editor
.
commit
();
}
...
...
app/src/main/res/values/strings.xml
View file @
816fab51
...
...
@@ -93,4 +93,12 @@
<string
name=
"connection_alert_dialog_message"
>
Please check your device settings to ensure you have a working internet connection.
</string>
<string
name=
"cancel"
>
Cancel
</string>
<string
name=
"settings"
>
Settings
</string>
<!--Catalogue Variable form screen - key for pre fill value-->
<string
name=
"catalogue_user_full_name"
>
full_name
</string>
<string
name=
"catalogue_user_id"
>
user_id
</string>
<!--Preference keys for pre fill value-->
<string
name=
"preference_full_name"
>
full_name
</string>
<string
name=
"preference_user_id"
>
user_id
</string>
</resources>
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