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 159 additions and 121 deletions
......@@ -54,7 +54,7 @@ public abstract class PictoAction extends Action {
final String param_picto_id="id";
final String param_picto_uri="uri";
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_cat, picto.get_category());
JSONObject attributes = new JSONObject(picto.get_json_attrs());
......
......@@ -67,7 +67,7 @@ public class PictosAction extends Action {
final String param_picto_id="id";
final String param_picto_uri="uri";
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_cat, picto.get_category());
......
......@@ -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(12), cursor.getString(13),cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17),
cursor.getString(18),cursor.getString(19));
cursor.close();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
return user;
......@@ -231,9 +232,10 @@ public class Device extends SQLiteOpenHelper {
while (cursor.moveToNext())
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),
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(18),cursor.getString(19)));
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(18), cursor.getString(19)));
cursor.close();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
return users;
......@@ -296,13 +298,14 @@ public class Device extends SQLiteOpenHelper {
while (cursor.moveToNext()) {
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(12), cursor.getString(13),cursor.getString(14), cursor.getString(15), cursor.getString(16), cursor.getString(17),
cursor.getString(18),cursor.getString(19));
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(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);
supervisors.add(cursor.getInt(9));
supervisors.add(user.get_id_sup());
}
}
cursor.close();
......
......@@ -254,9 +254,9 @@ public class PCBDBHelper extends SQLiteOpenHelper {
values.put("id_stu", id_stu);
db.beginTransaction();
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_stupicto", picto.get_stupicto_id());
values.put("url", picto.get_url());
......@@ -281,15 +281,15 @@ public class PCBDBHelper extends SQLiteOpenHelper {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values=new ContentValues(7);
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
values.put("id_scene",this.currentUser.get_active_scene());
values.put("id_stupicto",picto.get_stupicto_id());
values.put("url", picto.get_url());
values.put("translation",picto.get_translation());
values.put("attributes",picto.get_json_attrs());
db.insert("collection_detail", null, values);
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());
db.insertWithOnConflict("collection_detail", null, values,SQLiteDatabase.CONFLICT_REPLACE);
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
}
......
......@@ -62,6 +62,7 @@ public class Picto extends Img {
public static String STATUS = "status";
public static String COLOR = "color";
public static String PCB_STATUS_MODIFICATION="pcb_status_modification";
public static String PCB_UPDATE="pcb_update";
public static String EXPRESSION = "expression";
public static String MIRROR = "mirror";
public static String LEGEND = "legend";
......@@ -150,7 +151,7 @@ public class Picto extends Img {
*/
public String get_audioPath() {
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 {
*
* @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 {
e.printStackTrace();
}
json.remove(JSON_ATTTRS.PCB_STATUS_MODIFICATION);
json.remove(JSON_ATTTRS.PCB_UPDATE);
return json.toString();
}
/**
......@@ -287,7 +289,7 @@ public class Picto extends Img {
*/
public boolean is_disabled() {
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) {
return false;
}
......@@ -300,7 +302,7 @@ public class Picto extends Img {
public boolean is_invisible() {
try {
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) {
return false;
}
......@@ -332,7 +334,9 @@ public class Picto extends Img {
*/
public String get_status() {
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) {
return "enabled"; // By default
}
......@@ -358,14 +362,7 @@ public class Picto extends Img {
* @return the associated person of a picto
*/
public String get_user_avatar() {
String associated_user;
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;
return this.attributes.optString(JSON_ATTTRS.USER_AVATAR);
}
/**
......@@ -485,7 +482,7 @@ public class Picto extends Img {
* toString method
*/
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 {
}
/**
* 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) {
if (local)
try {
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) {
e.printStackTrace();
Log.e(LOG_TAG, e.getMessage());
......@@ -533,10 +538,32 @@ public class Picto extends Img {
}
else {
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
* @param is the stream where the image is available
......
......@@ -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 {
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,
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 {
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,
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.nickname_stu=nickname_stu;
this.pwd_stu=pwd_stu;
......@@ -92,7 +95,7 @@ public class User {
*
* @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 {
*
* @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 {
* Two user are equals whenever they have the same student and supervisor id
*/
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 {
try {
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.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);
loginActivity.putExtra("sup_id", localUsers.elementAt(0).get_id_sup());
loginActivity.putExtra("name", localUsers.elementAt(0).get_name_sup());
......
......@@ -127,7 +127,7 @@ public class ImgDownloader extends AsyncTask<Vector<Img>, Void, Img> {
". Sounds downloaded:"+isound+
". Used time: "+seconds+" seconds at "+new SimpleDateFormat("HH:mm:ss"));
return imgs.size() > 1 ? null
return imgs.size()!=1 ? null
: imgs.get(0);
}
......
......@@ -41,7 +41,7 @@ public class PictoUploader {
boolean success;
Response<JsonObject> response=null;
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());
......@@ -51,7 +51,7 @@ public class PictoUploader {
response=ion.with(PCBcontext.getContext())
.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("owner", Integer.toString(PCBcontext.getPcbdb().getCurrentUser().get_id_sup()))
.setMultipartParameter("folder", "custompictos")
......@@ -98,7 +98,7 @@ public class PictoUploader {
if (!extension.equalsIgnoreCase("mp3"))
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());
try {
......@@ -145,7 +145,7 @@ public class PictoUploader {
/**
* 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);
try {
......@@ -167,7 +167,7 @@ public class PictoUploader {
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
public void preExecute() {
}
......@@ -229,7 +229,7 @@ public class PictoUploader {
@Override
public void result(JSONObject result) {
Log.i(LOG_TAG, "Uploaded translation result: " + result.toString());
uploadAttributes(picto.get_id());
uploadAttributes();
}
@Override
......@@ -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:
* 0) to delete the previous picto, if it exists
* i) to upload the image,
* ii) to upload the expression
* iii) to upload the attributes
......@@ -292,18 +254,12 @@ public class PictoUploader {
*
**/
public void upload() throws IOException {
final int stupicto_id=this.picto.get_stupicto_id();
if (this.picto.get_stupicto_id()!= Picto.STUPICTO_NULL)
deleteRemotePictoAndUpload(stupicto_id);
else
uploadLocalPicto();
}
private void uploadLocalPicto() throws IOException {
final int local_id = this.picto.get_id();
final int local_id = this.picto.get_ImgId();
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)
uploadTranslation(picto.get_id());
uploadTranslation(picto.get_ImgId());
else
fail(PCBcontext.getContext().getResources().getString(R.string.upload_error) + ":" + PictoUploader.this.picto.get_translation());
}
......@@ -335,7 +291,7 @@ public class PictoUploader {
@Override
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);
PCBcontext.getRoom().emit(new VocabularyAction(VocabularyAction.ALTERATTRS,PictoUploader.this.picto));
}
......@@ -361,26 +317,29 @@ public class PictoUploader {
}
private void success(JSONObject server_response) {
Log.i(LOG_TAG,"Deleting local picto?????????????????????????????????? "+picto.get_id()+" ");
if (picto.is_local()) {
Log.i(LOG_TAG,"Deleting local picto "+picto.get_id()+" ");
PCBcontext.getPcbdb().deletePicto(picto.get_id());
}
int stupicto_id= 0;
Log.i(LOG_TAG,"Deleting local picto "+picto.get_ImgId()+" ");
PCBcontext.getPcbdb().deletePicto(picto.get_ImgId());
try {
stupicto_id = server_response.getInt("id");
int stupicto_id= server_response.getInt("id");
picto.set_stupicto_id(stupicto_id);
PCBcontext.getVocabulary().addPicto(picto);
PCBcontext.getVocabulary().removePicto(picto.get_category(),picto.get_ImgId());
} 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();
} catch (JSONException e) {
fail(e.getMessage());
Log.e(LOG_TAG,"Error uploading picto when getting json from server:"+e.getMessage()+":"+server_response.toString());
}
}
}
......@@ -81,7 +81,7 @@ public class Img {
}
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 void set_url(String url) {this.url=url;}
public String get_type() { return this.type;}
......
......@@ -6,7 +6,7 @@ android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.yottacode.pictogram.supervisor"
applicationId "com.yottacode.pictogram.supervisor_tablet"
minSdkVersion 21
targetSdkVersion 22
versionCode 3
......
......@@ -282,7 +282,7 @@ public class PictoMenu {
ll.removeAllViewsInLayout();
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) {
e.printStackTrace();
}
......
......@@ -298,7 +298,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
int y = Math.round(event.getY());
int position = ((GridView) v).pointToPosition(x, y);
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)
v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
......@@ -562,7 +562,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
if (inserting) return;
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);
// If the picto is a category
......@@ -627,7 +627,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
if (p == null) {
// 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()) {
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);
} else
Toast.makeText(VocabularyManager.this, VocabularyManager.this.getResources().getString(R.string.notNewCats), Toast.LENGTH_SHORT).show();
......
......@@ -345,7 +345,8 @@ public class EditPictoActivity extends Activity {
if(editar){
p = PCBcontext.getVocabulary().get_picto(getIntent().getExtras().getInt(Picto.JSON_ATTTRS.CATEGORY),getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE));
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
if(p.get_audioFile() != null){
......@@ -366,6 +367,7 @@ public class EditPictoActivity extends Activity {
layoutGrabacion.setVisibility(View.VISIBLE);
hayGrabacion = false;
tiempoTotal = 0;
supAsociado.setText(NO_SUP_TEXT);
}
legend.setHorizontallyScrolling(false);
legend.setMaxLines(1);
......@@ -415,7 +417,7 @@ public class EditPictoActivity extends Activity {
filepath = editar ? dirImagePath + File.separator + legend.getText().toString() + "_" + id_pic + ".png"
: dirImagePath + File.separator + legend.getText().toString() + "_new_" + pathNumber+ ".png";
Log.e(LOG_TAG,"FILEPATH:"+filepath);
File imageFile = new File(filepath);
if(!editar) { //Si es añadir uno nuevo comprobar que el random no existe ya en el path
while (imageFile.exists()) {
......@@ -431,10 +433,12 @@ public class EditPictoActivity extends Activity {
outputStream.flush();
outputStream.close();
Log.e(LOG_TAG,"FILEPATH IMG OK TO PNG:"+filepath);
} catch (FileNotFoundException e) {
e.printStackTrace();
Log.e(LOG_TAG,"Error when getting image:"+e.getMessage());
} catch (IOException e) {
Log.e(LOG_TAG,"Error when getting image:"+e.getMessage());
e.printStackTrace();
}
......@@ -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(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.USER_AVATAR, supAsociado.getText());
intent.putExtra(Picto.JSON_ATTTRS.USER_AVATAR, supAsociado.getText().equals(NO_SUP_TEXT) ? null : supAsociado.getText());
setResult(RESULT_OK, intent);
......
......@@ -72,7 +72,7 @@ public class LoginActivity extends FragmentActivity {
this.getIntent().getStringExtra("surname") + " (" + this.getIntent().getStringExtra("email") + ")");
final Vector<Img> imgs = new Vector<>(1);
Log.e("DETAIL","IMG SUP: "+this.getIntent().getStringExtra("pic"));
imgs.add(new Img(
this.getIntent().getIntExtra("sup_id", -1),
this.getIntent().getStringExtra("pic"),
......
......@@ -20,7 +20,7 @@ import com.yottacode.net.RestapiWrapper;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.ImgDownloader;
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.PCBcontext;
import com.yottacode.tools.GUITools;
......@@ -92,7 +92,7 @@ public class StudentFragmentGrid extends Fragment {
Log.e(StudentFragmentGrid.this.getClass().getCanonicalName(), e.getMessage());
}
PCBcontext.set_user(currentUser, null, null);
Intent pictogramActivity = new Intent(getActivity(), VOCAS.class);
Intent pictogramActivity = new Intent(getActivity(), VocabularyManager.class);
startActivity(pictogramActivity);
} else {
if (this.nameStudents[i].equals(getString(R.string.addStudent)))
......@@ -222,7 +222,7 @@ public class StudentFragmentGrid extends Fragment {
if (progressDialog != null && progressDialog.isShowing())
progressDialog.dismiss();
PCBcontext.getPcbdb().user_valid(license_valid);
Intent pictogramActivity = new Intent(getActivity(), VOCAS.class);
Intent pictogramActivity = new Intent(getActivity(), VocabularyManager.class);
startActivity(pictogramActivity);
}
......@@ -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_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(),
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) {
e.printStackTrace();
......
......@@ -344,7 +344,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
int y = Math.round(event.getY());
int position = ((GridView) v).pointToPosition(x, y);
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)
v.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS,
......@@ -745,7 +745,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
if (inserting) return;
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);
// If the picto is a category
......@@ -847,7 +847,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
Picto p = getCurrentPictoGridAdapter().getItem(position);
if (p != null && !p.is_invisible() && p.is_enabled()) {
// 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("disabled") &&
tapeAdapter.getCount() < VOCA.this.maxInTape) {
......
......@@ -2,6 +2,8 @@ package com.yottacode.pictogram.tabletlibrary.gui.login;
import android.app.Activity;
import android.graphics.Bitmap;
import android.os.AsyncTask;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
......@@ -10,7 +12,11 @@ import android.widget.ImageView;
import android.widget.TextView;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.ImgDownloader;
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.util.Vector;
......@@ -20,9 +26,39 @@ import java.util.Vector;
*/
public class CustomListLogin extends ArrayAdapter<User>{
private static final String LOG_TAG = CustomListLogin.class.getSimpleName();
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) {
super(context,R.layout.user_login_item, users);
this.context = context;
......@@ -44,7 +80,11 @@ public class CustomListLogin extends ArrayAdapter<User>{
ImageView fondo = (ImageView) rowView.findViewById(R.id.fondoFotoLogin);
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());
fondo.setImageResource(R.drawable.round_design_photo_white);
if (photo!=null) imageView.setImageBitmap(photo);
else imageView.setImageResource(R.drawable.anonymous_student);
......
......@@ -51,6 +51,7 @@
android:layout_height="match_parent"
android:src="@drawable/disabled_picto" />
</FrameLayout>
</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