Commit f4473d5c by Arturo Montejo Ráez

merge conflict fixed

parents 632b8f4f 8f1ecc7d
Showing with 456 additions and 218 deletions
......@@ -21,6 +21,7 @@ android {
resValue "bool", "ssl_connect", "true"
resValue "bool", "force_img_download", "false"
resValue "integer", "netservice_timing", "5"
resValue "integer", "netservice_force_restfull_synchro", "0"
}
debug {
resValue "string", "server", "https://dev.yottacode.com"
......@@ -28,6 +29,7 @@ android {
resValue "bool", "ssl_connect", "false"
resValue "bool", "force_img_download", "false"
resValue "integer", "netservice_timing", "5"
resValue "integer", "netservice_force_restfull_synchro", "0"
}
}
}
......
......@@ -41,7 +41,7 @@ public class RestapiWrapper {
private static final String SERVER_ERROR="error";
// String constant for logs
private final String LOG_TAG = this.getClass().getSimpleName(); // Or .getCanonicalName()
private final static String LOG_TAG = RestapiWrapper.class.getSimpleName(); // Or .getCanonicalName()
public RestapiWrapper(String server, String token) {
this.server=server;
......@@ -123,7 +123,7 @@ public class RestapiWrapper {
return false;
} catch (IOException e) {
e.printStackTrace();
Log.i(com.yottacode.net.RestapiWrapper.class.getName(), "ping failed at"+ping_op);
Log.i(LOG_TAG, "ping failed at"+ping_op);
//error_listener.error(e);
}
return pingResult;
......@@ -137,7 +137,7 @@ public class RestapiWrapper {
BufferedReader br = new BufferedReader(new InputStreamReader(responseCode == HttpsURLConnection.HTTP_OK
? urlConnection.getInputStream()
: urlConnection.getErrorStream()));
// Log.i(com.yottacode.net.RestapiWrapper.class.getName(), "starting to read server answer for"+urlConnection.getURL().toString());
// Log.i(LOG_TAG, "starting to read server answer for"+urlConnection.getURL().toString());
while ((line=br.readLine()) != null) {
response.append(line);
}
......@@ -145,7 +145,7 @@ public class RestapiWrapper {
if (Character.isAlphabetic(response.charAt(0)))
response.append('\'').insert(0,'\'');
Log.i(com.yottacode.net.RestapiWrapper.class.getName(), "Raw server answer: " + response);
Log.i(LOG_TAG, "Raw server answer: " + response);
try {
JSONresponse = new JSONObject("{ "+SERVER_RESULT+": " + response + (responseCode == HttpsURLConnection.HTTP_OK
? "}"
......@@ -154,7 +154,7 @@ public class RestapiWrapper {
JSONresponse = null;
Log.e(RestapiWrapper.class.getCanonicalName(),e.getMessage());
}
Log.i(com.yottacode.net.RestapiWrapper.class.getName(), "server answer: " + JSONresponse.toString());
Log.i(LOG_TAG, "server answer: " + JSONresponse.toString());
return JSONresponse;
}
......@@ -252,7 +252,7 @@ public class RestapiWrapper {
protected HttpAsyncTaskParams doInBackground(HttpAsyncTaskParams... params) {
JSONObject jresult=null;
try {
Log.i(com.yottacode.net.RestapiWrapper.class.getName(), " Asking to the server for " + params[0].url+" params:"+params[0].url_params +" JSON?"+params[0].json_params);
Log.i(LOG_TAG, " Asking to the server for " + params[0].url+" params:"+params[0].url_params +" JSON?"+params[0].json_params);
jresult = params[0].request_method.equalsIgnoreCase("GET")
? GET(params[0].url, params[0].url_params)
: POST(params[0].url, params[0].request_method, params[0].url_params, params[0].json_params);
......@@ -260,11 +260,11 @@ public class RestapiWrapper {
if (jresult.has(SERVER_ERROR))
params[0].error= new HTTPException(params[0].result+" (err code "+jresult.getString(SERVER_ERROR)+")", jresult.getInt(SERVER_ERROR));
} catch (IOException e) {
Log.e(com.yottacode.net.RestapiWrapper.class.getName(), "Error: '" + e.getLocalizedMessage() + "' when asking for " + params[0].url);
Log.e(LOG_TAG, "Error: '" + e.getLocalizedMessage() + "' when asking for " + params[0].url);
params[0].result=null;
params[0].error=new HTTPException(e.getMessage(),-1);
} catch (JSONException e) {
Log.e(com.yottacode.net.RestapiWrapper.class.getName(), "Error: '" + e.getLocalizedMessage() +
Log.e(LOG_TAG, "Error: '" + e.getLocalizedMessage() +
"' when parsing " + jresult==null ? "null json result" : jresult.toString());
params[0].result=null;
params[0].error=new HTTPException(e.getMessage(),-1);
......
......@@ -2,25 +2,17 @@ package com.yottacode.net;
import android.util.Log;
import com.github.nkzawa.emitter.Emitter;
import com.github.nkzawa.socketio.client.Ack;
import com.github.nkzawa.socketio.client.IO;
import com.github.nkzawa.socketio.client.Socket;
import com.github.nkzawa.emitter.Emitter;
import org.json.JSONException;
import org.json.JSONObject;
import java.net.URISyntaxException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import java.security.SecureRandom;
/**
......@@ -74,7 +66,14 @@ public class SailsSocketsIO {
Log.d(this.getClass().getName(), " Listening:"+message);
socket.on(message, listener);
}
/**
* Unregisters a connection listener to a given message
* @param message
*/
public void unregisterMessage(String message) {
Log.d(this.getClass().getName(), " Unlistening:"+message);
socket.off(message);
}
public SailsSocketsIO(String sails_socket_io_url, String ptransport, Emitter.Listener connectListener, Emitter.Listener errorListener) {
......@@ -114,11 +113,13 @@ public class SailsSocketsIO {
JSONObject obj=new JSONObject().put("url", msg).put("data", params);
Log.d(this.getClass().getName(), "Emitted messsage:" + obj);
Log.i(this.getClass().getName(), "Emitted messsage:" + obj);
socket.emit(this.EMIT_METHOD, obj, ack);
}
public void destroy() {
this.socket.disconnect();
this.socket.off();
if (this.socket.connected()) {
this.socket.off();
this.socket.disconnect();
}
}
}
......@@ -36,6 +36,8 @@ import java.util.Vector;
public class Device extends SQLiteOpenHelper {
Context context;
final static class PARAMS {
static String keyword="key";
static String deviceID="deviceID";
......@@ -444,5 +446,4 @@ public class Device extends SQLiteOpenHelper {
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
......@@ -19,7 +19,8 @@ import org.json.JSONObject;
* @author Fernando Martinez Santiago
* @version 1.0
*/
public class Picto extends Img {
public class
Picto extends Img {
public final static class JSON_ATTTRS {
......
......@@ -50,6 +50,7 @@ public class ServerLogin {
PCBcontext.getPcbdb().user_online(true);
PCBcontext.getRestapiWrapper().setToken(result.getString(TAG_TOKEN));
PCBcontext.getVocabulary().synchronize();
PCBcontext.getRoom().connect();
}
listener.result(result);
}catch (JSONException e) {
......
......@@ -35,7 +35,7 @@ public class Room {
public Room( ) {
Log.i(this.getClass().getName(), "Entering room");
listeners=new Hashtable<>();
reconnect();
connect();
}
private JSONObject common_data(String action, JSONObject attributes) throws JSONException {
......@@ -67,10 +67,9 @@ public class Room {
/**
* Reconnect to the room. It is useful if the server connection is lost for a time
*/
public void reconnect() {
public void connect() {
final String transport="polling";
exit();
this.socket=new SailsSocketsIO(PCBcontext.getRestapiWrapper().getServer(), transport, new Emitter.Listener() {
@Override
public void call(Object... args) {
......@@ -83,6 +82,7 @@ public class Room {
@Override
public void call(Object... args) {
Log.e(this.getClass().getName(), "IO sockects error: "+args[0]);
for (StackTraceElement element: Thread.currentThread().getStackTrace() ) Log.e(this.getClass().getName(), "IO sockect error detail: "+element.getClassName()+"."+element.getMethodName());
inRoom=false;
PCBcontext.getNetService().setOffline(new SocketIOException(args[0].toString()));
}
......@@ -108,9 +108,16 @@ public class Room {
Log.e(this.getClass().getCanonicalName(), "subscribe room failed:"+e.getMessage());
}
}
void unlisten() {
for (String msg: this.listeners.keySet()) {
Log.i(this.getClass().getName(), "Unlistening to "+msg);
this.socket.unregisterMessage(msg);
}
}
void unsubscribe() {
void unsubscribe() {
try {
UnsubscribeAction action = new UnsubscribeAction();
this.emit(action);
}catch (Exception e) {
......@@ -120,13 +127,16 @@ public class Room {
public void exit() {
if (this.socket!=null) {
Log.i(this.getClass().getName(), "Leaving room");
unlisten();
unsubscribe();
this.socket.destroy();
this.socket=null;
}
}
public void finalize() throws java.lang.Throwable {
super.finalize();
Log.i(this.getClass().getName(), "Discarding room");
exit();
}
......
......@@ -33,7 +33,7 @@ public class StudentTalk implements Emitter.Listener {
@Override
public void call(Object... args) {
if (PCBcontext.getPcbdb()!=null)
try {
JSONObject msg = ((JSONObject) args[0]).getJSONObject("student");
Log.i(this.getClass().getName(), "raw Received message " +msg.toString());
......
......@@ -17,7 +17,7 @@ public class VocabularyTalk implements Emitter.Listener {
private static final String URL ="vocabulary";
private Room room;
private final String LOG_TAG=this.getClass().getName();
iVocabularyListener listeners[];
public VocabularyTalk(Room room, iVocabularyListener listeners[]) {
......@@ -40,7 +40,7 @@ public class VocabularyTalk implements Emitter.Listener {
JSONObject msg = (JSONObject) args[0];
try {
Log.i(this.getClass().getName(), "raw Received message " +msg.toString());
Log.i(LOG_TAG, "raw Received message " +msg.toString());
String action = msg.getString(param_action).toLowerCase();
JSONObject stu_picto= msg.getJSONObject(param_attributes).getJSONObject(param_stu_picto);
JSONObject attrs_stu_picto = stu_picto.optJSONObject(param_attributes);
......@@ -48,7 +48,7 @@ public class VocabularyTalk implements Emitter.Listener {
int picto_id = picto_stupicto.getInt(param_picto_id);
int picto_cat = attrs_stu_picto!=null ? attrs_stu_picto.optInt(param_picto_cat, Picto.NO_CATEGORY) : 0;
Log.i(this.getClass().getName(), "Received message '" + action +
Log.i(LOG_TAG, "Received message '" + action +
"' for picto " + picto_id + " (cat " + picto_cat + ", picto: " + picto_stupicto);
for (iVocabularyListener listener: this.listeners)
listener.change(action.equals(action_update) ? iVocabularyListener.action.update
......@@ -57,7 +57,7 @@ public class VocabularyTalk implements Emitter.Listener {
, picto_cat, picto_id, stu_picto);
} catch (JSONException e) {
Log.e(this.getClass().getCanonicalName(), e.getClass().getCanonicalName() + "--" + e);
Log.e(LOG_TAG, e.getClass().getCanonicalName() + "--" + e);
}
}
......
......@@ -26,7 +26,7 @@ public final class PCBcontext {
private static Vocabulary vocabulary;
private static ActionLog actionLog;
private static boolean init=false;
private static StudentTalk studentTalk;
/**
......@@ -45,8 +45,8 @@ public final class PCBcontext {
Log.i(PCBcontext.class.getCanonicalName(), "PCB context started. It's required" +
"set_user method call");
} else {
Log.e(PCBcontext.class.getClass().getCanonicalName(), "Init method was previously" +
"invoked! Please, check your code");
Log.e(PCBcontext.class.getCanonicalName(), "Init method was previously " +
" invoked! Please, check your code");
}
}
......@@ -70,12 +70,12 @@ public final class PCBcontext {
actionLog = new ActionLog();
vocabulary = new Vocabulary(listener);
getNetService().notifyStatus();
if (getNetService().online()) new StudentTalk(room, new StudentTalk.iStudentListener[] {new StudentTalk.iStudentListener() {
studentTalk=new StudentTalk(room, new StudentTalk.iStudentListener[] {new StudentTalk.iStudentListener() {
@Override
public void change(User updatedStudent) {
PCBcontext.getDevice().insertUser(updatedStudent);
if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big())
PCBcontext.getNetService().getNetServiceDevice().restart_app(true);
if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big() || updatedStudent.has_categories()!=getPcbdb().getCurrentUser().has_categories())
PCBcontext.getNetService().restart_app(true);
else {
PCBcontext.getPcbdb().setCurrentUser(updatedStudent);
PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent);
......@@ -88,8 +88,8 @@ public final class PCBcontext {
public static void unset_user() {
Log.i(PCBcontext.class.getCanonicalName(), "User unset. Student " + getPcbdb().getCurrentUser().get_name_stu());
pcbdb = null;
if (room!=null) room.exit();
pcbdb = null;
room = null;
vocabulary = null;
getNetService().notifyStatus();
......@@ -145,6 +145,15 @@ public final class PCBcontext {
return device;
}
public static StudentTalk getStudentTalk() {
if (studentTalk == null) {
throw new java.lang.NullPointerException("studentTalk is null. PCBcontext.init must be" +
"invoked previously");
}
return studentTalk;
}
/**
* @return PCBDB
* @TODO complete documentation
......
......@@ -54,7 +54,7 @@ public class TTSHelper {
Set<Voice> voices = this.ttobj.getVoices();
if (voices!=null)
for (Voice avoice : voices) { Log.i(context.getApplicationInfo().processName,"Voice "+avoice+" available");
for (Voice avoice : voices) { //Log.i(context.getApplicationInfo().processName,"Voice "+avoice+" available");
if (avoice.getName().equalsIgnoreCase(voice)) {
this.ttobj.setVoice(avoice);
this.voice_ok=true;
......
......@@ -20,6 +20,7 @@
<string name="loginErrorTxt">Login</string>
<string name="loginErrorMsg">Invalid user or password. Please, try it again.</string>
<string name="loginNoLicenseMsg">Not valid user license. Please, contact with Yotta.</string>
<string name="loginExpiredLicenseMsg">User license was expired on</string>
<string name="userInetErrorMsg">Unknown new user name because Internet conection is not available</string>
<string name="userLoadingTxt">Loading</string>
<string name="userLoadingMsg">Loading students. Please wait.</string>
......
......@@ -20,7 +20,8 @@
<string name="loginTitle">¿Quién eres?</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="loginNoLicenseMsg">El usuario no tiene una licencia válida. Contacte con Yotta para adquirir una.</string>
<string name="loginNoLicenseMsg">La licencia del usuario expiró con fecha. Contacte con Yotta para adquirir una.</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="imguserLoadingErrMsg">Imagen con formato no válido.</string>
......
......@@ -21,6 +21,7 @@
<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="loginNoLicenseMsg">El usuario no tiene una licencia válida. Contacte con Yotta para adquirir una.</string>
<string name="loginExpiredLicenseMsg">La licencia del usuario expiró con fecha</string>
<string name="userInetErrorMsg">Este usuario requiere conexión a internet para ser validado</string>
<string name="userLoadingTxt">Cargando</string>
<string name="userLoadingMsg">Cargando alumnos. Por favor espere.</string>
......
......@@ -66,14 +66,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/assets" type="java-test-resource" />
......@@ -82,6 +74,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
......@@ -124,6 +124,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/animated-vector-drawable/24.2.1/jars" />
......
......@@ -112,7 +112,7 @@ public class LoginActivity extends FragmentActivity {
@Override
protected void onStop() {
super.onStop();
Log.i(LOG_TAG,"Closing app");
Log.i(LOG_TAG,"Closing Login window");
PCBcontext.getNetService().closeNotifyStatus();
}
}
......@@ -62,7 +62,6 @@ 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;
......@@ -122,7 +121,6 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
private boolean feedback_read;
private boolean feedback_highlight;
private boolean deleting;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -140,6 +138,7 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
return;
}
this.vocabulary = PCBcontext.getVocabulary();
this.vocabulary.listen(PCBcontext.getRoom(), this, new ActionTalk.iActionListener() {
@Override
......@@ -218,11 +217,13 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
this.tapeGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.i(PictogramActivity.class.getCanonicalName(), " Deleting item " + position + "-"+id+"(" + PictogramActivity.this.tapeAdapter.getItem(position).get_translation() + ")");
if (!deleting) {
Log.i(PictogramActivity.class.getCanonicalName(), " Deleting item " + position + "-" + id + "(" + PictogramActivity.this.tapeAdapter.getItem(position).get_translation() + ")");
animateImageView(view,position);
PictogramActivity.this.tapeAdapter.notifyDataSetChanged();
PCBcontext.getActionLog().log(new TalkAction(TalkAction.DELETE, PictogramActivity.this.tapeAdapter.getItem(position)));
animateImageView(view, position);
PictogramActivity.this.tapeAdapter.notifyDataSetChanged();
PCBcontext.getActionLog().log(new TalkAction(TalkAction.DELETE, PictogramActivity.this.tapeAdapter.getItem(position)));
}
}});
((NetServiceTablet) PCBcontext.getNetService().getNetServiceDevice()).setPictogramActivity(this);
......@@ -1126,27 +1127,48 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if (PCBcontext.getPcbdb()!=null && PCBcontext.getPcbdb().getCurrentUser().is_supervisor())
int in=0,out=0;
Intent nextActivity=null;
Intent intent =getIntent();
boolean student_view=intent.getBooleanExtra("student_view",false);
if (PCBcontext.getPcbdb()!=null && (PCBcontext.getPcbdb().getCurrentUser().is_supervisor() || student_view)) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
firstTouchX = event.getX();
break;
case MotionEvent.ACTION_MOVE:
if (firstTouchX > event.getX()+100) {
if (!PCBcontext.getNetService().online())
GUITools.show_alert(this,R.string.pictogram_offline);
else {
Intent sessionActivity = new Intent(this, SessionActivity.class);
sessionActivity.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(sessionActivity);
overridePendingTransition(R.anim.leftin, R.anim.leftout);
case MotionEvent.ACTION_UP:
if (event.getX() > firstTouchX + 100) { //izquierda a derecha
if (!student_view) {
PCBcontext.getPcbdb().getCurrentUser().get_Img_sup().update_id(User.NO_SUPERVISOR);
nextActivity = intent;
} else {
PCBcontext.getPcbdb().getCurrentUser().get_Img_sup().update_id(PCBcontext.getDevice().getLastSupId());
nextActivity = new Intent(this, SessionActivity.class);
}
in = R.anim.rightin;
out = R.anim.rightout;
overridePendingTransition(R.anim.leftin, R.anim.leftout);
} else if (firstTouchX > event.getX() + 100) { //derecha a izquierda
if (!student_view) {
nextActivity = new Intent(this, SessionActivity.class);
} else {
PCBcontext.getPcbdb().getCurrentUser().get_Img_sup().update_id(PCBcontext.getDevice().getLastSupId());
nextActivity = intent;
}
in = R.anim.leftin;
out = R.anim.leftout;
}
if (nextActivity != null) {
intent.putExtra("student_view", !PCBcontext.getPcbdb().getCurrentUser().is_supervisor());
finish();
startActivity(nextActivity);
overridePendingTransition(in, out);
}
break;
case MotionEvent.ACTION_UP:
firstTouchX = -1;
}
}
return super.dispatchTouchEvent(event);
}
......
......@@ -55,7 +55,7 @@ public class SerialActivity extends Activity {
String username = intent.getStringExtra("switch_usr");
String password = intent.getStringExtra("switch_pwd");
if (username==null) {
if (username==null || password==null) {
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
username = settings.getString("username", "");
password = settings.getString("password", "");
......@@ -119,7 +119,7 @@ public class SerialActivity extends Activity {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("username", stuUsers.elementAt(position).get_name_stu());
editor.putString("username", stuUsers.elementAt(position).get_nickname_stu());
editor.putString("password", stuUsers.elementAt(position).get_pwd_stu());
editor.commit();
new UserLogin().login(stuUsers.elementAt(position).get_nickname_stu(),
......@@ -131,8 +131,9 @@ public class SerialActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.e(this.getClass().getCanonicalName(),"Creating serial activity");
PCBcontext.init(this, new NetServiceTablet());
Log.i(this.getClass().getCanonicalName(),"Creating serial activity");
if (!PCBcontext.init())
PCBcontext.init(this, new NetServiceTablet());
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_serial);
......@@ -170,7 +171,7 @@ public class SerialActivity extends Activity {
@Override
public void onStart() {
Vector<User> users;
Log.e(this.getClass().getCanonicalName(),"Starting serial activity");
Log.i(this.getClass().getCanonicalName(),"Starting serial activity (direct login:"+!getIntent().getBooleanExtra("resetPrevUser", true)+")");
if (!PCBcontext.init()) PCBcontext.init(this, new NetServiceTablet());
String default_user[] = loginUserPolicy();
String username = default_user[0];
......
package com.yottacode.pictogram.tabletlibrary.gui.session;
import android.app.Activity;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.app.ProgressDialog;
import android.content.Context;
......@@ -14,6 +15,7 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import com.yottacode.pictogram.tabletlibrary.gui.PictogramActivity;
import com.yottacode.pictogram.tabletlibrary.net.SessionWrapper;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tools.PCBcontext;
......@@ -114,13 +116,17 @@ public class ListInstructionsFragment extends Fragment{
}
private void checkStudent() {
SessionWrapper.validateStudent(new SessionWrapper.iValidateStudent() {
void close() {
ListInstructionsFragment.this.getActivity().finish();
startActivity(new Intent(getActivity(), PictogramActivity.class));
}
@Override
public void validLicense(boolean valid_license) {
public void validLicense(boolean valid_license, String sexpiration) {
if (!valid_license) {
GUITools.show_alert(ListInstructionsFragment.this.getContext(), R.string.loginNoLicenseMsg, getString(R.string.server), new GUITools.iOKListener() {
GUITools.show_alert(ListInstructionsFragment.this.getContext(), R.string.loginExpiredLicenseMsg, sexpiration, new GUITools.iOKListener() {
@Override
public void ok() {
ListInstructionsFragment.this.getActivity().finish();
close();
}
});
}
......@@ -131,7 +137,7 @@ public class ListInstructionsFragment extends Fragment{
GUITools.show_alert(ListInstructionsFragment.this.getContext(), R.string.session_notclosed, getString(R.string.server), new GUITools.iOKListener() {
@Override
public void ok() {
ListInstructionsFragment.this.getActivity().finish();
close();
}
});
}
......@@ -142,7 +148,7 @@ public class ListInstructionsFragment extends Fragment{
GUITools.show_alert(ListInstructionsFragment.this.getContext(), R.string.session_error, message,new GUITools.iOKListener() {
@Override
public void ok() {
ListInstructionsFragment.this.getActivity().finish();
close();
}
});
}
......
......@@ -17,6 +17,7 @@ import android.widget.TextView;
import android.widget.ToggleButton;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.NetService;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.PictogramActivity;
import com.yottacode.pictogram.tabletlibrary.net.SessionWrapper;
......@@ -36,6 +37,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
private int currentInstruction;
private int id_session;
private Hashtable<Integer,Integer> msgs=new Hashtable<>(20);
private NetService.iNetServiceStatus listenerStatus;
float firstTouchX=-1;
......@@ -188,6 +190,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
});
}
});
}
@Override
......@@ -197,7 +200,34 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
set_fragment_sesion();
else set_fragment_method();
this.listenerStatus = new NetService.iNetServiceStatus() {
boolean m_updated=true;
@Override
public void notifyStatus(final boolean updated) {
runOnUiThread(new Runnable() {
public void run() {
if (!updated && m_updated) {
m_updated=false;
GUITools.show_alert(SessionActivity.this, R.string.session_noinet);
addLogMsg(getString(R.string.session_noinet));
} else
if (updated && !m_updated) {
m_updated=true;
GUITools.show_alert(SessionActivity.this, R.string.session_inetok);
addLogMsg(getString(R.string.session_inetok));
}
}
});
}
};
PCBcontext.getNetService().addListener(listenerStatus);
}
@Override
protected void onStop() {
super.onStop();
PCBcontext.getNetService().removeListener(listenerStatus);
}
@Override
public void instruction_selected(int instruction, String instruction_name) {
......@@ -216,22 +246,32 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
if (PCBcontext.getPcbdb().getCurrentUser().is_supervisor())
switch (event.getAction()) {
int in=0,out=0;
Intent nextActivity=null;
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
firstTouchX = event.getX();
break;
case MotionEvent.ACTION_MOVE:
if (firstTouchX> event.getX()+100) {
Intent pictogramActivity = new Intent(this, PictogramActivity.class);
startActivity(pictogramActivity);
overridePendingTransition(R.anim.leftin, R.anim.leftout);
case MotionEvent.ACTION_UP:
if (event.getX()> firstTouchX+100) { //izquierda->derecha
nextActivity=new Intent(this,PictogramActivity.class);
nextActivity.putExtra("student_view", false);
in=R.anim.rightin;
out=R.anim.rightout;
}
else if (firstTouchX > event.getX()+100) { //derecha->izquierda
nextActivity=new Intent(this,PictogramActivity.class);
nextActivity.putExtra("student_view", true);
PCBcontext.getPcbdb().getCurrentUser().get_Img_sup().update_id(User.NO_SUPERVISOR);
in=R.anim.leftin;
out=R.anim.leftout;
}
if (nextActivity!=null) {
startActivity(nextActivity);
overridePendingTransition(in, out);
}
break;
case MotionEvent.ACTION_UP:
firstTouchX = 100000;
}
}
return super.dispatchTouchEvent(event);
}
......@@ -289,6 +329,10 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
findViewById(R.id.sessionTopbarMethodName).setVisibility(View.INVISIBLE);
findViewById(R.id.sessionTopbarInstructionName).setVisibility(View.INVISIBLE);
}
void close() {
finish();
startActivity(new Intent(SessionActivity.this, PictogramActivity.class));
}
private void set_fragment(boolean isChecked) {
if (isChecked) {
......@@ -306,7 +350,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
GUITools.show_alert(SessionActivity.this, R.string.session_error, "error " + error, new GUITools.iOKListener() {
@Override
public void ok() {
finish();
close();
}
});
}
......@@ -319,7 +363,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
GUITools.show_alert(SessionActivity.this, R.string.session_closed_ok, end, new GUITools.iOKListener() {
@Override
public void ok() {
finish();
close();
}
});
......@@ -330,7 +374,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
GUITools.show_alert(SessionActivity.this, R.string.session_error, getString(R.string.server) + "(error " + error + ")", new GUITools.iOKListener() {
@Override
public void ok() {
finish();
close();
}
});
}
......
......@@ -83,6 +83,10 @@ public class NetServiceTablet implements NetService.iNetServiceDevice {
serialActivity = new Intent(PCBcontext.getContext(), serialClass);
}
serialActivity.putExtra("resetPrevUser", !direct_login);
if (direct_login) {
serialActivity.putExtra("switch_usr",PCBcontext.getPcbdb().getCurrentUser().is_supervisor() ? PCBcontext.getPcbdb().getCurrentUser().get_email_sup() : PCBcontext.getPcbdb().getCurrentUser().get_nickname_stu());
serialActivity.putExtra("switch_pwd",PCBcontext.getPcbdb().getCurrentUser().is_supervisor() ? PCBcontext.getPcbdb().getCurrentUser().get_pwd_sup() : PCBcontext.getPcbdb().getCurrentUser().get_pwd_stu());
}
PCBcontext.getContext().startActivity(serialActivity);
}
......
......@@ -30,7 +30,7 @@ public class SessionWrapper {
public interface iValidateStudent {
void lastTryOpen(boolean is_open);
void validLicense(boolean valid);
void validLicense(boolean valid, String sexpiration);
void error(String msg);
}
......@@ -148,15 +148,16 @@ public class SessionWrapper {
try {
boolean valid_license;
String license = result.getString("license");
String sexpiration=null;
if (license.equals("null")) valid_license = false;
else {
JSONObject jlicense = new JSONObject(license);
String sexpiration = jlicense.getString("expiration_ts");
sexpiration = jlicense.getString("expiration_ts");
sexpiration = sexpiration.substring(0, sexpiration.indexOf('T'));
Date dexpiration = new java.text.SimpleDateFormat("yyyy-mm-dd").parse(sexpiration);
Date dexpiration = new java.text.SimpleDateFormat("yyyy-MM-dd").parse(sexpiration);
valid_license = dexpiration.after(new Date());
}
listener.validLicense(valid_license);
listener.validLicense(valid_license,sexpiration);
JSONArray lastInstruction = result.getJSONArray("lastInstruction");
......@@ -168,7 +169,7 @@ public class SessionWrapper {
}
@Override
public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getCanonicalName(),"Raw error from server when login:"+e.getMessage()+" (error "+e.getCode()+")");
Log.e(this.getClass().getCanonicalName(),"Raw error from server when getting student info:"+e.getMessage()+" (error "+e.getCode()+")");
listener.error("Internet error: "+e.getMessage());
}
});
......
......@@ -4,7 +4,7 @@
android:shareInterpolator="false">
<translate
android:duration="500"
android:fromXDelta="100%p"
android:fromXDelta="-100%p"
android:toXDelta="0"
android:interpolator="@android:anim/linear_interpolator" />
</set>
......
......@@ -5,7 +5,7 @@
<translate
android:duration="500"
android:fromXDelta="0%"
android:toXDelta="-100%"
android:toXDelta="100%"
android:fromYDelta="0%"
android:toYDelta="0%"
android:interpolator="@android:anim/linear_interpolator" />
......
......@@ -15,6 +15,8 @@
<string name="session_closed_ok">Session upload ok</string>
<string name="session_closed_fail">Session not uploaded. Please, try it from</string>
<string name="session_pause_error">Pause session failed</string>
<string name="session_noinet">No server conexion. Internet conexion is available?</string>
<string name="session_inetok">Server conexion ok</string>
<string name="session_log_startingsession">iniciando sesión</string>
<string name="session_log_startsession">sesión iniciada</string>
<string name="session_log_closingsession">cerrando sesión</string>
......
......@@ -11,10 +11,12 @@
<string name="session_noinstructions">Alumno sin ninguna instrucción asignada. Por favor, asigne al menos una instrucción al alumno desde Pictogram Web</string>
<string name="session_loading">Desargando instrucciones</string>
<string name="session_empty">Este alumno no tiene ningún método asignado. Por favor asigne un método a este alumno en</string>
<string name="session_notclosed">Este alumno tiene una sesión abierta. Por favor cierre la sesión desde Pictogram Tablet en</string>
<string name="session_notclosed">Este alumno tiene una sesión abierta. Por favor cierre la sesión desde Pictogram Web en</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_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_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>
<string name="session_log_startsession">sesión iniciada</string>
......
......@@ -13,10 +13,12 @@
<string name="session_noinstructions">Student without any instrucction assigment</string>
<string name="session_loading">Desargando instrucciones</string>
<string name="session_empty">Este alumno no tiene ningún método asignado. Por favor asigne un método a este alumno en</string>
<string name="session_notclosed">Este alumno tiene una sesión abierta. Por favor cierre la sesión en el panel de control de Pictogram Tablet</string>
<string name="session_notclosed">Este alumno tiene una sesión abierta. Por favor cierre la sesión en el panel de control de Pictogram Web</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_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_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>
<string name="session_log_startsession">sesión iniciada</string>
......
......@@ -73,14 +73,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
......@@ -89,6 +81,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
......
......@@ -43,13 +43,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavorDebug/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavorDebug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavorDebug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/DefaultFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/DefaultFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/assets" type="java-test-resource" />
......@@ -58,6 +51,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/DefaultFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/DefaultFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/DefaultFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/assets" type="java-resource" />
......@@ -66,14 +66,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/assets" type="java-test-resource" />
......@@ -82,6 +74,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDefaultFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
......@@ -106,14 +106,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
......@@ -122,9 +114,15 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/9.2.1/jars" />
......@@ -133,13 +131,11 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-wearable/9.2.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.support/wearable/2.0.0-alpha2/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 24 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
......
......@@ -66,14 +66,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/assets" type="java-test-resource" />
......@@ -82,6 +74,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDevFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavor/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
......@@ -106,14 +106,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
......@@ -122,6 +114,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
......
......@@ -59,6 +59,7 @@ mostradas más adelante hacen todo el trabajo, basta con ejecutar [./install.sh]
### Opción B (desarrollo en local)
0. Comprobar que VT-x (virtualización) está habilitada en la BIOS y tenemos IP estática.
1. Instalar [virtualbox][1] y [vagrant][2] (version >1.5 para este último).
2. Ejecutar `vagrant up` desde este directorio.
......
......@@ -161,8 +161,6 @@ CREATE TABLE IF NOT EXISTS `picto` (
COMMENT="Main information about a pictogram, either coming from a source like Symbolstix or added by a supervisor. It can belongs to a category (id_cat)";
-- --------------------------------------------------------
--
-- Estructura de tabla para la tabla `picto_acl`
-- NOT IN USE (candidate for removal)
......
......@@ -293,7 +293,7 @@ module.exports = {
sails.log.debug("Uploading picto with FileName: " + pictoFileName);
req.file('file').upload({
maxBytes: 1000000,
maxBytes: 1048576,
dirname: pictoDirectory,
saveAs: pictoFileName
}, function whenDone(err, uploadedFiles) {
......
......@@ -171,7 +171,7 @@ module.exports = {
License.activate(params.license_number, created.id, function(err, license) {
if (err)
return res.serverError(err);
created = created.toObject();
created = created.toJSON();
created.license = license.toObject();
return res.ok(created);
});
......@@ -270,7 +270,7 @@ module.exports = {
})
.catch(function (err) {
res.notFound();
res.notFound(err);
});
},
......@@ -1007,18 +1007,19 @@ module.exports = {
newAvatarFileName = sails.config.pictogram.paths.getStudentAvatarFileName(student.id);
req.file('file').upload({
maxBytes: 1000000,
maxBytes: 1048576,
dirname: newAvatarDirectory,
saveAs: newAvatarFileName
}, function whenDone(error, uploadedFiles) {
if (error || (uploadedFiles.length === 0)) {
throw new Error("upload failed");
return res.badRequest("Upload failed");
}
try {
newAvatarFileDescriptor = uploadedFiles[0].fd;
if (student.pic !== sails.config.pictogram.paths.defaultAvatarFileName) {
fs.unlinkSync(path.join(newAvatarDirectory, student.pic));
if (fs.existsSync(path.join(newAvatarDirectory, student.pic)))
fs.unlinkSync(path.join(newAvatarDirectory, student.pic));
}
student.pic = newAvatarFileName;
......@@ -1028,9 +1029,9 @@ module.exports = {
}
res.ok({file: {name: student.pic}});
});
} catch (updateAvatarError) {
} catch (err) {
fs.unlinkSync(newAvatarFileDescriptor);
res.serverError("Error when updating profile image in server");
res.serverError("Error when updating profile image in server: " + err);
}
});
})
......
......@@ -530,19 +530,20 @@ module.exports = {
sails.log.debug("Saving file to " + newAvatarDirectory + "/" + newAvatarFileName);
req.file('file').upload({
maxBytes: 1000000,
maxBytes: 1048576,
dirname: newAvatarDirectory,
saveAs: newAvatarFileName
}, function whenDone(error, uploadedFiles) {
if (error || (uploadedFiles.length === 0)) {
throw new Error("upload failed");
return res.badRequest("Upload failed");
}
try {
newAvatarFileDescriptor = uploadedFiles[0].fd;
if (supervisor.pic !== sails.config.pictogram.paths.defaultAvatarFileName) {
sails.log.debug("removing old profile image");
fs.unlinkSync(path.join(newAvatarDirectory, supervisor.pic));
if (fs.existsSync(path.join(newAvatarDirectory, supervisor.pic)))
fs.unlinkSync(path.join(newAvatarDirectory, supervisor.pic));
}
supervisor.pic = newAvatarFileName;
......
......@@ -176,7 +176,6 @@ module.exports = {
},
legend: false,
legend_size: 'normal',
pic: "defaultAvatar.jpg",
size: 'large',
picto_background: '#0000ff',
tape_background: '#00ffff',
......@@ -202,9 +201,6 @@ module.exports = {
}
});
}
if (typeof validAttributes.pic !== 'string') {
delete validAttributes.pic;
}
if (typeof validAttributes.input_selection !== 'object') {
delete validAttributes.input_selection;
} else {
......@@ -245,7 +241,7 @@ module.exports = {
beforeCreate: function (attrs, next) {
attrs.attributes = Student.getValidAttributes(attrs.attributes);
attrs.password = bcrypt.hashSync(attrs.password, bcrypt.genSaltSync());
attrs.pic = sails.config.pictogram.urls.getStudentAvatarUrl();
attrs.pic = sails.config.pictogram.paths.defaultAvatarFileName;
next();
},
......@@ -519,7 +515,9 @@ module.exports = {
username: Math.floor((Math.random() * 100000000) + 1) + "_" + student.username,
id_off: null
})
.then((updated) => {cb()})
.then((updated) => {
License.destroy({id_stu: id_stu}).exec(cb);
})
.catch((err) => {cb(err)});
});
}
......
......@@ -235,7 +235,7 @@ module.exports = {
async.eachSeries(stuSups, function(stuSup, next_cb) {
// Filter logically deleted students
if (stuSup.student.office == null)
next_cb();
return next_cb();
// set current method and instruction if any
Student.findOne(stuSup.student.id)
......
......@@ -29,7 +29,7 @@ module.exports = function notFound (data, options) {
// Log error to console
if (data !== undefined) {
sails.log.verbose('Sending 404 ("Not Found") response: \n',data);
sails.log.verbose('Sending 404 ("Not Found") response: \n', JSON.stringify(data));
}
else sails.log.verbose('Sending 404 ("Not Found") response');
......
......@@ -100,6 +100,7 @@
"error_only_support_images": "Only images are supported (JPG, PNG or GIF files)",
"error_on_request": "The request has not been processed. Please, check your fields",
"error_on_request_sup_not_found": "Account not found or it has not been activated",
"error_on_upload": "Error on image upload. The maximum allowed size for images is 1 MB.",
"error_loading_pictos": "Error loading pictos information",
"error_general": "An error has been produced",
"expand_navigation": "Expand navigation",
......
......@@ -103,6 +103,7 @@
"error_only_support_images": "Sólo se soportan imágenes (ficheros JPG, PNG o GIF)",
"error_on_request": "Se ha producido un error. Por favor, compruebe los valores introducidos.",
"error_on_request_sup_not_found": "La cuenta no existe o no ha sido activada",
"error_on_upload": "Error al subir la imagen. Compruebe que el archivo no supera 1MB de tamaño.",
"error_loading_pictos": "Error cargando información de los pictos",
"error_general": "Se ha producido un error",
"February": "Febrero",
......
......@@ -17,7 +17,7 @@
</ul>
<!-- The content -->
<div ui-view></div>
<div ui-view id="main-content"></div>
</div>
<!-- Fin de container -->
......
......@@ -63,9 +63,14 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
ngToast.success({ content: $translate.instant('student_updated') });
$scope.studentData.pic = '/upload/studentAvatar/' + data.file.name;
$scope.spin_disabled = true;
})
.error(function (err) {
ngToast.danger({content: $translate.instant('error_on_upload')});
$scope.spin_disabled = true;
});
} else {
ngToast.danger({ content: $translate.instant('error_only_support_images') });
$scope.spin_disabled = true;
}
}
};
......@@ -139,9 +144,9 @@ dashboardControllers.controller('StudentSetupCtrl', function StudentSetupCtrl(
})
.error(function (err) {
console.log(err);
if (err.message && err.message.search('nvalid license'))
if (err.message && err.message.search('nvalid license') > 0)
ngToast.danger({ content: $translate.instant('license_invalid') });
else if (err.message && err.message.search('in use'))
else if (err.message && err.message.search('in use') > 0)
ngToast.danger({ content: $translate.instant('license_already_activated') });
else
ngToast.danger({ content: $translate.instant('student_not_updated') });
......
......@@ -153,7 +153,17 @@
}"/>
<div
class="picto_options"
ng-if="studentPicto !== emptyStudentPicto">
ng-if="studentPicto == emptyStudentPicto">
<a
ng-click="open_add(rowIndex, colIndex)"
class="picto_add"
title="{{ 'add_picto' | translate}}">
<i class="color_green glyphicon glyphicon-plus-sign" aria-hidden="true"></i>
</a>
</div>
<div
class="picto_options"
ng-if="studentPicto !== emptyStudentPicto && studentPicto.attributes.coord_y != '0'">
<a ng-click="view_picto(studentPicto)" class="picto_ok" >
<i
ng-class="{
......@@ -164,6 +174,41 @@
aria-hidden="true"
title="{{ studentPicto.attributes.status | translate}}"></i>
</a>
<a
ng-click=""
class="picto_cat_edit">
<i class="glyphicon glyphicon-picture" aria-hidden="true"></i>
</a>
</div>
<div
class="picto_options"
ng-if="studentPicto !== emptyStudentPicto && studentPicto.attributes.coord_y == '0'">
<a
ng-click="delete_picto(studentPicto)"
class="picto_remove"
title="{{ 'delete' | translate}}">
<i class="color_red glyphicon glyphicon-remove-circle" aria-hidden="true"></i>
</a>
<a ng-click="view_picto(studentPicto)" class="picto_ok" >
<i ng-class="{
color_green: studentPicto.attributes.status == 'invisible',
color_black: studentPicto.attributes.status == 'enabled'
}"
class="glyphicon glyphicon-eye-open"
aria-hidden="true"
title="{{ studentPicto.attributes.status | translate}}">
</i>
</a>
<a
class="picto_tags"
ng-click="open_tags(studentPicto)">
<i class="glyphicon glyphicon-tags" aria-hidden="true"></i>
</a>
<a
class="picto_config"
ng-click="open_config(studentPicto)">
<i class="glyphicon glyphicon-cog" aria-hidden="true"></i>
</a>
</div>
</div>
<div class="clearfix"></div>
......
......@@ -62,10 +62,12 @@ dashboardControllers.controller('SetupCtrl', function SetupCtrl(
$scope.spin_disabled = true;
})
.error(function (err) {
console.log("ERROR while uploading image: " + err);
ngToast.danger({content: $translate.instant('error_on_upload')});
$scope.spin_disabled = true;
});
} else {
ngToast.danger({ content: $translate.instant('error_only_support_images') });
$scope.spin_disabled = true;
}
}
};
......
......@@ -4,9 +4,9 @@
<header-supervisor></header-supervisor>
<!-- The content -->
<div ui-view></div>
<div ui-view id="main-content"></div>
</div>
<!-- Fin de container -->
<!-- Footer Translate -->
<footer-translate></footer-translate>
\ No newline at end of file
<footer-translate></footer-translate>
......@@ -115,7 +115,6 @@ div.footer-space {
width: 100%;
clear: both;
}
div.languages{
position: absolute;
bottom: 0;
......@@ -131,6 +130,9 @@ div.languages{
position: absolute;
margin-top: -10px;
}
div#main-content {
padding-bottom: 67px;
}
/* Botones de operacioens en listados de gabinetes y supervisores (admin) */
.ops a{
......@@ -468,6 +470,8 @@ textarea.editable{
.picto .picto_options .picto_minus{ position: absolute; top: 2px; right: 2px; }
.picto .picto_options .picto_cat_edit{ position: absolute; top: 2px; left: 2px; }
/* Picto legend */
.picto-legend-normal {
position: absolute;
......
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