Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f2c56467
authored
Aug 22, 2017
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
issues
#276
,
#310
,
#311
and
#312
closed
parent
d5dc05d9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
33 deletions
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/UserLogin.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/tools/PCBcontext.java
android/Pictogram/commonlibrary/src/main/res/values-es/strings.xml
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/VocabularyManager.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/login/StudentFragmentGrid.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/dao/UserLogin.java
View file @
f2c56467
...
@@ -50,8 +50,6 @@ public class UserLogin {
...
@@ -50,8 +50,6 @@ public class UserLogin {
if
(
online
)
{
if
(
online
)
{
Log
.
i
(
LOG_TAG
,
"Online login request for supervisor "
+
email
);
Log
.
i
(
LOG_TAG
,
"Online login request for supervisor "
+
email
);
final
ProgressDialog
progressDialog
=
ProgressDialog
.
show
(
activity
,
activity
.
getBaseContext
().
getString
(
R
.
string
.
userLoadingTxt
),
activity
.
getBaseContext
().
getString
(
R
.
string
.
userLoadingTxt
),
false
,
false
);
ServerLogin
.
login_supervisor
(
email
,
password
,
new
RestapiWrapper
.
iRestapiListener
()
{
ServerLogin
.
login_supervisor
(
email
,
password
,
new
RestapiWrapper
.
iRestapiListener
()
{
@Override
@Override
public
void
preExecute
()
{
public
void
preExecute
()
{
...
@@ -65,7 +63,6 @@ public class UserLogin {
...
@@ -65,7 +63,6 @@ public class UserLogin {
@Override
@Override
public
void
result
(
JSONObject
result
)
{
public
void
result
(
JSONObject
result
)
{
if
(
progressDialog
.
isShowing
())
progressDialog
.
dismiss
();
String
jsonToken
;
String
jsonToken
;
JSONObject
user
;
JSONObject
user
;
try
{
try
{
...
@@ -108,7 +105,6 @@ public class UserLogin {
...
@@ -108,7 +105,6 @@ public class UserLogin {
@Override
@Override
public
void
error
(
RestapiWrapper
.
HTTPException
e
)
{
public
void
error
(
RestapiWrapper
.
HTTPException
e
)
{
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Login fail:"
+
e
.
getMessage
()+
" ("
+
e
.
getClass
().
getCanonicalName
()+
")"
);
Log
.
i
(
this
.
getClass
().
getCanonicalName
(),
"Login fail:"
+
e
.
getMessage
()+
" ("
+
e
.
getClass
().
getCanonicalName
()+
")"
);
if
(
progressDialog
.
isShowing
())
progressDialog
.
dismiss
();
if
(
e
instanceof
LoginException
)
if
(
e
instanceof
LoginException
)
if
(((
LoginException
)
e
).
invalidLicense
())
if
(((
LoginException
)
e
).
invalidLicense
())
GUITools
.
show_alert
(
activity
,
R
.
string
.
loginNoLicenseMsg
);
GUITools
.
show_alert
(
activity
,
R
.
string
.
loginNoLicenseMsg
);
...
...
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/tools/PCBcontext.java
View file @
f2c56467
...
@@ -197,7 +197,7 @@ public final class PCBcontext {
...
@@ -197,7 +197,7 @@ public final class PCBcontext {
public
static
RestapiWrapper
getRestapiWrapper
(){
public
static
RestapiWrapper
getRestapiWrapper
(){
if
(
wrapper
==
null
)
{
if
(
wrapper
==
null
)
{
throw
new
java
.
lang
.
NullPointerException
(
"RestapiWrapper is null. PCBcontext.init"
+
throw
new
java
.
lang
.
NullPointerException
(
"RestapiWrapper is null. PCBcontext.init"
+
"must be invoked previously"
);
"
must be invoked previously"
);
}
}
return
wrapper
;
return
wrapper
;
}
}
...
...
android/Pictogram/commonlibrary/src/main/res/values-es/strings.xml
View file @
f2c56467
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
<string
name=
"userLoadingMsg"
>
Cargando alumnos. Por favor espere.
</string>
<string
name=
"userLoadingMsg"
>
Cargando alumnos. Por favor espere.
</string>
<string
name=
"loginErrorTxt"
>
Login
</string>
<string
name=
"loginErrorTxt"
>
Login
</string>
<string
name=
"loginErrorMsg"
>
El usuario no existe o la contraseña indicada no es correcta. Inténtelo de nuevo.
</string>
<string
name=
"loginErrorMsg"
>
El usuario no existe o la contraseña indicada no es correcta. Inténtelo de nuevo.
</string>
<string
name=
"loginNoLicenseMsg"
>
L
a licencia del usuario expiró con fech
a. Contacte con Yotta para adquirir una.
</string>
<string
name=
"loginNoLicenseMsg"
>
L
icencia incorrecta o caducad
a. Contacte con Yotta para adquirir una.
</string>
<string
name=
"loginExpiredLicenseMsg"
>
La licencia del usuario expiró con fecha
</string>
<string
name=
"loginExpiredLicenseMsg"
>
La licencia del usuario expiró con fecha
</string>
<string
name=
"imguserLoadingMsg"
>
Cargando imágenes de los alumnos. Por favor espere.
</string>
<string
name=
"imguserLoadingMsg"
>
Cargando imágenes de los alumnos. Por favor espere.
</string>
<string
name=
"imguserLoadingErrMsg"
>
Imagen con formato no válido.
</string>
<string
name=
"imguserLoadingErrMsg"
>
Imagen con formato no válido.
</string>
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/VocabularyManager.java
View file @
f2c56467
...
@@ -271,8 +271,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
...
@@ -271,8 +271,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
toUserListBtn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
toUserListBtn
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
Intent
nextActivity
=
new
Intent
(
getBaseContext
(),
LoginActivity
.
class
);
PCBcontext
.
getNetService
().
restart_app
(
false
);
startActivity
(
nextActivity
);
}
}
});
});
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/login/StudentFragmentGrid.java
View file @
f2c56467
...
@@ -51,7 +51,6 @@ public class StudentFragmentGrid extends Fragment{
...
@@ -51,7 +51,6 @@ public class StudentFragmentGrid extends Fragment{
final
String
TAG_PIC
=
"pic"
;
final
String
TAG_PIC
=
"pic"
;
final
String
TAG_LANG
=
"lang"
;
final
String
TAG_LANG
=
"lang"
;
final
String
TAG_ATTRIBUTES
=
"attributes"
;
final
String
TAG_ATTRIBUTES
=
"attributes"
;
//TODO: para qué sirve: final String TAG_SUPERVISION="supervision";
ProgressDialog
progressDialog
;
ProgressDialog
progressDialog
;
Vector
<
Integer
>
idStudents
;
Vector
<
Integer
>
idStudents
;
String
nameStudents
[];
String
nameStudents
[];
...
@@ -63,7 +62,6 @@ public class StudentFragmentGrid extends Fragment{
...
@@ -63,7 +62,6 @@ public class StudentFragmentGrid extends Fragment{
boolean
onlineStudentsOK
=
false
;
boolean
onlineStudentsOK
=
false
;
private
void
showStudentsGrid
(){
private
void
showStudentsGrid
(){
CustomList
adapter
=
new
CustomList
(
getActivity
(),
nameStudents
,
imageStudents
);
CustomList
adapter
=
new
CustomList
(
getActivity
(),
nameStudents
,
imageStudents
);
gridView
.
setAdapter
(
adapter
);
gridView
.
setAdapter
(
adapter
);
gridView
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
gridView
.
setOnItemClickListener
(
new
AdapterView
.
OnItemClickListener
()
{
...
@@ -88,14 +86,14 @@ public class StudentFragmentGrid extends Fragment{
...
@@ -88,14 +86,14 @@ public class StudentFragmentGrid extends Fragment{
startActivity
(
pictogramActivity
);
startActivity
(
pictogramActivity
);
}
else
{
}
else
{
if
(
this
.
nameStudents
[
i
].
equals
(
getString
(
R
.
string
.
addStudent
)))
if
(
this
.
nameStudents
[
i
].
equals
(
getString
(
R
.
string
.
addStudent
)))
register_student
();
register_student
(
getActivity
().
getIntent
().
getIntExtra
(
"sup_id"
,
0
)
);
else
{
else
{
new_user
(
i
);
new_user
(
i
);
download_supervisors
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_id_stu
());
download_supervisors
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_id_stu
());
}
}
}
}
}
}
private
void
register_student
()
{
private
void
register_student
(
final
int
sup_id
)
{
AlertDialog
.
Builder
alert
=
new
AlertDialog
.
Builder
(
this
.
getActivity
());
AlertDialog
.
Builder
alert
=
new
AlertDialog
.
Builder
(
this
.
getActivity
());
final
EditText
edittext
=
new
EditText
(
this
.
getActivity
());
final
EditText
edittext
=
new
EditText
(
this
.
getActivity
());
alert
.
setMessage
(
getString
(
R
.
string
.
getLicenseStudent
));
alert
.
setMessage
(
getString
(
R
.
string
.
getLicenseStudent
));
...
@@ -106,7 +104,30 @@ private void register_student() {
...
@@ -106,7 +104,30 @@ private void register_student() {
alert
.
setPositiveButton
(
"Ok"
,
new
DialogInterface
.
OnClickListener
()
{
alert
.
setPositiveButton
(
"Ok"
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
whichButton
)
{
public
void
onClick
(
DialogInterface
dialog
,
int
whichButton
)
{
//What ever you want to do with the value
//What ever you want to do with the value
String
license
=
edittext
.
getText
().
toString
();
String
license
=
edittext
.
getText
().
toString
().
replaceAll
(
"[^a-zA-Z0-9]"
,
""
).
toUpperCase
();
RestapiWrapper
wrapper
=
PCBcontext
.
getRestapiWrapper
();
String
operation
=
"stu/license/sup/"
+
sup_id
;
Hashtable
<
String
,
String
>
params
=
new
Hashtable
<
String
,
String
>(
1
);
params
.
put
(
"license"
,
license
);
wrapper
.
ask
(
operation
,
params
,
"post"
,
new
RestapiWrapper
.
iRestapiListener
()
{
@Override
public
void
error
(
RestapiWrapper
.
HTTPException
e
)
{
Log
.
e
(
this
.
getClass
().
getName
(),
" Server restapi error: "
+
e
.
getLocalizedMessage
());
String
err
=
e
.
getLocalizedMessage
();
if
(
err
.
indexOf
(
"nvalid license"
)
>
0
)
GUITools
.
show_alert
(
getActivity
(),
R
.
string
.
loginNoLicenseMsg
);
}
@Override
public
void
preExecute
()
{
}
@Override
public
void
result
(
JSONArray
result
)
{
}
@Override
public
void
result
(
JSONObject
result
)
{
PCBcontext
.
getNetService
().
restart_app
(
false
);
}
});
}
}
});
});
...
@@ -175,7 +196,7 @@ private void register_student() {
...
@@ -175,7 +196,7 @@ private void register_student() {
}
}
}
}
private
void
show_student_list_online
()
{
private
void
show_student_list_online
()
{
int
listsize
=
downloaded_students
.
size
()+
1
;
final
int
listsize
=
downloaded_students
.
size
()+
1
;
final
Vector
<
Img
>
imgs
=
new
Vector
<>(
listsize
);
final
Vector
<
Img
>
imgs
=
new
Vector
<>(
listsize
);
this
.
nameStudents
=
new
String
[
listsize
];
this
.
nameStudents
=
new
String
[
listsize
];
this
.
idStudents
=
new
Vector
<>(
listsize
);
this
.
idStudents
=
new
Vector
<>(
listsize
);
...
@@ -202,21 +223,16 @@ private void register_student() {
...
@@ -202,21 +223,16 @@ private void register_student() {
nameStudents
[
listsize
-
1
]=
getString
(
R
.
string
.
addStudent
);
nameStudents
[
listsize
-
1
]=
getString
(
R
.
string
.
addStudent
);
idStudents
.
add
(-
1
);
idStudents
.
add
(-
1
);
imgs
.
add
(
new
Img
(-
1
,
null
,
Img
.
STUDENT
));
//it's required to download student's images
imgs
.
add
(
new
Img
(-
1
,
null
,
Img
.
STUDENT
));
//it's required to download student's images
progressDialog
=
ProgressDialog
.
show
(
getActivity
(),
getString
(
R
.
string
.
imguserLoadingMsg
),
getString
(
R
.
string
.
userLoadingTxt
),
false
,
false
);
ImgDownloader
downloader
=
new
ImgDownloader
(
getActivity
(),
new
ImgDownloader
.
iImgDownloaderListener
()
{
ImgDownloader
downloader
=
new
ImgDownloader
(
getActivity
(),
new
ImgDownloader
.
iImgDownloaderListener
()
{
private
void
loaded
()
{
private
void
loaded
()
{
if
(
progressDialog
!=
null
&&
progressDialog
.
isShowing
())
progressDialog
.
dismiss
();
try
{
if
(
downloaded_students
.
size
()
>=
1
)
{
if
(
downloaded_students
.
size
()
>=
1
)
for
(
int
i
=
0
;
i
<
imgs
.
size
();
i
++)
for
(
int
i
=
0
;
i
<
imgs
.
size
();
i
++)
try
{
imageStudents
.
add
(
imgs
.
get
(
i
).
get_bitmap
(
getActivity
().
getBaseContext
()));
imageStudents
.
add
(
imgs
.
get
(
i
).
get_bitmap
(
getActivity
().
getBaseContext
()));
}
catch
(
IOException
e
)
{
imageStudents
.
add
(
imgs
.
get
(
listsize
-
1
).
get_bitmap
(
getActivity
().
getBaseContext
()));
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
Log
.
e
(
StudentFragmentGrid
.
this
.
getClass
().
getCanonicalName
(),
e
.
getMessage
()
);
e
.
printStackTrace
(
);
}
Log
.
e
(
StudentFragmentGrid
.
this
.
getClass
().
getCanonicalName
(),
e
.
getMessage
());
}
}
if
(
StudentFragmentGrid
.
super
.
getView
()!=
null
)
if
(
StudentFragmentGrid
.
super
.
getView
()!=
null
)
showStudentsGrid
();
showStudentsGrid
();
...
@@ -312,19 +328,15 @@ private void register_student() {
...
@@ -312,19 +328,15 @@ private void register_student() {
});
});
}
}
private
void
download_students
(
int
sup_id
)
{
private
void
download_students
(
final
int
sup_id
)
{
String
token
=
getActivity
().
getIntent
().
getExtras
().
getString
(
"token"
);
String
token
=
getActivity
().
getIntent
().
getExtras
().
getString
(
"token"
);
RestapiWrapper
wrapper
=
PCBcontext
.
getRestapiWrapper
();
RestapiWrapper
wrapper
=
PCBcontext
.
getRestapiWrapper
();
wrapper
.
setToken
(
token
);
wrapper
.
setToken
(
token
);
String
operation
=
"sup/"
+
sup_id
+
"/students"
;
String
operation
=
"sup/"
+
sup_id
+
"/students"
;
progressDialog
=
ProgressDialog
.
show
(
getActivity
(),
getString
(
R
.
string
.
userLoadingTxt
),
getString
(
R
.
string
.
userLoadingTxt
),
false
,
false
);
wrapper
.
ask
(
operation
,
new
RestapiWrapper
.
iRestapiListener
()
{
wrapper
.
ask
(
operation
,
new
RestapiWrapper
.
iRestapiListener
()
{
@Override
@Override
public
void
error
(
RestapiWrapper
.
HTTPException
e
)
{
public
void
error
(
RestapiWrapper
.
HTTPException
e
)
{
Log
.
e
(
this
.
getClass
().
getName
(),
" Server restapi error: "
+
e
.
getLocalizedMessage
());
Log
.
e
(
this
.
getClass
().
getName
(),
" Server restapi error: "
+
e
.
getLocalizedMessage
());
if
(
progressDialog
.
isShowing
())
progressDialog
.
dismiss
();
GUITools
.
show_alert
(
getActivity
(),
R
.
string
.
loginErrorTxt
,
getString
(
R
.
string
.
serverError
),
new
GUITools
.
iOKListener
()
{
GUITools
.
show_alert
(
getActivity
(),
R
.
string
.
loginErrorTxt
,
getString
(
R
.
string
.
serverError
),
new
GUITools
.
iOKListener
()
{
@Override
@Override
public
void
ok
()
{
public
void
ok
()
{
...
@@ -343,8 +355,7 @@ private void register_student() {
...
@@ -343,8 +355,7 @@ private void register_student() {
JSONObject
student
;
JSONObject
student
;
try
{
try
{
student
=
students
.
getJSONObject
(
i
);
student
=
students
.
getJSONObject
(
i
);
//if (student.getInt(TAG_SUPERVISION)>0)
StudentFragmentGrid
.
this
.
downloaded_students
.
add
(
student
);
StudentFragmentGrid
.
this
.
downloaded_students
.
add
(
student
);
}
catch
(
JSONException
e
)
{
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
...
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