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
fcb995bb
authored
Feb 09, 2017
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
#issue #900,#902 closed. working on #903
parent
2bc412d7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
66 deletions
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/NetService.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictogramActivity.java
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/net/NetServiceTablet.java
android/Pictogram/tabletlibrary/src/main/res/values-es/strings.xml
android/Pictogram/tabletlibrary/src/main/res/values/strings.xml
android/Pictogram/yotta_tablet/src/main/java/com/yottacode/pictogram/yotta_tablet/kiosk/AppContext.java
android/Pictogram/commonlibrary/src/main/java/com/yottacode/pictogram/net/NetService.java
View file @
fcb995bb
...
@@ -17,6 +17,7 @@ import com.yottacode.pictogram.dao.DeviceHelper;
...
@@ -17,6 +17,7 @@ import com.yottacode.pictogram.dao.DeviceHelper;
import
com.yottacode.pictogram.dao.LoginException
;
import
com.yottacode.pictogram.dao.LoginException
;
import
com.yottacode.pictogram.dao.User
;
import
com.yottacode.pictogram.dao.User
;
import
com.yottacode.pictogram.tools.PCBcontext
;
import
com.yottacode.pictogram.tools.PCBcontext
;
import
com.yottacode.tools.GUITools
;
import
org.json.JSONArray
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONException
;
...
@@ -142,7 +143,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
...
@@ -142,7 +143,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
public
void
restart_app
(
boolean
direct_login
)
{
public
void
restart_app
(
boolean
direct_login
)
{
for
(
iNetServiceStatus
listener:
listeners
)
for
(
iNetServiceStatus
listener:
listeners
)
if
(
listener
instanceof
iNetServiceDevice
)
((
iNetServiceDevice
)
listener
).
restart_app
(
direct_login
);
if
(
listener
instanceof
iNetServiceDevice
)
((
iNetServiceDevice
)
listener
).
restart_app
(
direct_login
);
PCBcontext
.
unset_user
();
PCBcontext
.
unset_user
();
}
}
public
void
restart_app
(
Intent
intent
,
boolean
direct_login
)
{
public
void
restart_app
(
Intent
intent
,
boolean
direct_login
)
{
for
(
iNetServiceStatus
listener:
listeners
)
for
(
iNetServiceStatus
listener:
listeners
)
...
@@ -155,66 +156,69 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
...
@@ -155,66 +156,69 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
*/
*/
@Override
@Override
public
void
run
()
{
public
void
run
()
{
PCBcontext
.
getRestapiWrapper
().
ask
(
ping_session
,
new
RestapiWrapper
.
iRestapiListener
()
{
try
{
@Override
PCBcontext
.
getRestapiWrapper
().
ask
(
ping_session
,
new
RestapiWrapper
.
iRestapiListener
()
{
public
void
preExecute
()
{
@Override
public
void
preExecute
()
{
}
@Override
public
void
result
(
JSONArray
result
)
{
}
@Override
public
void
result
(
JSONObject
result
)
{
try
{
float
version
=
Float
.
valueOf
(
result
.
getString
(
"version"
)).
floatValue
();
if
(
PCBcontext
.
getActivityContext
()!=
null
&&
version
>
DeviceHelper
.
getAppVersion
(
PCBcontext
.
getActivityContext
()))
{
Log
.
e
(
LOG_TAG
,
"New version is required! from v"
+
DeviceHelper
.
getAppVersion
(
PCBcontext
.
getContext
())+
" to v"
+
version
);
newVersionAlert
(
PCBcontext
.
getActivityContext
(),
version
);
}
}
catch
(
JSONException
e
)
{
Log
.
e
(
LOG_TAG
,
"PING JSON ERROR: "
+
result
+
" "
+
e
.
getMessage
());
}
}
if
(!
updated
)
{
lastRestfullSynchro
=
new
Date
().
getTime
();
@Override
updated
=
true
;
public
void
result
(
JSONArray
result
)
{
if
(
PCBcontext
.
is_user_logged
())
//si el usuario aun no hizo login, en realidad no es necesario hacer nada
// Comprobar si hay usuario offline, para hacer login transparente
if
(
PCBcontext
.
is_user_offline
()){
Log
.
i
(
LOG_TAG
,
"PCB online login from offline login"
);
login
();
}
else
if
(
PCBcontext
.
is_user_online
()){
Log
.
i
(
LOG_TAG
,
"PCB reconnect"
);
PCBcontext
.
getRoom
().
connect
();
PCBcontext
.
getVocabulary
().
synchronize
();
PCBcontext
.
getActionLog
().
batch
();
}
notifyStatus
();
}
}
else
{
//cada restfullSynchroTimming aprox. se fuerza sincronización de vocabulario y configuración de usuario
long
now
=
new
Date
().
getTime
();
if
(
PCBcontext
.
is_user_logged
())
{
if
(
restfullSynchroTimming
>
0
&&
(
now
-
lastRestfullSynchro
>
restfullSynchroTimming
))
{
Log
.
i
(
LOG_TAG
,
"Vocabulary request"
);
PCBcontext
.
getVocabulary
().
synchronize
();
synchronizeStudentAttributes
();
lastRestfullSynchro
=
now
;
}
}
else
lastRestfullSynchro
=
new
Date
().
getTime
();
}
}
@Override
public
void
result
(
JSONObject
result
)
{
try
{
float
version
=
Float
.
valueOf
(
result
.
getString
(
"version"
)).
floatValue
();
if
(
PCBcontext
.
getActivityContext
()
!=
null
&&
version
>
DeviceHelper
.
getAppVersion
(
PCBcontext
.
getActivityContext
()))
{
Log
.
e
(
LOG_TAG
,
"New version is required! from v"
+
DeviceHelper
.
getAppVersion
(
PCBcontext
.
getContext
())
+
" to v"
+
version
);
newVersionAlert
(
PCBcontext
.
getActivityContext
(),
version
);
}
}
catch
(
JSONException
e
)
{
Log
.
e
(
LOG_TAG
,
"PING JSON ERROR: "
+
result
+
" "
+
e
.
getMessage
());
}
if
(!
updated
)
{
lastRestfullSynchro
=
new
Date
().
getTime
();
updated
=
true
;
if
(
PCBcontext
.
is_user_logged
())
//si el usuario aun no hizo login, en realidad no es necesario hacer nada
// Comprobar si hay usuario offline, para hacer login transparente
if
(
PCBcontext
.
is_user_offline
())
{
Log
.
i
(
LOG_TAG
,
"PCB online login from offline login"
);
login
();
}
else
if
(
PCBcontext
.
is_user_online
())
{
Log
.
i
(
LOG_TAG
,
"PCB reconnect"
);
PCBcontext
.
getRoom
().
connect
();
PCBcontext
.
getVocabulary
().
synchronize
();
PCBcontext
.
getActionLog
().
batch
();
}
}
else
{
//cada restfullSynchroTimming aprox. se fuerza sincronización de vocabulario y configuración de usuario
long
now
=
new
Date
().
getTime
();
if
(
PCBcontext
.
is_user_logged
())
{
if
(
restfullSynchroTimming
>
0
&&
(
now
-
lastRestfullSynchro
>
restfullSynchroTimming
))
{
Log
.
i
(
LOG_TAG
,
"Vocabulary request"
);
PCBcontext
.
getVocabulary
().
synchronize
();
synchronizeStudentAttributes
();
lastRestfullSynchro
=
now
;
}
}
else
lastRestfullSynchro
=
new
Date
().
getTime
();
}
@Override
}
public
void
error
(
RestapiWrapper
.
HTTPException
e
)
{
setOffline
(
e
);
}
});
@Override
public
void
error
(
RestapiWrapper
.
HTTPException
e
)
{
setOffline
(
e
);
}
});
notifyStatus
();
Log
.
e
(
LOG_TAG
,
"working"
);
}
catch
(
Exception
e
)
{
Log
.
e
(
LOG_TAG
,
"NOT WORKING BECAUSE:"
+
e
.
getMessage
());
this
.
restart_app
(
true
);
}
}
}
private
void
synchronizeStudentAttributes
()
{
private
void
synchronizeStudentAttributes
()
{
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/gui/communicator/PictogramActivity.java
View file @
fcb995bb
...
@@ -57,6 +57,7 @@ import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet;
...
@@ -57,6 +57,7 @@ import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet;
import
com.yottacode.pictogram.tools.Img
;
import
com.yottacode.pictogram.tools.Img
;
import
com.yottacode.pictogram.tools.PCBcontext
;
import
com.yottacode.pictogram.tools.PCBcontext
;
import
com.yottacode.pictogram.tts.TTSHelper
;
import
com.yottacode.pictogram.tts.TTSHelper
;
import
com.yottacode.tools.GUITools
;
import
org.json.JSONException
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
org.json.JSONObject
;
...
@@ -1055,16 +1056,22 @@ protected void showOnlyTape(boolean onlyTape) {
...
@@ -1055,16 +1056,22 @@ protected void showOnlyTape(boolean onlyTape) {
if
(!
student_view
||
!
PCBcontext
.
getPcbdb
().
getCurrentUser
().
is_teacher
())
{
if
(!
student_view
||
!
PCBcontext
.
getPcbdb
().
getCurrentUser
().
is_teacher
())
{
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_Img_sup
().
update_id
(
student_view
?
PCBcontext
.
getDevice
().
getLastSupId
()
:
User
.
NO_SUPERVISOR
);
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_Img_sup
().
update_id
(
student_view
?
PCBcontext
.
getDevice
().
getLastSupId
()
:
User
.
NO_SUPERVISOR
);
nextActivity
=
intent
;
nextActivity
=
intent
;
}
else
{
}
else
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_Img_sup
().
update_id
(
PCBcontext
.
getDevice
().
getLastSupId
());
if
(!
PCBcontext
.
getNetService
().
online
())
nextActivity
=
new
Intent
(
this
,
SessionActivity
.
class
);
GUITools
.
show_alert
(
PictogramActivity
.
this
,
R
.
string
.
session_noinet
);
}
else
{
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_Img_sup
().
update_id
(
PCBcontext
.
getDevice
().
getLastSupId
());
nextActivity
=
new
Intent
(
this
,
SessionActivity
.
class
);
}
in
=
R
.
anim
.
rightin
;
in
=
R
.
anim
.
rightin
;
out
=
R
.
anim
.
rightout
;
out
=
R
.
anim
.
rightout
;
overridePendingTransition
(
R
.
anim
.
leftin
,
R
.
anim
.
leftout
);
overridePendingTransition
(
R
.
anim
.
leftin
,
R
.
anim
.
leftout
);
}
else
if
(
firstTouchX
>
event
.
getX
()
+
150
)
{
//derecha a izquierda
}
else
if
(
firstTouchX
>
event
.
getX
()
+
150
)
{
//derecha a izquierda
if
(!
student_view
&&
PCBcontext
.
getPcbdb
().
getCurrentUser
().
is_teacher
()
)
{
if
(!
student_view
&&
PCBcontext
.
getPcbdb
().
getCurrentUser
().
is_teacher
()
)
{
nextActivity
=
new
Intent
(
this
,
SessionActivity
.
class
);
if
(!
PCBcontext
.
getNetService
().
online
())
GUITools
.
show_alert
(
PictogramActivity
.
this
,
R
.
string
.
session_noinet
);
else
nextActivity
=
new
Intent
(
this
,
SessionActivity
.
class
);
}
else
{
}
else
{
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_Img_sup
().
update_id
(
student_view
?
PCBcontext
.
getDevice
().
getLastSupId
()
:
User
.
NO_SUPERVISOR
);
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_Img_sup
().
update_id
(
student_view
?
PCBcontext
.
getDevice
().
getLastSupId
()
:
User
.
NO_SUPERVISOR
);
nextActivity
=
intent
;
nextActivity
=
intent
;
...
...
android/Pictogram/tabletlibrary/src/main/java/com/yottacode/pictogram/tabletlibrary/net/NetServiceTablet.java
View file @
fcb995bb
package
com
.
yottacode
.
pictogram
.
tabletlibrary
.
net
;
package
com
.
yottacode
.
pictogram
.
tabletlibrary
.
net
;
import
android.app.NotificationManager
;
import
android.app.NotificationManager
;
import
android.app.PendingIntent
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.app.NotificationCompat
;
import
android.support.v4.app.TaskStackBuilder
;
import
android.util.Log
;
import
android.util.Log
;
import
com.yottacode.pictogram.dao.User
;
import
com.yottacode.pictogram.dao.User
;
...
@@ -22,11 +24,12 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
...
@@ -22,11 +24,12 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
private
static
NotificationCompat
.
Builder
builder
;
private
static
NotificationCompat
.
Builder
builder
;
private
PictogramActivity
pictogramActivity
;
private
PictogramActivity
pictogramActivity
;
int
notifyID
=
666
;
public
void
build
()
{
public
void
build
()
{
this
.
builder
=
new
NotificationCompat
.
Builder
(
PCBcontext
.
getContext
());
this
.
builder
=
new
NotificationCompat
.
Builder
(
PCBcontext
.
getContext
())
.
setAutoCancel
(
true
)
;
/*
Intent resultIntent = new Intent(PCBcontext.getContext(), PictogramActivity.class);
/*
Intent resultIntent = new Intent(PCBcontext.getContext(), PictogramActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(PCBcontext.getContext());
TaskStackBuilder stackBuilder = TaskStackBuilder.create(PCBcontext.getContext());
stackBuilder.addParentStack(PictogramActivity.class);
stackBuilder.addParentStack(PictogramActivity.class);
stackBuilder.addNextIntent(resultIntent);
stackBuilder.addNextIntent(resultIntent);
...
@@ -36,8 +39,8 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
...
@@ -36,8 +39,8 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
}
}
public
void
notifyStatus
(
boolean
updated
)
{
public
void
notifyStatus
(
boolean
updated
)
{
int
notifyID
=
1
;
String
user
=
""
;
String
user
=
""
;
if
(
PCBcontext
.
getPcbdb
()!=
null
)
{
if
(
PCBcontext
.
getPcbdb
()!=
null
)
{
user
=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_name_stu
()+
" "
+
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_surname_stu
();
user
=
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_name_stu
()+
" "
+
PCBcontext
.
getPcbdb
().
getCurrentUser
().
get_surname_stu
();
if
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
is_supervisor
())
if
(
PCBcontext
.
getPcbdb
().
getCurrentUser
().
is_supervisor
())
...
@@ -57,7 +60,6 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
...
@@ -57,7 +60,6 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
mNotificationManager
.
notify
(
notifyID
,
builder
.
build
());
mNotificationManager
.
notify
(
notifyID
,
builder
.
build
());
}
}
public
void
closeNotifyStatus
(){
public
void
closeNotifyStatus
(){
int
notifyID
=
1
;
NotificationManager
mNotificationManager
=
NotificationManager
mNotificationManager
=
(
NotificationManager
)
PCBcontext
.
getContext
().
getSystemService
(
PCBcontext
.
getContext
().
NOTIFICATION_SERVICE
);
(
NotificationManager
)
PCBcontext
.
getContext
().
getSystemService
(
PCBcontext
.
getContext
().
NOTIFICATION_SERVICE
);
mNotificationManager
.
cancel
(
notifyID
);
mNotificationManager
.
cancel
(
notifyID
);
...
...
android/Pictogram/tabletlibrary/src/main/res/values-es/strings.xml
View file @
fcb995bb
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
<string
name=
"session_closed_ok"
>
Sesión grabada correctamente. Hora
</string>
<string
name=
"session_closed_ok"
>
Sesión grabada correctamente. Hora
</string>
<string
name=
"session_closed_fail"
>
Sesión no cerrada. Por favor cierre la sesión en el panel de control de Pictogram Tablet
</string>
<string
name=
"session_closed_fail"
>
Sesión no cerrada. Por favor cierre la sesión en el panel de control de Pictogram Tablet
</string>
<string
name=
"session_pause_error"
>
Error pausando la sesión
</string>
<string
name=
"session_pause_error"
>
Error pausando la sesión
</string>
<string
name=
"session_noinet"
>
No hay conexión con el servidor. Por favor, asegúrese que tiene conexión a Internet
</string>
<string
name=
"session_noinet"
>
Conexión a Internet necesaria para grabar sesiones. Por favor, asegúrese que tiene conexión
</string>
<string
name=
"session_inetok"
>
Conexión con el servidor restablecida
</string>
<string
name=
"session_inetok"
>
Conexión con el servidor restablecida
</string>
<string
name=
"session_log_startingsession"
>
iniciando sesión
</string>
<string
name=
"session_log_startingsession"
>
iniciando sesión
</string>
<string
name=
"session_log_closingsession"
>
cerrando sesión
</string>
<string
name=
"session_log_closingsession"
>
cerrando sesión
</string>
...
...
android/Pictogram/tabletlibrary/src/main/res/values/strings.xml
View file @
fcb995bb
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
<string
name=
"session_closed_ok"
>
Sesión grabada correctamente
</string>
<string
name=
"session_closed_ok"
>
Sesión grabada correctamente
</string>
<string
name=
"session_closed_fail"
>
Sesión no cerrada. Por favor intente cerrarla desde
</string>
<string
name=
"session_closed_fail"
>
Sesión no cerrada. Por favor intente cerrarla desde
</string>
<string
name=
"session_pause_error"
>
Error pausando la sesión
</string>
<string
name=
"session_pause_error"
>
Error pausando la sesión
</string>
<string
name=
"session_noinet"
>
No hay conexión con el servidor. Por favor, asegúrese que tiene conexión a Internet
</string>
<string
name=
"session_noinet"
>
Conexión a Internet necesaria para grabar sesiones. Por favor, asegúrese que tiene conexión
</string>
<string
name=
"session_inetok"
>
Conexión con el servidor restablecida
</string>
<string
name=
"session_inetok"
>
Conexión con el servidor restablecida
</string>
<string
name=
"session_log_startingsession"
>
iniciando sesión
</string>
<string
name=
"session_log_startingsession"
>
iniciando sesión
</string>
<string
name=
"session_log_closingsession"
>
cerrando sesión
</string>
<string
name=
"session_log_closingsession"
>
cerrando sesión
</string>
...
...
android/Pictogram/yotta_tablet/src/main/java/com/yottacode/pictogram/yotta_tablet/kiosk/AppContext.java
View file @
fcb995bb
...
@@ -22,6 +22,7 @@ public class AppContext extends Application {
...
@@ -22,6 +22,7 @@ public class AppContext extends Application {
instance
=
this
;
instance
=
this
;
registerKioskModeScreenOffReceiver
();
registerKioskModeScreenOffReceiver
();
startKioskService
();
// Service for restarting the app when another app go to foreground
startKioskService
();
// Service for restarting the app when another app go to foreground
}
}
private
void
registerKioskModeScreenOffReceiver
()
{
private
void
registerKioskModeScreenOffReceiver
()
{
...
...
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