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
643a50d8
authored
Mar 28, 2016
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
working on serial/login activity refactorization
parent
c8c6ea4d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
76 additions
and
52 deletions
android/Pictogram/app/build.gradle
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/LoginActivity.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/SerialActivity.java
android/Pictogram/app/src/main/java/com/yottacode/pictogram/tools/PCBcontext.java
android/Pictogram/app/src/main/res/values-en/strings.xml
android/Pictogram/app/src/main/res/values-es/strings.xml
android/Pictogram/app/src/main/res/values/strings.xml
android/Pictogram/app/build.gradle
View file @
643a50d8
...
...
@@ -31,7 +31,7 @@ android {
debug
{
resValue
"string"
,
"db_name"
,
"PCB.db"
resValue
"bool"
,
"force_db_create"
,
"
fals
e"
resValue
"bool"
,
"force_db_create"
,
"
tru
e"
resValue
"bool"
,
"ssl_connect"
,
"false"
resValue
"bool"
,
"force_img_download"
,
"false"
resValue
"integer"
,
"netservice_timing"
,
"20"
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/LoginActivity.java
View file @
643a50d8
...
...
@@ -106,9 +106,6 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener{
//startLockTask();
// FIN del modo Kiosko
// Llamo al WS para coger los usuarios y los supervisores de este dispositivo
SSLDummyContext
.
init
(
getResources
().
getBoolean
(
R
.
bool
.
ssl_connect
));
PCBcontext
.
init
(
this
);
// Compruebo si tengo acceso a internet y al servicio web
if
(!
RestapiWrapper
.
ping
(
getResources
().
getString
(
R
.
string
.
server
),
"server/ping"
,
this
))
{
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/gui/SerialActivity.java
View file @
643a50d8
...
...
@@ -95,7 +95,27 @@ public class SerialActivity extends Activity implements iRestapiListener {
context
=
this
;
if
(!
username
.
equals
(
""
)
&&
!
password
.
equals
(
""
)){
// Tengo usuario, sigo con este usuario
if
(
RestapiWrapper
.
ping
(
context
.
getResources
().
getString
(
R
.
string
.
server
),
"server/ping"
,
this
))
{
if
(
RestapiWrapper
.
ping
(
context
.
getResources
().
getString
(
R
.
string
.
server
),
"server/ping"
,
new
iRestapiListener
()
{
@Override
public
void
preExecute
()
{
}
@Override
public
void
result
(
JSONArray
result
)
{
}
@Override
public
void
result
(
JSONObject
result
)
{
}
@Override
public
void
error
(
Exception
e
)
{
SerialActivity
.
this
.
error
(
e
);
}
}))
{
// Tengo conexión a internet. Modo ONLINE
RestapiWrapper
wrapper
=
PCBcontext
.
getRestapiWrapper
();
if
(
username
.
contains
(
"@"
)){
...
...
@@ -110,7 +130,47 @@ public class SerialActivity extends Activity implements iRestapiListener {
postDataParams.put("desc", _MODEL);
postDataParams.put("serial", serial);
*/
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
(
iRestapiListener
)
context
);
wrapper
.
ask
(
operation
,
postDataParams
,
"post"
,
new
iRestapiListener
()
{
@Override
public
void
preExecute
()
{
progressDialog
=
ProgressDialog
.
show
(
SerialActivity
.
this
,
SerialActivity
.
this
.
getBaseContext
().
getString
(
R
.
string
.
userLoadingMsg
),
SerialActivity
.
this
.
getBaseContext
().
getString
(
R
.
string
.
userLoadingTxt
),
false
,
false
);
}
@Override
public
void
result
(
JSONArray
result
)
{
}
@Override
public
void
result
(
JSONObject
result
)
{
Log
.
d
(
LOG_TAG
,
"Es un SUPERVISOR. Sigo..."
);
Log
.
d
(
LOG_TAG
,
"jsonToken válido:"
+
jsonToken
);
Integer
su_id
=
user
.
getInt
(
TAG_ID
);
int
su_id_int
=
su_id
.
intValue
();
//close the progress dialog
if
(!
username
.
contains
(
"@"
)
&&
progressDialog
!=
null
){
progressDialog
.
dismiss
();
}
// Llamo a LoginActivity
Intent
loginActivity
=
new
Intent
(
SerialActivity
.
this
,
LoginActivity
.
class
);
loginActivity
.
putExtra
(
"offline"
,
false
);
loginActivity
.
putExtra
(
"token"
,
jsonToken
);
loginActivity
.
putExtra
(
"sup_id"
,
su_id_int
);
startActivity
(
loginActivity
);
}
@Override
public
void
error
(
Exception
e
)
{
SerialActivity
.
this
.
error
(
e
);
}
});
}
else
{
// Es un estudiante
Log
.
d
(
LOG_TAG
,
"Entro con usuario y password"
);
...
...
@@ -269,21 +329,7 @@ public class SerialActivity extends Activity implements iRestapiListener {
}
}
@Override
public
void
preExecute
(){
if
(!
username
.
contains
(
"@"
)){
progressDialog
=
ProgressDialog
.
show
(
SerialActivity
.
this
,
"Cargando..."
,
"Cargando datos, espere por favor..."
,
false
,
false
);
}
}
@Override
public
void
result
(
JSONArray
result
)
{
Log
.
d
(
LOG_TAG
,
"Users:"
+
result
.
toString
());
}
@Override
public
void
result
(
JSONObject
result
)
{
public
boolean
checkLogin
(
JSONObject
result
)
{
// Si llego aquí es porque hay un único valor, no un array
try
{
Log
.
d
(
LOG_TAG
,
"JSON en result:"
+
result
.
toString
());
...
...
@@ -374,35 +420,7 @@ public class SerialActivity extends Activity implements iRestapiListener {
}
else
{
// Es un Supervisor
Log
.
d
(
LOG_TAG
,
"Es un SUPERVISOR. Sigo..."
);
Log
.
d
(
LOG_TAG
,
"jsonToken válido:"
+
jsonToken
);
Integer
su_id
=
user
.
getInt
(
TAG_ID
);
int
su_id_int
=
su_id
.
intValue
();
//close the progress dialog
if
(!
username
.
contains
(
"@"
)
&&
progressDialog
!=
null
){
progressDialog
.
dismiss
();
}
/*
AlertDialog.Builder builder = new AlertDialog.Builder(SerialActivity.this);
builder.setMessage("Es un supervisor. Sigo...")
.setCancelable(false)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
AlertDialog alert = builder.create();
alert.show();
*/
// Llamo a LoginActivity
Intent
loginActivity
=
new
Intent
(
this
,
LoginActivity
.
class
);
loginActivity
.
putExtra
(
"offline"
,
false
);
loginActivity
.
putExtra
(
"token"
,
jsonToken
);
loginActivity
.
putExtra
(
"sup_id"
,
su_id_int
);
startActivity
(
loginActivity
);
}
}
catch
(
JSONException
ex
){
//Log.d(LOG_TAG, "ERROR 1");
...
...
android/Pictogram/app/src/main/java/com/yottacode/pictogram/tools/PCBcontext.java
View file @
643a50d8
...
...
@@ -4,6 +4,7 @@ import android.content.Context;
import
android.util.Log
;
import
com.yottacode.net.RestapiWrapper
;
import
com.yottacode.net.SSLDummyContext
;
import
com.yottacode.pictogram.R
;
import
com.yottacode.pictogram.action.ActionLog
;
import
com.yottacode.pictogram.dao.Device
;
...
...
@@ -54,6 +55,7 @@ public final class PCBcontext {
init
=
true
;
context
=
c
;
device
=
new
Device
(
c
,
null
,
1
);
SSLDummyContext
.
init
(
context
.
getResources
().
getBoolean
(
R
.
bool
.
ssl_connect
));
wrapper
=
new
RestapiWrapper
(
context
.
getResources
().
getString
(
R
.
string
.
server
),
null
);
service
=
new
NetService
(
context
.
getResources
().
getInteger
(
R
.
integer
.
netservice_timing
));
device
.
deleteDeprecatedImgs
();
...
...
android/Pictogram/app/src/main/res/values-en/strings.xml
View file @
643a50d8
...
...
@@ -19,7 +19,9 @@
<string
name=
"passErrorTxt"
>
Invalid password
</string>
<string
name=
"passErrorMsg"
>
This password is not correct. Try again.
</string>
<string
name=
"userErrorTxt"
>
User not found
</string>
<string
name=
"userErrorMsg"
>
The user is not correct. Inténtelo de nuevo.
</string>
<string
name=
"userErrorMsg"
>
The user is not correct. Try again.
</string>
<string
name=
"userLoadingTxt"
>
Loading
</string>
<string
name=
"userLoadingMsg"
>
Loading students. Please wait.
</string>
<!-- Alert dialogs -->
<string
name=
"exitPictogram"
>
Exit Pictogram
</string>
...
...
android/Pictogram/app/src/main/res/values-es/strings.xml
View file @
643a50d8
...
...
@@ -21,6 +21,9 @@
<string
name=
"passErrorMsg"
>
La contraseña indicada no es correcta. Inténtelo de nuevo.
</string>
<string
name=
"userErrorTxt"
>
User not found
</string>
<string
name=
"userErrorMsg"
>
El usuario indicado no es correcto. Inténtelo de nuevo.
</string>
<string
name=
"userLoadingTxt"
>
Cargando
</string>
<string
name=
"userLoadingMsg"
>
Cargando alumnos. Por favor espere.
</string>
<!-- Alert dialogs -->
<string
name=
"exitPictogram"
>
Salir de Pictogram
</string>
...
...
android/Pictogram/app/src/main/res/values/strings.xml
View file @
643a50d8
...
...
@@ -17,10 +17,12 @@
<string
name=
"prompt_serial_pass"
>
Contraseña
</string>
<string
name=
"action_entrar"
>
Entrar
</string>
<string
name=
"loginTitle"
>
¿Quién eres?
</string>
<string
name=
"passErrorTxt"
>
Invalid password
</string>
<string
name=
"passErrorTxt"
>
Clave inválida
</string>
<string
name=
"passErrorMsg"
>
La contraseña indicada no es correcta. Inténtelo de nuevo.
</string>
<string
name=
"userErrorTxt"
>
Us
er not found
</string>
<string
name=
"userErrorTxt"
>
Us
uario no encontrado
</string>
<string
name=
"userErrorMsg"
>
El usuario indicado no es correcto. Inténtelo de nuevo.
</string>
<string
name=
"userLoadingTxt"
>
Cargando
</string>
<string
name=
"userLoadingMsg"
>
Cargando alumnos. Por favor espere.
</string>
<!-- Alert dialogs -->
<string
name=
"exitPictogram"
>
Salir de Pictogram
</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