Commit 7e78e312 by Arturo Montejo Ráez

Merge branch 'develop'

parents f880c2f6 97294694
Showing with 1736 additions and 545 deletions
...@@ -5,7 +5,7 @@ buildscript { ...@@ -5,7 +5,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.2.2' classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
......
...@@ -21,6 +21,7 @@ android { ...@@ -21,6 +21,7 @@ android {
resValue "bool", "ssl_connect", "true" resValue "bool", "ssl_connect", "true"
resValue "bool", "force_img_download", "false" resValue "bool", "force_img_download", "false"
resValue "integer", "netservice_timing", "5" resValue "integer", "netservice_timing", "5"
resValue "integer", "netservice_force_restfull_synchro", "0"
} }
debug { debug {
resValue "string", "server", "https://dev.yottacode.com" resValue "string", "server", "https://dev.yottacode.com"
...@@ -28,6 +29,7 @@ android { ...@@ -28,6 +29,7 @@ android {
resValue "bool", "ssl_connect", "false" resValue "bool", "ssl_connect", "false"
resValue "bool", "force_img_download", "false" resValue "bool", "force_img_download", "false"
resValue "integer", "netservice_timing", "5" resValue "integer", "netservice_timing", "5"
resValue "integer", "netservice_force_restfull_synchro", "0"
} }
} }
} }
......
...@@ -2,25 +2,17 @@ package com.yottacode.net; ...@@ -2,25 +2,17 @@ package com.yottacode.net;
import android.util.Log; import android.util.Log;
import com.github.nkzawa.emitter.Emitter;
import com.github.nkzawa.socketio.client.Ack; import com.github.nkzawa.socketio.client.Ack;
import com.github.nkzawa.socketio.client.IO; import com.github.nkzawa.socketio.client.IO;
import com.github.nkzawa.socketio.client.Socket; import com.github.nkzawa.socketio.client.Socket;
import com.github.nkzawa.emitter.Emitter;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.net.URISyntaxException; 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.SSLContext;
import javax.net.ssl.TrustManager;
import java.security.SecureRandom;
/** /**
...@@ -74,7 +66,14 @@ public class SailsSocketsIO { ...@@ -74,7 +66,14 @@ public class SailsSocketsIO {
Log.d(this.getClass().getName(), " Listening:"+message); Log.d(this.getClass().getName(), " Listening:"+message);
socket.on(message, listener); 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) { public SailsSocketsIO(String sails_socket_io_url, String ptransport, Emitter.Listener connectListener, Emitter.Listener errorListener) {
...@@ -114,11 +113,13 @@ public class SailsSocketsIO { ...@@ -114,11 +113,13 @@ public class SailsSocketsIO {
JSONObject obj=new JSONObject().put("url", msg).put("data", params); 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); socket.emit(this.EMIT_METHOD, obj, ack);
} }
public void destroy() { public void destroy() {
this.socket.disconnect(); if (this.socket.connected()) {
this.socket.off(); this.socket.off();
this.socket.disconnect();
}
} }
} }
package com.yottacode.net;
import org.json.JSONArray;
import org.json.JSONObject;
/**
* This interface specifies which are the methods to be implemented by classes receiving
* responses to API requests.
*
* Generally, it is extended by Activities from which API requests are performed
*
* @author dofer
*/
public interface iRestapiListener {
public void preExecute();
public void result(JSONArray result);
public void result(JSONObject result);
public void error(Exception e);
}
...@@ -2,8 +2,7 @@ package com.yottacode.pictogram.action; ...@@ -2,8 +2,7 @@ package com.yottacode.pictogram.action;
import android.util.Log; import android.util.Log;
import com.yottacode.net.iRestapiListener; import com.yottacode.net.RestapiWrapper;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
import org.json.JSONArray; import org.json.JSONArray;
...@@ -18,7 +17,7 @@ import java.util.Vector; ...@@ -18,7 +17,7 @@ import java.util.Vector;
* Modified by Fernando on 10/11/15 * Modified by Fernando on 10/11/15
* More info at http://scm.ujaen.es/softuno/pictogram/wikis/LUActions * More info at http://scm.ujaen.es/softuno/pictogram/wikis/LUActions
*/ */
public class ActionLog implements iRestapiListener { public class ActionLog implements RestapiWrapper.iRestapiListener {
Vector<JSONObject> actions_buffer; Vector<JSONObject> actions_buffer;
...@@ -91,7 +90,7 @@ public class ActionLog implements iRestapiListener { ...@@ -91,7 +90,7 @@ public class ActionLog implements iRestapiListener {
} }
@Override @Override
public void error(Exception e) { public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getCanonicalName(),"Error:"+e.getMessage()+" on actions="+this.actions_buffer); Log.e(this.getClass().getCanonicalName(),"Error:"+e.getMessage()+" on actions="+this.actions_buffer);
} }
} }
...@@ -36,6 +36,8 @@ import java.util.Vector; ...@@ -36,6 +36,8 @@ import java.util.Vector;
public class Device extends SQLiteOpenHelper { public class Device extends SQLiteOpenHelper {
Context context; Context context;
final static class PARAMS { final static class PARAMS {
static String keyword="key"; static String keyword="key";
static String deviceID="deviceID"; static String deviceID="deviceID";
...@@ -262,7 +264,6 @@ public class Device extends SQLiteOpenHelper { ...@@ -262,7 +264,6 @@ public class Device extends SQLiteOpenHelper {
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
user = new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8), user = new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getString(5), cursor.getString(6), cursor.getString(7), cursor.getString(8),
cursor.getInt(9), cursor.getString(10), cursor.getString(11), cursor.getString(12), cursor.getString(13), cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17)); cursor.getInt(9), cursor.getString(10), cursor.getString(11), cursor.getString(12), cursor.getString(13), cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17));
users.add(user); users.add(user);
} }
...@@ -273,7 +274,6 @@ public class Device extends SQLiteOpenHelper { ...@@ -273,7 +274,6 @@ public class Device extends SQLiteOpenHelper {
public void insertUser(User user) { public void insertUser(User user) {
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("INSERT INTO users_detail values (" + db.execSQL("INSERT INTO users_detail values (" +
user.get_id_stu() + ", " + user.get_id_stu() + ", " +
"'" + user.get_nickname_stu() + "', " + "'" + user.get_nickname_stu() + "', " +
...@@ -446,5 +446,4 @@ public class Device extends SQLiteOpenHelper { ...@@ -446,5 +446,4 @@ public class Device extends SQLiteOpenHelper {
@Override @Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
} }
} }
package com.yottacode.pictogram.dao; package com.yottacode.pictogram.dao;
import com.yottacode.net.RestapiWrapper;
/** /**
* Created by Fernando on 15/03/2016. * Created by Fernando on 15/03/2016.
*/ */
public class LoginException extends Exception{ public class LoginException extends RestapiWrapper.HTTPException {
public static final int BAD_LOGIN=1; public static final int BAD_LOGIN=1;
public static final int NO_STUDENTS=2; public static final int NO_STUDENTS=2;
public static final int TIME_OUT=3; public static final int TIME_OUT=3;
int code; public static final int NO_LICENSE=4;
public LoginException(String msg, int code) { public LoginException(String msg, int code) {
super(msg); super(msg,code);
this.code=code;
this.code=msg.contains("without students")
? LoginException.NO_STUDENTS
: msg.contains("failed to connect")
? LoginException.TIME_OUT
: msg.contains("invalid license")
? LoginException.NO_LICENSE
: LoginException.BAD_LOGIN
;
} }
public boolean login_failed() {return this.code==LoginException.BAD_LOGIN;} public boolean login_failed() {return this.code==LoginException.BAD_LOGIN;}
public boolean no_supervisor_students() {return this.code==LoginException.NO_STUDENTS;} public boolean no_supervisor_students() {return this.code==LoginException.NO_STUDENTS;}
public boolean time_out() {return this.code==LoginException.TIME_OUT;} public boolean time_out() {return this.code==LoginException.TIME_OUT;}
public boolean invalidLicense() {
return this.code==NO_LICENSE;
}
public String getLocalizedMessage() { public String getLocalizedMessage() {
return super.getLocalizedMessage()+" Login ok:"+!login_failed()+" Supervisor without students:"+no_supervisor_students(); return super.getLocalizedMessage()+" Login failed:"+login_failed()+" Supervisor without students:"+no_supervisor_students()+" Invalid license:"+invalidLicense();
} }
} }
package com.yottacode.pictogram.dao; package com.yottacode.pictogram.dao;
import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.util.Log; import android.util.Log;
...@@ -20,12 +19,9 @@ import org.json.JSONObject; ...@@ -20,12 +19,9 @@ import org.json.JSONObject;
* @author Fernando Martinez Santiago * @author Fernando Martinez Santiago
* @version 1.0 * @version 1.0
*/ */
public class Picto extends Img { public class
int cont = 0; Picto extends Img {
Bitmap bitmap;
// String constant for logs
private final String LOG_TAG = this.getClass().getSimpleName(); // Or .getCanonicalName()
public final static class JSON_ATTTRS { public final static class JSON_ATTTRS {
public static String CATEGORY = "id_cat"; public static String CATEGORY = "id_cat";
...@@ -64,12 +60,23 @@ public class Picto extends Img { ...@@ -64,12 +60,23 @@ public class Picto extends Img {
private String translation; private String translation;
private boolean is_mirror=false; private boolean is_mirror=false;
private boolean highlight_background=false; private boolean highlight_background=false;
public boolean is_mirror() {return is_mirror;} public boolean is_mirror() {return is_mirror;}
public boolean is_highlight_background() {return highlight_background;} public boolean is_highlight_background() {return highlight_background;}
public void set_mirror(boolean is_mirror, boolean highlight_background) { public void set_mirror(boolean is_mirror, boolean highlight_background) {
this.highlight_background =highlight_background; this.highlight_background =highlight_background;
this.is_mirror=is_mirror;} this.is_mirror=is_mirror;}
public Picto(Picto p) {
super(p);
try {
this.attributes=new JSONObject(p.attributes.toString());
} catch (JSONException e) {
Log.e(this.getClass().getCanonicalName(),e.getMessage());
}
translation=new String(p.get_translation());
}
public Picto(int id, String url, String translation, int cat, int row, int column, int freeRow, int freeColumn) throws JSONException { public Picto(int id, String url, String translation, int cat, int row, int column, int freeRow, int freeColumn) throws JSONException {
this(id, url, translation, new JSONObject() this(id, url, translation, new JSONObject()
.put(JSON_ATTTRS.CATEGORY, cat) .put(JSON_ATTTRS.CATEGORY, cat)
...@@ -304,7 +311,7 @@ public class Picto extends Img { ...@@ -304,7 +311,7 @@ public class Picto extends Img {
public int get_color() { public int get_color() {
try { try {
String color = this.attributes.getString(JSON_ATTTRS.COLOR); String color = this.attributes.getString(JSON_ATTTRS.COLOR);
int icolor = Color.parseColor(color); int icolor = color==null || color.equals("null") ? Color.WHITE : Color.parseColor(color);
return icolor; return icolor;
} catch (JSONException e) { } catch (JSONException e) {
......
...@@ -31,6 +31,7 @@ public class User { ...@@ -31,6 +31,7 @@ public class User {
static String PICTOGRAM_SIZE ="size"; static String PICTOGRAM_SIZE ="size";
static String TTS_ENGINE = "tts engine"; static String TTS_ENGINE = "tts engine";
static String TTS_VOICE = "tts voice"; static String TTS_VOICE = "tts voice";
static String DELETE_STRIP = "delete_strip_after_delivery";
} }
public final static class JSON_STUDENT_INPUT_FEEDBACK { public final static class JSON_STUDENT_INPUT_FEEDBACK {
public static String VIBRATION="vibration"; public static String VIBRATION="vibration";
...@@ -46,6 +47,7 @@ public class User { ...@@ -46,6 +47,7 @@ public class User {
private boolean mirror_mode=false; private boolean mirror_mode=false;
public User(int id_stu, String nickname_stu, String pwd_stu, String name_stu, String surname_stu, String url_img_stu, String gender_stu, String lang_stu, String attributes_stu) throws JSONException { public User(int id_stu, String nickname_stu, String pwd_stu, String name_stu, String surname_stu, String url_img_stu, String gender_stu, String lang_stu, String attributes_stu) throws JSONException {
this(id_stu, nickname_stu, pwd_stu, name_stu, surname_stu, url_img_stu, gender_stu, lang_stu, attributes_stu,User.NO_SUPERVISOR,"","","","","","M","es-es",null); this(id_stu, nickname_stu, pwd_stu, name_stu, surname_stu, url_img_stu, gender_stu, lang_stu, attributes_stu,User.NO_SUPERVISOR,"","","","","","M","es-es",null);
} }
...@@ -258,6 +260,19 @@ public class User { ...@@ -258,6 +260,19 @@ public class User {
} }
} }
/**
*
* @return input feedback of the student configuration (default: "vibration")
*/
public boolean delete_tape_after_delivery() {
try {
return this.attributes_stu.getBoolean(JSON_STUDENT_ATTTRS.DELETE_STRIP);
} catch (JSONException e) {
return false;
}
}
/** /**
* *
* @return input selection of the student configuration (default: "click") * @return input selection of the student configuration (default: "click")
......
...@@ -6,10 +6,9 @@ import android.content.Intent; ...@@ -6,10 +6,9 @@ import android.content.Intent;
import android.util.Log; import android.util.Log;
import com.yottacode.net.RestapiWrapper; import com.yottacode.net.RestapiWrapper;
import com.yottacode.net.iRestapiListener;
import com.yottacode.pictogram.R; import com.yottacode.pictogram.R;
import com.yottacode.pictogram.net.ImgDownloader;
import com.yottacode.pictogram.net.ServerLogin; import com.yottacode.pictogram.net.ServerLogin;
import com.yottacode.pictogram.net.iImgDownloaderListener;
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.tools.GUITools; import com.yottacode.tools.GUITools;
...@@ -50,7 +49,7 @@ public class UserLogin { ...@@ -50,7 +49,7 @@ public class UserLogin {
Log.i(LOG_TAG, "Online login request for supervisor "+email); Log.i(LOG_TAG, "Online login request for supervisor "+email);
final ProgressDialog progressDialog = ProgressDialog.show(activity, activity.getBaseContext().getString(R.string.userLoadingTxt), final ProgressDialog progressDialog = ProgressDialog.show(activity, activity.getBaseContext().getString(R.string.userLoadingTxt),
activity.getBaseContext().getString(R.string.userLoadingTxt), false, false); activity.getBaseContext().getString(R.string.userLoadingTxt), false, false);
ServerLogin.login_supervisor(email, password, new iRestapiListener() { ServerLogin.login_supervisor(email, password, new RestapiWrapper.iRestapiListener() {
@Override @Override
public void preExecute() { public void preExecute() {
...@@ -98,18 +97,20 @@ public class UserLogin { ...@@ -98,18 +97,20 @@ public class UserLogin {
} }
} }
@Override @Override
public void error(Exception e) { public void error(RestapiWrapper.HTTPException e) {
Log.i(this.getClass().getCanonicalName(),"Login fail:"+e.getMessage()+" ("+e.getClass().getCanonicalName()+")"); Log.i(this.getClass().getCanonicalName(),"Login fail:"+e.getMessage()+" ("+e.getClass().getCanonicalName()+")");
if (progressDialog.isShowing()) progressDialog.dismiss(); if (progressDialog.isShowing()) progressDialog.dismiss();
if (e instanceof LoginException) if (e instanceof LoginException)
if (((LoginException)e).login_failed()) if (((LoginException)e).invalidLicense())
GUITools.show_alert(activity, R.string.loginNoLicenseMsg);
else if (((LoginException)e).login_failed())
GUITools.show_alert(activity, R.string.loginErrorMsg); GUITools.show_alert(activity, R.string.loginErrorMsg);
else if (((LoginException)e).no_supervisor_students()) else if (((LoginException)e).no_supervisor_students())
GUITools.show_alert(activity, R.string.noStudentsError); GUITools.show_alert(activity, R.string.noStudentsError);
else else
GUITools.show_alert(activity, R.string.serverError, e.getMessage()); GUITools.show_alert(activity, R.string.serverError, e.getMessage()+"( error "+e.getCode()+")");
else else
GUITools.show_alert(activity, R.string.serverError, e.getMessage()); GUITools.show_alert(activity, R.string.serverError, e.getMessage()+"( error "+e.getCode()+")");
} }
}); });
} else //offline } else //offline
...@@ -153,7 +154,7 @@ public class UserLogin { ...@@ -153,7 +154,7 @@ public class UserLogin {
if (online) { if (online) {
Log.i(this.getClass().getCanonicalName(), "Online login request for student "+username); Log.i(this.getClass().getCanonicalName(), "Online login request for student "+username);
final ProgressDialog progressDialog=ProgressDialog.show(activity, activity.getString(R.string.userLoadingTxt),activity.getString(R.string.userLoadingTxt)); final ProgressDialog progressDialog=ProgressDialog.show(activity, activity.getString(R.string.userLoadingTxt),activity.getString(R.string.userLoadingTxt));
ServerLogin.login_student(username,password,new iRestapiListener() { ServerLogin.login_student(username,password,new RestapiWrapper.iRestapiListener() {
@Override @Override
public void preExecute() { public void preExecute() {
...@@ -199,16 +200,19 @@ public class UserLogin { ...@@ -199,16 +200,19 @@ public class UserLogin {
} }
@Override @Override
public void error(Exception e) { public void error(RestapiWrapper.HTTPException e) {
if(progressDialog.isShowing()) progressDialog.dismiss(); if(progressDialog.isShowing()) progressDialog.dismiss();
if (e instanceof LoginException) if (e instanceof LoginException)
if (((LoginException)e).login_failed()) if (((LoginException)e).invalidLicense())
GUITools.show_alert(activity, R.string.loginNoLicenseMsg);
else
if (((LoginException)e).login_failed())
GUITools.show_alert(activity, R.string.loginErrorMsg); GUITools.show_alert(activity, R.string.loginErrorMsg);
else else
GUITools.show_alert(activity, R.string.serverError, e.getMessage()); GUITools.show_alert(activity, R.string.serverError, e.getMessage());
else else
GUITools.show_alert(activity, R.string.serverError, e.getMessage()); GUITools.show_alert(activity, R.string.serverError, e.getMessage());
Log.e(this.getClass().getCanonicalName(), "Server error:"+ e.getLocalizedMessage()); Log.e(this.getClass().getCanonicalName(), "Server Error:"+ e.getLocalizedMessage());
}}); }});
} }
...@@ -229,7 +233,7 @@ public class UserLogin { ...@@ -229,7 +233,7 @@ public class UserLogin {
public void set_student_oline(final User student, String token, final Intent pictogramActivity, final Activity activity) { public void set_student_oline(final User student, String token, final Intent pictogramActivity, final Activity activity) {
final ProgressDialog progressDialog=ProgressDialog.show(activity, activity.getString(R.string.userLoadingTxt),activity. getString(R.string.loadingGrammar)); final ProgressDialog progressDialog=ProgressDialog.show(activity, activity.getString(R.string.userLoadingTxt),activity. getString(R.string.loadingGrammar));
PCBcontext.set_user(student, token, new iImgDownloaderListener() { PCBcontext.set_user(student, token, new ImgDownloader.iImgDownloaderListener() {
@Override @Override
public void loadComplete() { public void loadComplete() {
PCBcontext.getDevice().insertUser(student); PCBcontext.getDevice().insertUser(student);
......
...@@ -3,18 +3,15 @@ package com.yottacode.pictogram.grammar; ...@@ -3,18 +3,15 @@ package com.yottacode.pictogram.grammar;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.util.Log; import android.util.Log;
import com.yottacode.net.iRestapiListener; import com.yottacode.net.RestapiWrapper;
import com.yottacode.pictogram.R; import com.yottacode.pictogram.R;
import com.yottacode.pictogram.action.VocabularyAction; import com.yottacode.pictogram.action.VocabularyAction;
import com.yottacode.pictogram.dao.Picto; import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.net.ImgDownloader; import com.yottacode.pictogram.net.ImgDownloader;
import com.yottacode.pictogram.net.PictoUploader; import com.yottacode.pictogram.net.PictoUploader;
import com.yottacode.pictogram.net.iImgDownloaderListener;
import com.yottacode.pictogram.net.websockets.ActionTalk; import com.yottacode.pictogram.net.websockets.ActionTalk;
import com.yottacode.pictogram.net.websockets.Room; import com.yottacode.pictogram.net.websockets.Room;
import com.yottacode.pictogram.net.websockets.VocabularyTalk; import com.yottacode.pictogram.net.websockets.VocabularyTalk;
import com.yottacode.pictogram.net.websockets.iActionListener;
import com.yottacode.pictogram.net.websockets.iVocabularyListener;
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.tools.GUITools; import com.yottacode.tools.GUITools;
...@@ -41,14 +38,15 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -41,14 +38,15 @@ public class Vocabulary implements Iterable<Picto> {
Hashtable<Integer,LinkedList<Picto>> pictos; Hashtable<Integer,LinkedList<Picto>> pictos;
static int DEFAULT_VOCABULARY_SIZE=200; static int DEFAULT_VOCABULARY_SIZE=200;
iImgDownloaderListener imgListener; ImgDownloader.iImgDownloaderListener imgListener;
private ActionTalk actionTalk;
/** /**
* Creates a new vocabulary and download/load the vocabulary and the corresponding pictos * Creates a new vocabulary and download/load the vocabulary and the corresponding pictos
* @param listener * @param listener
*/ */
public Vocabulary(iImgDownloaderListener listener) { public Vocabulary(ImgDownloader.iImgDownloaderListener listener) {
this.pictos = new Hashtable<>(Vocabulary.DEFAULT_VOCABULARY_SIZE); this.pictos = new Hashtable<>(Vocabulary.DEFAULT_VOCABULARY_SIZE);
this.imgListener=listener; this.imgListener=listener;
if (PCBcontext.getNetService().online()) { if (PCBcontext.getNetService().online()) {
...@@ -64,8 +62,8 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -64,8 +62,8 @@ public class Vocabulary implements Iterable<Picto> {
} }
} }
public void listen(Room room, iVocabularyListener listener, iActionListener action_listener) { public void listen(Room room, VocabularyTalk.iVocabularyListener listener, ActionTalk.iActionListener action_listener) {
iVocabularyListener vocabulary_listeners[] = {new iVocabularyListener() { VocabularyTalk.iVocabularyListener vocabulary_listeners[] = {new VocabularyTalk.iVocabularyListener() {
@Override @Override
public void change(action action, int picto_cat, int picto_id, JSONObject args) { public void change(action action, int picto_cat, int picto_id, JSONObject args) {
switch (action) { switch (action) {
...@@ -103,10 +101,16 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -103,10 +101,16 @@ public class Vocabulary implements Iterable<Picto> {
} }
},listener}; },listener};
new VocabularyTalk(room, vocabulary_listeners); new VocabularyTalk(room, vocabulary_listeners);
new ActionTalk(room, new iActionListener[] {action_listener}); addActionTalkListener(action_listener);
} }
public void addActionTalkListener(ActionTalk.iActionListener listener) {
if (actionTalk==null) actionTalk=new ActionTalk(PCBcontext.getRoom(), listener);
else actionTalk.addListener(listener);
}
public void removeActionTalkListener(ActionTalk.iActionListener listener) {
actionTalk.removeListener(listener);
}
/** /**
* UPload local status modifications and new pictos. Note that when * UPload local status modifications and new pictos. Note that when
* a picto is uploaded is not required to delete from the local PCB * a picto is uploaded is not required to delete from the local PCB
...@@ -144,12 +148,12 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -144,12 +148,12 @@ public class Vocabulary implements Iterable<Picto> {
public void synchronize() { public void synchronize() {
synchronize_upload(); synchronize_upload(); // (i) uploading
//download // and (ii) downloading
final String picto_str="/pictos"; final String picto_str="/pictos";
String operation=PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu()+picto_str; String operation=PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu()+picto_str;
PCBcontext.getRestapiWrapper().ask(operation, new iRestapiListener() { PCBcontext.getRestapiWrapper().ask(operation, new RestapiWrapper.iRestapiListener() {
@Override @Override
public void preExecute() { public void preExecute() {
...@@ -188,7 +192,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -188,7 +192,7 @@ public class Vocabulary implements Iterable<Picto> {
for (StackTraceElement s: traces) for (StackTraceElement s: traces)
Log.e(s.getClassName()+"."+s.getFileName()+"."+s.getLineNumber(),s.toString()); Log.e(s.getClassName()+"."+s.getFileName()+"."+s.getLineNumber(),s.toString());
Log.e(this.getClass().getName(), " Picto JSON error from server: " + ojpicto.toString()); Log.e(this.getClass().getName(), " Picto JSON error from server: " + ojpicto.toString());
this.error(e); this.error(new RestapiWrapper.HTTPException("JSON Error:"+e.getMessage(),-1));
} }
} }
} }
...@@ -198,7 +202,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -198,7 +202,7 @@ public class Vocabulary implements Iterable<Picto> {
} }
@Override @Override
public void error(Exception e) { public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getName(), " Server RESTAPI error: " + e.getLocalizedMessage()); Log.e(this.getClass().getName(), " Server RESTAPI error: " + e.getLocalizedMessage());
Vocabulary.this.imgListener.error(e); Vocabulary.this.imgListener.error(e);
} }
...@@ -247,7 +251,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -247,7 +251,7 @@ public class Vocabulary implements Iterable<Picto> {
public void addPicto(Picto pic, ImgDownloader.tsource source){ public void addPicto(Picto pic, ImgDownloader.tsource source){
addPicto(pic, source, this.imgListener); addPicto(pic, source, this.imgListener);
} }
public void addPicto(Picto pic, ImgDownloader.tsource source, iImgDownloaderListener imgListener){ public void addPicto(Picto pic, ImgDownloader.tsource source, ImgDownloader.iImgDownloaderListener imgListener){
Vector<Img> imgs=new Vector<Img>(1); Vector<Img> imgs=new Vector<Img>(1);
imgs.add(new Img(pic.get_id(), pic.get_url(), Img.VOCABULARY)); imgs.add(new Img(pic.get_id(), pic.get_url(), Img.VOCABULARY));
...@@ -259,7 +263,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -259,7 +263,7 @@ public class Vocabulary implements Iterable<Picto> {
PCBcontext.getPcbdb().addPicto(pic); PCBcontext.getPcbdb().addPicto(pic);
} }
public void setImgDownloaderListener(iImgDownloaderListener listener) { public void setImgDownloaderListener(ImgDownloader.iImgDownloaderListener listener) {
this.imgListener=listener; this.imgListener=listener;
} }
...@@ -383,7 +387,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -383,7 +387,7 @@ public class Vocabulary implements Iterable<Picto> {
final Picto picto[]=new Picto[1]; final Picto picto[]=new Picto[1];
try { try {
picto[0] = new Picto(id, url, exp, cat, coord_x, coord_y, free_category_coord_x, free_category_coord_y); picto[0] = new Picto(id, url, exp, cat, coord_x, coord_y, free_category_coord_x, free_category_coord_y);
addPicto(picto[0], ImgDownloader.tsource.local, new iImgDownloaderListener() { addPicto(picto[0], ImgDownloader.tsource.local, new ImgDownloader.iImgDownloaderListener() {
@Override @Override
public void loadComplete() { public void loadComplete() {
listener.saved(picto[0]); listener.saved(picto[0]);
......
...@@ -8,7 +8,6 @@ import android.util.Log; ...@@ -8,7 +8,6 @@ import android.util.Log;
import com.yottacode.pictogram.R; import com.yottacode.pictogram.R;
import com.yottacode.pictogram.tools.Img; import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
...@@ -64,7 +63,7 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> { ...@@ -64,7 +63,7 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> {
int seconds = Calendar.getInstance().get(Calendar.SECOND); int seconds = Calendar.getInstance().get(Calendar.SECOND);
try { try {
;
for (Img img: imgs) { for (Img img: imgs) {
if (!img.exists_bitmap(this.context) || this.force_download || this.source==source.local) try { if (!img.exists_bitmap(this.context) || this.force_download || this.source==source.local) try {
this.activityManager.getMemoryInfo(mi); this.activityManager.getMemoryInfo(mi);
...@@ -79,6 +78,7 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> { ...@@ -79,6 +78,7 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> {
} }
int size=img.save_bitmap(this.context, is); int size=img.save_bitmap(this.context, is);
allsize+=size; allsize+=size;
if (is != null) is.close();
i++; i++;
} catch (IOException e) { } catch (IOException e) {
j++; j++;
...@@ -117,4 +117,13 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> { ...@@ -117,4 +117,13 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> {
else imgListener.loadImg(img); else imgListener.loadImg(img);
} }
/**
* Created by emblanco on 24/09/15.
* MOdified by dofer on 27/06/16.
*/
public static interface iImgDownloaderListener {
public void loadComplete(); // for loading the vocabulary
public void loadImg(Img image); // for loading one image
public void error(Exception err); //error happens
}
} }
...@@ -2,20 +2,17 @@ package com.yottacode.pictogram.net; ...@@ -2,20 +2,17 @@ package com.yottacode.pictogram.net;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log; import android.util.Log;
import android.widget.Toast;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.koushikdutta.ion.Ion; import com.koushikdutta.ion.Ion;
import com.koushikdutta.ion.Response; import com.koushikdutta.ion.Response;
import com.yottacode.net.iRestapiListener; import com.yottacode.net.RestapiWrapper;
import com.yottacode.pictogram.R; import com.yottacode.pictogram.R;
import com.yottacode.pictogram.action.VocabularyAction; import com.yottacode.pictogram.action.VocabularyAction;
import com.yottacode.pictogram.dao.Picto; import com.yottacode.pictogram.dao.Picto;
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.tools.BitmapTools;
import com.yottacode.tools.GUITools; import com.yottacode.tools.GUITools;
import org.json.JSONArray; import org.json.JSONArray;
...@@ -25,6 +22,7 @@ import org.json.JSONObject; ...@@ -25,6 +22,7 @@ import org.json.JSONObject;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.HttpRetryException;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
...@@ -124,7 +122,7 @@ public class PictoUploader { ...@@ -124,7 +122,7 @@ public class PictoUploader {
e.printStackTrace(); e.printStackTrace();
Log.e(this.getClass().getCanonicalName(), " Error: " + e.getLocalizedMessage()); Log.e(this.getClass().getCanonicalName(), " Error: " + e.getLocalizedMessage());
} }
PCBcontext.getRestapiWrapper().ask(PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + "/picto/"+id_picto, params, "post", true, new iRestapiListener() { PCBcontext.getRestapiWrapper().ask(PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + "/picto/"+id_picto, params, "post", true, new RestapiWrapper.iRestapiListener() {
@Override @Override
public void preExecute() { public void preExecute() {
} }
...@@ -141,7 +139,7 @@ public class PictoUploader { ...@@ -141,7 +139,7 @@ public class PictoUploader {
} }
@Override @Override
public void error(Exception e) { public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getCanonicalName(), " Error uploading attributes: " + e.getLocalizedMessage()); Log.e(this.getClass().getCanonicalName(), " Error uploading attributes: " + e.getLocalizedMessage());
listener.success(false); listener.success(false);
...@@ -158,7 +156,9 @@ public class PictoUploader { ...@@ -158,7 +156,9 @@ public class PictoUploader {
params.put("picto", Integer.toString(id_picto)); params.put("picto", Integer.toString(id_picto));
params.put("lang", PCBcontext.getPcbdb().getCurrentUser().get_lang_stu()); params.put("lang", PCBcontext.getPcbdb().getCurrentUser().get_lang_stu());
params.put("text", picto.get_translation()); params.put("text", picto.get_translation());
PCBcontext.getRestapiWrapper().ask("picto/exp", params, "post", new iRestapiListener() { Log.i(this.getClass().getCanonicalName(), "Uploading translation: " + picto.get_translation());
PCBcontext.getRestapiWrapper().ask("picto/exp", params, "post", new RestapiWrapper.iRestapiListener() {
@Override @Override
public void preExecute() { public void preExecute() {
} }
...@@ -174,7 +174,7 @@ public class PictoUploader { ...@@ -174,7 +174,7 @@ public class PictoUploader {
} }
@Override @Override
public void error(Exception e) { public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getCanonicalName(), "Error uploading translation: " + e.getLocalizedMessage()+" Picto:"+params.get("picto")+" Lang:"+params.get("lang")+" Text:"+params.get("text")); Log.e(this.getClass().getCanonicalName(), "Error uploading translation: " + e.getLocalizedMessage()+" Picto:"+params.get("picto")+" Lang:"+params.get("lang")+" Text:"+params.get("text"));
listener.success(false); listener.success(false);
} }
...@@ -232,7 +232,7 @@ public class PictoUploader { ...@@ -232,7 +232,7 @@ public class PictoUploader {
Log.i(this.getClass().getCanonicalName(), "Picto Uploading " + params.toString()); Log.i(this.getClass().getCanonicalName(), "Picto Uploading " + params.toString());
PCBcontext.getRestapiWrapper().ask( PCBcontext.getRestapiWrapper().ask(
PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + "/picto", PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + "/picto",
params, "put", new iRestapiListener() { params, "put", new RestapiWrapper.iRestapiListener() {
@Override @Override
public void preExecute() { public void preExecute() {
} }
...@@ -250,7 +250,7 @@ public class PictoUploader { ...@@ -250,7 +250,7 @@ public class PictoUploader {
} }
@Override @Override
public void error(Exception e) { public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getCanonicalName(), "Picto Error: " + e.getLocalizedMessage()); Log.e(this.getClass().getCanonicalName(), "Picto Error: " + e.getLocalizedMessage());
} }
} }
...@@ -258,4 +258,10 @@ public class PictoUploader { ...@@ -258,4 +258,10 @@ public class PictoUploader {
} }
/**
* Created by Fernando on 28/07/2016.
*/
public static interface iPictoUploaderListener {
void success(boolean success);
}
} }
...@@ -3,7 +3,6 @@ package com.yottacode.pictogram.net; ...@@ -3,7 +3,6 @@ package com.yottacode.pictogram.net;
import android.util.Log; import android.util.Log;
import com.yottacode.net.RestapiWrapper; import com.yottacode.net.RestapiWrapper;
import com.yottacode.net.iRestapiListener;
import com.yottacode.pictogram.dao.LoginException; import com.yottacode.pictogram.dao.LoginException;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
...@@ -18,20 +17,20 @@ import java.util.Hashtable; ...@@ -18,20 +17,20 @@ import java.util.Hashtable;
*/ */
public class ServerLogin { public class ServerLogin {
public static void login_student(String username, String password, iRestapiListener listener) { public static void login_student(String username, String password, RestapiWrapper.iRestapiListener listener) {
login("stu/login", null, username, password, listener); login("stu/login", null, username, password, listener);
} }
public static void login_supervisor(String email, String password, iRestapiListener listener) { public static void login_supervisor(String email, String password, RestapiWrapper.iRestapiListener listener) {
login("sup/login", email, null, password, listener); login("sup/login", email, null, password, listener);
} }
private static void login(String operation, String email, String username, String password, final iRestapiListener listener){ private static void login(String operation, String email, String username, String password, final RestapiWrapper.iRestapiListener listener){
Hashtable<String, String> postDataParams = new Hashtable<String, String>(); Hashtable<String, String> postDataParams = new Hashtable<String, String>();
if (email!=null) postDataParams.put("email", email); if (email!=null) postDataParams.put("email", email);
if (username!=null) postDataParams.put("username", username); if (username!=null) postDataParams.put("username", username);
postDataParams.put("password", password); postDataParams.put("password", password);
PCBcontext.getRestapiWrapper().ask(operation, postDataParams, "post", new iRestapiListener() { PCBcontext.getRestapiWrapper().ask(operation, postDataParams, "post", new RestapiWrapper.iRestapiListener() {
@Override @Override
public void preExecute() { public void preExecute() {
listener.preExecute(); listener.preExecute();
...@@ -51,20 +50,18 @@ public class ServerLogin { ...@@ -51,20 +50,18 @@ public class ServerLogin {
PCBcontext.getPcbdb().user_online(true); PCBcontext.getPcbdb().user_online(true);
PCBcontext.getRestapiWrapper().setToken(result.getString(TAG_TOKEN)); PCBcontext.getRestapiWrapper().setToken(result.getString(TAG_TOKEN));
PCBcontext.getVocabulary().synchronize(); PCBcontext.getVocabulary().synchronize();
PCBcontext.getRoom().connect();
} }
listener.result(result); listener.result(result);
} catch (JSONException e) { }catch (JSONException e) {
listener.error(e); listener.error(new RestapiWrapper.HTTPException("JSON Error:"+e.getMessage(),-1));
} }
} }
@Override @Override
public void error(Exception e) { public void error(RestapiWrapper.HTTPException e) {
listener.error(new LoginException(e.getMessage(),e.getMessage().contains("User without students") Log.e(this.getClass().getCanonicalName(),"Raw error from server when login:"+e.getMessage()+" (error "+e.getCode()+")");
? LoginException.NO_STUDENTS listener.error(new LoginException(e.getMessage(),e.getCode()));
: e.getMessage().contains("failed to connect")
? LoginException.TIME_OUT
: LoginException.BAD_LOGIN));
} }
}); });
} }
......
package com.yottacode.pictogram.net;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tools.Img;
import java.util.LinkedList;
/**
* Created by emblanco on 24/09/15.
* MOdified by dofer on 27/06/16.
*/
public interface iImgDownloaderListener {
public void loadComplete(); // for loading the vocabulary
public void loadImg(Img image); // for loading one image
public void error(Exception err); //error happens
}
package com.yottacode.pictogram.net;
import android.content.Intent;
import com.yottacode.pictogram.dao.User;
/**
* Created by Fernando on 12/08/2016.
*/
public interface iNetServiceDevice {
public void build();
public void notifyStatus(boolean updated);
public void closeNotifyStatus();
public void restart_app(boolean direct_login);
public void restart_app(Intent intent, boolean direct_login);
public void updateUserConfig(User user);
}
package com.yottacode.pictogram.net;
/**
* Created by Fernando on 28/07/2016.
*/
public interface iPictoUploaderListener {
void success(boolean success);
}
...@@ -9,6 +9,9 @@ import com.yottacode.pictogram.tools.PCBcontext; ...@@ -9,6 +9,9 @@ import com.yottacode.pictogram.tools.PCBcontext;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.Iterator;
import java.util.Vector;
/** /**
* Websocket Vocabulary Room based on Room * Websocket Vocabulary Room based on Room
* @author Fernando Martinez Santiago * @author Fernando Martinez Santiago
...@@ -19,12 +22,13 @@ public class ActionTalk implements Emitter.Listener { ...@@ -19,12 +22,13 @@ public class ActionTalk implements Emitter.Listener {
private static final String URL ="action"; private static final String URL ="action";
private Room room; private Room room;
iActionListener listeners[]; Vector<iActionListener> listeners;
public ActionTalk(Room room, iActionListener listeners[]) { public ActionTalk(Room room, iActionListener listener) {
this.room = room; this.room = room;
this.room.listen(URL, this); this.room.listen(URL, this);
this.listeners=listeners; this.listeners=new Vector<>(2);
listeners.add(listener);
} }
@Override @Override
...@@ -37,23 +41,36 @@ public class ActionTalk implements Emitter.Listener { ...@@ -37,23 +41,36 @@ public class ActionTalk implements Emitter.Listener {
final String param_picto_cat="id_cat"; final String param_picto_cat="id_cat";
final String action_select="select"; final String action_select="select";
final String action_add="add"; final String action_add="add";
final String action_show="show";
JSONObject msg = (JSONObject) args[0]; JSONObject msg = (JSONObject) args[0];
try { try {
Log.i(this.getClass().getName(), "raw Received message " +msg.toString()); Log.i(this.getClass().getName(), "Received message (raw): " +msg.toString()+" mirror:"+PCBcontext.getPcbdb().getCurrentUser().is_mirror_on());
String action = msg.getString(param_action).toLowerCase(); String action = msg.getString(param_action).toLowerCase();
if (action.equals(action_add) || action.equals(action_select)) { if (action.equals(action_add) || action.equals(action_select) ||action.equals(action_show)) {
JSONObject stu_picto = msg.getJSONObject(param_attributes).getJSONObject(param_stu_picto); int picto_id;
JSONObject attrs_stu_picto = stu_picto.optJSONObject(param_attributes); int picto_cat;
JSONObject picto_stupicto = stu_picto.optJSONObject(param_picto); boolean mirroing=PCBcontext.getPcbdb().getCurrentUser().is_mirror_on();
int picto_id = picto_stupicto.getInt(param_picto_id); if (action.equals(action_show)) {
int picto_cat = attrs_stu_picto != null ? attrs_stu_picto.optInt(param_picto_cat, Picto.NO_CATEGORY) : 0; picto_id=picto_cat=-1;
if (PCBcontext.getPcbdb().getCurrentUser().is_mirror_on() || attrs_stu_picto.has(Picto.JSON_ATTTRS.MIRROR)) { } else {
JSONObject stu_picto = msg.getJSONObject(param_attributes).getJSONObject(param_stu_picto);
JSONObject attrs_stu_picto = stu_picto.optJSONObject(param_attributes);
JSONObject picto_stupicto = stu_picto.optJSONObject(param_picto);
picto_id = picto_stupicto.getInt(param_picto_id);
picto_cat = attrs_stu_picto != null ? attrs_stu_picto.optInt(param_picto_cat, Picto.NO_CATEGORY) : 0;
mirroing|=attrs_stu_picto.has(Picto.JSON_ATTTRS.MIRROR);
}
if ( mirroing) {
Log.i(this.getClass().getName(), "Received message '" + action + Log.i(this.getClass().getName(), "Received message '" + action +
"' for picto " + picto_id + " (cat " + picto_cat + ", picto: " + picto_stupicto); "' for picto " + picto_id + " (cat " + picto_cat);
for (iActionListener listener : this.listeners) for (iActionListener listener : this.listeners)
listener.action(action.equals(action_add) ? iActionListener.action.add : iActionListener.action.select, picto_cat, picto_id); listener.action(action.equals(action_add)
? iActionListener.action.add
: action.equals(action_select)
? iActionListener.action.select
: iActionListener.action.show
, picto_cat, picto_id);
} }
} }
...@@ -62,4 +79,24 @@ public class ActionTalk implements Emitter.Listener { ...@@ -62,4 +79,24 @@ public class ActionTalk implements Emitter.Listener {
} }
} }
public void addListener(iActionListener listener) {
if (!listeners.contains(listener)) listeners.add(listener);
}
public void removeListener(iActionListener removedlistener) {
Iterator listeners=this.listeners.iterator();
while (listeners.hasNext() )
if (listeners.next()==removedlistener) listeners.remove();
}
/**
* Vocabulary Listener
* @author Fernando Martinez Santiago
* @version 1.0
*/
public interface iActionListener {
enum action {add,select,show}
void action(action action, int picto_cat, int picto_id);
}
} }
...@@ -35,7 +35,7 @@ public class Room { ...@@ -35,7 +35,7 @@ public class Room {
public Room( ) { public Room( ) {
Log.i(this.getClass().getName(), "Entering room"); Log.i(this.getClass().getName(), "Entering room");
listeners=new Hashtable<>(); listeners=new Hashtable<>();
reconnect(); connect();
} }
private JSONObject common_data(String action, JSONObject attributes) throws JSONException { private JSONObject common_data(String action, JSONObject attributes) throws JSONException {
...@@ -67,10 +67,9 @@ public class Room { ...@@ -67,10 +67,9 @@ public class Room {
/** /**
* Reconnect to the room. It is useful if the server connection is lost for a time * 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"; final String transport="polling";
exit(); exit();
this.socket=new SailsSocketsIO(PCBcontext.getRestapiWrapper().getServer(), transport, new Emitter.Listener() { this.socket=new SailsSocketsIO(PCBcontext.getRestapiWrapper().getServer(), transport, new Emitter.Listener() {
@Override @Override
public void call(Object... args) { public void call(Object... args) {
...@@ -83,6 +82,7 @@ public class Room { ...@@ -83,6 +82,7 @@ public class Room {
@Override @Override
public void call(Object... args) { public void call(Object... args) {
Log.e(this.getClass().getName(), "IO sockects error: "+args[0]); 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; inRoom=false;
PCBcontext.getNetService().setOffline(new SocketIOException(args[0].toString())); PCBcontext.getNetService().setOffline(new SocketIOException(args[0].toString()));
} }
...@@ -108,9 +108,16 @@ public class Room { ...@@ -108,9 +108,16 @@ public class Room {
Log.e(this.getClass().getCanonicalName(), "subscribe room failed:"+e.getMessage()); 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 { try {
UnsubscribeAction action = new UnsubscribeAction(); UnsubscribeAction action = new UnsubscribeAction();
this.emit(action); this.emit(action);
}catch (Exception e) { }catch (Exception e) {
...@@ -120,13 +127,16 @@ public class Room { ...@@ -120,13 +127,16 @@ public class Room {
public void exit() { public void exit() {
if (this.socket!=null) { if (this.socket!=null) {
Log.i(this.getClass().getName(), "Leaving room"); Log.i(this.getClass().getName(), "Leaving room");
unlisten();
unsubscribe(); unsubscribe();
this.socket.destroy(); this.socket.destroy();
this.socket=null; this.socket=null;
} }
} }
public void finalize() throws java.lang.Throwable { public void finalize() throws java.lang.Throwable {
super.finalize(); super.finalize();
Log.i(this.getClass().getName(), "Discarding room");
exit(); exit();
} }
......
...@@ -33,7 +33,7 @@ public class StudentTalk implements Emitter.Listener { ...@@ -33,7 +33,7 @@ public class StudentTalk implements Emitter.Listener {
@Override @Override
public void call(Object... args) { public void call(Object... args) {
if (PCBcontext.getPcbdb()!=null)
try { try {
JSONObject msg = ((JSONObject) args[0]).getJSONObject("student"); JSONObject msg = ((JSONObject) args[0]).getJSONObject("student");
Log.i(this.getClass().getName(), "raw Received message " +msg.toString()); Log.i(this.getClass().getName(), "raw Received message " +msg.toString());
...@@ -57,4 +57,13 @@ public class StudentTalk implements Emitter.Listener { ...@@ -57,4 +57,13 @@ public class StudentTalk implements Emitter.Listener {
} }
} }
/**
* Vocabulary Listener
* @author Fernando Martinez Santiago
* @version 1.0
*/
public static interface iStudentListener {
public void change(User updatedStudent);
}
} }
...@@ -17,7 +17,7 @@ public class VocabularyTalk implements Emitter.Listener { ...@@ -17,7 +17,7 @@ public class VocabularyTalk implements Emitter.Listener {
private static final String URL ="vocabulary"; private static final String URL ="vocabulary";
private Room room; private Room room;
private final String LOG_TAG=this.getClass().getName();
iVocabularyListener listeners[]; iVocabularyListener listeners[];
public VocabularyTalk(Room room, iVocabularyListener listeners[]) { public VocabularyTalk(Room room, iVocabularyListener listeners[]) {
...@@ -40,7 +40,7 @@ public class VocabularyTalk implements Emitter.Listener { ...@@ -40,7 +40,7 @@ public class VocabularyTalk implements Emitter.Listener {
JSONObject msg = (JSONObject) args[0]; JSONObject msg = (JSONObject) args[0];
try { 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(); String action = msg.getString(param_action).toLowerCase();
JSONObject stu_picto= msg.getJSONObject(param_attributes).getJSONObject(param_stu_picto); JSONObject stu_picto= msg.getJSONObject(param_attributes).getJSONObject(param_stu_picto);
JSONObject attrs_stu_picto = stu_picto.optJSONObject(param_attributes); JSONObject attrs_stu_picto = stu_picto.optJSONObject(param_attributes);
...@@ -48,7 +48,7 @@ public class VocabularyTalk implements Emitter.Listener { ...@@ -48,7 +48,7 @@ public class VocabularyTalk implements Emitter.Listener {
int picto_id = picto_stupicto.getInt(param_picto_id); 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; 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 picto " + picto_id + " (cat " + picto_cat + ", picto: " + picto_stupicto);
for (iVocabularyListener listener: this.listeners) for (iVocabularyListener listener: this.listeners)
listener.change(action.equals(action_update) ? iVocabularyListener.action.update listener.change(action.equals(action_update) ? iVocabularyListener.action.update
...@@ -57,8 +57,18 @@ public class VocabularyTalk implements Emitter.Listener { ...@@ -57,8 +57,18 @@ public class VocabularyTalk implements Emitter.Listener {
, picto_cat, picto_id, stu_picto); , picto_cat, picto_id, stu_picto);
} catch (JSONException e) { } catch (JSONException e) {
Log.e(this.getClass().getCanonicalName(), e.getClass().getCanonicalName() + "--" + e); Log.e(LOG_TAG, e.getClass().getCanonicalName() + "--" + e);
} }
} }
/**
* Vocabulary Listener
* @author Fernando Martinez Santiago
* @version 1.0
*/
public static interface iVocabularyListener {
public enum action {delete,add,update}
public void change(action action, int picto_cat, int picto_id, JSONObject args);
}
} }
package com.yottacode.pictogram.net.websockets;
/**
* Vocabulary Listener
* @author Fernando Martinez Santiago
* @version 1.0
*/
public interface iActionListener {
public enum action {add,select}
public void action(iActionListener.action action, int picto_cat, int picto_id);
}
package com.yottacode.pictogram.net.websockets;
import com.yottacode.pictogram.dao.User;
/**
* Vocabulary Listener
* @author Fernando Martinez Santiago
* @version 1.0
*/
public interface iStudentListener {
public void change(User updatedStudent);
}
package com.yottacode.pictogram.net.websockets;
import org.json.JSONObject;
/**
* Vocabulary Listener
* @author Fernando Martinez Santiago
* @version 1.0
*/
public interface iVocabularyListener {
public enum action {delete,add,update}
public void change(iVocabularyListener.action action, int picto_cat, int picto_id, JSONObject args);
}
...@@ -57,6 +57,18 @@ public class Img { ...@@ -57,6 +57,18 @@ public class Img {
this.type=type; this.type=type;
this.bitmap=null; this.bitmap=null;
} }
public Img(Img i) {
this.id = i.id;
this.url = new String(i.url);
this.type=new String(i.type);
try {
if (PCBcontext.getContext()!=null && i.get_bitmap(PCBcontext.getContext())!=null)
this.bitmap=i.get_bitmap(PCBcontext.getContext()).copy(i.get_bitmap(PCBcontext.getContext()).getConfig(),true);
} catch (IOException e) {
Log.e(this.getClass().getCanonicalName(),e.getMessage());
}
}
public String file_name() { return this.id+"."+Img.FILETYPE; } public String file_name() { return this.id+"."+Img.FILETYPE; }
public int get_id() { return this.id;} public int get_id() { return this.id;}
......
...@@ -11,12 +11,10 @@ import com.yottacode.pictogram.dao.Device; ...@@ -11,12 +11,10 @@ import com.yottacode.pictogram.dao.Device;
import com.yottacode.pictogram.dao.PCBDBHelper; import com.yottacode.pictogram.dao.PCBDBHelper;
import com.yottacode.pictogram.dao.User; import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.grammar.Vocabulary; import com.yottacode.pictogram.grammar.Vocabulary;
import com.yottacode.pictogram.net.ImgDownloader;
import com.yottacode.pictogram.net.NetService; import com.yottacode.pictogram.net.NetService;
import com.yottacode.pictogram.net.iImgDownloaderListener;
import com.yottacode.pictogram.net.iNetServiceDevice;
import com.yottacode.pictogram.net.websockets.Room; import com.yottacode.pictogram.net.websockets.Room;
import com.yottacode.pictogram.net.websockets.StudentTalk; import com.yottacode.pictogram.net.websockets.StudentTalk;
import com.yottacode.pictogram.net.websockets.iStudentListener;
public final class PCBcontext { public final class PCBcontext {
private static Context context; private static Context context;
...@@ -28,14 +26,14 @@ public final class PCBcontext { ...@@ -28,14 +26,14 @@ public final class PCBcontext {
private static Vocabulary vocabulary; private static Vocabulary vocabulary;
private static ActionLog actionLog; private static ActionLog actionLog;
private static boolean init=false; private static boolean init=false;
private static StudentTalk studentTalk;
/** /**
* Init method for passing params to the singleton * Init method for passing params to the singleton
* @param c @TODO application or activity context? * @param c @TODO application or activity context?
*/ */
public static void init(Context c, iNetServiceDevice listener){ public static void init(Context c, NetService.iNetServiceDevice listener){
if (!init) { if (!init) {
init = true; init = true;
context = c; context = c;
...@@ -47,16 +45,18 @@ public final class PCBcontext { ...@@ -47,16 +45,18 @@ public final class PCBcontext {
Log.i(PCBcontext.class.getCanonicalName(), "PCB context started. It's required" + Log.i(PCBcontext.class.getCanonicalName(), "PCB context started. It's required" +
"set_user method call"); "set_user method call");
} else { } else {
Log.e(PCBcontext.class.getClass().getCanonicalName(), "Init method was previously" + Log.e(PCBcontext.class.getCanonicalName(), "Init method was previously " +
"invoked! Please, check your code"); " invoked! Please, check your code");
} }
} }
public static boolean init() {return init;}
/** /**
* @param student * @param student
* @param listener * @param listener
*/ */
public static void set_user(User student, String token, iImgDownloaderListener listener) { public static void set_user(User student, String token, ImgDownloader.iImgDownloaderListener listener) {
if (!init) { if (!init) {
Log.i(PCBcontext.class.getCanonicalName(), "PCBcontext.init must be called once previously "); Log.i(PCBcontext.class.getCanonicalName(), "PCBcontext.init must be called once previously ");
throw new java.lang.AssertionError("init must be called once previously "); throw new java.lang.AssertionError("init must be called once previously ");
...@@ -70,12 +70,12 @@ public final class PCBcontext { ...@@ -70,12 +70,12 @@ public final class PCBcontext {
actionLog = new ActionLog(); actionLog = new ActionLog();
vocabulary = new Vocabulary(listener); vocabulary = new Vocabulary(listener);
getNetService().notifyStatus(); getNetService().notifyStatus();
if (getNetService().online()) new StudentTalk(room, new iStudentListener[] {new iStudentListener() { studentTalk=new StudentTalk(room, new StudentTalk.iStudentListener[] {new StudentTalk.iStudentListener() {
@Override @Override
public void change(User updatedStudent) { public void change(User updatedStudent) {
PCBcontext.getDevice().insertUser(updatedStudent); PCBcontext.getDevice().insertUser(updatedStudent);
if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big()) if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big() || updatedStudent.has_categories()!=getPcbdb().getCurrentUser().has_categories())
PCBcontext.getNetService().getNetServiceDevice().restart_app(true); PCBcontext.getNetService().restart_app(true);
else { else {
PCBcontext.getPcbdb().setCurrentUser(updatedStudent); PCBcontext.getPcbdb().setCurrentUser(updatedStudent);
PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent); PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent);
...@@ -88,8 +88,8 @@ public final class PCBcontext { ...@@ -88,8 +88,8 @@ public final class PCBcontext {
public static void unset_user() { public static void unset_user() {
Log.i(PCBcontext.class.getCanonicalName(), "User unset. Student " + getPcbdb().getCurrentUser().get_name_stu()); Log.i(PCBcontext.class.getCanonicalName(), "User unset. Student " + getPcbdb().getCurrentUser().get_name_stu());
pcbdb = null;
if (room!=null) room.exit(); if (room!=null) room.exit();
pcbdb = null;
room = null; room = null;
vocabulary = null; vocabulary = null;
getNetService().notifyStatus(); getNetService().notifyStatus();
...@@ -145,6 +145,15 @@ public final class PCBcontext { ...@@ -145,6 +145,15 @@ public final class PCBcontext {
return device; 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 * @return PCBDB
* @TODO complete documentation * @TODO complete documentation
......
...@@ -54,7 +54,7 @@ public class TTSHelper { ...@@ -54,7 +54,7 @@ public class TTSHelper {
Set<Voice> voices = this.ttobj.getVoices(); Set<Voice> voices = this.ttobj.getVoices();
if (voices!=null) 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)) { if (avoice.getName().equalsIgnoreCase(voice)) {
this.ttobj.setVoice(avoice); this.ttobj.setVoice(avoice);
this.voice_ok=true; this.voice_ok=true;
......
...@@ -49,9 +49,9 @@ public class BitmapTools { ...@@ -49,9 +49,9 @@ public class BitmapTools {
return resize(width,height); return resize(width,height);
} }
public BitmapTools paintSquare(int thickness, int color ) { public BitmapTools paintSquare(int thickness, int color, int step ) {
for (int i = 0; i < this.bitmap.getWidth(); i++) for (int i = 0; i < this.bitmap.getWidth(); i+=step)
for (int t = 1; t <= thickness; t++) { for (int t = 1; t <= thickness; t+=step) {
this.bitmap.setPixel(i, 0 + t-1, color); this.bitmap.setPixel(i, 0 + t-1, color);
this.bitmap.setPixel(i, this.bitmap.getHeight() - t, color); this.bitmap.setPixel(i, this.bitmap.getHeight() - t, color);
} }
...@@ -136,4 +136,25 @@ public class BitmapTools { ...@@ -136,4 +136,25 @@ public class BitmapTools {
// return out final image // return out final image
return bmOut; return bmOut;
} }
public BitmapTools disableBitmap() {
Canvas canvas = new Canvas(bitmap);
Paint alphaPaint = new Paint();
alphaPaint.setAlpha(30);
canvas.drawBitmap(bitmap, 0, 0, alphaPaint);
return this;
}
public BitmapTools paintPause( ) {
int thickness=8;
int color=Color.DKGRAY;
for (int i = this.bitmap.getWidth()/2; i < this.bitmap.getWidth()/2+thickness; i++)
for (int t = this.bitmap.getHeight()/8; t <= this.bitmap.getHeight()-this.bitmap.getHeight()/8; t++) {
this.bitmap.setPixel(i-8, t, color);
this.bitmap.setPixel(i+8, t, color);
}
return this;
}
} }
...@@ -18,7 +18,9 @@ ...@@ -18,7 +18,9 @@
<string name="logout">Logout</string> <string name="logout">Logout</string>
<string name="loginTitle">Who are you?</string> <string name="loginTitle">Who are you?</string>
<string name="loginErrorTxt">Login</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="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="userInetErrorMsg">Unknown new user name because Internet conection is not available</string>
<string name="userLoadingTxt">Loading</string> <string name="userLoadingTxt">Loading</string>
<string name="userLoadingMsg">Loading students. Please wait.</string> <string name="userLoadingMsg">Loading students. Please wait.</string>
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
<string name="loginTitle">¿Quién eres?</string> <string name="loginTitle">¿Quién eres?</string>
<string name="loginErrorTxt">Login</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="loginErrorMsg">El usuario no existe o la contraseña indicada no es correcta. Inténtelo de nuevo.</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="imguserLoadingMsg">Cargando imágenes de los alumnos. Por favor espere.</string>
<string name="imguserLoadingErrMsg">Imagen con formato no válido.</string> <string name="imguserLoadingErrMsg">Imagen con formato no válido.</string>
...@@ -69,5 +71,6 @@ ...@@ -69,5 +71,6 @@
<string name="default_tts_voice_male">es-es-x-ana#male_1-local</string> <string name="default_tts_voice_male">es-es-x-ana#male_1-local</string>
<string name="default_tts_voice_female">es-es-x-ana#female_2-local</string> <string name="default_tts_voice_female">es-es-x-ana#female_2-local</string>
</resources> </resources>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">8px</dimen>
<dimen name="activity_vertical_margin">8px</dimen>
<dimen name="small_padding">4px</dimen>
<dimen name="picto_grid_spacing">1px</dimen>
<dimen name="picto_border_width">2px</dimen>
<dimen name="picto_padding">1px</dimen>
<dimen name="picto_normal_height">90px</dimen>
<dimen name="picto_normal_width">90px</dimen>
<dimen name="tape_normal_height">100px</dimen>
<dimen name="picto_big_height">115px</dimen>
<dimen name="picto_big_width">115px</dimen>
<dimen name="tape_big_height">125px</dimen>
<dimen name="picto_session_height">75px</dimen>
<dimen name="picto_session_width">75px</dimen>
</resources>
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">8px</dimen>
<dimen name="activity_vertical_margin">8px</dimen>
<dimen name="small_padding">4px</dimen>
<dimen name="picto_grid_spacing">2px</dimen>
<dimen name="picto_border_width">1px</dimen>
<dimen name="picto_padding">1px</dimen>
<dimen name="picto_normal_height">90px</dimen>
<dimen name="picto_normal_width">90px</dimen>
<dimen name="tape_normal_height">100px</dimen>
<dimen name="picto_big_height">135px</dimen>
<dimen name="picto_big_width">135px</dimen>
<dimen name="tape_big_height">145px</dimen>
<dimen name="picto_session_height">84dp</dimen>
<dimen name="picto_session_width">84dp</dimen>
</resources>
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">8px</dimen>
<dimen name="activity_vertical_margin">8px</dimen>
<dimen name="small_padding">4px</dimen>
<dimen name="picto_grid_spacing">1px</dimen>
<dimen name="picto_border_width">1px</dimen>
<dimen name="picto_padding">1px</dimen>
<dimen name="picto_normal_height">90px</dimen>
<dimen name="picto_normal_width">90px</dimen>
<dimen name="tape_normal_height">100px</dimen>
<dimen name="picto_big_height">116px</dimen>
<dimen name="picto_big_width">116px</dimen>
<dimen name="tape_big_height">118px</dimen>
<dimen name="picto_session_height">75px</dimen>
<dimen name="picto_session_width">75px</dimen>
</resources>
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<item name="red" type="color">#FFFF4444</item> <item name="red" type="color">#FFFF4444</item>
<item name="darkblue" type="color">#FF0099CC</item> <item name="darkblue" type="color">#FF0099CC</item>
<item name="darkpurple" type="color">#FF9933CC</item> <item name="darkpurple" type="color">#FF9933CC</item>
<item name="darkgreen" type="color">#FF669900</item> <item name="darkgreen" type="color">#669900</item>
<item name="darkorange" type="color">#FFFF8800</item> <item name="darkorange" type="color">#FFFF8800</item>
<item name="darkred" type="color">#cc0000</item> <item name="darkred" type="color">#cc0000</item>
......
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="small_padding">8dp</dimen>
<dimen name="picto_grid_spacing">4dp</dimen>
<dimen name="picto_border_width">1dp</dimen>
<dimen name="picto_padding">4dp</dimen>
<dimen name="picto_normal_height">75dp</dimen>
<dimen name="picto_normal_width">75dp</dimen>
<dimen name="tape_normal_height">90dp</dimen>
<dimen name="picto_big_height">90dp</dimen>
<dimen name="picto_big_width">90dp</dimen>
<dimen name="tape_big_height">110dp</dimen>
</resources>
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
<string name="loginTitle">¿Quién eres?</string> <string name="loginTitle">¿Quién eres?</string>
<string name="loginErrorTxt">Login</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="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="userInetErrorMsg">Este usuario requiere conexión a internet para ser validado</string>
<string name="userLoadingTxt">Cargando</string> <string name="userLoadingTxt">Cargando</string>
<string name="userLoadingMsg">Cargando alumnos. Por favor espere.</string> <string name="userLoadingMsg">Cargando alumnos. Por favor espere.</string>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" /> <uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.READ_CALL_LOG" /> <uses-permission android:name="android.permission.READ_CALL_LOG" />
<application <application
android:allowBackup="true" android:allowBackup="true"
...@@ -54,6 +54,12 @@ ...@@ -54,6 +54,12 @@
android:label="@string/app_name" android:label="@string/app_name"
android:launchMode="singleTop" android:launchMode="singleTop"
android:screenOrientation="landscape" /> android:screenOrientation="landscape" />
<activity
android:name="com.yottacode.pictogram.tabletlibrary.gui.session.SessionActivity"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleTop"
android:screenOrientation="landscape" />
</application> </application>
</manifest> </manifest>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".gui.Supervisor_SerialActivity">
<EditText
android:id="@+id/serialmail"
android:layout_width="400px"
android:layout_height="wrap_content"
android:hint="@string/prompt_serial_mail"
android:imeActionId="@+id/login"
android:imeOptions="actionUnspecified"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
android:layout_alignParentTop="true" />
<EditText
android:id="@+id/serialpass"
android:layout_width="400px"
android:layout_height="wrap_content"
android:hint="@string/prompt_serial_pass"
android:imeActionId="@+id/login"
android:imeActionLabel="@string/action_entrar"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
android:layout_below="@+id/serialmail"
/>
<Button
android:id="@+id/entrar_button" style="?android:textAppearanceSmall"
android:layout_width="400px"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="@string/action_entrar"
android:textStyle="bold"
android:layout_below="@+id/serialpass"/>
<ImageView
android:layout_width="200px"
android:layout_height="120px"
android:layout_marginLeft="30px"
android:orientation="horizontal"
android:src="@drawable/pictogram_logo"
android:id="@+id/imageView"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/serialmail"
/>
<TextView
android:text="SUPERVISOR"
android:textStyle="bold"
android:textColor="@color/green"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/text_supervisor"
android:layout_below="@+id/imageView"
android:layout_toEndOf="@+id/serialmail"
android:layout_marginLeft="60px"
/>
</RelativeLayout>
...@@ -8,7 +8,7 @@ android { ...@@ -8,7 +8,7 @@ android {
targetSdkVersion 22 targetSdkVersion 22
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
resValue "string","SerialClass","com.yottacode.pictogram.tabletlibrary.gui.SerialActivity" resValue "string", "SerialClass", "com.yottacode.pictogram.tabletlibrary.gui.SerialActivity"
resValue "integer", "rows", "5" resValue "integer", "rows", "5"
resValue "integer", "columns", "10" resValue "integer", "columns", "10"
resValue "integer", "rows_big", "4" resValue "integer", "rows_big", "4"
...@@ -27,8 +27,8 @@ android { ...@@ -27,8 +27,8 @@ android {
} }
dependencies { dependencies {
compile 'com.android.support:appcompat-v7:24.+'
compile 'com.android.support:support-v4:24.1.1'
compile fileTree(include: ['*.jar'], dir: 'libs') compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':commonlibrary') compile project(':commonlibrary')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
} }
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yottacode.pictogram.tabletlibrary"> package="com.yottacode.pictogram.tabletlibrary">
<application android:allowBackup="true" android:label="@string/app_name" <application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"> android:supportsRtl="true">
</application> </application>
......
package com.yottacode.pictogram.tabletlibrary.gui;
import android.app.Activity;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.tabletlibrary.R;
import java.io.IOException;
import java.util.Vector;
/**
* Created by german on 20/12/2016.
*/
public class CustomListLogin extends ArrayAdapter<User>{
private final Activity context;
public CustomListLogin(Activity context, Vector<User> users) {
super(context,R.layout.user_login_item, users);
this.context = context;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View rowView= inflater.inflate(R.layout.user_login_item, null, true);
TextView txtName = (TextView) rowView.findViewById(R.id.label_name);
txtName.setText(getItem(position).is_supervisor() ? getItem(position).get_name_sup() : getItem(position).get_name_stu());
TextView txtSurname = (TextView) rowView.findViewById(R.id.label_surname);
txtSurname.setText(getItem(position).is_supervisor() ? getItem(position).get_surname_sup() : getItem(position).get_surname_stu());
ImageView imageView = (ImageView) rowView.findViewById(R.id.photo);
try {
Bitmap photo=getItem(position).is_supervisor() ? getItem(position).get_bitmap_sup(getContext()) : getItem(position).get_bitmap_stu(getContext());
if (photo!=null) imageView.setImageBitmap(photo);
else imageView.setImageResource(R.drawable.anonymous_student);
} catch (IOException e) {
e.printStackTrace();
}
return rowView;
}
}
...@@ -14,7 +14,6 @@ import android.widget.ImageView; ...@@ -14,7 +14,6 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import com.yottacode.pictogram.net.ImgDownloader; import com.yottacode.pictogram.net.ImgDownloader;
import com.yottacode.pictogram.net.iImgDownloaderListener;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tools.Img; import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
...@@ -86,7 +85,7 @@ public class LoginActivity extends FragmentActivity { ...@@ -86,7 +85,7 @@ public class LoginActivity extends FragmentActivity {
this.getIntent().getStringExtra("pic"), this.getIntent().getStringExtra("pic"),
Img.SUPERVISOR Img.SUPERVISOR
)); ));
ImgDownloader downloader = new ImgDownloader(this, new iImgDownloaderListener() { ImgDownloader downloader = new ImgDownloader(this, new ImgDownloader.iImgDownloaderListener() {
@Override @Override
public void loadComplete() { public void loadComplete() {
try { try {
...@@ -113,7 +112,7 @@ public class LoginActivity extends FragmentActivity { ...@@ -113,7 +112,7 @@ public class LoginActivity extends FragmentActivity {
@Override @Override
protected void onStop() { protected void onStop() {
super.onStop(); super.onStop();
Log.i(LOG_TAG,"Closing app"); Log.i(LOG_TAG,"Closing Login window");
PCBcontext.getNetService().closeNotifyStatus(); PCBcontext.getNetService().closeNotifyStatus();
} }
} }
package com.yottacode.pictogram.tabletlibrary.gui; package com.yottacode.pictogram.tabletlibrary.gui;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.util.Log; import android.support.v4.content.ContextCompat;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
...@@ -32,6 +34,7 @@ public class PictoItemViewGenerator { ...@@ -32,6 +34,7 @@ public class PictoItemViewGenerator {
public static final int LAYOUT_BIG = R.layout.picto_grid_item_big; public static final int LAYOUT_BIG = R.layout.picto_grid_item_big;
public static int mirror_color=0; public static int mirror_color=0;
/** /**
* *
* @param picto Pictogram to set the legend text * @param picto Pictogram to set the legend text
...@@ -162,7 +165,8 @@ public class PictoItemViewGenerator { ...@@ -162,7 +165,8 @@ public class PictoItemViewGenerator {
if (convertView == null) { if (convertView == null) {
convertView = LayoutInflater.from(parent.getContext()).inflate(PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big() ? LAYOUT_BIG : LAYOUT, parent, false); convertView = LayoutInflater.from(parent.getContext()).inflate(PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big() ? LAYOUT_BIG : LAYOUT, parent, false);
} }
if (parent.getId()==R.id.tape_grid_view)
convertView.setPadding(0,0,0,0);
RelativeLayout layoutWrapper ; RelativeLayout layoutWrapper ;
FrameLayout layout ; FrameLayout layout ;
final ImageView pictoImage ; final ImageView pictoImage ;
...@@ -236,6 +240,7 @@ public class PictoItemViewGenerator { ...@@ -236,6 +240,7 @@ public class PictoItemViewGenerator {
pictoImage.setScaleY(scale[mirror_color%scale.length]); pictoImage.setScaleY(scale[mirror_color%scale.length]);
if (picto.is_highlight_background()) layout.setBackgroundColor(color[mirror_color%color.length]); if (picto.is_highlight_background()) layout.setBackgroundColor(color[mirror_color%color.length]);
} }
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
...@@ -244,4 +249,6 @@ public class PictoItemViewGenerator { ...@@ -244,4 +249,6 @@ public class PictoItemViewGenerator {
return convertView; return convertView;
} }
} }
package com.yottacode.pictogram.tabletlibrary.gui; package com.yottacode.pictogram.tabletlibrary.gui;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ListView;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.dao.UserLogin; import com.yottacode.pictogram.dao.UserLogin;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet; import com.yottacode.pictogram.tabletlibrary.net.NetServiceTablet;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
import org.json.JSONException;
import java.util.Vector;
/** /**
* A login screen that offers login via email/password. * A login screen that offers login via email/password.
...@@ -28,6 +37,11 @@ public class SerialActivity extends Activity { ...@@ -28,6 +37,11 @@ public class SerialActivity extends Activity {
// String constant for logs // String constant for logs
private final String LOG_TAG = this.getClass().getSimpleName(); // Or .getCanonicalName() private final String LOG_TAG = this.getClass().getSimpleName(); // Or .getCanonicalName()
EditText mSerialViewMail;
EditText mSerialViewPass;
LinearLayout stuList;
LinearLayout supList;
protected boolean is_legal_user(String user_name, Activity activity) {return true;} protected boolean is_legal_user(String user_name, Activity activity) {return true;}
/** /**
...@@ -41,62 +55,98 @@ public class SerialActivity extends Activity { ...@@ -41,62 +55,98 @@ public class SerialActivity extends Activity {
String username = intent.getStringExtra("switch_usr"); String username = intent.getStringExtra("switch_usr");
String password = intent.getStringExtra("switch_pwd"); String password = intent.getStringExtra("switch_pwd");
if (username==null) { if (username==null || password==null) {
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
username = settings.getString("username", ""); username = settings.getString("username", "");
password = settings.getString("password", ""); password = settings.getString("password", "");
} }
return new String[]{username,password}; return new String[]{username,password};
} }
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
PCBcontext.init(this, new NetServiceTablet());
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_serial);
//Initial keyboard hide
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
final EditText mSerialViewMail = (EditText) findViewById(R.id.serialmail); private void createListSup(Vector<User> users){
final EditText mSerialViewPass = (EditText) findViewById(R.id.serialpass); final Vector<User> supUsers = new Vector<>();
Vector<Integer> idUsers=new Vector<>();
String default_user[]=loginUserPolicy(); //Rellenar la lista con solo usuarios supervisor
String username=default_user[0]; if(!users.isEmpty()){
String password=default_user[1]; for(User user: users){
if(user.is_supervisor() && !idUsers.contains(user.get_id_sup())) {
supUsers.add(user);
idUsers.add(user.get_id_sup());
}
}
}
// Escribo el último valor indicado de username if(!supUsers.isEmpty()){
mSerialViewMail.setText(username); CustomListLogin adapterSup = new CustomListLogin(this,supUsers);
mSerialViewPass.setText(password); ListView listaSup = (ListView) findViewById(R.id.supList);
listaSup.setAdapter(adapterSup);
listaSup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
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", supUsers.elementAt(position).get_email_sup());
editor.putString("password", supUsers.elementAt(position).get_pwd_sup());
editor.commit();
new UserLogin().login(supUsers.elementAt(position).get_email_sup(),
supUsers.elementAt(position).get_pwd_sup(),SerialActivity.this, PictogramActivity.class, LoginActivity.class);
}
});
}
}
final LinearLayout stuList = (LinearLayout) findViewById(R.id.stuLay); private void createListStu(Vector<User> users){
final LinearLayout supList = (LinearLayout) findViewById(R.id.supLay); final Vector<User> stuUsers = new Vector<>();
Vector<Integer> idUsers=new Vector<>();
mSerialViewMail.setOnFocusChangeListener(new View.OnFocusChangeListener() { //Rellenar la lista con solo usuarios supervisor
@Override if(!users.isEmpty()){
public void onFocusChange(View view,boolean hasFocus) { for(User user: users){
if(hasFocus){ if(!user.is_supervisor()) {
stuList.setVisibility(View.INVISIBLE); stuUsers.add(user);
supList.setVisibility(View.INVISIBLE); idUsers.add(user.get_id_stu());
} }
} }
}); }
mSerialViewPass.setOnFocusChangeListener(new View.OnFocusChangeListener() { if(!stuUsers.isEmpty()){
@Override CustomListLogin adapterStu = new CustomListLogin(this,stuUsers);
public void onFocusChange(View view,boolean hasFocus) { ListView listaStu = (ListView) findViewById(R.id.stuList);
if(hasFocus){ listaStu.setAdapter(adapterStu);
stuList.setVisibility(View.INVISIBLE); listaStu.setOnItemClickListener(new AdapterView.OnItemClickListener() {
supList.setVisibility(View.INVISIBLE); @Override
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_nickname_stu());
editor.putString("password", stuUsers.elementAt(position).get_pwd_stu());
editor.commit();
new UserLogin().login(stuUsers.elementAt(position).get_nickname_stu(),
stuUsers.elementAt(position).get_pwd_stu(),SerialActivity.this, PictogramActivity.class, LoginActivity.class);
} }
} });
}); }
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
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);
//Initial keyboard hide
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
final InputMethodManager imm = (InputMethodManager) this
.getSystemService(Context.INPUT_METHOD_SERVICE);
// Escribo el último valor indicado de username mSerialViewMail = (EditText) findViewById(R.id.serialmail);
mSerialViewMail.setText(username); mSerialViewPass = (EditText) findViewById(R.id.serialpass);
if (!username.equals("") && !password.equals("") && !getIntent().getBooleanExtra("resetPrevUser", true)) new UserLogin().login(username, password,SerialActivity.this, PictogramActivity.class, LoginActivity.class); stuList = (LinearLayout) findViewById(R.id.stuLay);
supList = (LinearLayout) findViewById(R.id.supLay);
Button mEntrarButton = (Button) findViewById(R.id.entrar_button); Button mEntrarButton = (Button) findViewById(R.id.entrar_button);
mEntrarButton.setOnClickListener(new OnClickListener() { mEntrarButton.setOnClickListener(new OnClickListener() {
...@@ -118,4 +168,34 @@ public class SerialActivity extends Activity { ...@@ -118,4 +168,34 @@ public class SerialActivity extends Activity {
}); });
} }
@Override
public void onStart() {
Vector<User> users;
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];
String password = default_user[1];
// Escribo el último valor indicado de username
mSerialViewMail.setText(username);
mSerialViewPass.setText(password);
if (!username.equals("") && !password.equals("") && !getIntent().getBooleanExtra("resetPrevUser", true))
new UserLogin().login(username, password, SerialActivity.this, PictogramActivity.class, LoginActivity.class);
super.onStart();
try {
users = PCBcontext.getDevice().getUsers();
createListSup(users);
createListStu(users);
} catch (JSONException e) {
e.printStackTrace();
Log.e(this.getClass().getCanonicalName(), e.getMessage());
}
}
} }
...@@ -14,10 +14,8 @@ import android.widget.AdapterView; ...@@ -14,10 +14,8 @@ import android.widget.AdapterView;
import android.widget.GridView; import android.widget.GridView;
import com.yottacode.net.RestapiWrapper; import com.yottacode.net.RestapiWrapper;
import com.yottacode.net.iRestapiListener;
import com.yottacode.pictogram.dao.User; import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.ImgDownloader; import com.yottacode.pictogram.net.ImgDownloader;
import com.yottacode.pictogram.net.iImgDownloaderListener;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tools.Img; import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
...@@ -113,7 +111,7 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -113,7 +111,7 @@ public class StudentFragmentGrid extends Fragment{
Log.i(this.getClass().getCanonicalName(),"Loading vocabulary for "+new_user.get_name_stu()); Log.i(this.getClass().getCanonicalName(),"Loading vocabulary for "+new_user.get_name_stu());
progressDialog=ProgressDialog.show(getActivity(), getString(R.string.loadingGrammar), progressDialog=ProgressDialog.show(getActivity(), getString(R.string.loadingGrammar),
getString(R.string.userLoadingTxt), false, false); getString(R.string.userLoadingTxt), false, false);
PCBcontext.set_user(new_user, intent.getStringExtra("token"), new iImgDownloaderListener() { PCBcontext.set_user(new_user, intent.getStringExtra("token"), new ImgDownloader.iImgDownloaderListener() {
@Override @Override
public void loadComplete() { public void loadComplete() {
if (progressDialog!=null && progressDialog.isShowing()) progressDialog.dismiss(); if (progressDialog!=null && progressDialog.isShowing()) progressDialog.dismiss();
...@@ -163,7 +161,7 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -163,7 +161,7 @@ public class StudentFragmentGrid extends Fragment{
} //for } //for
progressDialog= ProgressDialog.show(getActivity(), getString(R.string.imguserLoadingMsg), progressDialog= ProgressDialog.show(getActivity(), getString(R.string.imguserLoadingMsg),
getString(R.string.userLoadingTxt), false, false); getString(R.string.userLoadingTxt), false, false);
ImgDownloader downloader = new ImgDownloader(getActivity(), new iImgDownloaderListener() { ImgDownloader downloader = new ImgDownloader(getActivity(), new ImgDownloader.iImgDownloaderListener() {
private void loaded() { private void loaded() {
if (progressDialog!=null && progressDialog.isShowing()) progressDialog.dismiss(); if (progressDialog!=null && progressDialog.isShowing()) progressDialog.dismiss();
...@@ -208,9 +206,9 @@ public class StudentFragmentGrid extends Fragment{ ...@@ -208,9 +206,9 @@ public class StudentFragmentGrid extends Fragment{
String operation = "sup/" + sup_id + "/students"; String operation = "sup/" + sup_id + "/students";
progressDialog= ProgressDialog.show(getActivity(), getString(R.string.userLoadingTxt), progressDialog= ProgressDialog.show(getActivity(), getString(R.string.userLoadingTxt),
getString(R.string.userLoadingTxt), false, false); getString(R.string.userLoadingTxt), false, false);
wrapper.ask(operation, new iRestapiListener() { wrapper.ask(operation, new RestapiWrapper.iRestapiListener() {
@Override @Override
public void error(Exception e) { public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getName(), " Server restapi error: " + e.getLocalizedMessage()); Log.e(this.getClass().getName(), " Server restapi error: " + e.getLocalizedMessage());
if (progressDialog.isShowing()) progressDialog.dismiss(); if (progressDialog.isShowing()) progressDialog.dismiss();
GUITools.show_alert(getActivity(), R.string.loginErrorTxt, getString(R.string.serverError), new GUITools.iOKListener() { GUITools.show_alert(getActivity(), R.string.loginErrorTxt, getString(R.string.serverError), new GUITools.iOKListener() {
......
...@@ -9,6 +9,7 @@ import android.view.ViewGroup; ...@@ -9,6 +9,7 @@ import android.view.ViewGroup;
import android.widget.BaseAdapter; import android.widget.BaseAdapter;
import com.yottacode.pictogram.dao.Picto; import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.pictogram.tts.TTSHelper; import com.yottacode.pictogram.tts.TTSHelper;
import java.util.Iterator; import java.util.Iterator;
...@@ -52,6 +53,7 @@ public class TapeAdapter extends BaseAdapter { ...@@ -52,6 +53,7 @@ public class TapeAdapter extends BaseAdapter {
pictoLinkedList.remove(position); pictoLinkedList.remove(position);
} }
// ELIMINAR el último ITEM DEL ADAPTADOR // ELIMINAR el último ITEM DEL ADAPTADOR
public void deleteLastView(){ public void deleteLastView(){
// Controlar excepcion al intentar eliminar el último cuando no hay elementos // Controlar excepcion al intentar eliminar el último cuando no hay elementos
...@@ -64,7 +66,7 @@ public class TapeAdapter extends BaseAdapter { ...@@ -64,7 +66,7 @@ public class TapeAdapter extends BaseAdapter {
// ELIMINAR TODOS LOS ITEMS DEL ADAPTADOR // ELIMINAR TODOS LOS ITEMS DEL ADAPTADOR
public void endPlay(){ public void endPlay(){
pictoLinkedList.clear(); if (PCBcontext.getPcbdb().getCurrentUser().delete_tape_after_delivery()) pictoLinkedList.clear();
play=false; play=false;
} }
...@@ -96,10 +98,11 @@ public class TapeAdapter extends BaseAdapter { ...@@ -96,10 +98,11 @@ public class TapeAdapter extends BaseAdapter {
@Override @Override
public View getView(int position, View convertView, ViewGroup parent){ public View getView(int position, View convertView, ViewGroup parent){
return PictoItemViewGenerator.getPictoView( View pictoView = PictoItemViewGenerator.getPictoView(
this.pictoLinkedList.get(position), this.pictoLinkedList.get(position),
convertView, convertView,
parent,true); parent, true);
return pictoView;
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) @TargetApi(Build.VERSION_CODES.LOLLIPOP)
......
package com.yottacode.pictogram.tabletlibrary.gui;
import android.content.Context;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ViewGroup;
public class customViewGroup extends ViewGroup {
public customViewGroup(Context context) {
super(context);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
Log.i(this.getClass().getCanonicalName(), "**********Intercepted");
return false;
}
}
package com.yottacode.pictogram.tabletlibrary.gui.session;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.tools.BitmapTools;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Vector;
/**
* Created by Fernando on 18/12/2016.
*/
class PictoAdapter extends BaseAdapter {
public void setCurrentMsg(int currentMsg) {
this.currentMsg = currentMsg;
}
public static class Item {
Bitmap img;
String secs;
StringBuilder sentence;
public Item(Bitmap img, String secs) {
this.img=img;
this.secs=secs;
this.sentence=new StringBuilder("");
}
Bitmap getImg() {
return img;
}
String getTime() {
return secs;
}
public String getMsg() { return sentence.toString();}
public void setImg(Bitmap currmsg, String word) {
this.img=currmsg;
sentence.append(" "+word);
}
}
Context context;
Vector<Item> msg;
private int currentMsg=0;
final long base_time=new Date().getTime();
private static LayoutInflater inflater = null;
public PictoAdapter(Context context) {
this.context = context;
msg=new Vector<>(3);
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
private String getTimeDiff(long time) {
long mills = time - this.base_time;
int mins = (int) (mills / (1000*60));
int secs = (int)(mills/(1000)) - mins*60;
return "+"+mins+ "' " + secs+"''";
}
@Override
public int getCount() {
return msg.size();
}
@Override
public Item getItem(int position) {
return msg.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View vi = convertView;
if (vi == null)
vi = inflater.inflate(R.layout.session_picto_view, null);
ImageView picto=(ImageView)vi.findViewById(R.id.session_picto);
picto.setImageBitmap(this.msg.get(position).getImg());
if (currentMsg== position)
vi.setBackgroundColor(Color.LTGRAY);
else
vi.setBackgroundColor(Color.TRANSPARENT);
return vi;
}
public void addItem(Bitmap bmp,String text) {
Item item=this.msg.get(this.msg.size()-1);
Bitmap oldmsg=item.getImg();
bmp=set_text(context,bmp,getTimeDiff(new Date().getTime()));
Bitmap currmsg=combineImages(oldmsg,bmp);
item.setImg(currmsg,text);
}
public void evaluateItem(Bitmap bmp, String evaluation,int position) {
Item item=this.msg.get(position);
Bitmap oldmsg=item.getImg();
float width =context.getResources().getDimension(R.dimen.picto_session_width);
float height = context.getResources().getDimension(R.dimen.picto_session_height);
bmp=new BitmapTools(bmp).resize((int)width ,(int)height).get();
bmp=set_text(context,bmp,getTimeDiff(new Date().getTime()));
Bitmap currmsg=this.currentMsg==this.msg.size()-1 ? combineImages(oldmsg,bmp) : updateImage(oldmsg,bmp);
item.setImg(currmsg,": "+evaluation);
}
public int newMsg() {
Bitmap bmp=BitmapFactory.decodeResource(context.getResources(),
R.drawable.application_online);
float width =context.getResources().getDimension(R.dimen.picto_session_width);
float height = context.getResources().getDimension(R.dimen.picto_session_height);
bmp=new BitmapTools(bmp).resize((int)width,(int)height).get();
Calendar calendar = GregorianCalendar.getInstance(); // creates a new calendar instance
calendar.setTime(new Date()); // assigns calendar to given date
String time= calendar.get(Calendar.HOUR_OF_DAY)+":"+calendar.get(Calendar.MINUTE)+":"+calendar.get(Calendar.SECOND);
bmp=set_text(context,bmp,time);
this.currentMsg = this.msg.size();
msg.add(new Item(bmp, time));
return msg.size()-1;
}
private Bitmap combineImages(Bitmap c, Bitmap s) {
Bitmap cs = null;
int width, height = 0;
width = c.getWidth() + s.getWidth();
height = c.getHeight();
cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(cs);
comboImage.drawBitmap(c, 0f, 0f, null);
comboImage.drawBitmap(s, c.getWidth(), 0f, null);
return cs;
}
private Bitmap updateImage(Bitmap c, Bitmap s) {
Bitmap cs = null;
int width= c.getWidth(), height= c.getHeight();
int cutwidth=c.getWidth()-s.getWidth();
cs = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas comboImage = new Canvas(cs);
comboImage.drawBitmap(Bitmap.createBitmap(c,0,0,cutwidth,height), 0f, 0f, null);
comboImage.drawBitmap(s, c.getWidth()-s.getWidth(), 0f, null);
return cs;
}
static Bitmap set_text(Context context,Bitmap param_bitmap,String texto) {
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
float width = param_bitmap.getWidth();
float height=param_bitmap.getHeight();
android.graphics.Bitmap.Config bitmapConfig = param_bitmap.getConfig();
if (bitmapConfig == null) {
bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
}
Bitmap bitmap = param_bitmap.copy(bitmapConfig, true);
Canvas canvas = new Canvas(bitmap);
Bitmap bm = Bitmap.createScaledBitmap(bitmap, (int)Math.round(0.8*width), (int)Math.round(0.8*height), false);
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); //Poner en blanco el bitmap original para dibujar encima
canvas.drawBitmap(bm, 0, 0, paint);
TextView textView = new TextView(context);
textView.layout(0, 20, 100, 100);
textView.setPadding(0, 0, 0, 0);
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, 13);
textView.setTextColor(Color.BLACK);
textView.setBackgroundColor(Color.LTGRAY);
textView.setWidth(100);
textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setMaxLines(1);
textView.setText(texto);
textView.setDrawingCacheEnabled(true);
canvas.drawBitmap(textView.getDrawingCache(), 0, 60, null);
return bitmap;
}
public int getCurrentPosition() {
return currentMsg;
}
public String getCurrentMsgText() {
return this.getItem(currentMsg).getMsg();
}
}
package com.yottacode.pictogram.tabletlibrary.gui.session;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.net.websockets.ActionTalk;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.BitmapTools;
import java.io.IOException;
public class SessionFragment extends Fragment implements ActionTalk.iActionListener {
interface iSessionFragment {
public void newMsg(int msg_pos);
public void selectedMsg(int msg_pos);
public void play_msg(int msg_pos);
}
private iSessionFragment mListener=null;
ListView list_pictomsg;
PictoAdapter adapter_pictomsg;
private boolean paused=false;
public SessionFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_session, container, false);
list_pictomsg = (ListView) view.findViewById(R.id.session_pictomsg_list);
adapter_pictomsg=new PictoAdapter(this.getContext());
list_pictomsg.setAdapter(adapter_pictomsg);
list_pictomsg.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
((PictoAdapter)list_pictomsg.getAdapter()).setCurrentMsg(position);
mListener.selectedMsg(position);
((PictoAdapter)list_pictomsg.getAdapter()).notifyDataSetChanged();
}
});
mListener.newMsg(this.adapter_pictomsg.getCount());
return view;
}
@SuppressWarnings("deprecation")
@Override
public void onAttach(Activity context) {
super.onAttach(context);
if ( mListener==null)
if (context instanceof iSessionFragment ) {
mListener = (iSessionFragment) context;
PCBcontext.getVocabulary().addActionTalkListener(this);
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
if ( mListener==null)
if (context instanceof iSessionFragment ) {
mListener = (iSessionFragment) context;
PCBcontext.getVocabulary().addActionTalkListener(this);
} else {
throw new RuntimeException(context.toString()
+ " must implement OnFragmentInteractionListener");
}
}
@Override
public void onDetach() {
super.onDetach();
PCBcontext.getVocabulary().removeActionTalkListener(this);
}
@Override
public void action(action action, int picto_cat, int picto_id) {
if (action==ActionTalk.iActionListener.action.show) {
if (!paused) {
mListener.play_msg(this.adapter_pictomsg.getCount()-1);
mListener.newMsg(this.adapter_pictomsg.getCount());
}
} else try {
Picto picto=PCBcontext.getVocabulary().get_picto(picto_cat,picto_id);
Bitmap bmp=picto.get_bitmap(getContext());
if (paused) {
bmp=bmp.copy(bmp.getConfig(),true);
new BitmapTools(bmp).paintPause();
}
this.adapter_pictomsg.addItem(bmp,picto.get_translation());
getActivity().runOnUiThread(new Runnable() {
public void run() {
adapter_pictomsg.notifyDataSetChanged();
}});
} catch (IOException e) {
e.printStackTrace();
}
}
public int newMsg() {
int newmsg_position=this.adapter_pictomsg.newMsg();
getActivity().runOnUiThread(new Runnable() {
public void run() {
adapter_pictomsg.notifyDataSetChanged();
}});
return newmsg_position;
}
public void evaluateMsg(Bitmap bmp, String evaluation,int position) {
this.adapter_pictomsg.evaluateItem(bmp, evaluation,position);
getActivity().runOnUiThread(new Runnable() {
public void run() {
adapter_pictomsg.notifyDataSetChanged();
}});
}
public void paused(boolean isChecked) {
this.paused=isChecked;
}
public int get_current_msg_pos() {
return this.adapter_pictomsg.getCurrentPosition();
}
public String get_current_msg_text() {
return this.adapter_pictomsg.getCurrentMsgText();
}
public int get_last_msg_pos() {
return adapter_pictomsg.getCount()-1;
}
}
...@@ -6,7 +6,7 @@ import android.support.v4.app.NotificationCompat; ...@@ -6,7 +6,7 @@ import android.support.v4.app.NotificationCompat;
import android.util.Log; import android.util.Log;
import com.yottacode.pictogram.dao.User; import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.iNetServiceDevice; import com.yottacode.pictogram.net.NetService;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.PictogramActivity; import com.yottacode.pictogram.tabletlibrary.gui.PictogramActivity;
import com.yottacode.pictogram.tabletlibrary.gui.SerialActivity; import com.yottacode.pictogram.tabletlibrary.gui.SerialActivity;
...@@ -18,7 +18,7 @@ import com.yottacode.pictogram.tools.PCBcontext; ...@@ -18,7 +18,7 @@ import com.yottacode.pictogram.tools.PCBcontext;
* @version 1.0 * @version 1.0
*/ */
public class NetServiceTablet implements iNetServiceDevice { public class NetServiceTablet implements NetService.iNetServiceDevice {
private static NotificationCompat.Builder builder; private static NotificationCompat.Builder builder;
private PictogramActivity pictogramActivity; private PictogramActivity pictogramActivity;
...@@ -83,6 +83,10 @@ public class NetServiceTablet implements iNetServiceDevice { ...@@ -83,6 +83,10 @@ public class NetServiceTablet implements iNetServiceDevice {
serialActivity = new Intent(PCBcontext.getContext(), serialClass); serialActivity = new Intent(PCBcontext.getContext(), serialClass);
} }
serialActivity.putExtra("resetPrevUser", !direct_login); 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); PCBcontext.getContext().startActivity(serialActivity);
} }
......
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="500"
android:fromXDelta="100%p"
android:toXDelta="0"
android:interpolator="@android:anim/linear_interpolator" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="500"
android:fromXDelta="0"
android:toXDelta="-100%p"
android:interpolator="@android:anim/linear_interpolator" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="500"
android:fromXDelta="-100%p"
android:toXDelta="0"
android:interpolator="@android:anim/linear_interpolator" />
</set>
<?xml version="1.0" encoding="utf-8"?>
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:duration="500"
android:fromXDelta="0%"
android:toXDelta="100%"
android:fromYDelta="0%"
android:toYDelta="0%"
android:interpolator="@android:anim/linear_interpolator" />
</set>
...@@ -86,6 +86,18 @@ ...@@ -86,6 +86,18 @@
android:id="@+id/loginStudentGrid" android:id="@+id/loginStudentGrid"
android:layout_gravity="center" android:layout_gravity="center"
tools:layout="@layout/fragment_new_student" /> tools:layout="@layout/fragment_new_student" />
</FrameLayout> </FrameLayout>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="@+id/imageView4"
android:background="@drawable/pictogram_logo"
android:layout_marginRight="30dp"
android:layout_below="@+id/view"
android:layout_alignEnd="@+id/loginTopbarLayout"
android:layout_marginTop="320dp" />
</RelativeLayout> </RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".gui.SerialActivity"> tools:context=".gui.SerialActivity">
<ImageView <ImageView
android:layout_width="200px" android:layout_width="200px"
...@@ -21,6 +21,20 @@ ...@@ -21,6 +21,20 @@
android:layout_toEndOf="@+id/serialmail" /> android:layout_toEndOf="@+id/serialmail" />
<EditText <EditText
android:id="@+id/serialmail"
android:layout_width="400px"
android:layout_height="wrap_content"
android:hint="@string/prompt_serial_mail"
android:imeActionId="@+id/login"
android:imeOptions="actionUnspecified"
android:inputType="text"
android:maxLines="1"
android:layout_marginStart="145dp"
android:selectAllOnFocus="false"
android:layout_alignParentTop="true"
/>
<EditText
android:id="@+id/serialpass" android:id="@+id/serialpass"
android:layout_width="400px" android:layout_width="400px"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -30,92 +44,93 @@ ...@@ -30,92 +44,93 @@
android:imeOptions="actionUnspecified" android:imeOptions="actionUnspecified"
android:inputType="textPassword" android:inputType="textPassword"
android:maxLines="1" android:maxLines="1"
android:singleLine="true"
android:layout_below="@+id/serialmail" android:layout_below="@+id/serialmail"
android:layout_toStartOf="@+id/imageView" /> android:layout_toStartOf="@+id/imageView"
android:selectAllOnFocus="false"
android:singleLine="false" />
<Button <Button
android:id="@+id/entrar_button" style="?android:textAppearanceSmall" android:id="@+id/entrar_button" style="?android:textAppearanceSmall"
android:layout_width="400px" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="11dp" android:layout_marginTop="11dp"
android:text="@string/action_entrar" android:text="@string/action_entrar"
android:textStyle="bold" android:textStyle="bold"
android:layout_below="@+id/serialpass" android:layout_below="@+id/serialpass"
android:layout_alignStart="@+id/serialpass" /> android:layout_alignStart="@+id/serialpass"
android:layout_alignEnd="@+id/serialpass" />
<View <View
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" android:layout_height="4dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="@android:color/darker_gray" android:background="@android:color/darker_gray"
android:layout_below="@+id/entrar_button" android:layout_below="@+id/entrar_button"
android:layout_alignParentEnd="true" android:layout_alignEnd="@+id/supLay"
android:layout_marginEnd="18dp" /> android:layout_alignStart="@id/entrar_button"
android:id="@+id/loginseparator"
<EditText />
android:id="@+id/serialmail"
android:layout_width="400px"
android:layout_height="wrap_content"
android:hint="@string/prompt_serial_mail"
android:imeActionId="@+id/login"
android:imeOptions="actionUnspecified"
android:inputType="text"
android:maxLines="1"
android:layout_marginStart="212dp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<LinearLayout <LinearLayout
android:layout_below="@+id/loginseparator"
android:orientation="vertical" android:orientation="vertical"
android:background="@color/blue" android:layout_height="wrap_content"
android:layout_height="350px" android:background="@color/common_plus_signin_btn_text_dark_pressed"
android:layout_width="400px" android:layout_width="200dp"
android:layout_alignParentBottom="true" android:layout_alignStart="@id/entrar_button"
android:layout_alignStart="@+id/entrar_button" android:id="@+id/stuLay">
android:layout_marginStart="270dp"
android:id="@+id/supLay">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/labelSup" android:id="@+id/labelStu"
tools:text="Supervisores" tools:text="Alumnos"
android:text="@string/supervisores" android:text="@string/alumnos"
android:textAppearance="@style/TextAppearance.AppCompat"
android:textAlignment="center" android:textAlignment="center"
android:textSize="18sp" /> android:textSize="18sp"
android:textColor="@android:color/black"
android:background="@color/common_plus_signin_btn_text_light_disabled" />
<ListView <ListView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/supList" /> android:id="@+id/stuList"
android:divider="@color/common_plus_signin_btn_text_light_disabled"
android:dividerHeight="2px"
tools:paddingBottom="@dimen/small_padding" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_height="350px" android:background="@color/common_google_signin_btn_text_dark_default"
android:layout_marginStart="67dp" android:layout_height="wrap_content"
android:background="@color/darkred" android:layout_width="200dp"
android:layout_width="400px" android:layout_marginStart="10dp"
android:layout_alignParentBottom="true" android:layout_alignTop="@id/stuLay"
android:layout_alignParentStart="true" android:layout_toEndOf="@id/stuLay"
android:id="@+id/stuLay"> android:id="@+id/supLay"
android:gravity="right">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/labelStu" android:id="@+id/labelSup"
tools:text="Alumnos" tools:text="Supervisores"
android:text="@string/alumnos" android:text="@string/supervisores"
android:textAppearance="@style/TextAppearance.AppCompat"
android:textAlignment="center" android:textAlignment="center"
android:textSize="18sp" /> android:textSize="18sp"
android:textColor="@android:color/black"
android:background="@color/common_plus_signin_btn_text_light_disabled" />
<ListView <ListView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/stuList" /> android:id="@+id/supList"
android:divider="@color/common_plus_signin_btn_text_light_disabled"
android:dividerHeight="2px"
android:paddingBottom="@dimen/small_padding" />
</LinearLayout> </LinearLayout>
</RelativeLayout> </RelativeLayout>
......
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
tools:context="com.yottacode.pictogram.tabletlibrary.gui.session.SessionActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_margin="8dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="0dp"
android:id="@+id/sessionTopbarLayout">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:id="@+id/sessionTopbarStudentPhoto"
android:layout_gravity="left"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:background="@color/accent_material_dark"
android:scaleType="centerCrop" />
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/sessionTopbarStudentNameLayout"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/sessionTopbarStudentPhoto"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="@+id/sessionTopbarStudentFullName" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
android:id="@+id/sessionTopbarStudentUserName"
android:textColor="@color/abc_secondary_text_material_light" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/methodLayout"
android:layout_centerVertical="true"
android:gravity="end"
android:layout_toLeftOf="@+id/sessionPauseBtn"
android:layout_marginRight="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="@+id/sessionTopbarMethodName"
android:textColor="@color/blue" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
android:id="@+id/sessionTopbarInstructionName"
android:textColor="@color/blue" />
</LinearLayout>
<ToggleButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sessionPauseBtn"
android:layout_alignParentBottom="true"
android:textOff="||"
android:textOn="||"
android:layout_toLeftOf="@+id/sessionOnOffBtn"
android:textColorLink="@color/darkgreen"
android:layout_marginRight="10px" />
<ToggleButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/sessionOnOffBtn"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:textOff="REC"
android:textOn="REC"
android:textColorLink="@color/darkgreen" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="@android:color/darker_gray"
android:layout_marginBottom="16dp"
android:id="@+id/view"
android:layout_below="@+id/sessionTopbarLayout"
android:layout_marginTop="0dp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:id="@+id/sessionFragmentLayout"
android:layout_below="@+id/view"
android:layout_alignParentEnd="true"
android:layout_height="310dp">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/sessions_fragment_container"
android:layout_weight="1"
android:layout_alignParentStart="true" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"
android:id="@+id/view_as2"
android:layout_below="@+id/sessionFragmentLayout"
android:layout_alignParentEnd="true"
android:layout_marginBottom="16dp" />
<LinearLayout
android:id="@+id/view_session_buttons0"
android:layout_below="@+id/view_as2"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_gravity="top"
android:layout_marginBottom="10dp">
<LinearLayout
android:id="@+id/view_session_buttons"
android:layout_below="@+id/view_as2"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="84dp">
<Button style="@style/sessionBtn"
android:id="@+id/btn_correct"
android:background="@drawable/session_ok"
/>
<Button style="@style/sessionBtn"
android:id="@+id/btn_fail"
android:background="@drawable/session_fail"
/>
<Button style="@style/sessionBtn"
android:id="@+id/btn_spontaneous"
android:background="@drawable/session_spontaneous"
/>
<Button style="@style/sessionBtn"
android:id="@+id/btn_supervised"
android:background="@drawable/session_supervised"
/>
<Button style="@style/sessionBtn"
android:id="@+id/btn_model"
android:background="@drawable/session_model"
/>
<Button style="@style/sessionBtn"
android:id="@+id/btn_discarded"
android:background="@drawable/session_discarded"
android:layout_marginRight="20dp" />
</LinearLayout>
</LinearLayout>
<ScrollView
android:id="@+id/SCROLLER_ID"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:layout_toLeftOf="@+id/imageView3"
android:layout_toRightOf="@+id/view_session_buttons0"
android:layout_below="@+id/view_as2"
android:layout_alignBottom="@+id/imageView3"
android:layout_alignTop="@+id/imageView3"
android:fillViewport="true">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:ems="12"
android:id="@+id/session_serverlog"
android:layout_weight="1"
android:background="@color/common_google_signin_btn_text_light_disabled" />
</ScrollView>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
app:srcCompat="@drawable/pictogram_logo"
android:id="@+id/imageView3"
android:maxLines = "100"
android:background="@drawable/pictogram_logo"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
android:layout_gravity="right"
android:layout_weight="1"
android:layout_below="@+id/view_as2"
android:layout_alignEnd="@+id/sessionFragmentLayout"
android:layout_marginEnd="21dp" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/sessionTopbarLayout">
<TextView
android:text="@string/session_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
tools:textStyle="normal|bold"
android:textAppearance="@android:style/TextAppearance.DeviceDefault.Medium"
android:textStyle="normal|bold" />
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_below="@+id/sessionTopbarLayout">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4">
<TextView
android:text="@string/session_method"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="normal|bold"
android:textAlignment="center"
android:background="@color/common_google_signin_btn_text_light_disabled" />
<ListView
android:id="@+id/methodsListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical|center|center_horizontal"
android:padding="32dp"
android:horizontalSpacing="16dp"
android:verticalSpacing="16dp"
/>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:gravity="left|center_vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3">
<TextView
android:text="@string/session_instruction"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="normal|bold"
android:background="@color/common_google_signin_btn_text_light_disabled"
android:textAlignment="center" />
<ListView
android:id="@+id/instructionsListView"
android:gravity="center_vertical|left"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="32dp"
android:horizontalSpacing="16dp"
android:verticalSpacing="16dp"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.yottacode.pictogram.tabletlibrary.gui.session.SessionFragment"
android:orientation="vertical" >
<ListView
android:id="@+id/session_pictomsg_list"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|start">
</ListView>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/sessionName"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_centerHorizontal="true"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:gravity="center" />
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="@dimen/picto_big_width"
android:layout_height="wrap_content" android:layout_height="@dimen/picto_big_height"
android:gravity="center_vertical|center|center_horizontal" android:gravity="center_vertical|center|center_horizontal"
android:id="@+id/picto_grid_item_layout_wrapper_big" android:id="@+id/picto_grid_item_layout_wrapper_big"
android:background="@drawable/picto_grid_item_border" android:background="@drawable/picto_grid_item_border"
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/picto_big_height" android:layout_height="match_parent"
android:id="@+id/picto_grid_item_layout_big" android:id="@+id/picto_grid_item_layout_big"
android:background="@color/picto_default_background" android:background="@color/picto_default_background"
android:padding="@dimen/picto_padding"> >
<ImageView <ImageView
android:id="@+id/picto_grid_item_image_big" android:id="@+id/picto_grid_item_image_big"
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:orientation="vertical"
<ListView android:layout_height="match_parent"
android:layout_width="match_parent" android:id="@+id/session_picto_layout"
android:background="@color/picto_default_background"
android:padding="@dimen/picto_padding">
<ImageView
android:id="@+id/session_picto"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@android:id/list" /> android:layout_width="wrap_content"
</LinearLayout> android:contentDescription="" />
\ No newline at end of file
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<TextView
android:text="Nombre"
android:layout_height="wrap_content"
android:id="@+id/label_name"
android:layout_weight="0.15"
android:textSize="18sp"
android:textColor="@android:color/black"
android:layout_alignTop="@+id/photo"
android:layout_toEndOf="@+id/photo"
android:layout_width="wrap_content"
android:layout_marginStart="15dp" />
<TextView
android:text="Apellidos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/label_surname"
android:textSize="18sp"
android:textAlignment="textStart"
android:textColor="@android:color/black"
android:layout_alignBottom="@+id/photo"
android:layout_toEndOf="@+id/photo"
android:layout_marginStart="15dp" />
<ImageView
app:srcCompat="@drawable/anonymous_student"
android:id="@+id/photo"
android:layout_weight="0.15"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
</RelativeLayout>
<resources>
<string name="app_name">com.yottacode.pictogram.Tablet</string>
<item name="maxInTape" type="integer">8</item>
<item name="maxInTape_big" type="integer">6</item>
<!---session-->
<string name="session_method">Method</string>
<string name="session_instruction">Instruction</string>
<string name="session_header">Seleccion de método e instrucción</string>
<string name="session_error">Error de conexión</string>
<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">Downloading instructions</string>
<string name="session_empty">Student without any method</string>
<string name="session_notclosed">Last session was not closed. Please close from </string>
<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>
<string name="session_log_endingsession">finalizando sesión</string>
<string name="session_log_newtry">nuevo ensayo</string>
<string name="session_log_endtry">ensayo finalizado</string>
<string name="session_log_evaluatedtry">ensayo evaluado</string>
<string name="session_log_pausedtry">sesión en pausa</string>
<string name="session_log_continuedtry">sesión retomada</string>
<string name="session_eval_success">ok</string>
<string name="session_eval_fail">fail</string>
<string name="session_eval_spontaneous">spontaneous</string>
<string name="session_eval_supervised">supervised</string>
<string name="session_eval_guide">guided</string>
<string name="session_eval_model">modeled</string>
<string name="session_eval_notevuated">not evaluated</string>
<string name="session_eval_discarded">discarded</string>
</resources>
<resources>
<string name="app_name">com.yottacode.pictogram.Tablet</string>
<item name="maxInTape" type="integer">8</item>
<item name="maxInTape_big" type="integer">6</item>
<!---session-->
<string name="session_method">Método</string>
<string name="session_insrtuction">Instrucción</string>
<string name="session_header">Seleccion de método e instrucción</string>
<string name="session_error">Error de conexión</string>
<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 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>
<string name="session_log_endingsession">finalizando sesión</string>
<string name="session_log_newtry">nuevo ensayo</string>
<string name="session_log_endtry">ensayo finalizado</string>
<string name="session_log_evaluatedtry">ensayo evaluado</string>
<string name="session_log_pausedtry">sesión en pausa</string>
<string name="session_log_continuedtry">sesión retomada</string>
<string name="session_eval_success">correcto</string>
<string name="session_eval_fail">incorrecto</string>
<string name="session_eval_spontaneous">espontáneo</string>
<string name="session_eval_supervised">supervisado</string>
<string name="session_eval_guide">guiado</string>
<string name="session_eval_model">modelado</string>
<string name="session_eval_notevuated">no evaluado</string>
<string name="session_eval_discarded">inválido</string>
</resources>
...@@ -4,4 +4,37 @@ ...@@ -4,4 +4,37 @@
<string name="supervisores">Supervisores</string> <string name="supervisores">Supervisores</string>
<item name="maxInTape" type="integer">8</item> <item name="maxInTape" type="integer">8</item>
<item name="maxInTape_big" type="integer">6</item> <item name="maxInTape_big" type="integer">6</item>
<!---session-->
<string name="session_method">Método</string>
<string name="session_instruction">Instrucción</string>
<string name="session_header">Select method and instruction</string>
<string name="session_error">Server Error </string>
<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 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>
<string name="session_log_endingsession">finalizando sesión</string>
<string name="session_log_newtry">nuevo ensayo</string>
<string name="session_log_endtry">ensayo finalizado</string>
<string name="session_log_evaluatedtry">ensayo evaluado</string>
<string name="session_log_pausedtry">sesión en pausa</string>
<string name="session_log_continuedtry">sesión retomada</string>
<string name="session_eval_success">correcto</string>
<string name="session_eval_fail">incorrecto</string>
<string name="session_eval_spontaneous">espontáneo</string>
<string name="session_eval_supervised">supervisado</string>
<string name="session_eval_guide">guiado</string>
<string name="session_eval_model">modelado</string>
<string name="session_eval_notevuated">no evaluado</string>
<string name="session_eval_discarded">inválido</string>
</resources> </resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="sessionBtn">
<item name="android:layout_height">64dp</item>
<item name="android:layout_width">64dp</item>
<item name="android:layout_marginLeft">20dp</item>
<item name="android:layout_gravity">center_vertical</item>
</style>
</resources>
...@@ -73,14 +73,6 @@ ...@@ -73,14 +73,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" /> <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/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" 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/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" 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/assets" type="java-test-resource" />
...@@ -89,6 +81,14 @@ ...@@ -89,6 +81,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" 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/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" 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/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
......
package com.yottacode.pictogram.watch.gui; package com.yottacode.pictogram.watch.gui;
import android.app.Activity; import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle; import android.os.Bundle;
import android.support.wearable.view.WatchViewStub; import android.support.wearable.view.WatchViewStub;
import android.util.Log; import android.util.Log;
import android.widget.TextView; import android.widget.TextView;
import com.yottacode.pictogram.dao.UserLogin; import com.yottacode.pictogram.dao.UserLogin;
import com.yottacode.pictogram.net.NetService;
import com.yottacode.pictogram.net.iNetServiceDevice;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.pictogram.watch.R; import com.yottacode.pictogram.watch.R;
import com.yottacode.pictogram.watch.net.NetServiceWatch; import com.yottacode.pictogram.watch.net.NetServiceWatch;
......
...@@ -5,7 +5,7 @@ import android.util.Log; ...@@ -5,7 +5,7 @@ import android.util.Log;
import android.widget.TextView; import android.widget.TextView;
import com.yottacode.pictogram.dao.User; import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.iNetServiceDevice; import com.yottacode.pictogram.net.NetService;
import com.yottacode.pictogram.tools.PCBcontext; import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.pictogram.watch.R; import com.yottacode.pictogram.watch.R;
...@@ -16,7 +16,7 @@ import com.yottacode.pictogram.watch.R; ...@@ -16,7 +16,7 @@ import com.yottacode.pictogram.watch.R;
* @version 1.0 * @version 1.0
*/ */
public class NetServiceWatch implements iNetServiceDevice { public class NetServiceWatch implements NetService.iNetServiceDevice {
TextView status; TextView status;
Class Activity; Class Activity;
......
...@@ -43,13 +43,6 @@ ...@@ -43,13 +43,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavorDebug/jni" isTestSource="false" /> <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/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavorDebug/shaders" 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/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/resources" 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" /> <sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/assets" type="java-test-resource" />
...@@ -58,6 +51,13 @@ ...@@ -58,6 +51,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/jni" isTestSource="true" /> <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/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDefaultFlavorDebug/shaders" 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/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/resources" 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" /> <sourceFolder url="file://$MODULE_DIR$/src/DefaultFlavor/assets" type="java-resource" />
...@@ -123,8 +123,6 @@ ...@@ -123,8 +123,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" 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/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" /> <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/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.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" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/9.2.1/jars" />
...@@ -133,13 +131,11 @@ ...@@ -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.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/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" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" /> <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content> </content>
<orderEntry type="jdk" jdkName="Android API 24 Platform" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 24 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" /> <uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.READ_CALL_LOG" /> <uses-permission android:name="android.permission.READ_CALL_LOG" />
<application <application
android:name=".kiosk.AppContext" android:name=".kiosk.AppContext"
...@@ -66,6 +66,12 @@ ...@@ -66,6 +66,12 @@
android:name=".kiosk.KioskService" android:name=".kiosk.KioskService"
android:exported="false" /> android:exported="false" />
<activity
android:name="com.yottacode.pictogram.tabletlibrary.gui.session.SessionActivity"
android:exported="true"
android:label="@string/app_name"
android:launchMode="singleInstance"
android:screenOrientation="landscape" />
</application> </application>
</manifest> </manifest>
...@@ -88,7 +88,7 @@ public class KioskService extends Service { ...@@ -88,7 +88,7 @@ public class KioskService extends Service {
private void restoreApp() { private void restoreApp() {
// Restart activity // Restart activity
Intent i = new Intent(ctx, com.yottacode.pictogram.tabletlibrary.gui.PictogramActivity.class); Intent i = new Intent(ctx, com.yottacode.pictogram.tabletlibrary.gui.SerialActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(i); ctx.startActivity(i);
} }
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Pictogram Tablet</string>
<string name="ilegal_user">There is not any supervisor named</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Pictogram Tablet</string>
<string name="ilegal_user"> No existe ningún supervisor </string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Pictogram Tablet</string>
<string name="ilegal_user">There is not any supervisor named</string>
</resources>
...@@ -59,6 +59,7 @@ mostradas más adelante hacen todo el trabajo, basta con ejecutar [./install.sh] ...@@ -59,6 +59,7 @@ mostradas más adelante hacen todo el trabajo, basta con ejecutar [./install.sh]
### Opción B (desarrollo en local) ### 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). 1. Instalar [virtualbox][1] y [vagrant][2] (version >1.5 para este último).
2. Ejecutar `vagrant up` desde este directorio. 2. Ejecutar `vagrant up` desde este directorio.
......
...@@ -5,6 +5,8 @@ Vagrant.configure(2) do |config| ...@@ -5,6 +5,8 @@ Vagrant.configure(2) do |config|
# "ubuntu/trusty64" for ubuntu environment # "ubuntu/trusty64" for ubuntu environment
# "boxcutter/centos72" for AWS similar environment # "boxcutter/centos72" for AWS similar environment
config.vm.box = "aspyatkin/ubuntu-16.04-server-amd64" config.vm.box = "aspyatkin/ubuntu-16.04-server-amd64"
# Set locale UTF-8
ENV['LC_ALL']="en_US.UTF-8"
config.vm.network "forwarded_port", guest: 1337, host: 1337 config.vm.network "forwarded_port", guest: 1337, host: 1337
config.vm.network "forwarded_port", guest: 80, host: 8080 config.vm.network "forwarded_port", guest: 80, host: 8080
config.ssh.insert_key = false config.ssh.insert_key = false
......
...@@ -140,6 +140,7 @@ CREATE TABLE IF NOT EXISTS `office` ( ...@@ -140,6 +140,7 @@ CREATE TABLE IF NOT EXISTS `office` (
`name` varchar(80) COLLATE utf8_unicode_ci NOT NULL, `name` varchar(80) COLLATE utf8_unicode_ci NOT NULL,
`logo_url` varchar(240) COLLATE utf8_unicode_ci NOT NULL, `logo_url` varchar(240) COLLATE utf8_unicode_ci NOT NULL,
`address` varchar(180) COLLATE utf8_unicode_ci NOT NULL, `address` varchar(180) COLLATE utf8_unicode_ci NOT NULL,
`postal_code` char(10) COLLATE utf8_unicode_ci NOT NULL,
`country` varchar(2) COLLATE utf8_unicode_ci NOT NULL, `country` varchar(2) COLLATE utf8_unicode_ci NOT NULL,
`lang` varchar(5) COLLATE utf8_unicode_ci NOT NULL, `lang` varchar(5) COLLATE utf8_unicode_ci NOT NULL,
`contact_person` varchar(80) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Contact person, main responsible', `contact_person` varchar(80) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Contact person, main responsible',
...@@ -308,6 +309,7 @@ CREATE TABLE IF NOT EXISTS `license` ( ...@@ -308,6 +309,7 @@ CREATE TABLE IF NOT EXISTS `license` (
`number` varchar(16) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `number` varchar(16) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`creation_ts` datetime DEFAULT CURRENT_TIMESTAMP, `creation_ts` datetime DEFAULT CURRENT_TIMESTAMP,
`activation_ts` datetime NULL, `activation_ts` datetime NULL,
`expiration_ts` datetime NULL,
`duration` int(11) DEFAULT 0, `duration` int(11) DEFAULT 0,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `number` (`number`), UNIQUE KEY `number` (`number`),
...@@ -532,7 +534,7 @@ ALTER TABLE `student` ...@@ -532,7 +534,7 @@ ALTER TABLE `student`
-- Filtros para la tabla `license` -- Filtros para la tabla `license`
-- --
ALTER TABLE `license` ALTER TABLE `license`
ADD CONSTRAINT `license_fk_1` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`); ADD CONSTRAINT `license_fk_1` FOREIGN KEY (`id_stu`) REFERENCES `student` (`id`) ON DELETE CASCADE;
-- --
-- Filtros para la tabla `supervisor` -- Filtros para la tabla `supervisor`
-- --
......
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