Pictogram 1.6: soporte a tableros

parent 22883795
Showing with 120 additions and 218 deletions
...@@ -97,7 +97,7 @@ public class RestapiWrapper { ...@@ -97,7 +97,7 @@ public class RestapiWrapper {
httpAsyncTaskParams.url=this.server + '/' + operation; httpAsyncTaskParams.url=this.server + '/' + operation;
httpAsyncTaskParams.json_params=json; httpAsyncTaskParams.json_params=json;
new HttpAsyncTask().executeOnExecutor(HttpAsyncTask.THREAD_POOL_EXECUTOR,httpAsyncTaskParams); new HttpAsyncTask().executeOnExecutor(HttpAsyncTask.SERIAL_EXECUTOR,httpAsyncTaskParams);
} }
/** /**
......
...@@ -114,7 +114,7 @@ public class SailsSocketsIO { ...@@ -114,7 +114,7 @@ public class SailsSocketsIO {
JSONObject obj=new JSONObject().put("url", msg).put("data", params); JSONObject obj=new JSONObject().put("url", msg).put("data", params);
Log.i(this.getClass().getName(), "Emitted messsage:" + obj); Log.i(this.getClass().getName(), "Emitted messsage:" + obj);
socket.emit(this.EMIT_METHOD, obj, ack); socket.emit(EMIT_METHOD, obj, ack);
} }
public void destroy() { public void destroy() {
if (this.socket.connected()) { if (this.socket.connected()) {
......
...@@ -33,6 +33,7 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -33,6 +33,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
User currentUser; User currentUser;
boolean user_online; //true if the given user logged into the server boolean user_online; //true if the given user logged into the server
boolean user_valid; //true if the given user has a valid license boolean user_valid; //true if the given user has a valid license
int active_grid=Picto.NO_CHILD_GRID;
/** /**
* Create a helper object to create, open, and/or manage a database. * Create a helper object to create, open, and/or manage a database.
* *
...@@ -153,51 +154,28 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -153,51 +154,28 @@ public class PCBDBHelper extends SQLiteOpenHelper {
/** /**
* To insert into grid the data of grid that come from the server (Actually only insert the active scene) * To insert into grid the data of grid that come from the server (Actually only insert the active scene)
* @param params example JSONObject{ * @param "id": the id scene
* "supervisor": 23, *
* "student": 105,
* "id": 135,
* "name": "sin",
* "active": true,
* "pictos": [.....] Pictos of that scene
*/ */
public void setActiveGridForStudent(JSONObject params){ public void setActiveGrid(int id_grid){
try { String sql_grid = "UPDATE student SET id_grid = "+id_grid+" WHERE id = "+getCurrentUser().get_id_stu();
int id_sup = -1; this.active_grid=id_grid;
/*if(!params.get("supervisor").equals(null)){
id_sup = params.getInt("supervisor");
}
String sql_grid="INSERT OR REPLACE INTO grid VALUES ("
+params.getInt("id")
+","+id_sup
+","+params.getInt("student")
+",'"+params.getString("name")
+"','"+params.getBoolean("active")
+"','"+params.getString("color")
+"')";
getWritableDatabase().execSQL(sql_grid);*/
//Added
String sql_grid = "UPDATE student SET id_grid = "+params.getInt("id")+" WHERE id = "+params.getInt("student");
getWritableDatabase().execSQL(sql_grid); getWritableDatabase().execSQL(sql_grid);
} catch (JSONException e) {
e.printStackTrace();
Log.e(LOG_TAG,"Error setting active grid:"+e.getMessage());
}
} }
/** /**
* Return the active scene for an student (Actually only find by id_stu cause table scene means activeScene of the student) * Return the active scene for an student (Actually only find by id_stu cause table scene means activeScene of the student)
* @param id_stu * @return active grid
* @return
*/ */
public int getActiveSceneForStudent(int id_stu){ public int getActiveGrid(){
SQLiteDatabase db = this.getReadableDatabase(); if (this.active_grid==Picto.NO_CHILD_GRID) {
Cursor cursor = db.rawQuery("SELECT id_scene FROM student WHERE id = "+id_stu,null); Cursor cursor=getReadableDatabase().query("student",new String[]{"id_grid"},"id=?",new String[]{String.valueOf(getCurrentUser().get_id_stu())},null,null,null,null);
cursor.moveToFirst(); cursor.moveToFirst();
Log.i(LOG_TAG,"Scene: "+cursor.getInt(0)+"-- For student: "+id_stu); if(cursor.getCount() > 0){
return cursor.getInt(0); this.active_grid=cursor.getInt(0);
}
}
return this.active_grid;
} }
/** /**
...@@ -227,6 +205,7 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -227,6 +205,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
int id_stu = this.currentUser.get_id_stu(); int id_stu = this.currentUser.get_id_stu();
int id_grid = this.currentUser.get_active_grid(); int id_grid = this.currentUser.get_active_grid();
getActiveGrid();
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT id_stu, id_picto, id_grid, id_child_grid, id_stupicto, url, translation, attributes FROM collection_detail WHERE id_stu = "+id_stu+" AND id_grid = "+id_grid,null); Cursor cursor = db.rawQuery("SELECT id_stu, id_picto, id_grid, id_child_grid, id_stupicto, url, translation, attributes FROM collection_detail WHERE id_stu = "+id_stu+" AND id_grid = "+id_grid,null);
...@@ -248,27 +227,44 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -248,27 +227,44 @@ public class PCBDBHelper extends SQLiteOpenHelper {
* *
* @param grids All the grids of an student * @param grids All the grids of an student
*/ */
public void saveGridForStudent(JSONArray grids) { public void saveGridsForStudent(JSONArray grids) {
for (int i = 0; i < grids.length(); i++) { for (int i = 0; i < grids.length(); i++) {
try { try {
JSONObject grid = grids.getJSONObject(i); saveGridForStudent(grids.getJSONObject(i));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
/**
* Save the grids of an student into the db
*
* @param grid a grid of an student
*/
public void saveGridForStudent(JSONObject grid) {
try {
int id_sup = -1; int id_sup = -1;
if(!grid.get("supervisor").equals(null)){ if(!grid.get("supervisor").equals(null)){
id_sup = grid.getInt("supervisor"); id_sup = grid.getInt("supervisor");
} }
String sql_grid="INSERT OR REPLACE INTO grid VALUES (" String sql_grid="INSERT OR REPLACE INTO grid VALUES ("
+grid.getInt("id") +grid.getInt("id")
+","+id_sup +","+id_sup
+",'"+grid.getInt("student") +",'"+grid.getInt("student")
+"','"+grid.getString("name") +"','"+grid.getString("name")
+"','"+grid.getBoolean("active") +"','"+grid.getBoolean("active")
+"','"+grid.getString("color") +"','"+grid.getString("color")
+"')"; +"')";
getWritableDatabase().execSQL(sql_grid); getWritableDatabase().execSQL(sql_grid);
if (grid.getBoolean("active")) {
setActiveGrid(grid.getInt("id"));
Log.e(LOG_TAG,"ACTIVE GRID->"+getActiveGrid());
}
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
}
} }
/** /**
......
...@@ -29,7 +29,9 @@ public class Picto extends Img { ...@@ -29,7 +29,9 @@ public class Picto extends Img {
private static final String LOG_TAG =Img.class.getName(); private static final String LOG_TAG =Img.class.getName();
public static final int STUPICTO_NULL = -1; public static final int STUPICTO_NULL = -1;
public static final int NO_CHILD_GRID = -99;
public final static int NO_CATEGORY=-1;
public static final int ACTIVE_GRID = -3;
private int id_stupicto; private int id_stupicto;
private int id_grid; private int id_grid;
private int id_child_grid; private int id_child_grid;
...@@ -76,7 +78,7 @@ public class Picto extends Img { ...@@ -76,7 +78,7 @@ public class Picto extends Img {
static String DISABLED = "disabled"; static String DISABLED = "disabled";
static String INVISIBLE = "invisible"; static String INVISIBLE = "invisible";
} }
public final static int NO_CATEGORY=-1;
private boolean is_mirror=false; private boolean is_mirror=false;
private boolean highlight_background=false; private boolean highlight_background=false;
...@@ -276,7 +278,7 @@ public class Picto extends Img { ...@@ -276,7 +278,7 @@ public class Picto extends Img {
*/ */
public boolean is_disabled() { public boolean is_disabled() {
try { try {
return !PCBcontext.getPcbdb().getCurrentUser().is_supervisor() ? false : this.attributes.getString(JSON_ATTTRS.STATUS).equals(JSON_ATTTR_STATUS_VALUES.DISABLED); return PCBcontext.getPcbdb().getCurrentUser().is_supervisor() && this.attributes.getString(JSON_ATTTRS.STATUS).equals(JSON_ATTTR_STATUS_VALUES.DISABLED);
} catch (JSONException e) { } catch (JSONException e) {
return false; return false;
} }
...@@ -544,9 +546,7 @@ public class Picto extends Img { ...@@ -544,9 +546,7 @@ public class Picto extends Img {
} }
public boolean has_child_grid(){ public boolean has_child_grid(){
if(this.id_child_grid != -1) return this.id_child_grid != NO_CHILD_GRID;
return true;
return false;
} }
......
...@@ -337,7 +337,7 @@ public class User { ...@@ -337,7 +337,7 @@ public class User {
} }
public boolean is_teacher() { public boolean is_teacher() {
return get_office() == null ? false : get_office().length()>0; return get_office()!=null && get_office().length()>0;
} }
......
package com.yottacode.pictogram.grammar; package com.yottacode.pictogram.grammar;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.support.annotation.Nullable;
import android.util.Log; import android.util.Log;
import com.yottacode.net.RestapiWrapper; import com.yottacode.net.RestapiWrapper;
import com.yottacode.pictogram.commonlibrary.R;
import com.yottacode.pictogram.action.VocabularyAction; import com.yottacode.pictogram.action.VocabularyAction;
import com.yottacode.pictogram.commonlibrary.R;
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;
...@@ -23,6 +22,7 @@ import org.json.JSONObject; ...@@ -23,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.util.Enumeration;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -52,8 +52,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -52,8 +52,7 @@ public class Vocabulary implements Iterable<Picto> {
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()) {
download_grids(); synchronize();
synchronize(-3);
}else }else
try { try {
PCBcontext.getPcbdb().getStudentVocabulary(this); PCBcontext.getPcbdb().getStudentVocabulary(this);
...@@ -77,7 +76,6 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -77,7 +76,6 @@ public class Vocabulary implements Iterable<Picto> {
} }
case update:{ case update:{
Log.e("MENSAJE", "Entra en update");
Log.i(this.getClass().getCanonicalName(), "Picto update "+args.toString()); Log.i(this.getClass().getCanonicalName(), "Picto update "+args.toString());
try { try {
modifyAttsPicto(picto_grid, picto_id, args.getJSONObject("attributes")); modifyAttsPicto(picto_grid, picto_id, args.getJSONObject("attributes"));
...@@ -88,7 +86,6 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -88,7 +86,6 @@ public class Vocabulary implements Iterable<Picto> {
break; break;
} }
case update_category:{ case update_category:{
Log.e("MENSAJE", "Entra en update_category");
Log.i(this.getClass().getCanonicalName(), "Picto category update "+args.toString()); Log.i(this.getClass().getCanonicalName(), "Picto category update "+args.toString());
Vocabulary.this.synchronize(get_picto(picto_grid,picto_id).get_grid()); Vocabulary.this.synchronize(get_picto(picto_grid,picto_id).get_grid());
} }
...@@ -180,7 +177,8 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -180,7 +177,8 @@ public class Vocabulary implements Iterable<Picto> {
/** /**
* save all the grids of an student * save all the grids of an student
*/ */
public void download_grids() { public JSONArray download_grids() {
final JSONArray[] grids = new JSONArray[1];
final String picto_str = "/grids"; final String picto_str = "/grids";
String operation = PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + picto_str; String operation = PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + picto_str;
...@@ -193,7 +191,8 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -193,7 +191,8 @@ public class Vocabulary implements Iterable<Picto> {
@Override @Override
public void result(JSONArray result) { public void result(JSONArray result) {
if (result != null && PCBcontext.is_user_logged()) { if (result != null && PCBcontext.is_user_logged()) {
PCBcontext.getPcbdb().saveGridForStudent(result); PCBcontext.getPcbdb().saveGridsForStudent(result);
grids[0]=result;
}else }else
Log.e(this.getClass().getName(), "Downloaded images ended when the user comes to logout"); Log.e(this.getClass().getName(), "Downloaded images ended when the user comes to logout");
} }
...@@ -209,15 +208,20 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -209,15 +208,20 @@ public class Vocabulary implements Iterable<Picto> {
if (Vocabulary.this.imgListener != null) Vocabulary.this.imgListener.error(e); if (Vocabulary.this.imgListener != null) Vocabulary.this.imgListener.error(e);
} }
}); });
return grids[0];
}
public void synchronize() {
this.pictos.clear();
synchronize(Picto.ACTIVE_GRID);
PCBcontext.getPcbdb().setStudentVocabulary(Vocabulary.this);
} }
public void synchronize(final int id_grid) { public void synchronize(final int id_grid) {
boolean upload_pending=synchronize_upload(); // (i) uploading boolean upload_pending=synchronize_upload(); // (i) uploading
// and (ii) downloading // and (ii) downloading
if (!upload_pending) { if (!upload_pending) {
final String picto_str = "/activeGrid"; String operation = id_grid==Picto.ACTIVE_GRID ? PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + "/activeGrid"
String operation = PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + picto_str; : "grid/"+id_grid;
PCBcontext.getRestapiWrapper().ask(operation, new RestapiWrapper.iRestapiListener() { PCBcontext.getRestapiWrapper().ask(operation, new RestapiWrapper.iRestapiListener() {
@Override @Override
public void preExecute() { public void preExecute() {
...@@ -247,13 +251,16 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -247,13 +251,16 @@ public class Vocabulary implements Iterable<Picto> {
picto.getString("uri"), picto.getString("uri"),
stupicto.getInt("id"), stupicto.getInt("id"),
stupicto.getInt("id_grid"), stupicto.getInt("id_grid"),
stupicto.isNull("id_child_grid") ? -99 : stupicto.getInt("id_child_grid"), stupicto.isNull("id_child_grid") ? Picto.NO_CHILD_GRID : stupicto.getInt("id_child_grid"),
attributes); attributes);
} }
PCBcontext.getPcbdb().saveGridForStudent(result);
synchronizeImgs(pictos_list); synchronizeImgs(pictos_list);
PCBcontext.getPcbdb().setStudentVocabulary(Vocabulary.this); for (int i = 0; i < stu_pictos.length(); i++)
PCBcontext.getPcbdb().setActiveGridForStudent(result); //Aqui inserto en scene los datos que llegan de la activa if (pictos_list[i].has_child_grid() && !find_scene(pictos_list[i].get_child_grid())) {
Log.e(this.getClass().getCanonicalName(), "Invocando escenario " + pictos_list[i].get_child_grid()+":"+pictos_list[i].get_stupicto_id());
synchronize(pictos_list[i].get_child_grid());
}
Log.i(this.getClass().getName(), " Pictos downloaded: " + result.getJSONArray("pictos").length()); Log.i(this.getClass().getName(), " Pictos downloaded: " + result.getJSONArray("pictos").length());
} catch (JSONException e) { } catch (JSONException e) {
...@@ -277,73 +284,6 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -277,73 +284,6 @@ public class Vocabulary implements Iterable<Picto> {
} }
public void synchronize_child(final int id_grid) {
boolean upload_pending=synchronize_upload(); // (i) uploading
String picto_str = "/grid";
String operation = picto_str + "/" +id_grid;
while(!upload_pending){ // Id_child_grid != null
PCBcontext.getRestapiWrapper().ask(operation, new RestapiWrapper.iRestapiListener() {
@Override
public void preExecute() {
}
@Override
public void result(JSONArray result) {
}
@Override
public void result(JSONObject result) {
if (result != null && PCBcontext.is_user_logged()) {
JSONObject picto, attributes;
JSONObject stupicto = null;
try {
JSONArray stu_pictos = result.getJSONArray("pictos"); //Obtengo el JSONArray de los stupictos
Picto[] pictos_list = new Picto[stu_pictos.length()];
for (int i = 0; i < stu_pictos.length(); i++) {
stupicto = stu_pictos.getJSONObject(i);
picto = stupicto.getJSONObject("picto");
attributes = stupicto.getJSONObject("attributes");
attributes.put(Picto.JSON_ATTTRS.STUPICTO_ID, stupicto.getInt("id"));
if(!stupicto.isNull("id_child_grid")){
if(!pictos.containsKey(new Integer(stupicto.getInt("id_child_grid")))){
Log.i("MENSAJE","Tiene id_child: "+stupicto.getInt("id_child_grid"));
synchronize_child(stupicto.getInt("id_child_grid"));
}
}
Log.e(getClass().getCanonicalName(),"GRID: "+(stupicto.isNull("id_child_grid") ? -99 : stupicto.getInt("id_child_grid")));
pictos_list[i] = new Picto(picto.getInt("id"),
picto.getString("uri"),
stupicto.getInt("id"),
stupicto.getInt("id_grid"),
stupicto.isNull("id_child_grid") ? -99 : stupicto.getInt("id_child_grid"),
attributes);
}
//synchronizeImgs(pictos_list);
Log.i(this.getClass().getName(), " Pictos downloaded: " + result.getJSONArray("pictos").length());
} catch (JSONException e) {
StackTraceElement traces[] = e.getStackTrace();
for (StackTraceElement s : traces)
Log.e(s.getClassName() + "." + s.getFileName() + "." + s.getLineNumber(), s.toString());
Log.e(this.getClass().getName(), " Picto JSON error from server: " + stupicto.toString());
this.error(new RestapiWrapper.HTTPException("JSON Error:" + e.getMessage(), -1));
}
}
else Log.e(this.getClass().getName(), "Downloaded images ended when the user comes to logout");
}
@Override
public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getName(), " Server RESTAPI error: " + e.getLocalizedMessage());
if (Vocabulary.this.imgListener != null) Vocabulary.this.imgListener.error(e);
}
});
}
}
/** /**
...@@ -356,8 +296,6 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -356,8 +296,6 @@ public class Vocabulary implements Iterable<Picto> {
Vector<Img> imgs=new Vector<Img>(updated_collection.length); Vector<Img> imgs=new Vector<Img>(updated_collection.length);
this.pictos.clear();
for (Picto updated_picto: updated_collection) { for (Picto updated_picto: updated_collection) {
LinkedList<Picto> pictos_grid; LinkedList<Picto> pictos_grid;
Picto picto = new Picto(updated_picto.get_ImgId(), Picto picto = new Picto(updated_picto.get_ImgId(),
...@@ -424,6 +362,14 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -424,6 +362,14 @@ public class Vocabulary implements Iterable<Picto> {
} }
private boolean find_scene(int pic_grid) {
Enumeration<Integer> grids=this.pictos.keys();
Integer a_grid=pic_grid-1;
while (grids.hasMoreElements() && (a_grid=grids.nextElement())!=pic_grid);
return a_grid.intValue()==pic_grid;
}
//case:categories //case:categories
private Picto find_picto(int pic_grid, int row,int column) { private Picto find_picto(int pic_grid, int row,int column) {
LinkedList<Picto> pictos_grid=this.pictos.get(pic_grid); LinkedList<Picto> pictos_grid=this.pictos.get(pic_grid);
...@@ -490,7 +436,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -490,7 +436,7 @@ public class Vocabulary implements Iterable<Picto> {
String old_legend=picto.get_legend(); String old_legend=picto.get_legend();
picto.set_json_attr(attrs); picto.set_json_attr(attrs);
if (!old_legend.equals(picto.get_legend())) //puede ocurrir que se cambie la leyenda de TODOS los pictos if (!old_legend.equals(picto.get_legend())) //puede ocurrir que se cambie la leyenda de TODOS los pictos
this.synchronize(-3); this.synchronize();
PCBcontext.getPcbdb().modifyPicto(pic_id, attrs.toString()); PCBcontext.getPcbdb().modifyPicto(pic_id, attrs.toString());
} }
else else
...@@ -524,55 +470,29 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -524,55 +470,29 @@ public class Vocabulary implements Iterable<Picto> {
LinkedList<Picto> startpictos = null; LinkedList<Picto> startpictos = null;
if (pictos.size()==0) if (pictos.size()==0)
startpictos=null; startpictos=null;
else
Log.e("MENSAJE", "Pictos size: "+pictos.size());
for(int i = 0;i<pictos.size();i++){
LinkedList<Picto> category = pictos.get(i);
Log.e("MENSAJE", "Cat: "+i);
if(pictos.get(i)!= null) {
for (int j = 0; j < category.size(); j++) {
Log.e("MENSAJE", "Picto: " + category.get(j).get_stupicto_id());
}
}
}
/*startpictos = new LinkedList<>();
LinkedList<Picto> category=pictos.get();
for (Picto picto: category) {
if (picto.get_row() != -1 && picto.get_column() != -1) {
startpictos.add(picto);
}
}*/
return startpictos;
/*LinkedList<Picto> startpictos;
if (pictos.size()==0)
startpictos=null;
else { else {
startpictos = new LinkedList<>(); startpictos = new LinkedList<>();
LinkedList<Picto> grid = this.pictos.get(new Integer(Picto.NO_CATEGORY)); Log.e(LOG_TAG,"ACTIVE GRID:"+PCBcontext.getPcbdb().getActiveGrid()+this.pictos.get(PCBcontext.getPcbdb().getActiveGrid()));
for (Picto picto : grid) { LinkedList<Picto> pictos = this.pictos.get(PCBcontext.getPcbdb().getActiveGrid());
//if (picto.getFreeRow() != -1 && picto.getFreeColumn() != -1) { for (Picto picto : pictos) {
startpictos.add(picto); startpictos.add(picto);
//}
} }
} }
return startpictos;*/ return startpictos;
} }
/** /**
* A vocabulary is visible iif it has at least an enabled concept * A vocabulary is visible iif it the active scene has at least an enabled concept
* @return * @return
*/ */
public boolean isVisibleAnyPicto() { public boolean isVisibleAnyPicto() {
boolean visible=false; boolean visible = false;
if (this.pictos.size()>0) if (this.pictos.size()>0)
for (Picto picto : this.pictos.get(Picto.NO_CATEGORY)) { for (Picto picto : this.pictos.get(PCBcontext.getPcbdb().getActiveGrid())) {
visible=!picto.is_invisible(); visible = !picto.is_invisible();
if (visible) break; if (visible) break;
} }
return visible; return visible;
} }
/* /*
...@@ -624,7 +544,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -624,7 +544,7 @@ public class Vocabulary implements Iterable<Picto> {
* @return set of pictos which should be selectable in a given sentence state * @return set of pictos which should be selectable in a given sentence state
*/ */
public LinkedList<Picto> next(Picto picto){ public LinkedList<Picto> next(Picto picto){
return startSentence(); return this.pictos.get(picto.get_child_grid());
} }
......
...@@ -38,7 +38,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin { ...@@ -38,7 +38,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
private boolean updated; private boolean updated;
private final Vector<iNetServiceStatus> listeners; private final Vector<iNetServiceStatus> listeners;
private static final long restfullSynchroTimming=PCBcontext.getContext().getResources().getInteger(R.integer.netservice_force_restfull_synchro)*1000; private static final long restfullSynchroTimming=PCBcontext.getContext().getResources().getInteger(R.integer.netservice_force_restfull_synchro)*100000;
private long nextRestfullSynchro; private long nextRestfullSynchro;
public NetService(int delay, iNetServiceStatus listener) { public NetService(int delay, iNetServiceStatus listener) {
this.updated=RestapiWrapper.ping(PCBcontext.getContext().getResources().getString(R.string.server), ping_session); this.updated=RestapiWrapper.ping(PCBcontext.getContext().getResources().getString(R.string.server), ping_session);
...@@ -174,7 +174,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin { ...@@ -174,7 +174,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
} else if (PCBcontext.is_user_online()) { } else if (PCBcontext.is_user_online()) {
Log.i(LOG_TAG, "PCB reconnect"); Log.i(LOG_TAG, "PCB reconnect");
PCBcontext.getRoom().connect(); PCBcontext.getRoom().connect();
PCBcontext.getVocabulary().synchronize(-3); PCBcontext.getVocabulary().synchronize();
synchronizeStudentAttributes(); synchronizeStudentAttributes();
PCBcontext.getActionLog().batch(); PCBcontext.getActionLog().batch();
} }
...@@ -188,7 +188,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin { ...@@ -188,7 +188,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
if(!PCBcontext.getRoom().inRoom()){ if(!PCBcontext.getRoom().inRoom()){
PCBcontext.getRoom().connect(); PCBcontext.getRoom().connect();
} }
PCBcontext.getVocabulary().synchronize(-3); PCBcontext.getVocabulary().synchronize();
synchronizeStudentAttributes(); synchronizeStudentAttributes();
nextSynchro(now+restfullSynchroTimming); nextSynchro(now+restfullSynchroTimming);
} }
......
...@@ -49,7 +49,7 @@ public class ServerLogin { ...@@ -49,7 +49,7 @@ public class ServerLogin {
final String TAG_TOKEN="token"; final String TAG_TOKEN="token";
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(-3); PCBcontext.getVocabulary().synchronize();
PCBcontext.getRoom().connect(); PCBcontext.getRoom().connect();
} }
listener.result(result); listener.result(result);
......
...@@ -6,10 +6,10 @@ android { ...@@ -6,10 +6,10 @@ android {
compileSdkVersion 24 compileSdkVersion 24
buildToolsVersion '25.0.0' buildToolsVersion '25.0.0'
defaultConfig { defaultConfig {
applicationId "com.yottacode.pictogram.supervisor_tablet" applicationId "com.yottacode.pictogram.supervisor"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 22 targetSdkVersion 22
versionCode 3 versionCode 4
versionName "1.5" versionName "1.5"
resValue "bool","NotifyAllwaysVisible","false" resValue "bool","NotifyAllwaysVisible","false"
resValue "string", "VersionManagerClass", "com.yottacode.pictogram.supervisor.net.VersionManager" resValue "string", "VersionManagerClass", "com.yottacode.pictogram.supervisor.net.VersionManager"
......
...@@ -84,14 +84,10 @@ public class PictoMenu { ...@@ -84,14 +84,10 @@ public class PictoMenu {
public void addPicto(int row, int col, int cat, int source) { public void addPicto(int row, int col, int cat, int source) {
//Enviar al voca los datos necesarios para crear el picto despues //Enviar al voca los datos necesarios para crear el picto despues
/*if (/*PCBcontext.getPcbdb().getCurrentUser().has_categories()*--PCBcontext.getVocabulary().has_categories()) {*/
activity.getIntent().putExtra(Picto.JSON_ATTTRS.ROW, row); activity.getIntent().putExtra(Picto.JSON_ATTTRS.ROW, row);
activity.getIntent().putExtra(Picto.JSON_ATTTRS.COLUMN, col); activity.getIntent().putExtra(Picto.JSON_ATTTRS.COLUMN, col);
/* } else {
activity.getIntent().putExtra(Picto.JSON_ATTTRS.FREE_ROW, row);
activity.getIntent().putExtra(Picto.JSON_ATTTRS.FREE_COLUMN, col);
}*/
if (source == 0) { //Pick from camera if (source == 0) { //Pick from camera
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
...@@ -109,16 +105,9 @@ public class PictoMenu { ...@@ -109,16 +105,9 @@ public class PictoMenu {
Intent intent = new Intent(activity, EditPictoActivity.class); Intent intent = new Intent(activity, EditPictoActivity.class);
intent.putExtra(ID_PICTO_IMAGE,id_picto); intent.putExtra(ID_PICTO_IMAGE,id_picto);
//Enviar al voca los datos necesarios para editar el picto despues intent.putExtra(Picto.JSON_ATTTRS.ROW, row);
/*if (/*PCBcontext.getPcbdb().getCurrentUser().has_categories()*--PCBcontext.getVocabulary().has_categories()) {*/ intent.putExtra(Picto.JSON_ATTTRS.COLUMN, col);
intent.putExtra(Picto.JSON_ATTTRS.ROW, row);
intent.putExtra(Picto.JSON_ATTTRS.COLUMN, col);
/*} else {
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, Picto.NO_CATEGORY);
intent.putExtra(Picto.JSON_ATTTRS.FREE_ROW, free_row);
intent.putExtra(Picto.JSON_ATTTRS.FREE_COLUMN, free_col);
}*/
/*ByteArrayOutputStream stream = new ByteArrayOutputStream(); /*ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
......
...@@ -720,16 +720,12 @@ public class RadialMenuWidget extends View { ...@@ -720,16 +720,12 @@ public class RadialMenuWidget extends View {
} }
private boolean pntInCircle(double px, double py, double x1, double y1, double radius) { private boolean pntInCircle(double px, double py, double x1, double y1, double radius) {
double diffX = x1 - px; double diffX = x1 - px;
double diffY = y1 - py; double diffY = y1 - py;
double dist = diffX*diffX + diffY*diffY; double dist = diffX * diffX + diffY * diffY;
if (dist < radius*radius) { return dist < radius * radius;
return true; }
}
else {
return false;
}
}
private boolean pntInWedge(double px, double py, private boolean pntInWedge(double px, double py,
......
...@@ -181,8 +181,7 @@ public class EditPictoActivity extends Activity { ...@@ -181,8 +181,7 @@ public class EditPictoActivity extends Activity {
layoutPreview.setVisibility(tiempoGrabado > 1 ? View.VISIBLE : View.GONE); layoutPreview.setVisibility(tiempoGrabado > 1 ? View.VISIBLE : View.GONE);
layoutGrabacion.setVisibility(tiempoGrabado > 1 ? View.GONE : View.VISIBLE); layoutGrabacion.setVisibility(tiempoGrabado > 1 ? View.GONE : View.VISIBLE);
botonGrabar.PhidePressedRing(); botonGrabar.PhidePressedRing();
hayGrabacion = (tiempoGrabado>=1 ? true : false); //Si lo grabado es al menos 1s => hay grabacion if(tiempoGrabado>=1)
if(hayGrabacion)
assignFileToPlayer(new File(previewAudioPath)); assignFileToPlayer(new File(previewAudioPath));
reiniciarGrabacion(); reiniciarGrabacion();
......
...@@ -209,7 +209,7 @@ public class ListInstructionsFragment extends Fragment{ ...@@ -209,7 +209,7 @@ public class ListInstructionsFragment extends Fragment{
public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) { public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
ListInstructionsFragment.this.instructionPosition = pos; ListInstructionsFragment.this.instructionPosition = pos;
((ArrayAdapter<String>) listview_instructions.getAdapter()).notifyDataSetChanged(); ((ArrayAdapter<String>) listview_instructions.getAdapter()).notifyDataSetChanged();
int instructionID=ListInstructionsFragment.this.instructionsID.get((String)listview_instructions.getAdapter().getItem(instructionPosition)); int instructionID=ListInstructionsFragment.this.instructionsID.get(listview_instructions.getAdapter().getItem(instructionPosition));
listener.instruction_selected(instructionID,(String)listview_instructions.getAdapter().getItem(instructionPosition)); listener.instruction_selected(instructionID,(String)listview_instructions.getAdapter().getItem(instructionPosition));
} }
}); });
......
...@@ -256,7 +256,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction ...@@ -256,7 +256,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
@Override @Override
public void method_selected(int method, String method_name) { public void method_selected(int method, String method_name) {
((ToggleButton) findViewById(R.id.sessionOnOffBtn)).setEnabled(false); findViewById(R.id.sessionOnOffBtn).setEnabled(false);
((TextView) findViewById(R.id.sessionTopbarMethodName)).setText(method_name); ((TextView) findViewById(R.id.sessionTopbarMethodName)).setText(method_name);
} }
......
...@@ -123,6 +123,7 @@ ...@@ -123,6 +123,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
...@@ -132,6 +133,7 @@ ...@@ -132,6 +133,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" /> <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" /> <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" />
......
...@@ -163,7 +163,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -163,7 +163,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
mensaje += (i != pictos.length() - 1 ? picto.get("expression").toString() + " - " : picto.get("expression").toString()); mensaje += (i != pictos.length() - 1 ? picto.get("expression").toString() + " - " : picto.get("expression").toString());
} }
Log.i(LOG_TAG, "Mensaje: " + msg.toString());
final AlertDialog.Builder builder = new AlertDialog.Builder(VOCA.this); final AlertDialog.Builder builder = new AlertDialog.Builder(VOCA.this);
builder.setMessage(mensaje) builder.setMessage(mensaje)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() { .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
...@@ -749,13 +749,13 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -749,13 +749,13 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
p.set_mirror(false, false); p.set_mirror(false, false);
// If the picto is a category // If the picto is a category
Log.e(LOG_TAG,"CHILD?"+p.has_child_grid()+" p id:"+p.get_stupicto_id());
/*if (PCBcontext.getVocabulary().is_category(p)) { if (p.has_child_grid()) {
currentCategory = p; currentCategory = p;
PCBcontext.getActionLog().log(new TalkAction(TalkAction.SELECT, p)); PCBcontext.getActionLog().log(new TalkAction(TalkAction.SELECT, p));
hidePictoMainGridView(); hidePictoMainGridView();
} else*/ if (tapeAdapter.getCount() < VOCA.this.maxInTape && !VOCA.this.tapeAdapter.play()) { } else if (tapeAdapter.getCount() < VOCA.this.maxInTape && !VOCA.this.tapeAdapter.play()) {
addPictoWord(parent.getChildAt(position), p); addPictoWord(parent.getChildAt(position), p);
if (PCBcontext.getPcbdb().getCurrentUser().one_picto_delivery()) { if (PCBcontext.getPcbdb().getCurrentUser().one_picto_delivery()) {
(new Handler()).postDelayed(new Runnable() { (new Handler()).postDelayed(new Runnable() {
......
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