es.ugr.swad.swadroid
Class Global

java.lang.Object
  extended by es.ugr.swad.swadroid.Global

public class Global
extends java.lang.Object

Global data of application.

Author:
Juan Miguel Boyero Corral , Antonio Aguilera Malagon , Helena Rodriguez Gijon

Field Summary
private static java.lang.String AB
          Base string to generate random alphanumeric strings
private static java.lang.String accountType
          Account type
static java.lang.String APP_TAG
          Prefix tag name for Logcat
private static java.lang.String authority
          Synchronization authority
private static java.lang.String BugsenseAPIKey
          Bugsense application key
static int COURSES_REQUEST_CODE
          Request code for Courses module.
private static int currentUserRole
          Role of the logged User in the current selected course
static java.lang.String DB_TABLE_COURSES
          Table name for courses
static java.lang.String DB_TABLE_GROUP_TYPES
          Table name for group types
static java.lang.String DB_TABLE_GROUPS
          Table name for groups
static java.lang.String DB_TABLE_GROUPS_COURSES
          Table name for relationship between groups and courses
static java.lang.String DB_TABLE_GROUPS_GROUPTYPES
          Table name for relationship between groups and group types
static java.lang.String DB_TABLE_NOTIFICATIONS
          Table name for notifications
static java.lang.String DB_TABLE_PRACTICE_SESSIONS
          Table name for practice sessions
static java.lang.String DB_TABLE_ROLLCALL
          Table name for rollcall
static java.lang.String DB_TABLE_TEST_ANSWERS
          Table name for test's answers
static java.lang.String DB_TABLE_TEST_CONFIG
          Table name for test's configuration
static java.lang.String DB_TABLE_TEST_QUESTION_ANSWERS
          Table name for relationship between test's questions and answers
static java.lang.String DB_TABLE_TEST_QUESTION_TAGS
          Table name for relationship between test's questions and tags
static java.lang.String DB_TABLE_TEST_QUESTIONS
          Table name for test's questions
static java.lang.String DB_TABLE_TEST_QUESTIONS_COURSE
          Table name for relationship between test's questions and courses
static java.lang.String DB_TABLE_TEST_TAGS
          Table name for test's tags
static java.lang.String DB_TABLE_USERS
          Table name for users
static java.lang.String DB_TABLE_USERS_COURSES
          Table name for relationship between users and courses
private static boolean dbCleaned
          Indicates if there are changes on db
private static java.lang.String DEFAULT_SERVER
          Server URL
private static long DEFAULT_SYNC_TIME
           
static int DIRECTORY_TREE_REQUEST_CODE
          Request code for Directory Tree Download module
static int DOCUMENTS_AREA_CODE
          Code to access to the documents in documents area
static int DOWNLOADSMANAGER_REQUEST_CODE
          Request code for Downloads Manager
static int GETFILE_REQUEST_CODE
          Request code for GetFile Manager
static int GROUPS_REQUEST_CODE
          Request code for Directory Tree Download module
static int GROUPTYPES_REQUEST_CODE
          Request code for Group Types module
private static long lastLoginTime
          Time of application's last login
private static boolean logged
          User logged flag
private static User loggedUser
          Logged user
static int LOGIN_REQUEST_CODE
          Request code for Login module.
static int MESSAGES_REQUEST_CODE
          Request code for Tests module.
static int MYGROUPSMANAGER_REQUEST_CODE
          Request code for MyGroups Manager
static int NOTICES_REQUEST_CODE
          Request code for Notice module
static int NOTIFICATIONS_REQUEST_CODE
          Request code for Notifications module.
static int NOTIFYDOWNLOAD_REQUEST_CODE
          Request code for Notify Download
static java.lang.String NULL_VALUE
          Null value returned by webservices when a field is empty
private static boolean preferencesChanged
          Indicates if there are changes on preferences
static int RELOGIN_TIME
          Time to force relogin
private static java.util.Random rnd
          Random generator
static int ROLLCALL_CONFIG_DOWNLOAD_REQUEST_CODE
          Request code for Rollcall Config Download module.
static int ROLLCALL_HISTORY_REQUEST_CODE
          Request code for Rollcall History module.
static int ROLLCALL_REQUEST_CODE
          Request code for Rollcall module.
static int SCAN_QR_REQUEST_CODE
          Request code for Scan QR module.
private static long selectedCourseCode
          Code of the chosen course.
private static java.lang.String selectedCourseFullName
          Short name of the full course.
