Pictogram 1.5 beta 3

CHANGELIST
- Pictogram Communicator y Pictogram Supervisor son ahora dos aplicaciones exclusivas de cada rol: supervisor o estudiate
- Bloqueo de Pictogram Communicator más seguro
- Botón Play más grande
- No se muestran pictos "tachados" en Pictogram Communicator (sí en Pictogram Supervisor)
- Se locutan frases con con voz grabada si todos los pictos tienen grabación asociada
- No se muestran tableros vacios, si no que se indica que debe añadirse al menos un picto visible
- Grabación de audio desde Pictogram Communicator más clara
- BUG: actualización de pictos desde Pictogram Communicator
- BUG: grabación de audio breve desde Pictogram Communicator
- BUG: imágenes de supervisores y alumnos se muestran correctamente en la ventana de login de Pictogram Communicator
- Soporte para actualización de imágenes manteniendo la clave anterior en SAILS
- Soporte para red de tableros en Pictogram Supervisor
parent 9cf4d38c
Showing with 168 additions and 130 deletions
...@@ -54,7 +54,7 @@ public abstract class PictoAction extends Action { ...@@ -54,7 +54,7 @@ public abstract class PictoAction extends Action {
final String param_picto_id="id"; final String param_picto_id="id";
final String param_picto_uri="uri"; final String param_picto_uri="uri";
final String param_picto_cat="category"; final String param_picto_cat="category";
JSONObject subsubPicto = new JSONObject().put(param_picto_id, picto.get_id()) JSONObject subsubPicto = new JSONObject().put(param_picto_id, picto.get_ImgId())
.put(param_picto_uri, picto.get_url()) .put(param_picto_uri, picto.get_url())
.put(param_picto_cat, picto.get_category()); .put(param_picto_cat, picto.get_category());
JSONObject attributes = new JSONObject(picto.get_json_attrs()); JSONObject attributes = new JSONObject(picto.get_json_attrs());
......
...@@ -67,7 +67,7 @@ public class PictosAction extends Action { ...@@ -67,7 +67,7 @@ public class PictosAction extends Action {
final String param_picto_id="id"; final String param_picto_id="id";
final String param_picto_uri="uri"; final String param_picto_uri="uri";
final String param_picto_cat="category"; final String param_picto_cat="category";
JSONObject subsubPicto = new JSONObject().put(param_picto_id, picto.get_id()) JSONObject subsubPicto = new JSONObject().put(param_picto_id, picto.get_ImgId())
.put(param_picto_uri, picto.get_url()) .put(param_picto_uri, picto.get_url())
.put(param_picto_cat, picto.get_category()); .put(param_picto_cat, picto.get_category());
......
...@@ -181,6 +181,7 @@ public class Device extends SQLiteOpenHelper { ...@@ -181,6 +181,7 @@ public class Device extends SQLiteOpenHelper {
cursor.getString(6), cursor.getString(7), cursor.getString(8),cursor.getString(9),cursor.getInt(10), cursor.getString(11), cursor.getString(6), cursor.getString(7), cursor.getString(8),cursor.getString(9),cursor.getInt(10), cursor.getString(11),
cursor.getString(12), cursor.getString(13),cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17), cursor.getString(12), cursor.getString(13),cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17),
cursor.getString(18),cursor.getString(19)); cursor.getString(18),cursor.getString(19));
cursor.close(); cursor.close();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ //db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
return user; return user;
...@@ -231,9 +232,10 @@ public class Device extends SQLiteOpenHelper { ...@@ -231,9 +232,10 @@ public class Device extends SQLiteOpenHelper {
while (cursor.moveToNext()) while (cursor.moveToNext())
if (cursor.getInt(10) == id_sup) if (cursor.getInt(10) == id_sup)
users.add(new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getInt(5), users.add(new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getInt(5),
cursor.getString(6), cursor.getString(7), cursor.getString(8),cursor.getString(9),cursor.getInt(10), cursor.getString(11), cursor.getString(6), cursor.getString(7), cursor.getString(8), cursor.getString(9), cursor.getInt(10), cursor.getString(11),
cursor.getString(12), cursor.getString(13),cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17), cursor.getString(12), cursor.getString(13), cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17),
cursor.getString(18),cursor.getString(19))); cursor.getString(18), cursor.getString(19)));
cursor.close(); cursor.close();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ //db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
return users; return users;
...@@ -295,14 +297,15 @@ public class Device extends SQLiteOpenHelper { ...@@ -295,14 +297,15 @@ public class Device extends SQLiteOpenHelper {
Vector<Integer> supervisors=new Vector<>(); Vector<Integer> supervisors=new Vector<>();
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.getInt(5), user = new User(cursor.getInt(0), cursor.getString(1), cursor.getString(2), cursor.getString(3), cursor.getString(4), cursor.getInt(5),
cursor.getString(6), cursor.getString(7), cursor.getString(8),cursor.getString(9),cursor.getInt(10), cursor.getString(11), cursor.getString(6), cursor.getString(7), cursor.getString(8), cursor.getString(9), cursor.getInt(10), cursor.getString(11),
cursor.getString(12), cursor.getString(13),cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17), cursor.getString(12), cursor.getString(13), cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17),
cursor.getString(18),cursor.getString(19)); cursor.getString(18), cursor.getString(19));
if (!context.getString(R.string.app_name).equals(context.getString(R.string.supervisorapp_name)) || !supervisors.contains(user.get_id_sup())) {
if (!context.getString(R.string.app_name).equals(context.getString(R.string.supervisorapp_name)) || !supervisors.contains(cursor.getInt(9))) users.add(user);
users.add(user); supervisors.add(user.get_id_sup());
supervisors.add(cursor.getInt(9)); }
} }
cursor.close(); cursor.close();
......
...@@ -254,9 +254,9 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -254,9 +254,9 @@ public class PCBDBHelper extends SQLiteOpenHelper {
values.put("id_stu", id_stu); values.put("id_stu", id_stu);
db.beginTransaction(); db.beginTransaction();
for (Picto picto : vocabulary) { for (Picto picto : vocabulary) {
Log.d(LOG_TAG,"inserting "+picto.get_id()+":"+picto.get_translation()+":"+picto.get_json_attrs()+"-id_sce: "+PCBcontext.getPcbdb().getCurrentUser().get_active_scene()); Log.d(LOG_TAG,"inserting "+picto.get_ImgId()+":"+picto.get_translation()+":"+picto.get_json_attrs()+"-id_sce: "+PCBcontext.getPcbdb().getCurrentUser().get_active_scene());
values.put("id_picto", picto.get_id()); values.put("id_picto", picto.get_ImgId());
values.put("id_scene", this.currentUser.get_active_scene()); values.put("id_scene", this.currentUser.get_active_scene());
values.put("id_stupicto", picto.get_stupicto_id()); values.put("id_stupicto", picto.get_stupicto_id());
values.put("url", picto.get_url()); values.put("url", picto.get_url());
...@@ -281,15 +281,15 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -281,15 +281,15 @@ public class PCBDBHelper extends SQLiteOpenHelper {
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
ContentValues values=new ContentValues(7); ContentValues values=new ContentValues(7);
values.put("id_stu", id_stu); values.put("id_stu", id_stu);
values.put("id_picto", picto.get_id()); values.put("id_picto", picto.get_ImgId());
//TODO: Añadir aqui el id de escena activa para el estudiante //TODO: Añadir aqui el id de escena activa para el estudiante
values.put("id_scene",this.currentUser.get_active_scene()); values.put("id_scene",this.currentUser.get_active_scene());
values.put("id_stupicto",picto.get_stupicto_id()); values.put("id_stupicto",picto.get_stupicto_id());
values.put("url", picto.get_url()); values.put("url", picto.get_url());
values.put("translation",picto.get_translation()); values.put("translation",picto.get_translation());
values.put("attributes",picto.get_json_attrs()); values.put("attributes",picto.get_json_attrs());
db.insert("collection_detail", null, values); db.insertWithOnConflict("collection_detail", null, values,SQLiteDatabase.CONFLICT_REPLACE);
Log.i(LOG_TAG,"Picto added:"+picto.get_translation()+" id:"+picto.get_id()+" stupicto_id:"+picto.get_stupicto_id()+" scene:"+PCBcontext.getPcbdb().getCurrentUser().get_active_scene()); Log.i(LOG_TAG,"Picto added:"+picto.get_translation()+" id:"+picto.get_ImgId()+" stupicto_id:"+picto.get_stupicto_id()+" scene:"+PCBcontext.getPcbdb().getCurrentUser().get_active_scene());
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ //db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
} }
......
...@@ -62,6 +62,7 @@ public class Picto extends Img { ...@@ -62,6 +62,7 @@ public class Picto extends Img {
public static String STATUS = "status"; public static String STATUS = "status";
public static String COLOR = "color"; public static String COLOR = "color";
public static String PCB_STATUS_MODIFICATION="pcb_status_modification"; public static String PCB_STATUS_MODIFICATION="pcb_status_modification";
public static String PCB_UPDATE="pcb_update";
public static String EXPRESSION = "expression"; public static String EXPRESSION = "expression";
public static String MIRROR = "mirror"; public static String MIRROR = "mirror";
public static String LEGEND = "legend"; public static String LEGEND = "legend";
...@@ -150,7 +151,7 @@ public class Picto extends Img { ...@@ -150,7 +151,7 @@ public class Picto extends Img {
*/ */
public String get_audioPath() { public String get_audioPath() {
String audioPath=getAudioPictosPath(); String audioPath=getAudioPictosPath();
return audioPath+File.separator+"pictosound_"+PCBcontext.getPcbdb().getCurrentUser().get_id_stu()+"_"+this.get_id()+".mp3"; return audioPath+File.separator+"pictosound_"+PCBcontext.getPcbdb().getCurrentUser().get_id_stu()+"_"+this.get_ImgId()+".mp3";
} }
/** /**
...@@ -180,7 +181,7 @@ public class Picto extends Img { ...@@ -180,7 +181,7 @@ public class Picto extends Img {
* *
* @return true if it's a local pictogram --> is was not uploaded ever * @return true if it's a local pictogram --> is was not uploaded ever
*/ */
public boolean is_local() {return this.get_id()<0;} public boolean is_local() {return this.get_ImgId()<0;}
/** /**
* *
...@@ -236,6 +237,7 @@ public class Picto extends Img { ...@@ -236,6 +237,7 @@ public class Picto extends Img {
e.printStackTrace(); e.printStackTrace();
} }
json.remove(JSON_ATTTRS.PCB_STATUS_MODIFICATION); json.remove(JSON_ATTTRS.PCB_STATUS_MODIFICATION);
json.remove(JSON_ATTTRS.PCB_UPDATE);
return json.toString(); return json.toString();
} }
/** /**
...@@ -287,7 +289,7 @@ public class Picto extends Img { ...@@ -287,7 +289,7 @@ public class Picto extends Img {
*/ */
public boolean is_disabled() { public boolean is_disabled() {
try { try {
return this.attributes.getString(JSON_ATTTRS.STATUS).equals(JSON_ATTTR_STATUS_VALUES.DISABLED); return !PCBcontext.getPcbdb().getCurrentUser().is_supervisor() ? false : this.attributes.getString(JSON_ATTTRS.STATUS).equals(JSON_ATTTR_STATUS_VALUES.DISABLED);
} catch (JSONException e) { } catch (JSONException e) {
return false; return false;
} }
...@@ -300,7 +302,7 @@ public class Picto extends Img { ...@@ -300,7 +302,7 @@ public class Picto extends Img {
public boolean is_invisible() { public boolean is_invisible() {
try { try {
return this.attributes.getString(JSON_ATTTRS.STATUS).equals(JSON_ATTTR_STATUS_VALUES.INVISIBLE) || return this.attributes.getString(JSON_ATTTRS.STATUS).equals(JSON_ATTTR_STATUS_VALUES.INVISIBLE) ||
(PCBcontext.getVocabulary().is_category(this) && !PCBcontext.getVocabulary().isVisibleCategory(this.get_id())); (PCBcontext.getVocabulary().is_category(this) && !PCBcontext.getVocabulary().isVisibleCategory(this.get_ImgId()));
} catch (JSONException e) { } catch (JSONException e) {
return false; return false;
} }
...@@ -332,7 +334,9 @@ public class Picto extends Img { ...@@ -332,7 +334,9 @@ public class Picto extends Img {
*/ */
public String get_status() { public String get_status() {
try { try {
return this.attributes.getString(JSON_ATTTRS.STATUS); return (!PCBcontext.getPcbdb().getCurrentUser().is_supervisor() && this.attributes.getString(JSON_ATTTRS.STATUS)== JSON_ATTTR_STATUS_VALUES.DISABLED) //el tablero del niño no tiene NUNCA pictos tachados
? JSON_ATTTR_STATUS_VALUES.ENABLED
: this.attributes.getString(JSON_ATTTRS.STATUS);
} catch (JSONException e) { } catch (JSONException e) {
return "enabled"; // By default return "enabled"; // By default
} }
...@@ -358,14 +362,7 @@ public class Picto extends Img { ...@@ -358,14 +362,7 @@ public class Picto extends Img {
* @return the associated person of a picto * @return the associated person of a picto
*/ */
public String get_user_avatar() { public String get_user_avatar() {
String associated_user; return this.attributes.optString(JSON_ATTTRS.USER_AVATAR);
try {
associated_user = this.attributes.has(JSON_ATTTRS.USER_AVATAR) ?this.attributes.getString(JSON_ATTTRS.USER_AVATAR) : null;
} catch (JSONException e) {
e.printStackTrace();
associated_user=null;
}
return associated_user;
} }
/** /**
...@@ -471,7 +468,7 @@ public class Picto extends Img { ...@@ -471,7 +468,7 @@ public class Picto extends Img {
this.getFreeColumn() == -1 && this.getFreeColumn() == -1 &&
this.getFreeRow() == -1; this.getFreeRow() == -1;
} }
/** /**
* *
* @overide * @overide
...@@ -485,7 +482,7 @@ public class Picto extends Img { ...@@ -485,7 +482,7 @@ public class Picto extends Img {
* toString method * toString method
*/ */
public String toString(){ public String toString(){
return "(" + get_id() + ") - ["+ get_row() +","+ get_column()+"]" + get_translation() + "(Cat: " + get_category() + ") - " + get_url() + " --- " + get_json_attrs(); return "(" + get_ImgId() + ") - ["+ get_row() +","+ get_column()+"]" + get_translation() + "(Cat: " + get_category() + ") - " + get_url() + " --- " + get_json_attrs();
} }
...@@ -519,13 +516,21 @@ public class Picto extends Img { ...@@ -519,13 +516,21 @@ public class Picto extends Img {
} }
/** /**
* when the status is locally modified, it is required to remove when it is uploaded since it is no longer a local modification *
* @return true if the picto was modified from the PCB
*/
public boolean local_update() {
return !this.attributes.isNull(JSON_ATTTRS.PCB_UPDATE);
}
/**
* status is locally modified,
*/ */
public void set_local_status(boolean local) { public void set_local_status(boolean local) {
if (local) if (local)
try { try {
this.attributes.put(JSON_ATTTRS.PCB_STATUS_MODIFICATION, true); this.attributes.put(JSON_ATTTRS.PCB_STATUS_MODIFICATION, true);
PCBcontext.getPcbdb().modifyPicto(this.get_id(), this.get_json_attrs()); PCBcontext.getPcbdb().modifyPicto(this.get_ImgId(), this.get_json_attrs());
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
Log.e(LOG_TAG, e.getMessage()); Log.e(LOG_TAG, e.getMessage());
...@@ -533,10 +538,32 @@ public class Picto extends Img { ...@@ -533,10 +538,32 @@ public class Picto extends Img {
} }
else { else {
this.attributes.remove(JSON_ATTTRS.PCB_STATUS_MODIFICATION); this.attributes.remove(JSON_ATTTRS.PCB_STATUS_MODIFICATION);
PCBcontext.getPcbdb().modifyPicto(this.get_id(), this.get_json_attrs()); PCBcontext.getPcbdb().modifyPicto(this.get_ImgId(), this.get_json_attrs());
}
}
/**
* picto is locally modified
*/
public void set_local_update(boolean update) {
if (update)
try {
this.attributes.put(JSON_ATTTRS.PCB_UPDATE, true);
PCBcontext.getPcbdb().modifyPicto(this.get_ImgId(), this.get_json_attrs());
} catch (JSONException e) {
e.printStackTrace();
Log.e(LOG_TAG, e.getMessage());
}
else {
this.attributes.remove(JSON_ATTTRS.PCB_UPDATE);
PCBcontext.getPcbdb().modifyPicto(this.get_ImgId(), this.get_json_attrs());
} }
} }
/** /**
* Save an picto into disk * Save an picto into disk
* @param is the stream where the image is available * @param is the stream where the image is available
......
...@@ -57,8 +57,11 @@ public class User { ...@@ -57,8 +57,11 @@ public class User {
public User(int id_stu, String nickname_stu, String pwd_stu, String name_stu, String surname_stu, int id_scene_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, int id_scene_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,id_scene_stu, url_img_stu, gender_stu, lang_stu, attributes_stu,User.NO_SUPERVISOR,"","","","","","M","es-es",null,null); this(id_stu, nickname_stu, pwd_stu, name_stu, surname_stu,id_scene_stu, url_img_stu, gender_stu, lang_stu, attributes_stu,User.NO_SUPERVISOR,"","","","","","M","es-es",null,null);
} }
public User(int id_stu, String nickname_stu, String pwd_stu, String name_stu, String surname_stu,int id_scene_stu, String url_img_stu, String gender_stu, String lang_stu, String attributes_stu, public User(int id_stu, String nickname_stu, String pwd_stu, String name_stu, String surname_stu,int id_scene_stu,
int id_sup, String email_sup, String pwd_sup, String name_sup, String surname_sup, String url_img_sup, String gender_sup, String lang_sup, String tts_engine_sup, String office_sup) throws JSONException { String url_img_stu, String gender_stu, String lang_stu, String attributes_stu,
int id_sup, String email_sup, String pwd_sup, String name_sup,
String surname_sup, String url_img_sup, String gender_sup, String lang_sup,
String tts_engine_sup, String office_sup) throws JSONException {
this.img_stu=new Img(id_stu,url_img_stu,Img.STUDENT); this.img_stu=new Img(id_stu,url_img_stu,Img.STUDENT);
this.nickname_stu=nickname_stu; this.nickname_stu=nickname_stu;
this.pwd_stu=pwd_stu; this.pwd_stu=pwd_stu;
...@@ -92,7 +95,7 @@ public class User { ...@@ -92,7 +95,7 @@ public class User {
* *
* @return id of the student * @return id of the student
*/ */
public int get_id_stu() {return this.img_stu.get_id();} public int get_id_stu() {return this.img_stu.get_ImgId();}
/** /**
* *
...@@ -165,7 +168,7 @@ public class User { ...@@ -165,7 +168,7 @@ public class User {
* *
* @return id of the supervisor * @return id of the supervisor
*/ */
public int get_id_sup() {return this.img_sup.get_id();} public int get_id_sup() {return this.img_sup.get_ImgId();}
/** /**
* *
...@@ -344,7 +347,7 @@ public class User { ...@@ -344,7 +347,7 @@ public class User {
* Two user are equals whenever they have the same student and supervisor id * Two user are equals whenever they have the same student and supervisor id
*/ */
public boolean equals(Object o) { public boolean equals(Object o) {
return ((User)o).img_stu.get_id()==this.img_stu.get_id() && ((User)o).img_sup.get_id()==this.img_sup.get_id(); return ((User)o).img_stu.get_ImgId()==this.img_stu.get_ImgId() && ((User)o).img_sup.get_ImgId()==this.img_sup.get_ImgId();
} }
......
...@@ -128,6 +128,7 @@ public class UserLogin { ...@@ -128,6 +128,7 @@ public class UserLogin {
try { try {
Vector<User> localUsers = PCBcontext.getDevice().findUser(email, password); Vector<User> localUsers = PCBcontext.getDevice().findUser(email, password);
Log.i(this.getClass().getCanonicalName(), "Offline login request for supervisor "+email+localUsers.elementAt(0).get_email_sup()+localUsers.elementAt(0).is_supervisor()); Log.i(this.getClass().getCanonicalName(), "Offline login request for supervisor "+email+localUsers.elementAt(0).get_email_sup()+localUsers.elementAt(0).is_supervisor());
Log.e(this.getClass().getCanonicalName(), "Offline login request for supervisor "+email+localUsers.elementAt(0).get_email_sup()+localUsers.elementAt(0).is_supervisor()+":"+localUsers.elementAt(0).get_Img_sup().file_name());
Intent loginActivity = new Intent(activity, LoginActivity); Intent loginActivity = new Intent(activity, LoginActivity);
loginActivity.putExtra("sup_id", localUsers.elementAt(0).get_id_sup()); loginActivity.putExtra("sup_id", localUsers.elementAt(0).get_id_sup());
loginActivity.putExtra("name", localUsers.elementAt(0).get_name_sup()); loginActivity.putExtra("name", localUsers.elementAt(0).get_name_sup());
......
...@@ -127,7 +127,7 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> { ...@@ -127,7 +127,7 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> {
". Sounds downloaded:"+isound+ ". Sounds downloaded:"+isound+
". Used time: "+seconds+" seconds at "+new SimpleDateFormat("HH:mm:ss")); ". Used time: "+seconds+" seconds at "+new SimpleDateFormat("HH:mm:ss"));
return imgs.size() > 1 ? null return imgs.size()!=1 ? null
: imgs.get(0); : imgs.get(0);
} }
......
...@@ -41,7 +41,7 @@ public class PictoUploader { ...@@ -41,7 +41,7 @@ public class PictoUploader {
boolean success; boolean success;
Response<JsonObject> response=null; Response<JsonObject> response=null;
if (!img.get_filetype().equalsIgnoreCase("png")) if (!img.get_filetype().equalsIgnoreCase("png"))
throw new UnsupportedEncodingException("Extension "+img.get_filetype()+" is not supported. Only png files"); throw new UnsupportedEncodingException("File: "+img.get_url()+". Extension "+img.get_filetype()+" is not supported. Only png files");
Ion ion = Ion.getDefault(PCBcontext.getContext()); Ion ion = Ion.getDefault(PCBcontext.getContext());
...@@ -51,7 +51,7 @@ public class PictoUploader { ...@@ -51,7 +51,7 @@ public class PictoUploader {
response=ion.with(PCBcontext.getContext()) response=ion.with(PCBcontext.getContext())
.load("POST", PCBcontext.getContext().getResources().getString(R.string.server) + "/picto/upload") .load("POST", PCBcontext.getContext().getResources().getString(R.string.server) + "/picto/upload")
.setMultipartParameter("filename", Integer.toString(img.get_id())) .setMultipartParameter("filename", Integer.toString(img.get_ImgId()))
.setMultipartParameter("extension", img.get_filetype()) .setMultipartParameter("extension", img.get_filetype())
.setMultipartParameter("owner", Integer.toString(PCBcontext.getPcbdb().getCurrentUser().get_id_sup())) .setMultipartParameter("owner", Integer.toString(PCBcontext.getPcbdb().getCurrentUser().get_id_sup()))
.setMultipartParameter("folder", "custompictos") .setMultipartParameter("folder", "custompictos")
...@@ -98,7 +98,7 @@ public class PictoUploader { ...@@ -98,7 +98,7 @@ public class PictoUploader {
if (!extension.equalsIgnoreCase("mp3")) if (!extension.equalsIgnoreCase("mp3"))
throw new UnsupportedEncodingException("Extension "+extension+" is not supported. Only mp3 files"); throw new UnsupportedEncodingException("Extension "+extension+" is not supported. Only mp3 files");
String url=PCBcontext.getContext().getResources().getString(R.string.server) + "/"+PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu()+"/upload_sound/"+picto.get_id(); String url=PCBcontext.getContext().getResources().getString(R.string.server) + "/"+PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu()+"/upload_sound/"+picto.get_ImgId();
Ion ion = Ion.getDefault(PCBcontext.getContext()); Ion ion = Ion.getDefault(PCBcontext.getContext());
try { try {
...@@ -145,7 +145,7 @@ public class PictoUploader { ...@@ -145,7 +145,7 @@ public class PictoUploader {
/** /**
* if a picto was included from the PCB, the translation is uploaded to the server * if a picto was included from the PCB, the translation is uploaded to the server
*/ */
private void uploadAttributes(int id_picto) { private void uploadAttributes() {
Hashtable<String, String> params = new Hashtable<String, String>(4); Hashtable<String, String> params = new Hashtable<String, String>(4);
try { try {
...@@ -167,7 +167,7 @@ public class PictoUploader { ...@@ -167,7 +167,7 @@ public class PictoUploader {
Log.e(LOG_TAG, " Error: " + e.getLocalizedMessage()); Log.e(LOG_TAG, " Error: " + e.getLocalizedMessage());
} }
PCBcontext.getRestapiWrapper().ask(PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + "/picto/"+id_picto, params, "post", true, new RestapiWrapper.iRestapiListener() { PCBcontext.getRestapiWrapper().ask(PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + "/picto/"+picto.get_ImgId(), params, "post", true, new RestapiWrapper.iRestapiListener() {
@Override @Override
public void preExecute() { public void preExecute() {
} }
...@@ -229,7 +229,7 @@ public class PictoUploader { ...@@ -229,7 +229,7 @@ public class PictoUploader {
@Override @Override
public void result(JSONObject result) { public void result(JSONObject result) {
Log.i(LOG_TAG, "Uploaded translation result: " + result.toString()); Log.i(LOG_TAG, "Uploaded translation result: " + result.toString());
uploadAttributes(picto.get_id()); uploadAttributes();
} }
@Override @Override
...@@ -242,48 +242,10 @@ public class PictoUploader { ...@@ -242,48 +242,10 @@ public class PictoUploader {
/**
* if the a picto was modified from the PCB, the original one is modified and a new one is included
*/
private void deleteRemotePictoAndUpload(final int id_stupicto) {
final String picto_str="/picto";
String operation=PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu()+picto_str+"/"+id_stupicto;
Log.i(LOG_TAG, "Delete picto request: " + operation);
PCBcontext.getRestapiWrapper().ask(operation, null, "delete", new RestapiWrapper.iRestapiListener() {
@Override
public void preExecute() {
}
@Override
public void result(JSONArray result) {
}
@Override
public void result(JSONObject result) {
String str="Picto "+id_stupicto+" deleted. Server side";
PictoUploader.this.picto.set_local_status(true);
try {
uploadLocalPicto();
} catch (IOException e) {
Log.e(LOG_TAG,"error after deleting remote picto:"+e.getMessage());
}
Log.i(LOG_TAG, str);
}
@Override
public void error(RestapiWrapper.HTTPException e) {
Log.e(LOG_TAG, "Error deleting picto: " + e.getLocalizedMessage()+" Picto:"+id_stupicto);
}
});
}
/** /**
*Try to Upload local picto. It requires: *Try to Upload local picto. It requires:
* 0) to delete the previous picto, if it exists
* i) to upload the image, * i) to upload the image,
* ii) to upload the expression * ii) to upload the expression
* iii) to upload the attributes * iii) to upload the attributes
...@@ -292,18 +254,12 @@ public class PictoUploader { ...@@ -292,18 +254,12 @@ public class PictoUploader {
* *
**/ **/
public void upload() throws IOException { public void upload() throws IOException {
final int stupicto_id=this.picto.get_stupicto_id();
if (this.picto.get_stupicto_id()!= Picto.STUPICTO_NULL) final int local_id = this.picto.get_ImgId();
deleteRemotePictoAndUpload(stupicto_id);
else
uploadLocalPicto();
}
private void uploadLocalPicto() throws IOException {
final int local_id = this.picto.get_id();
final boolean imgUpload_success = uploadImg(this.picto); final boolean imgUpload_success = uploadImg(this.picto);
Log.i(LOG_TAG, "Local Picto to be uploaded:" + this.picto.get_translation() + "(localID:" + local_id + ", new remoteID:" + this.picto.get_id() ); Log.i(LOG_TAG, "Local Picto to be uploaded:" + this.picto.get_translation() + "(local Image ID:" + local_id + ", new remote Image ID:" + this.picto.get_ImgId() +" Path:"+this.picto.file_name());
if (imgUpload_success) if (imgUpload_success)
uploadTranslation(picto.get_id()); uploadTranslation(picto.get_ImgId());
else else
fail(PCBcontext.getContext().getResources().getString(R.string.upload_error) + ":" + PictoUploader.this.picto.get_translation()); fail(PCBcontext.getContext().getResources().getString(R.string.upload_error) + ":" + PictoUploader.this.picto.get_translation());
} }
...@@ -335,7 +291,7 @@ public class PictoUploader { ...@@ -335,7 +291,7 @@ public class PictoUploader {
@Override @Override
public void result(JSONObject result) { public void result(JSONObject result) {
Log.i(PictoUploader.LOG_TAG, "Upload ok Picto " + PictoUploader.this.picto.get_id()); Log.i(PictoUploader.LOG_TAG, "Upload ok Picto " + PictoUploader.this.picto.get_ImgId());
picto.set_local_status(false); picto.set_local_status(false);
PCBcontext.getRoom().emit(new VocabularyAction(VocabularyAction.ALTERATTRS,PictoUploader.this.picto)); PCBcontext.getRoom().emit(new VocabularyAction(VocabularyAction.ALTERATTRS,PictoUploader.this.picto));
} }
...@@ -361,26 +317,29 @@ public class PictoUploader { ...@@ -361,26 +317,29 @@ public class PictoUploader {
} }
private void success(JSONObject server_response) { private void success(JSONObject server_response) {
Log.i(LOG_TAG,"Deleting local picto?????????????????????????????????? "+picto.get_id()+" ");
if (picto.is_local()) { if (picto.is_local()) {
Log.i(LOG_TAG,"Deleting local picto "+picto.get_id()+" "); Log.i(LOG_TAG,"Deleting local picto "+picto.get_ImgId()+" ");
PCBcontext.getPcbdb().deletePicto(picto.get_id()); PCBcontext.getPcbdb().deletePicto(picto.get_ImgId());
} try {
int stupicto_id= 0; int stupicto_id= server_response.getInt("id");
try {
stupicto_id = server_response.getInt("id");
picto.set_stupicto_id(stupicto_id); picto.set_stupicto_id(stupicto_id);
PCBcontext.getVocabulary().addPicto(picto); PCBcontext.getVocabulary().addPicto(picto);
PCBcontext.getPcbdb().savePicto(PictoUploader.this.picto); PCBcontext.getVocabulary().removePicto(picto.get_category(),picto.get_ImgId());
PCBcontext.getRoom().emit(new VocabularyAction(VocabularyAction.ADD, this.picto)); } catch (JSONException e) {
Toast.makeText( fail(e.getMessage());
PCBcontext.getActivityContext(), Log.e(LOG_TAG,"Error uploading picto when getting json from server:"+e.getMessage()+":"+server_response.toString());
(PCBcontext.getActivityContext().getResources().getString(R.string.upload_ok) }
+":"+this.picto.get_translation()), Toast.LENGTH_LONG).show();
} catch (JSONException e) {
fail(e.getMessage());
Log.e(LOG_TAG,"Error uploading picto when getting json from server:"+e.getMessage()+":"+server_response.toString());
} }
if (picto.local_update())
picto.set_local_update(false);
PCBcontext.getPcbdb().savePicto(PictoUploader.this.picto);
PCBcontext.getRoom().emit(new VocabularyAction(VocabularyAction.ADD, this.picto));
Toast.makeText(
PCBcontext.getActivityContext(),
(PCBcontext.getActivityContext().getResources().getString(R.string.upload_ok)
+":"+this.picto.get_translation()), Toast.LENGTH_LONG).show();
} }
} }
...@@ -81,7 +81,7 @@ public class Img { ...@@ -81,7 +81,7 @@ public class Img {
} }
public String file_name() { return this.id+"."+this.FILETYPE; } public String file_name() { return this.id+"."+this.FILETYPE; }
public int get_id() { return this.id;} public int get_ImgId() { return this.id;}
public String get_url() { return this.url;} public String get_url() { return this.url;}
public void set_url(String url) {this.url=url;} public void set_url(String url) {this.url=url;}
public String get_type() { return this.type;} public String get_type() { return this.type;}
......
...@@ -6,7 +6,7 @@ android { ...@@ -6,7 +6,7 @@ android {
compileSdkVersion 24 compileSdkVersion 24
buildToolsVersion '25.0.0' buildToolsVersion '25.0.0'
defaultConfig { defaultConfig {
applicationId "com.yottacode.pictogram.supervisor" applicationId "com.yottacode.pictogram.supervisor_tablet"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 22 targetSdkVersion 22
versionCode 3 versionCode 3
......
...@@ -282,7 +282,7 @@ public class PictoMenu { ...@@ -282,7 +282,7 @@ public class PictoMenu {
ll.removeAllViewsInLayout(); ll.removeAllViewsInLayout();
try { try {
setPicto(p.get_row(),p.get_column(),p.getFreeRow(),p.getFreeColumn(), p.get_category(),p.get_bitmap(PCBcontext.getContext()),p.get_id()); setPicto(p.get_row(),p.get_column(),p.getFreeRow(),p.getFreeColumn(), p.get_category(),p.get_bitmap(PCBcontext.getContext()),p.get_ImgId());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -298,7 +298,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab ...@@ -298,7 +298,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
int y = Math.round(event.getY()); int y = Math.round(event.getY());
int position = ((GridView) v).pointToPosition(x, y); int position = ((GridView) v).pointToPosition(x, y);
Picto p = position > -1 ? (Picto) ((GridView) v).getItemAtPosition(position) : null; Picto p = position > -1 ? (Picto) ((GridView) v).getItemAtPosition(position) : null;
enable_haptic = (p != null && p.get_id() != 0 && !p.is_invisible() && p.is_enabled()); enable_haptic = (p != null && p.get_ImgId() != 0 && !p.is_invisible() && p.is_enabled());
} }
if (enable_haptic) if (enable_haptic)
v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
...@@ -562,7 +562,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab ...@@ -562,7 +562,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
if (inserting) return; if (inserting) return;
Picto p = getCurrentPictoGridAdapter().getItem(position); Picto p = getCurrentPictoGridAdapter().getItem(position);
if (p != null && p.get_id() != 0 && !p.is_invisible() && p.is_enabled()) { if (p != null && p.get_ImgId() != 0 && !p.is_invisible() && p.is_enabled()) {
p.set_mirror(false, false); p.set_mirror(false, false);
// If the picto is a category // If the picto is a category
...@@ -627,7 +627,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab ...@@ -627,7 +627,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
if (p == null) { if (p == null) {
// No tengo pictograma. Abro una nueva ventana de selección desde el Carrete del device si no es categoria // No tengo pictograma. Abro una nueva ventana de selección desde el Carrete del device si no es categoria
if (getCurrentCategory() != null || /*!PCBcontext.getPcbdb().getCurrentUser().has_categories()*/!PCBcontext.getVocabulary().has_categories()) { if (getCurrentCategory() != null || /*!PCBcontext.getPcbdb().getCurrentUser().has_categories()*/!PCBcontext.getVocabulary().has_categories()) {
int cat = getCurrentCategory() != null ? currentCategory.get_id() : Picto.NO_CATEGORY; int cat = getCurrentCategory() != null ? currentCategory.get_ImgId() : Picto.NO_CATEGORY;
new PictoMenu(VocabularyManager.this).createMenuForNewPicto(position % maxColumns, (int) (position / maxColumns), cat); new PictoMenu(VocabularyManager.this).createMenuForNewPicto(position % maxColumns, (int) (position / maxColumns), cat);
} else } else
Toast.makeText(VocabularyManager.this, VocabularyManager.this.getResources().getString(R.string.notNewCats), Toast.LENGTH_SHORT).show(); Toast.makeText(VocabularyManager.this, VocabularyManager.this.getResources().getString(R.string.notNewCats), Toast.LENGTH_SHORT).show();
......
...@@ -345,7 +345,8 @@ public class EditPictoActivity extends Activity { ...@@ -345,7 +345,8 @@ public class EditPictoActivity extends Activity {
if(editar){ if(editar){
p = PCBcontext.getVocabulary().get_picto(getIntent().getExtras().getInt(Picto.JSON_ATTTRS.CATEGORY),getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE)); p = PCBcontext.getVocabulary().get_picto(getIntent().getExtras().getInt(Picto.JSON_ATTTRS.CATEGORY),getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE));
legend.setText(p.get_translation()); legend.setText(p.get_translation());
supAsociado.setText(p.get_user_avatar()==null ? NO_SUP_TEXT : p.get_user_avatar()); Log.e(LOG_TAG,"Avatar:"+p.get_user_avatar()+":"+(p.get_user_avatar()==null));
supAsociado.setText(p.get_user_avatar()==null || (p.get_user_avatar()!=null && p.get_user_avatar().equals("null")) ? NO_SUP_TEXT : p.get_user_avatar());
//Si el picto viene con sonido //Si el picto viene con sonido
if(p.get_audioFile() != null){ if(p.get_audioFile() != null){
...@@ -366,6 +367,7 @@ public class EditPictoActivity extends Activity { ...@@ -366,6 +367,7 @@ public class EditPictoActivity extends Activity {
layoutGrabacion.setVisibility(View.VISIBLE); layoutGrabacion.setVisibility(View.VISIBLE);
hayGrabacion = false; hayGrabacion = false;
tiempoTotal = 0; tiempoTotal = 0;
supAsociado.setText(NO_SUP_TEXT);
} }
legend.setHorizontallyScrolling(false); legend.setHorizontallyScrolling(false);
legend.setMaxLines(1); legend.setMaxLines(1);
...@@ -415,7 +417,7 @@ public class EditPictoActivity extends Activity { ...@@ -415,7 +417,7 @@ public class EditPictoActivity extends Activity {
filepath = editar ? dirImagePath + File.separator + legend.getText().toString() + "_" + id_pic + ".png" filepath = editar ? dirImagePath + File.separator + legend.getText().toString() + "_" + id_pic + ".png"
: dirImagePath + File.separator + legend.getText().toString() + "_new_" + pathNumber+ ".png"; : dirImagePath + File.separator + legend.getText().toString() + "_new_" + pathNumber+ ".png";
Log.e(LOG_TAG,"FILEPATH:"+filepath);
File imageFile = new File(filepath); File imageFile = new File(filepath);
if(!editar) { //Si es añadir uno nuevo comprobar que el random no existe ya en el path if(!editar) { //Si es añadir uno nuevo comprobar que el random no existe ya en el path
while (imageFile.exists()) { while (imageFile.exists()) {
...@@ -431,10 +433,12 @@ public class EditPictoActivity extends Activity { ...@@ -431,10 +433,12 @@ public class EditPictoActivity extends Activity {
outputStream.flush(); outputStream.flush();
outputStream.close(); outputStream.close();
Log.e(LOG_TAG,"FILEPATH IMG OK TO PNG:"+filepath);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
Log.e(LOG_TAG,"Error when getting image:"+e.getMessage());
} catch (IOException e) { } catch (IOException e) {
Log.e(LOG_TAG,"Error when getting image:"+e.getMessage());
e.printStackTrace(); e.printStackTrace();
} }
...@@ -458,7 +462,7 @@ public class EditPictoActivity extends Activity { ...@@ -458,7 +462,7 @@ public class EditPictoActivity extends Activity {
intent.putExtra(PictoMenu.PATH_SOUND,editar ? ((!borrado && p.getUriSound()!= null) ? p.get_audioPath() : audioPath) : audioPath); //Mandar el path del audio intent.putExtra(PictoMenu.PATH_SOUND,editar ? ((!borrado && p.getUriSound()!= null) ? p.get_audioPath() : audioPath) : audioPath); //Mandar el path del audio
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, legend.getText().toString()); //Mandar expresion nueva intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, legend.getText().toString()); //Mandar expresion nueva
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1)); intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1));
intent.putExtra(Picto.JSON_ATTTRS.USER_AVATAR, supAsociado.getText()); intent.putExtra(Picto.JSON_ATTTRS.USER_AVATAR, supAsociado.getText().equals(NO_SUP_TEXT) ? null : supAsociado.getText());
setResult(RESULT_OK, intent); setResult(RESULT_OK, intent);
......
...@@ -72,7 +72,7 @@ public class LoginActivity extends FragmentActivity { ...@@ -72,7 +72,7 @@ public class LoginActivity extends FragmentActivity {
this.getIntent().getStringExtra("surname") + " (" + this.getIntent().getStringExtra("email") + ")"); this.getIntent().getStringExtra("surname") + " (" + this.getIntent().getStringExtra("email") + ")");
final Vector<Img> imgs = new Vector<>(1); final Vector<Img> imgs = new Vector<>(1);
Log.e("DETAIL","IMG SUP: "+this.getIntent().getStringExtra("pic"));
imgs.add(new Img( imgs.add(new Img(
this.getIntent().getIntExtra("sup_id", -1), this.getIntent().getIntExtra("sup_id", -1),
this.getIntent().getStringExtra("pic"), this.getIntent().getStringExtra("pic"),
......
...@@ -20,7 +20,7 @@ import com.yottacode.net.RestapiWrapper; ...@@ -20,7 +20,7 @@ import com.yottacode.net.RestapiWrapper;
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.supervisor.R; import com.yottacode.pictogram.supervisor.R;
import com.yottacode.pictogram.supervisor.gui.VOCAS; import com.yottacode.pictogram.supervisor.gui.VocabularyManager;
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;
...@@ -92,7 +92,7 @@ public class StudentFragmentGrid extends Fragment { ...@@ -92,7 +92,7 @@ public class StudentFragmentGrid extends Fragment {
Log.e(StudentFragmentGrid.this.getClass().getCanonicalName(), e.getMessage()); Log.e(StudentFragmentGrid.this.getClass().getCanonicalName(), e.getMessage());
} }
PCBcontext.set_user(currentUser, null, null); PCBcontext.set_user(currentUser, null, null);
Intent pictogramActivity = new Intent(getActivity(), VOCAS.class); Intent pictogramActivity = new Intent(getActivity(), VocabularyManager.class);
startActivity(pictogramActivity); startActivity(pictogramActivity);
} else { } else {
if (this.nameStudents[i].equals(getString(R.string.addStudent))) if (this.nameStudents[i].equals(getString(R.string.addStudent)))
...@@ -222,7 +222,7 @@ public class StudentFragmentGrid extends Fragment { ...@@ -222,7 +222,7 @@ public class StudentFragmentGrid extends Fragment {
if (progressDialog != null && progressDialog.isShowing()) if (progressDialog != null && progressDialog.isShowing())
progressDialog.dismiss(); progressDialog.dismiss();
PCBcontext.getPcbdb().user_valid(license_valid); PCBcontext.getPcbdb().user_valid(license_valid);
Intent pictogramActivity = new Intent(getActivity(), VOCAS.class); Intent pictogramActivity = new Intent(getActivity(), VocabularyManager.class);
startActivity(pictogramActivity); startActivity(pictogramActivity);
} }
...@@ -366,7 +366,7 @@ public class StudentFragmentGrid extends Fragment { ...@@ -366,7 +366,7 @@ public class StudentFragmentGrid extends Fragment {
, currentUser.get_name_stu(), currentUser.get_surname_stu(), currentUser.get_active_scene(), currentUser.get_url_img_stu() , currentUser.get_name_stu(), currentUser.get_surname_stu(), currentUser.get_active_scene(), currentUser.get_url_img_stu()
, currentUser.get_gender_stu(), currentUser.get_lang_stu(), currentUser.get_json_attrs(), , currentUser.get_gender_stu(), currentUser.get_lang_stu(), currentUser.get_json_attrs(),
(int) supervisor.get("id"), supervisor.get("email").toString(), "_", supervisor.get("name").toString(), supervisor.get("surname").toString(), supervisor.get("pic").toString(), (int) supervisor.get("id"), supervisor.get("email").toString(), "_", supervisor.get("name").toString(), supervisor.get("surname").toString(), supervisor.get("pic").toString(),
supervisor.get("gender").toString(), supervisor.get("lang").toString(), supervisor.get("ttsEngine").toString(), supervisor.get("office").toString())); supervisor.get("gender").toString(), supervisor.get("lang").toString(), supervisor.get("ttsEngine").toString(), supervisor.optString("office")));
} }
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -344,7 +344,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -344,7 +344,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
int y = Math.round(event.getY()); int y = Math.round(event.getY());
int position = ((GridView) v).pointToPosition(x, y); int position = ((GridView) v).pointToPosition(x, y);
Picto p = position > -1 ? (Picto) ((GridView) v).getItemAtPosition(position) : null; Picto p = position > -1 ? (Picto) ((GridView) v).getItemAtPosition(position) : null;
enable_haptic = (p != null && p.get_id() != 0 && !p.is_invisible() && p.is_enabled()); enable_haptic = (p != null && p.get_ImgId() != 0 && !p.is_invisible() && p.is_enabled());
} }
if (enable_haptic) if (enable_haptic)
v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
...@@ -745,7 +745,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -745,7 +745,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
if (inserting) return; if (inserting) return;
Picto p = getCurrentPictoGridAdapter().getItem(position); Picto p = getCurrentPictoGridAdapter().getItem(position);
if (p != null && p.get_id() != 0 && !p.is_invisible() && p.is_enabled()) { if (p != null && p.get_ImgId() != 0 && !p.is_invisible() && p.is_enabled()) {
p.set_mirror(false, false); p.set_mirror(false, false);
// If the picto is a category // If the picto is a category
...@@ -847,7 +847,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -847,7 +847,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
Picto p = getCurrentPictoGridAdapter().getItem(position); Picto p = getCurrentPictoGridAdapter().getItem(position);
if (p != null && !p.is_invisible() && p.is_enabled()) { if (p != null && !p.is_invisible() && p.is_enabled()) {
// If is not the blank picto, it isn't invisible or disabled // If is not the blank picto, it isn't invisible or disabled
if (p.get_id() != 0 && if (p.get_ImgId() != 0 &&
!p.get_status().equalsIgnoreCase("invisible") && !p.get_status().equalsIgnoreCase("invisible") &&
!p.get_status().equalsIgnoreCase("disabled") && !p.get_status().equalsIgnoreCase("disabled") &&
tapeAdapter.getCount() < VOCA.this.maxInTape) { tapeAdapter.getCount() < VOCA.this.maxInTape) {
......
...@@ -2,6 +2,8 @@ package com.yottacode.pictogram.tabletlibrary.gui.login; ...@@ -2,6 +2,8 @@ package com.yottacode.pictogram.tabletlibrary.gui.login;
import android.app.Activity; import android.app.Activity;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -10,7 +12,11 @@ import android.widget.ImageView; ...@@ -10,7 +12,11 @@ import android.widget.ImageView;
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.ImgDownloader;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.GUITools;
import java.io.IOException; import java.io.IOException;
import java.util.Vector; import java.util.Vector;
...@@ -20,9 +26,39 @@ import java.util.Vector; ...@@ -20,9 +26,39 @@ import java.util.Vector;
*/ */
public class CustomListLogin extends ArrayAdapter<User>{ public class CustomListLogin extends ArrayAdapter<User>{
private static final String LOG_TAG = CustomListLogin.class.getSimpleName();
private final Activity context; private final Activity context;
public void downloadImgUser(User user, final ImageView imageView) {
final Vector<Img> imgs = new Vector<>(1);
imgs.add(user.is_supervisor()
? new Img( user.get_id_sup(), user.get_url_img_sup(), Img.SUPERVISOR)
: new Img( user.get_id_stu(), user.get_url_img_stu(), Img.STUDENT));
ImgDownloader downloader = new ImgDownloader(this.context, new ImgDownloader.iImgDownloaderListener() {
@Override
public void loadComplete() {
try {
imageView.setImageBitmap(imgs.get(0).get_bitmap(getContext()));
imageView.invalidate();
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void loadImg(Img image) {
}
@Override
public void error(Exception e) {
GUITools.show_alert(PCBcontext.getContext(), R.string.serverError, e.getMessage());
Log.e(this.getClass().getCanonicalName(), "Server error:" + e.getLocalizedMessage());
}
}, ImgDownloader.tsource.remote);
downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, imgs);
}
public CustomListLogin(Activity context, Vector<User> users) { public CustomListLogin(Activity context, Vector<User> users) {
super(context,R.layout.user_login_item, users); super(context,R.layout.user_login_item, users);
this.context = context; this.context = context;
...@@ -44,7 +80,11 @@ public class CustomListLogin extends ArrayAdapter<User>{ ...@@ -44,7 +80,11 @@ public class CustomListLogin extends ArrayAdapter<User>{
ImageView fondo = (ImageView) rowView.findViewById(R.id.fondoFotoLogin); ImageView fondo = (ImageView) rowView.findViewById(R.id.fondoFotoLogin);
try { try {
downloadImgUser(getItem(position),imageView);
Log.i(LOG_TAG,"Downloading "+getItem(position)+(getItem(position).is_supervisor() ? getItem(position).get_Img_sup().get_url() : getItem(position).get_img_stu().get_url()));
Bitmap photo=getItem(position).is_supervisor() ? getItem(position).get_bitmap_sup(getContext()) : getItem(position).get_bitmap_stu(getContext()); Bitmap photo=getItem(position).is_supervisor() ? getItem(position).get_bitmap_sup(getContext()) : getItem(position).get_bitmap_stu(getContext());
fondo.setImageResource(R.drawable.round_design_photo_white); fondo.setImageResource(R.drawable.round_design_photo_white);
if (photo!=null) imageView.setImageBitmap(photo); if (photo!=null) imageView.setImageBitmap(photo);
else imageView.setImageResource(R.drawable.anonymous_student); else imageView.setImageResource(R.drawable.anonymous_student);
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:src="@drawable/disabled_picto" /> android:src="@drawable/disabled_picto" />
</FrameLayout> </FrameLayout>
</RelativeLayout> </RelativeLayout>
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