#issue #900,#902 closed. working on #903

parent 2bc412d7
......@@ -17,6 +17,7 @@ import com.yottacode.pictogram.dao.DeviceHelper;
import com.yottacode.pictogram.dao.LoginException;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.GUITools;
import org.json.JSONArray;
import org.json.JSONException;
......@@ -155,6 +156,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
*/
@Override
public void run() {
try {
PCBcontext.getRestapiWrapper().ask(ping_session, new RestapiWrapper.iRestapiListener() {
@Override
public void preExecute() {
......@@ -168,43 +170,40 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
@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);
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());
Log.e(LOG_TAG, "PING JSON ERROR: " + result + " " + e.getMessage());
}
if (!updated) {
lastRestfullSynchro=new Date().getTime();
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()){
if (PCBcontext.is_user_offline()) {
Log.i(LOG_TAG, "PCB online login from offline login");
login();
} else if (PCBcontext.is_user_online()){
} else if (PCBcontext.is_user_online()) {
Log.i(LOG_TAG, "PCB reconnect");
PCBcontext.getRoom().connect();
PCBcontext.getVocabulary().synchronize();
PCBcontext.getActionLog().batch();
}
notifyStatus();
}
else {
} else {
//cada restfullSynchroTimming aprox. se fuerza sincronización de vocabulario y configuración de usuario
long now=new Date().getTime();
long now = new Date().getTime();
if (PCBcontext.is_user_logged()) {
if (restfullSynchroTimming>0 && (now - lastRestfullSynchro > restfullSynchroTimming)) {
if (restfullSynchroTimming > 0 && (now - lastRestfullSynchro > restfullSynchroTimming)) {
Log.i(LOG_TAG, "Vocabulary request");
PCBcontext.getVocabulary().synchronize();
synchronizeStudentAttributes();
lastRestfullSynchro = now;
}
}
else lastRestfullSynchro=new Date().getTime();
} else lastRestfullSynchro = new Date().getTime();
}
}
......@@ -214,7 +213,12 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
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() {
......
......@@ -57,6 +57,7 @@ import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet;
import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.pictogram.tts.TTSHelper;
import com.yottacode.tools.GUITools;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -1055,7 +1056,10 @@ protected void showOnlyTape(boolean onlyTape) {
if (!student_view || !PCBcontext.getPcbdb().getCurrentUser().is_teacher()) {
PCBcontext.getPcbdb().getCurrentUser().get_Img_sup().update_id(student_view ? PCBcontext.getDevice().getLastSupId() : User.NO_SUPERVISOR);
nextActivity = intent;
} else {
} else
if (!PCBcontext.getNetService().online())
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);
}
......@@ -1064,6 +1068,9 @@ protected void showOnlyTape(boolean onlyTape) {
overridePendingTransition(R.anim.leftin, R.anim.leftout);
} else if (firstTouchX > event.getX() + 150) { //derecha a izquierda
if (!student_view && PCBcontext.getPcbdb().getCurrentUser().is_teacher() ) {
if (!PCBcontext.getNetService().online())
GUITools.show_alert(PictogramActivity.this, R.string.session_noinet);
else
nextActivity = new Intent(this, SessionActivity.class);
} else {
PCBcontext.getPcbdb().getCurrentUser().get_Img_sup().update_id(student_view ? PCBcontext.getDevice().getLastSupId() : User.NO_SUPERVISOR);
......
package com.yottacode.pictogram.tabletlibrary.net;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.util.Log;
import com.yottacode.pictogram.dao.User;
......@@ -22,11 +24,12 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
private static NotificationCompat.Builder builder;
private PictogramActivity pictogramActivity;
int notifyID = 666;
public void build() {
this.builder = new NotificationCompat.Builder(PCBcontext.getContext());
/* Intent resultIntent = new Intent(PCBcontext.getContext(), PictogramActivity.class);
this.builder = new NotificationCompat.Builder(PCBcontext.getContext()).setAutoCancel(true);
/*Intent resultIntent = new Intent(PCBcontext.getContext(), PictogramActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(PCBcontext.getContext());
stackBuilder.addParentStack(PictogramActivity.class);
stackBuilder.addNextIntent(resultIntent);
......@@ -36,8 +39,8 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
}
public void notifyStatus(boolean updated) {
int notifyID = 1;
String user="";
if (PCBcontext.getPcbdb()!=null) {
user=PCBcontext.getPcbdb().getCurrentUser().get_name_stu()+" "+PCBcontext.getPcbdb().getCurrentUser().get_surname_stu();
if (PCBcontext.getPcbdb().getCurrentUser().is_supervisor())
......@@ -57,7 +60,6 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
mNotificationManager.notify(notifyID, builder.build());
}
public void closeNotifyStatus(){
int notifyID = 1;
NotificationManager mNotificationManager =
(NotificationManager) PCBcontext.getContext().getSystemService(PCBcontext.getContext().NOTIFICATION_SERVICE);
mNotificationManager.cancel(notifyID);
......
......@@ -15,7 +15,7 @@
<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_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_log_startingsession">iniciando sesión</string>
<string name="session_log_closingsession">cerrando sesión</string>
......
......@@ -17,7 +17,7 @@
<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_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_log_startingsession">iniciando sesión</string>
<string name="session_log_closingsession">cerrando sesión</string>
......
......@@ -22,6 +22,7 @@ public class AppContext extends Application {
instance = this;
registerKioskModeScreenOffReceiver();
startKioskService(); // Service for restarting the app when another app go to foreground
}
private void registerKioskModeScreenOffReceiver() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment