Pictogram 1.6: soporte a tableros

parent 22883795
Showing with 77 additions and 95 deletions
......@@ -97,7 +97,7 @@ public class RestapiWrapper {
httpAsyncTaskParams.url=this.server + '/' + operation;
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 {
JSONObject obj=new JSONObject().put("url", msg).put("data", params);
Log.i(this.getClass().getName(), "Emitted messsage:" + obj);
socket.emit(this.EMIT_METHOD, obj, ack);
socket.emit(EMIT_METHOD, obj, ack);
}
public void destroy() {
if (this.socket.connected()) {
......
......@@ -33,6 +33,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
User currentUser;
boolean user_online; //true if the given user logged into the server
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.
*
......@@ -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)
* @param params example JSONObject{
* "supervisor": 23,
* "student": 105,
* "id": 135,
* "name": "sin",
* "active": true,
* "pictos": [.....] Pictos of that scene
* @param "id": the id scene
*
*/
public void setActiveGridForStudent(JSONObject params){
try {
int id_sup = -1;
/*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");
public void setActiveGrid(int id_grid){
String sql_grid = "UPDATE student SET id_grid = "+id_grid+" WHERE id = "+getCurrentUser().get_id_stu();
this.active_grid=id_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)
* @param id_stu
* @return
* @return active grid
*/
public int getActiveSceneForStudent(int id_stu){
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT id_scene FROM student WHERE id = "+id_stu,null);
cursor.moveToFirst();
Log.i(LOG_TAG,"Scene: "+cursor.getInt(0)+"-- For student: "+id_stu);
return cursor.getInt(0);
public int getActiveGrid(){
if (this.active_grid==Picto.NO_CHILD_GRID) {
Cursor cursor=getReadableDatabase().query("student",new String[]{"id_grid"},"id=?",new String[]{String.valueOf(getCurrentUser().get_id_stu())},null,null,null,null);
cursor.moveToFirst();
if(cursor.getCount() > 0){
this.active_grid=cursor.getInt(0);
}
}
return this.active_grid;
}
/**
......@@ -227,6 +205,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
int id_stu = this.currentUser.get_id_stu();
int id_grid = this.currentUser.get_active_grid();
getActiveGrid();
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);
......@@ -248,27 +227,44 @@ public class PCBDBHelper extends SQLiteOpenHelper {
*
* @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++) {
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;
if(!grid.get("supervisor").equals(null)){
id_sup = grid.getInt("supervisor");
}
String sql_grid="INSERT OR REPLACE INTO grid VALUES ("
+grid.getInt("id")
+","+id_sup
+",'"+grid.getInt("student")
+"','"+grid.getString("name")
+"','"+grid.getBoolean("active")
+"','"+grid.getString("color")
+"')";
+grid.getInt("id")
+","+id_sup
+",'"+grid.getInt("student")
+"','"+grid.getString("name")
+"','"+grid.getBoolean("active")
+"','"+grid.getString("color")
+"')";
getWritableDatabase().execSQL(sql_grid);
if (grid.getBoolean("active")) {
setActiveGrid(grid.getInt("id"));
Log.e(LOG_TAG,"ACTIVE GRID->"+getActiveGrid());
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
/**
......
......@@ -29,7 +29,9 @@ public class Picto extends Img {
private static final String LOG_TAG =Img.class.getName();
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_grid;
private int id_child_grid;
......@@ -76,7 +78,7 @@ public class Picto extends Img {
static String DISABLED = "disabled";
static String INVISIBLE = "invisible";
}
public final static int NO_CATEGORY=-1;
private boolean is_mirror=false;
private boolean highlight_background=false;
......@@ -276,7 +278,7 @@ public class Picto extends Img {
*/
public boolean is_disabled() {
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) {
return false;
}
......@@ -544,9 +546,7 @@ public class Picto extends Img {
}
public boolean has_child_grid(){
if(this.id_child_grid != -1)
return true;
return false;
return this.id_child_grid != NO_CHILD_GRID;
}
......
......@@ -337,7 +337,7 @@ public class User {
}
public boolean is_teacher() {
return get_office() == null ? false : get_office().length()>0;
return get_office()!=null && get_office().length()>0;
}
......
......@@ -38,7 +38,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
private boolean updated;
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;
public NetService(int delay, iNetServiceStatus listener) {
this.updated=RestapiWrapper.ping(PCBcontext.getContext().getResources().getString(R.string.server), ping_session);
......@@ -174,7 +174,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
} else if (PCBcontext.is_user_online()) {
Log.i(LOG_TAG, "PCB reconnect");
PCBcontext.getRoom().connect();
PCBcontext.getVocabulary().synchronize(-3);
PCBcontext.getVocabulary().synchronize();
synchronizeStudentAttributes();
PCBcontext.getActionLog().batch();
}
......@@ -188,7 +188,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
if(!PCBcontext.getRoom().inRoom()){
PCBcontext.getRoom().connect();
}
PCBcontext.getVocabulary().synchronize(-3);
PCBcontext.getVocabulary().synchronize();
synchronizeStudentAttributes();
nextSynchro(now+restfullSynchroTimming);
}
......
......@@ -49,7 +49,7 @@ public class ServerLogin {
final String TAG_TOKEN="token";
PCBcontext.getPcbdb().user_online(true);
PCBcontext.getRestapiWrapper().setToken(result.getString(TAG_TOKEN));
PCBcontext.getVocabulary().synchronize(-3);
PCBcontext.getVocabulary().synchronize();
PCBcontext.getRoom().connect();
}
listener.result(result);
......
......@@ -6,10 +6,10 @@ android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.yottacode.pictogram.supervisor_tablet"
applicationId "com.yottacode.pictogram.supervisor"
minSdkVersion 21
targetSdkVersion 22
versionCode 3
versionCode 4
versionName "1.5"
resValue "bool","NotifyAllwaysVisible","false"
resValue "string", "VersionManagerClass", "com.yottacode.pictogram.supervisor.net.VersionManager"
......
......@@ -84,14 +84,10 @@ public class PictoMenu {
public void addPicto(int row, int col, int cat, int source) {
//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.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
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
......@@ -109,16 +105,9 @@ public class PictoMenu {
Intent intent = new Intent(activity, EditPictoActivity.class);
intent.putExtra(ID_PICTO_IMAGE,id_picto);
//Enviar al voca los datos necesarios para editar el picto despues
/*if (/*PCBcontext.getPcbdb().getCurrentUser().has_categories()*--PCBcontext.getVocabulary().has_categories()) {*/
intent.putExtra(Picto.JSON_ATTTRS.ROW, row);
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();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
......
......@@ -720,16 +720,12 @@ public class RadialMenuWidget extends View {
}
private boolean pntInCircle(double px, double py, double x1, double y1, double radius) {
double diffX = x1 - px;
double diffY = y1 - py;
double dist = diffX*diffX + diffY*diffY;
if (dist < radius*radius) {
return true;
}
else {
return false;
}
}
double diffX = x1 - px;
double diffY = y1 - py;
double dist = diffX * diffX + diffY * diffY;
return dist < radius * radius;
}
private boolean pntInWedge(double px, double py,
......
......@@ -181,8 +181,7 @@ public class EditPictoActivity extends Activity {
layoutPreview.setVisibility(tiempoGrabado > 1 ? View.VISIBLE : View.GONE);
layoutGrabacion.setVisibility(tiempoGrabado > 1 ? View.GONE : View.VISIBLE);
botonGrabar.PhidePressedRing();
hayGrabacion = (tiempoGrabado>=1 ? true : false); //Si lo grabado es al menos 1s => hay grabacion
if(hayGrabacion)
if(tiempoGrabado>=1)
assignFileToPlayer(new File(previewAudioPath));
reiniciarGrabacion();
......
......@@ -209,7 +209,7 @@ public class ListInstructionsFragment extends Fragment{
public void onItemClick(AdapterView<?> arg0, View arg1, int pos, long arg3) {
ListInstructionsFragment.this.instructionPosition = pos;
((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));
}
});
......
......@@ -256,7 +256,7 @@ public class SessionActivity extends FragmentActivity implements ListInstruction
@Override
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);
}
......
......@@ -123,6 +123,7 @@
<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/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/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
......@@ -132,6 +133,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 24 Platform" jdkType="Android SDK" />
......
......@@ -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());
}
Log.i(LOG_TAG, "Mensaje: " + msg.toString());
final AlertDialog.Builder builder = new AlertDialog.Builder(VOCA.this);
builder.setMessage(mensaje)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
......@@ -749,13 +749,13 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
p.set_mirror(false, false);
// If the picto is a category
/*if (PCBcontext.getVocabulary().is_category(p)) {
Log.e(LOG_TAG,"CHILD?"+p.has_child_grid()+" p id:"+p.get_stupicto_id());
if (p.has_child_grid()) {
currentCategory = p;
PCBcontext.getActionLog().log(new TalkAction(TalkAction.SELECT, p));
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);
if (PCBcontext.getPcbdb().getCurrentUser().one_picto_delivery()) {
(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