private static java.lang.String selectedCourseShortName
          Short name of the chosen course.
static int SENDMYGROUPS_REQUEST_CODE
          Request code for SendMyGroups
static int SESSIONS_LIST_REQUEST_CODE
          Request code for Sessions List module.
static int SHARE_AREA_CODE
          Code to access to the documents in share area
static int STUDENT_TYPE_CODE
          Student userRole for getUsers web service.
static int STUDENTS_HISTORY_REQUEST_CODE
          Request code for Students History module.
static int STUDENTS_LIST_REQUEST_CODE
          Request code for Students List module.
private static java.lang.String SWADAppKey
          SWAD application key
static int TEACHER_TYPE_CODE
          Teacher userTypeCode for getUsers web service.
static int TESTS_CONFIG_DOWNLOAD_REQUEST_CODE
          Request code for Tests module.
static int TESTS_MAKE_REQUEST_CODE
          Request code for Tests module.
static int TESTS_QUESTIONS_DOWNLOAD_REQUEST_CODE
          Request code for Tests module.
static int TESTS_REQUEST_CODE
          Request code for Tests module.
 
Constructor Summary
Global()
           
 
Method Summary
static boolean connectionAvailable(Context ctx)
          Checks if any connection is available
static java.lang.String getAccountType()
          Gets the account type for synchronization
static java.lang.String getAuthority()
          Gets the authority for synchronization
static java.lang.String getBugsenseAPIKey()
          Gets the Bugsense API key
static int getCurrentUserRole()
          Gets the role of the logged user in the current selected course
static java.lang.String getDefaultServer()
          Gets the server URL
static long getDefaultSyncTime()
          Gets the default synchronization interval
static long getLastLoginTime()
          Gets start time of application
static User getLoggedUser()
          Gets the user logged on SWAD
static long getSelectedCourseCode()
          Gets code of current course return -1 if no course chosen; code of current course in other case
static java.lang.String getSelectedCourseFullName()
           
static java.lang.String getSelectedCourseShortName()
           
static java.lang.String getSWADAppKey()
          Gets the SWAD application key
static boolean isDbCleaned()
          Indicates if the db was cleaned
static boolean isLogged()
          Checks if user is already logged on SWAD
static boolean isPreferencesChanged()
           
static int parseBoolInt(boolean b)
          Function to parse from Boolean to Integer
static java.lang.String parseBoolString(boolean b)
          Function to parse from Boolean to String
static boolean parseIntBool(int n)
          Function to parse from Integer to Boolean
static boolean parseStringBool(java.lang.String s)
          Function to parse from String to Boolean
static java.lang.String randomString(int len)
          Generates a random string of length len
static void setCurrentUserRole(int userRole)
          Sets user role in the current selected course
static void setDbCleaned(boolean state)
          Set the fact that the db was cleaned
static void setLastLoginTime(long l)
          Sets start time of application
static void setLogged(boolean logged)
          Sets user logged flag
static void setLoggedUser(User loggedUser)
          Sets the user logged on SWAD
static void setPreferencesChanged()
          Set the fact that the preferences has changed
static void setPreferencesChanged(boolean newState)
          Indicates if the preferences has changed
static void setSelectedCourseCode(long currentCourseCode)
          Sets code of current course
static void setSelectedCourseFullName(java.lang.String currentCourseFullName)
           
