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
f4d53000
authored
Mar 14, 2016
by
Miguel Ángel García Cumbreras
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Modificaciones menores de pictogramActivity y primeros casos OFFLINE en Serial
parent
38597dd9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
80 additions
and
82 deletions
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/SerialActivity.java
android/Pictogram/app/src/main/res/values-es/strings.xml
android/Pictogram/app/src/main/res/values/strings.xml
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/SerialActivity.java
View file @
f4d53000
...
@@ -108,7 +108,6 @@ public class SerialActivity extends Activity implements iRestapiListener {
...
@@ -108,7 +108,6 @@ public class SerialActivity extends Activity implements iRestapiListener {
password
=
""
;
password
=
""
;
}
}
// Escribo los últimos valores indicados
// Escribo los últimos valores indicados
mSerialViewMail
.
setText
(
username
);
mSerialViewMail
.
setText
(
username
);
//mSerialViewPass.setText(password);
//mSerialViewPass.setText(password);
...
@@ -124,78 +123,74 @@ public class SerialActivity extends Activity implements iRestapiListener {
...
@@ -124,78 +123,74 @@ public class SerialActivity extends Activity implements iRestapiListener {
Log
.
d
(
LOG_TAG
,
"PCBcontext iniciado"
);
Log
.
d
(
LOG_TAG
,
"PCBcontext iniciado"
);
//if (PCBcontext.getDevice().getLastStuId() != 0) {
//if (PCBcontext.getDevice().getLastStuId() != 0) {
if
(!
username
.
equals
(
""
)
&&
!
password
.
equals
(
""
)){
if
(!
username
.
equals
(
""
)
&&
!
password
.
equals
(
""
)){
// Tengo usuario, sigo con este usuario
// Tengo usuario, sigo con este usuario
if
(
RestapiWrapper
.
ping
(
context
.
getResources
().
getString
(
R
.
string
.
server
),
"server/ping"
,
this
))
{
RestapiWrapper
wrapper
=
PCBcontext
.
getRestapiWrapper
();
// Tengo conexión a internet. Compruebo ONLINE
if
(
username
.
contains
(
"@"
)){
RestapiWrapper
wrapper
=
PCBcontext
.
getRestapiWrapper
();
// Es un supervisor
if
(
username
.
contains
(
"@"
)){
String
operation
=
"sup/login"
;
// Es un supervisor
Hashtable
<
String
,
String
>
postDataParams
=
new
Hashtable
<
String
,
String
>();
String
operation
=
"sup/login"
;
Hashtable
<
String
,
String
>
postDataParams
=
new
Hashtable
<
String
,
String
>();
postDataParams
.
put
(
"email"
,
username
);
postDataParams
.
put
(
"password"
,
password
);
postDataParams
.
put
(
"email"
,
username
);
postDataParams
.
put
(
"password"
,
password
);
/*
/*
postDataParams.put("idFirmware", _ANDROIDID);
postDataParams.put("idFirmware", _ANDROIDID);
postDataParams.put("desc", _MODEL);
postDataParams.put("desc", _MODEL);
postDataParams.put("serial", serial);
postDataParams.put("serial", serial);
*/
*/
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
}
else
{
}
else
{
// Es un estudiante
// Es un estudiante
Log
.
d
(
LOG_TAG
,
"Entro con usuario y password"
);
Log
.
d
(
LOG_TAG
,
"Entro con usuario y password"
);
String
operation
=
"stu/login"
;
String
operation
=
"stu/login"
;
Hashtable
<
String
,
String
>
postDataParams
=
new
Hashtable
<
String
,
String
>();
Hashtable
<
String
,
String
>
postDataParams
=
new
Hashtable
<
String
,
String
>();
postDataParams
.
put
(
"username"
,
username
);
postDataParams
.
put
(
"username"
,
username
);
postDataParams
.
put
(
"password"
,
password
);
postDataParams
.
put
(
"password"
,
password
);
/*
/*
postDataParams.put("idFirmware", _ANDROIDID);
postDataParams.put("idFirmware", _ANDROIDID);
postDataParams.put("desc", _MODEL);
postDataParams.put("desc", _MODEL);
postDataParams.put("serial", serial);
postDataParams.put("serial", serial);
*/
*/
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
}
}
}
else
{
}
else
{
// Compruebo si tengo acceso a internet
// NO Tengo conexión a internet. Compruebo OFFLINE
//modificación FERNANDO
if
(
username
.
contains
(
"@"
))
{
if
(!
RestapiWrapper
.
ping
(
context
.
getResources
().
getString
(
R
.
string
.
server
),
"server/ping"
,
this
))
{
// Es un supervisor
// No puedo comprobar si el serial es válido. Muestro un alertdialog de error, y cierro la aplicación
}
else
{
AlertDialog
alertDialog
=
new
AlertDialog
.
Builder
(
// Es un estudiante
SerialActivity
.
this
).
create
();
}
alertDialog
.
setTitle
(
"Mensaje del sistema"
);
// ....
alertDialog
.
setMessage
(
"No hay conexión a Internet. Inténtelo más tarde"
);
//alertDialog.setIcon(R.drawable.tick);
/*
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), "Saliendo de la aplicación", Toast.LENGTH_SHORT).show();
}
}
});
*/
alertDialog
.
show
();
// ¿QUÉ HACEMOS CON LA APP?
}
else
{
Button
mEntrarButton
=
(
Button
)
findViewById
(
R
.
id
.
entrar_button
);
mEntrarButton
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
String
username
=
mSerialViewMail
.
getText
().
toString
();
String
password
=
mSerialViewPass
.
getText
().
toString
();
SharedPreferences
settings
=
getSharedPreferences
(
PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
settings
.
edit
();
editor
.
putString
(
"username"
,
username
);
editor
.
putString
(
"password"
,
password
);
editor
.
commit
();
// DE PRUEBA
// Alumno
//username = "faf0001";
//password = "faf0001";
// Supervisor
//username = "dofer@ujaen.es";
//password = "dofer";
}
else
{
// No tengo aún usuario. Espero a que lo indique
Button
mEntrarButton
=
(
Button
)
findViewById
(
R
.
id
.
entrar_button
);
mEntrarButton
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
view
)
{
String
username
=
mSerialViewMail
.
getText
().
toString
();
String
password
=
mSerialViewPass
.
getText
().
toString
();
SharedPreferences
settings
=
getSharedPreferences
(
PREFS_NAME
,
0
);
SharedPreferences
.
Editor
editor
=
settings
.
edit
();
editor
.
putString
(
"username"
,
username
);
editor
.
putString
(
"password"
,
password
);
editor
.
commit
();
// DE PRUEBA
// Alumno
username
=
"faf0001"
;
password
=
"faf0001"
;
// Supervisor
//username = "dofer@ujaen.es";
//password = "dofer";
// IMPORTANTE. FERNANDO: ¿Para qué el último argumento del listener?
if
(
RestapiWrapper
.
ping
(
context
.
getResources
().
getString
(
R
.
string
.
server
),
"server/ping"
,
null
))
{
// Tengo conexión a internet. Compruebo ONLINE
RestapiWrapper
wrapper
=
PCBcontext
.
getRestapiWrapper
();
RestapiWrapper
wrapper
=
PCBcontext
.
getRestapiWrapper
();
if
(
username
.
contains
(
"@"
)){
if
(
username
.
contains
(
"@"
)){
// Es un supervisor
// Es un supervisor
...
@@ -204,11 +199,6 @@ public class SerialActivity extends Activity implements iRestapiListener {
...
@@ -204,11 +199,6 @@ public class SerialActivity extends Activity implements iRestapiListener {
postDataParams
.
put
(
"email"
,
username
);
postDataParams
.
put
(
"email"
,
username
);
postDataParams
.
put
(
"password"
,
password
);
postDataParams
.
put
(
"password"
,
password
);
/*
postDataParams.put("idFirmware", _ANDROIDID);
postDataParams.put("desc", _MODEL);
postDataParams.put("serial", serial);
*/
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
}
else
{
}
else
{
// Es un estudiante
// Es un estudiante
...
@@ -217,16 +207,21 @@ public class SerialActivity extends Activity implements iRestapiListener {
...
@@ -217,16 +207,21 @@ public class SerialActivity extends Activity implements iRestapiListener {
postDataParams
.
put
(
"username"
,
username
);
postDataParams
.
put
(
"username"
,
username
);
postDataParams
.
put
(
"password"
,
password
);
postDataParams
.
put
(
"password"
,
password
);
/*
postDataParams.put("idFirmware", _ANDROIDID);
postDataParams.put("desc", _MODEL);
postDataParams.put("serial", serial);
*/
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
}
}
}
else
{
// NO Tengo conexión a internet. Compruebo OFFLINE
if
(
username
.
contains
(
"@"
))
{
// Es un supervisor
// Necesito una función local que dado el username y pass me devuelva el listado de usuarios o el usuario, si es correcto
// ....
}
else
{
// Es un estudiante
}
// ....
}
}
}
);
}
}
}
);
}
}
}
}
...
@@ -250,7 +245,7 @@ public class SerialActivity extends Activity implements iRestapiListener {
...
@@ -250,7 +245,7 @@ public class SerialActivity extends Activity implements iRestapiListener {
Log
.
d
(
LOG_TAG
,
"JSON en result:"
+
result
.
toString
());
Log
.
d
(
LOG_TAG
,
"JSON en result:"
+
result
.
toString
());
if
(
result
.
toString
().
contains
(
"error"
)){
if
(
result
.
toString
().
contains
(
"error"
)){
progressDialog
.
dismiss
();
if
(
progressDialog
!=
null
)
progressDialog
.
dismiss
();
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
SerialActivity
.
this
);
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
SerialActivity
.
this
);
...
@@ -308,7 +303,8 @@ public class SerialActivity extends Activity implements iRestapiListener {
...
@@ -308,7 +303,8 @@ public class SerialActivity extends Activity implements iRestapiListener {
PCBcontext
.
set_user
(
student
,
jsonToken
,
new
iImgDownloaderListener
()
{
PCBcontext
.
set_user
(
student
,
jsonToken
,
new
iImgDownloaderListener
()
{
@Override
@Override
public
void
loadComplete
()
{
public
void
loadComplete
()
{
progressDialog
.
dismiss
();
if
(
progressDialog
!=
null
)
progressDialog
.
dismiss
();
Intent
pictogramActivity
=
new
Intent
(
SerialActivity
.
this
,
PictogramActivity
.
class
);
Intent
pictogramActivity
=
new
Intent
(
SerialActivity
.
this
,
PictogramActivity
.
class
);
startActivity
(
pictogramActivity
);
startActivity
(
pictogramActivity
);
}
}
...
@@ -341,7 +337,7 @@ public class SerialActivity extends Activity implements iRestapiListener {
...
@@ -341,7 +337,7 @@ public class SerialActivity extends Activity implements iRestapiListener {
int
su_id_int
=
su_id
.
intValue
();
int
su_id_int
=
su_id
.
intValue
();
//close the progress dialog
//close the progress dialog
if
(!
username
.
contains
(
"@"
)){
if
(!
username
.
contains
(
"@"
)
&&
progressDialog
!=
null
){
progressDialog
.
dismiss
();
progressDialog
.
dismiss
();
}
}
...
@@ -379,10 +375,10 @@ public class SerialActivity extends Activity implements iRestapiListener {
...
@@ -379,10 +375,10 @@ public class SerialActivity extends Activity implements iRestapiListener {
Log
.
e
(
this
.
getClass
().
getName
(),
" Server restapi error: "
+
e
.
getLocalizedMessage
());
Log
.
e
(
this
.
getClass
().
getName
(),
" Server restapi error: "
+
e
.
getLocalizedMessage
());
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
SerialActivity
.
this
);
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
SerialActivity
.
this
);
builder
.
setMessage
(
getString
(
R
.
string
.
serverError
)+
":"
+
e
.
getLocalizedMessage
())
builder
.
setMessage
(
getString
(
R
.
string
.
serverError
)
+
":"
+
e
.
getLocalizedMessage
())
.
setCancelable
(
false
)
.
setCancelable
(
false
)
.
setPositiveButton
(
"Entendido"
,
new
DialogInterface
.
OnClickListener
()
{
.
setPositiveButton
(
"Entendido"
,
new
DialogInterface
.
OnClickListener
()
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
public
void
onClick
(
DialogInterface
dialog
,
int
id
)
{
//do things
//do things
}
}
});
});
...
...
android/Pictogram/app/src/main/res/values-es/strings.xml
View file @
f4d53000
...
@@ -46,9 +46,9 @@
...
@@ -46,9 +46,9 @@
<!--Semantic grammar -->
<!--Semantic grammar -->
<string
name=
"loadingGrammar"
>
Por favor espere, cargando gramática semántica
</string>
<string
name=
"loadingGrammar"
>
Por favor espere, cargando gramática semántica
</string>
<string
name=
"naturalgrammar"
>
SUpO_ES
</string>
<string
name=
"naturalgrammar"
>
SUpO_ES
</string>
<string
name=
"pictogrammar"
>
SUpO_PICTOES
</string>
<string
name=
"grammar"
>
SUpO_ES
</string>
<string
name=
"nogrammar"
>
Advertencia: Lenguaje no soportado
</string>
<string
name=
"nogrammar"
>
Advertencia: Lenguaje no soportado
</string>
<string
name=
"pictogrammar"
>
SUpO_PICTOES
</string>
<item
type=
"integer"
name=
"maxInTape"
>
8
</item>
<item
type=
"integer"
name=
"maxInTape"
>
8
</item>
...
...
android/Pictogram/app/src/main/res/values/strings.xml
View file @
f4d53000
...
@@ -45,8 +45,10 @@
...
@@ -45,8 +45,10 @@
<!--Semantic grammar -->
<!--Semantic grammar -->
<string
name=
"loadingGrammar"
>
Please wait, loading semmantic grammar
</string>
<string
name=
"loadingGrammar"
>
Please wait, loading semmantic grammar
</string>
<string
name=
"naturalgrammar"
>
SUpO_EN
</string>
<string
name=
"grammar"
>
SUpO_EN
</string>
<string
name=
"grammar"
>
SUpO_EN
</string>
<string
name=
"nogrammar"
>
Warning: unknown language
</string>
<string
name=
"nogrammar"
>
Warning: unknown language
</string>
<string
name=
"pictogrammar"
>
SUpO_PICTOEN
</string>
<!--Upload local img -->
<!--Upload local img -->
<string
name=
"enterImgLabel"
>
Introduzca etiqueta de la imagen
</string>
<string
name=
"enterImgLabel"
>
Introduzca etiqueta de la imagen
</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