static void setSelectedCourseShortName(java.lang.String currentCourseShortName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SWADAppKey

private static final java.lang.String SWADAppKey
SWAD application key

See Also:
Constant Field Values

BugsenseAPIKey

private static final java.lang.String BugsenseAPIKey
Bugsense application key

See Also:
Constant Field Values

DEFAULT_SERVER

private static final java.lang.String DEFAULT_SERVER
Server URL

See Also:
Constant Field Values

accountType

private static final java.lang.String accountType
Account type

See Also:
Constant Field Values

authority

private static final java.lang.String authority
Synchronization authority

See Also:
Constant Field Values

DEFAULT_SYNC_TIME

private static final long DEFAULT_SYNC_TIME
See Also:
Constant Field Values

logged

private static boolean logged
User logged flag


loggedUser

private static User loggedUser
Logged user


lastLoginTime

private static long lastLoginTime
Time of application's last login


selectedCourseCode

private static long selectedCourseCode
Code of the chosen course. All next actions are referred to this course.


selectedCourseShortName

private static java.lang.String selectedCourseShortName
Short name of the chosen course.


selectedCourseFullName

private static java.lang.String selectedCourseFullName
Short name of the full course.


currentUserRole

private static int currentUserRole
Role of the logged User in the current selected course


preferencesChanged

private static boolean preferencesChanged
Indicates if there are changes on preferences


dbCleaned

private static boolean dbCleaned
Indicates if there are changes on db


AB

private static final java.lang.String AB
Base string to generate random alphanumeric strings

See Also:
Constant Field Values

rnd

private static java.util.Random rnd
Random generator


NULL_VALUE

public static final java.lang.String NULL_VALUE
Null value returned by webservices when a field is empty

See Also:
Constant Field Values

RELOGIN_TIME

public static final int RELOGIN_TIME
Time to force relogin

See Also:
Constant Field Values

LOGIN_REQUEST_CODE

public static final int LOGIN_REQUEST_CODE
Request code for Login module.

See Also:
Constant Field Values

COURSES_REQUEST_CODE

public static final int COURSES_REQUEST_CODE
Request code for Courses module.

See Also:
Constant Field Values

NOTIFICATIONS_REQUEST_CODE

public static final int NOTIFICATIONS_REQUEST_CODE
Request code for Notifications module.

See Also:
Constant Field Values

TESTS_REQUEST_CODE

public static final int TESTS_REQUEST_CODE
Request code for Tests module.

See Also:
Constant Field Values

TESTS_CONFIG_DOWNLOAD_REQUEST_CODE

public static final int TESTS_CONFIG_DOWNLOAD_REQUEST_CODE
Request code for Tests module.

See Also:
Constant Field Values

TESTS_QUESTIONS_DOWNLOAD_REQUEST_CODE

public static final int TESTS_QUESTIONS_DOWNLOAD_REQUEST_CODE
Request code for Tests module.

See Also:
Constant Field Values

TESTS_MAKE_REQUEST_CODE

public static final int TESTS_MAKE_REQUEST_CODE
Request code for Tests module.

See Also:
Constant Field Values

MESSAGES_REQUEST_CODE

public static final int MESSAGES_REQUEST_CODE
Request code for Tests module.

See Also:
Constant Field Values

NOTICES_REQUEST_CODE

public static final int NOTICES_REQUEST_CODE
Request code for Notice module

See Also:
Constant Field Values

ROLLCALL_REQUEST_CODE

public static final int ROLLCALL_REQUEST_CODE
Request code for Rollcall module.

See Also:
Constant Field Values

SCAN_QR_REQUEST_CODE

public static final int SCAN_QR_REQUEST_CODE
Request code for Scan QR module.

See Also:
Constant Field Values

DIRECTORY_TREE_REQUEST_CODE

public static final int DIRECTORY_TREE_REQUEST_CODE
Request code for Directory Tree Download module

See Also:
Constant Field Values

GROUPS_REQUEST_CODE

public static final int GROUPS_REQUEST_CODE
Request code for Directory Tree Download module

See Also:
Constant Field Values

ROLLCALL_CONFIG_DOWNLOAD_REQUEST_CODE

public static final int ROLLCALL_CONFIG_DOWNLOAD_REQUEST_CODE
Request code for Rollcall Config Download module.

See Also:
Constant Field Values

ROLLCALL_HISTORY_REQUEST_CODE

public static final int ROLLCALL_HISTORY_REQUEST_CODE
Request code for Rollcall History module.

See Also:
Constant Field Values

STUDENTS_LIST_REQUEST_CODE

public static final int STUDENTS_LIST_REQUEST_CODE
Request code for Students List module.

See Also:
Constant Field Values

STUDENTS_HISTORY_REQUEST_CODE

public static final int STUDENTS_HISTORY_REQUEST_CODE
Request code for Students History module.

See Also:
Constant Field Values

SESSIONS_LIST_REQUEST_CODE

public static final int SESSIONS_LIST_REQUEST_CODE
Request code for Sessions List module.

See Also:
Constant Field Values

DOWNLOADSMANAGER_REQUEST_CODE

public static final int DOWNLOADSMANAGER_REQUEST_CODE
Request code for Downloads Manager

See Also:
Constant Field Values

NOTIFYDOWNLOAD_REQUEST_CODE

public static final int NOTIFYDOWNLOAD_REQUEST_CODE
Request code for Notify Download

See Also:
Constant Field Values

MYGROUPSMANAGER_REQUEST_CODE

public static final int MYGROUPSMANAGER_REQUEST_CODE
Request code for MyGroups Manager

See Also:
Constant Field Values

GROUPTYPES_REQUEST_CODE

public static final int GROUPTYPES_REQUEST_CODE
Request code for Group Types module

See Also:
Constant Field Values

SENDMYGROUPS_REQUEST_CODE

public static final int SENDMYGROUPS_REQUEST_CODE
Request code for SendMyGroups

See Also:
Constant Field Values

GETFILE_REQUEST_CODE

public static final int GETFILE_REQUEST_CODE
Request code for GetFile Manager

See Also:
Constant Field Values

APP_TAG

public static final java.lang.String APP_TAG
Prefix tag name for Logcat

See Also:
Constant Field Values

DB_TABLE_COURSES

public static final java.lang.String DB_TABLE_COURSES
Table name for courses

See Also:
Constant Field Values

DB_TABLE_NOTIFICATIONS

public static final java.lang.String DB_TABLE_NOTIFICATIONS
Table name for notifications

See Also:
Constant Field Values

DB_TABLE_TEST_ANSWERS

public static final java.lang.String DB_TABLE_TEST_ANSWERS
Table name for test's answers

See Also:
Constant Field Values

DB_TABLE_TEST_QUESTIONS

public static final java.lang.String DB_TABLE_TEST_QUESTIONS
Table name for test's questions

See Also:
Constant Field Values

DB_TABLE_TEST_TAGS

public static final java.lang.String DB_TABLE_TEST_TAGS
Table name for test's tags

See Also:
Constant Field Values

DB_TABLE_TEST_CONFIG

public static final java.lang.String DB_TABLE_TEST_CONFIG
Table name for test's configuration

See Also:
Constant Field Values

DB_TABLE_TEST_QUESTION_TAGS

public static final java.lang.String DB_TABLE_TEST_QUESTION_TAGS
Table name for relationship between test's questions and tags

See Also:
Constant Field Values

DB_TABLE_TEST_QUESTIONS_COURSE

public static final java.lang.String DB_TABLE_TEST_QUESTIONS_COURSE
Table name for relationship between test's questions and courses

See Also:
Constant Field Values

DB_TABLE_TEST_QUESTION_ANSWERS

public static final java.lang.String DB_TABLE_TEST_QUESTION_ANSWERS
Table name for relationship between test's questions and answers

See Also:
Constant Field Values

DB_TABLE_USERS

public static final java.lang.String DB_TABLE_USERS
Table name for users

See Also:
Constant Field Values

DB_TABLE_USERS_COURSES

public static final java.lang.String DB_TABLE_USERS_COURSES
Table name for relationship between users and courses

See Also:
Constant Field Values

DB_TABLE_GROUPS

public static final java.lang.String DB_TABLE_GROUPS
Table name for groups

See Also:
Constant Field Values

DB_TABLE_GROUPS_COURSES

public static final java.lang.String DB_TABLE_GROUPS_COURSES
Table name for relationship between groups and courses

See Also:
Constant Field Values

DB_TABLE_GROUP_TYPES

public static final java.lang.String DB_TABLE_GROUP_TYPES
Table name for group types

See Also:
Constant Field Values

DB_TABLE_GROUPS_GROUPTYPES

public static final java.lang.String DB_TABLE_GROUPS_GROUPTYPES
Table name for relationship between groups and group types

See Also:
Constant Field Values

DB_TABLE_PRACTICE_SESSIONS

public static final java.lang.String DB_TABLE_PRACTICE_SESSIONS
Table name for practice sessions

See Also:
Constant Field Values

DB_TABLE_ROLLCALL

public static final java.lang.String DB_TABLE_ROLLCALL
Table name for rollcall

See Also:
Constant Field Values

STUDENT_TYPE_CODE

public static final int STUDENT_TYPE_CODE
Student userRole for getUsers web service.

See Also:
Constant Field Values

TEACHER_TYPE_CODE

public static final int TEACHER_TYPE_CODE
Teacher userTypeCode for getUsers web service.

See Also:
Constant Field Values

DOCUMENTS_AREA_CODE

public static int DOCUMENTS_AREA_CODE
Code to access to the documents in documents area


SHARE_AREA_CODE

public static int SHARE_AREA_CODE
Code to access to the documents in share area

Constructor Detail

Global

public Global()
Method Detail

getSWADAppKey

public static java.lang.String getSWADAppKey()
Gets the SWAD application key

Returns:
SWAD application key

getBugsenseAPIKey

public static java.lang.String getBugsenseAPIKey()
Gets the Bugsense API key

Returns:
Bugsense API key

getDefaultServer

public static java.lang.String getDefaultServer()
Gets the server URL

Returns:
Server URL

isLogged

public static boolean isLogged()
Checks if user is already logged on SWAD

Returns:
User logged flag

setLogged

public static void setLogged(boolean logged)
Sets user logged flag

Parameters:
logged - User logged flag

getLoggedUser

public static User getLoggedUser()
Gets the user logged on SWAD

Parameters:
logged - User logged flag

setLoggedUser

public static void setLoggedUser(User loggedUser)
Sets the user logged on SWAD

Parameters:
logged - User logged flag

getLastLoginTime

public static long getLastLoginTime()
Gets start time of application

Returns:
Start time of application

setLastLoginTime

public static void setLastLoginTime(long l)
Sets start time of application

Parameters:
l - Start time of application

parseIntBool

public static boolean parseIntBool(int n)
Function to parse from Integer to Boolean

Parameters:
n - Integer to be parsed
Returns:
true if n!=0, false in other case

parseStringBool

public static boolean parseStringBool(java.lang.String s)
Function to parse from String to Boolean

Parameters:
s - String to be parsed
Returns:
true if s equals "Y", false in other case

parseBoolInt

public static int parseBoolInt(boolean b)
Function to parse from Boolean to Integer

Parameters:
b - Boolean to be parsed
Returns:
1 if b==true, 0 in other case

parseBoolString

public static java.lang.String parseBoolString(boolean b)
Function to parse from Boolean to String

Parameters:
b - Boolean to be parsed
Returns:
"Y" if b==true, "N" in other case

getSelectedCourseCode

public static long getSelectedCourseCode()
Gets code of current course return -1 if no course chosen; code of current course in other case


setSelectedCourseCode

public static void setSelectedCourseCode(long currentCourseCode)
Sets code of current course

Parameters:
courseCode. - Code of the chosen course. It should be courseCode>0. Otherwise nothing will change

setCurrentUserRole

public static void setCurrentUserRole(int userRole)
Sets user role in the current selected course

Parameters:
userRole: - Role of the user: 0- unknown STUDENT_TYPE_CODE - student TEACHER_TYPE_CODE - teacher

isPreferencesChanged

public static boolean isPreferencesChanged()

setPreferencesChanged

public static void setPreferencesChanged()
Set the fact that the preferences has changed

Parameters:
newState - - true when the preferences has changed - false after the fact is noticed and handled it

setPreferencesChanged

public static void setPreferencesChanged(boolean newState)
Indicates if the preferences has changed

Parameters:
newState - - true when the preferences has changed and it was not handled it - false if the preferences has not changed

setSelectedCourseShortName

public static void setSelectedCourseShortName(java.lang.String currentCourseShortName)

setSelectedCourseFullName

public static void setSelectedCourseFullName(java.lang.String currentCourseFullName)

getSelectedCourseShortName

public static java.lang.String getSelectedCourseShortName()

getSelectedCourseFullName

public static java.lang.String getSelectedCourseFullName()

getCurrentUserRole

public static int getCurrentUserRole()
Gets the role of the logged user in the current selected course

Returns:
-1 if the user role has not been fixed, 0 if the user role is unknown 2 (STUDENT_TYPE_CODE) if the user is a student 3 (TEACHER_TYPE_CODE) if the user is a teacher

getAccountType

public static java.lang.String getAccountType()
Gets the account type for synchronization

Returns:
the account type for synchronization

getAuthority

public static java.lang.String getAuthority()
Gets the authority for synchronization

Returns:
the authority for synchronization

getDefaultSyncTime

public static long getDefaultSyncTime()
Gets the default synchronization interval

Returns:
the default synchronization interval

connectionAvailable

public static boolean connectionAvailable(Context ctx)
Checks if any connection is available

Parameters:
ctx - Application context
Returns:
true if there is a connection available, false in other case

setDbCleaned

public static void setDbCleaned(boolean state)
Set the fact that the db was cleaned

Parameters:
newState - - true when the database was cleaned - false after the fact is noticed and handled it

isDbCleaned

public static boolean isDbCleaned()
Indicates if the db was cleaned

Parameters:
newState - - true when the database was cleaned and it was not handled it - false if the database does not change

randomString

public static java.lang.String randomString(int len)
Generates a random string of length len

Parameters:
len - Length of random string
Returns:
A random string of length len