Commit 10cf7caf by Arturo Montejo Ráez

Merge branch 'develop' of http://gitlab.ujaen.es/yotta/pictogram into develop

parents 25c043d1 4146cf9d
...@@ -10,7 +10,7 @@ android { ...@@ -10,7 +10,7 @@ android {
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
resValue "string", "db_name", "PCB.db" resValue "string", "db_name", "PCB.db"
resValue "integer", "db_version", "4" resValue "integer", "db_version", "7"
resValue "string", "app_version", "1.1" resValue "string", "app_version", "1.1"
resValue "string", "core_vocabulary", "core_vocabulary" resValue "string", "core_vocabulary", "core_vocabulary"
resValue "string", "apk", "to_be_set_in_subproject" resValue "string", "apk", "to_be_set_in_subproject"
......
...@@ -38,12 +38,13 @@ public class Device extends SQLiteOpenHelper { ...@@ -38,12 +38,13 @@ public class Device extends SQLiteOpenHelper {
private static final String LOG_TAG = SQLiteOpenHelper.class.getCanonicalName(); private static final String LOG_TAG = SQLiteOpenHelper.class.getCanonicalName();
Context context; Context context;
public static final String PREFS_NAME = "MyPrefsFile";
final static class PARAMS { final static class PARAMS {
static String keyword="key"; static String keyword="keyword";
static String stu_id="last__stu_id"; static String stu_id="last__stu_id";
static String sup_id="last__sup_id"; static String sup_id="last__sup_id";
static String db_version="db_version";
} }
/** /**
...@@ -51,18 +52,14 @@ public class Device extends SQLiteOpenHelper { ...@@ -51,18 +52,14 @@ public class Device extends SQLiteOpenHelper {
* *
* @param context the context of the activity * @param context the context of the activity
* @param factory null * @param factory null
* @param version 1
*/ */
public Device(Context context, CursorFactory factory, int version) { public Device(Context context, CursorFactory factory, int version) {
super(context, DeviceHelper.getDBName(context), factory, context.getSharedPreferences(PREFS_NAME, 0).getInt(PARAMS.db_version,version));
super(context, DeviceHelper.getDBName(context), factory, version); this.context = context;
if (DeviceHelper.force_create(context)) { if (DeviceHelper.force_create(context)) {
Log.i(this.getClass().getCanonicalName(),"Forcing create new Database "+DeviceHelper.getDBName(context)+" v."+ DeviceHelper.getDBVersion(context)); Log.i(this.getClass().getCanonicalName(),"Forcing create new Database "+DeviceHelper.getDBName(context)+" v."+ DeviceHelper.getDBVersion(context));
context.deleteDatabase(DeviceHelper.getDBName(context)); context.deleteDatabase(DeviceHelper.getDBName(context));
Log.i(this.getClass().getCanonicalName(), "Database dropped");
} }
this.context = context;
} }
/** /**
...@@ -70,7 +67,14 @@ public class Device extends SQLiteOpenHelper { ...@@ -70,7 +67,14 @@ public class Device extends SQLiteOpenHelper {
* *
*/ */
private void setParam(String param, String value) { private void setParam(String param, String value) {
SQLiteDatabase db = this.getWritableDatabase(); setParam(this.getWritableDatabase(),param,value);
}
/**
* Set the value of a param.
*
*/
private void setParam(SQLiteDatabase db, String param, String value) {
db.beginTransaction(); db.beginTransaction();
ContentValues values=new ContentValues(2); ContentValues values=new ContentValues(2);
values.put("key", param); values.put("key", param);
...@@ -88,18 +92,19 @@ public class Device extends SQLiteOpenHelper { ...@@ -88,18 +92,19 @@ public class Device extends SQLiteOpenHelper {
* @return value of key param * @return value of key param
*/ */
public String getParamValue(String key) { public String getParamValue(String key) {
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db= this.getReadableDatabase();
String value; String value;
Cursor cursor = db.query("params", new String[]{"value"}, "key=?", new String[]{key}, null, null, null, null); Cursor cursor = db.query("params", new String[]{"value"}, "key=?", new String[]{key}, null, null, null, null);
if (cursor.getCount() == 0){ if (cursor.getCount() == 0){
value = null; value = null;
Log.e(this.getClass().getCanonicalName(), "Error when getting param " + key); Log.e(LOG_TAG, "Error when getting param " + key);
}else { }else {
cursor.moveToFirst(); cursor.moveToFirst();
value = cursor.getString(0); value = cursor.getString(0);
} }
//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
cursor.close();
return value; return value;
} }
...@@ -337,8 +342,7 @@ public class Device extends SQLiteOpenHelper { ...@@ -337,8 +342,7 @@ public class Device extends SQLiteOpenHelper {
* delete the list of images (students, supervisors, pictograms) which are no longer used * delete the list of images (students, supervisors, pictograms) which are no longer used
*/ */
public void deleteDeprecatedImgs() { public void deleteDeprecatedImgs() {
SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = this.getWritableDatabase().query("deprecated_images", null, null, null, null, null, null);
Cursor cursor = db.query("deprecated_images", null, null, null, null, null, null);
while (cursor.moveToNext()) { while (cursor.moveToNext()) {
String type = cursor.getString(1); String type = cursor.getString(1);
String folder = type.equals("stu") ? Img.STUDENT : type.equals("sup") ? Img.SUPERVISOR : Img.VOCABULARY; String folder = type.equals("stu") ? Img.STUDENT : type.equals("sup") ? Img.SUPERVISOR : Img.VOCABULARY;
...@@ -347,7 +351,7 @@ public class Device extends SQLiteOpenHelper { ...@@ -347,7 +351,7 @@ public class Device extends SQLiteOpenHelper {
Log.i(this.getClass().getCanonicalName(), "Image file " + cursor.getString(1) + "." + cursor.getInt(0) + " deleted"); Log.i(this.getClass().getCanonicalName(), "Image file " + cursor.getString(1) + "." + cursor.getInt(0) + " deleted");
} }
cursor.close(); cursor.close();
db.delete("deprecated_images", null, null); this.getWritableDatabase().delete("deprecated_images", null, null);
//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
} }
...@@ -356,11 +360,11 @@ public class Device extends SQLiteOpenHelper { ...@@ -356,11 +360,11 @@ public class Device extends SQLiteOpenHelper {
* IMPORTANT: every DDL sentence has to finish with the sequence: ;-- * IMPORTANT: every DDL sentence has to finish with the sequence: ;--
* *
* @param database picto.db helper * @param database picto.db helper
* @param inputStream the stream where the ddl of picto.db is depicted
* @throws IOException * @throws IOException
*/ */
protected static void executeSQLScript(SQLiteDatabase database, InputStream inputStream) protected void executeSQLScript(SQLiteDatabase database)
throws IOException { throws IOException {
InputStream inputStream= DeviceHelper.getDBScriptStream(this.context);
Vector<String> commands = new Vector<String>(50); Vector<String> commands = new Vector<String>(50);
BufferedReader r = new BufferedReader(new InputStreamReader(inputStream)); BufferedReader r = new BufferedReader(new InputStreamReader(inputStream));
...@@ -377,7 +381,8 @@ public class Device extends SQLiteOpenHelper { ...@@ -377,7 +381,8 @@ public class Device extends SQLiteOpenHelper {
r.close(); r.close();
for (String sqlStatement : commands) for (String sqlStatement : commands)
database.execSQL(sqlStatement); database.execSQL(sqlStatement);
Log.i(Device.class.getName(), "Database created"); setParam(database,PARAMS.db_version, Integer.toString(DeviceHelper.getDBVersion(context)));
Log.i(Device.class.getName(), "Database v."+DeviceHelper.getDBVersion(context)+" created!");
} }
/** /**
...@@ -415,7 +420,7 @@ public class Device extends SQLiteOpenHelper { ...@@ -415,7 +420,7 @@ public class Device extends SQLiteOpenHelper {
@Override @Override
public void onCreate(SQLiteDatabase db) throws RuntimeException { public void onCreate(SQLiteDatabase db) throws RuntimeException {
try { try {
executeSQLScript(db, DeviceHelper.getDBScriptStream(this.context)); executeSQLScript(db);
Img.mkDirs(this.context); Img.mkDirs(this.context);
copyCoreVocabulary(); copyCoreVocabulary();
} catch (java.io.IOException io) { } catch (java.io.IOException io) {
...@@ -481,7 +486,7 @@ public class Device extends SQLiteOpenHelper { ...@@ -481,7 +486,7 @@ public class Device extends SQLiteOpenHelper {
try { try {
Log.i(LOG_TAG,"Upgrading db from "+oldVersion+" to "+newVersion); Log.i(LOG_TAG,"Upgrading db from "+oldVersion+" to "+newVersion);
executeSQLScript(db, DeviceHelper.getDBScriptStream(this.context)); executeSQLScript(db);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("Update database ir cached Images error", e); throw new RuntimeException("Update database ir cached Images error", e);
} }
......
...@@ -142,6 +142,55 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -142,6 +142,55 @@ public class PCBDBHelper extends SQLiteOpenHelper {
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
return db.delete("action",null,null); return db.delete("action",null,null);
} }
/**
* To insert into scene the data of scene 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,
* "categories": false,
* "pictos": [.....] Pictos of that scene
*/
public void setActiveSceneForStudent(JSONObject params){
try {
String sql_scene="INSERT OR REPLACE INTO scene VALUES ("
+params.getInt("id")
+","+params.getInt("supervisor")
+","+params.get("student")
+",'"+params.getString("name")
+"','"+params.getBoolean("active")
+"','"+params.getBoolean("categories")
+"')";
Log.i(LOG_TAG,"Scene to be inserted: "+sql_scene);
getWritableDatabase().execSQL(sql_scene);
} catch (JSONException e) {
e.printStackTrace();
Log.e(LOG_TAG,"Error setting active scene:"+e.getMessage());
}
Cursor cursor = getReadableDatabase().rawQuery("SELECT * FROM scene",null);
Log.i(LOG_TAG,"tam scen: "+cursor.getCount());
cursor.close();
}
/**
* 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
*/
public int getActiveSceneForStudent(int id_stu){
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT id FROM scene WHERE id_stu = "+id_stu,null);
cursor.moveToFirst();
if(cursor.getCount() > 0){
return cursor.getInt(0);
}
return -1;
}
/** /**
* the collection (set of pictos) of the current student * the collection (set of pictos) of the current student
* *
...@@ -150,7 +199,8 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -150,7 +199,8 @@ public class PCBDBHelper extends SQLiteOpenHelper {
public Vocabulary getStudentVocabulary(Vocabulary vocabulary ) throws JSONException { public Vocabulary getStudentVocabulary(Vocabulary vocabulary ) throws JSONException {
int id_stu = this.getCurrentUser().get_id_stu(); int id_stu = this.getCurrentUser().get_id_stu();
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.query("collection_detail", null, "id_stu=?", new String[]{String.valueOf(id_stu)}, null, null, null, null);
Cursor cursor = db.rawQuery("SELECT * FROM collection_detail WHERE id_stu = "+id_stu,null);
Log.i(LOG_TAG, "Local recovering " + cursor.getCount() + " pictos for student " + id_stu + " from local DB"); Log.i(LOG_TAG, "Local recovering " + cursor.getCount() + " pictos for student " + id_stu + " from local DB");
cursor.moveToFirst(); cursor.moveToFirst();
if (cursor.getCount()>0) do{ if (cursor.getCount()>0) do{
...@@ -163,9 +213,6 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -163,9 +213,6 @@ public class PCBDBHelper extends SQLiteOpenHelper {
return vocabulary; return vocabulary;
} }
/** /**
* Set/update the set of pictos of the current student. Pictos which are no longer used are dropped from the DB * Set/update the set of pictos of the current student. Pictos which are no longer used are dropped from the DB
* *
...@@ -176,17 +223,18 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -176,17 +223,18 @@ public class PCBDBHelper extends SQLiteOpenHelper {
SQLiteDatabase db = this.getWritableDatabase(); SQLiteDatabase db = this.getWritableDatabase();
int id_stu = this.getCurrentUser().get_id_stu(); int id_stu = this.getCurrentUser().get_id_stu();
int seconds1 = Calendar.getInstance().get(Calendar.SECOND); int seconds1 = Calendar.getInstance().get(Calendar.SECOND);
Log.i("TAG_PRUEBAS","tamVoc to insert: "+vocabulary.size());
db.delete("collection", "id_stu=" + id_stu, null); db.delete("collection", "id_stu=" + id_stu, null);
int newsize=0; int newsize=0;
ContentValues values=new ContentValues(5); ContentValues values=new ContentValues(6);
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.e(LOG_TAG,"inserting "+picto.get_id()+":"+picto.get_translation()+":"+picto.get_json_attrs()); Log.e("TAG_PRUEBAS","inserting "+picto.get_id()+":"+picto.get_translation()+":"+picto.get_json_attrs());
newsize++; newsize++;
values.put("id_picto", picto.get_id()); values.put("id_picto", picto.get_id());
values.put("id_scene", 135/*getActiveSceneForStudent(id_stu)*/);
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());
...@@ -194,7 +242,7 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -194,7 +242,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
} }
int seconds2 = Calendar.getInstance().get(Calendar.SECOND); int seconds2 = Calendar.getInstance().get(Calendar.SECOND);
Log.i(LOG_TAG, " Local student vocabulary updated, id:" + id_stu + ", cats: " + vocabulary.size() + " time:" + (seconds2 - seconds1) + " secs. Size: " + newsize + " read only?" + db.isReadOnly()); //Log.i(LOG_TAG, " Local student vocabulary updated, id:" + id_stu + ", cats: " + vocabulary.size() + " time:" + (seconds2 - seconds1) + " secs. Size: " + newsize + " read only?" + db.isReadOnly());
db.setTransactionSuccessful(); db.setTransactionSuccessful();
db.endTransaction(); db.endTransaction();
//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
...@@ -212,6 +260,7 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -212,6 +260,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
ContentValues values=new ContentValues(6); ContentValues values=new ContentValues(6);
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_id());
//values.put("id_scene",picto.get_scene());
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());
......
...@@ -256,6 +256,16 @@ public class User { ...@@ -256,6 +256,16 @@ public class User {
} }
/** /**
* Change the value wich knows if the user has categories or not
*/
public void set_has_categories(boolean categories){
try {
this.attributes_stu.put(JSON_STUDENT_ATTTRS.CATEGORIES, true);
} catch (JSONException e) {
e.printStackTrace();
}
}
/**
* *
* @return input feedback of the student configuration (default: "vibration") * @return input feedback of the student configuration (default: "vibration")
*/ */
......
...@@ -175,7 +175,6 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -175,7 +175,6 @@ public class Vocabulary implements Iterable<Picto> {
//final String picto_str = "/pictos"; //final String picto_str = "/pictos";
final String picto_str = "/activeScene"; final String picto_str = "/activeScene";
String operation = PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + picto_str; String operation = PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + picto_str;
Log.i("TAG_PRUEBAS","Ruta: "+operation);
PCBcontext.getRestapiWrapper().ask(operation, new RestapiWrapper.iRestapiListener() { PCBcontext.getRestapiWrapper().ask(operation, new RestapiWrapper.iRestapiListener() {
@Override @Override
public void preExecute() { public void preExecute() {
...@@ -190,7 +189,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -190,7 +189,7 @@ public class Vocabulary implements Iterable<Picto> {
@Override @Override
public void result(JSONObject result) { public void result(JSONObject result) {
if (result != null) { if (result != null) {
Log.i("TAG_PRUEBAS",result.toString()); //Log.i("TAG_PRUEBAS",result.toString());
/* final String jpicto = "picto"; /* final String jpicto = "picto";
final String jid = "id"; final String jid = "id";
final String juri = "uri"; final String juri = "uri";
...@@ -199,8 +198,8 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -199,8 +198,8 @@ public class Vocabulary implements Iterable<Picto> {
JSONObject picto, attributes; JSONObject picto, attributes;
JSONObject stupicto = null; JSONObject stupicto = null;
try { try {
PCBcontext.getPcbdb().getCurrentUser().set_has_categories(result.getBoolean("categories"));
JSONArray stu_pictos = result.getJSONArray("pictos"); //Obtengo el JSONArray de los pictos JSONArray stu_pictos = result.getJSONArray("pictos"); //Obtengo el JSONArray de los pictos
Log.i("TAG_PRUEBAS",stu_pictos.toString());
Picto[] pictos = new Picto[stu_pictos.length()]; Picto[] pictos = new Picto[stu_pictos.length()];
for (int i = 0; i < stu_pictos.length(); i++) { for (int i = 0; i < stu_pictos.length(); i++) {
...@@ -213,9 +212,11 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -213,9 +212,11 @@ public class Vocabulary implements Iterable<Picto> {
attributes); attributes);
} }
synchronizeImgs(pictos); synchronizeImgs(pictos);
if (PCBcontext.is_user_logged()) //HASTA AQUI BIEN
if (PCBcontext.is_user_logged()) {
PCBcontext.getPcbdb().setStudentVocabulary(Vocabulary.this); PCBcontext.getPcbdb().setStudentVocabulary(Vocabulary.this);
else PCBcontext.getPcbdb().setActiveSceneForStudent(result); //Aqui inserto en scene los datos que llegan de la activa
}else
Log.i(this.getClass().getName(), "Downloaded images ended when the user comes to logout"); Log.i(this.getClass().getName(), "Downloaded images ended when the user comes to logout");
Log.i(this.getClass().getName(), " Pictos downloaded: " + result.length()); Log.i(this.getClass().getName(), " Pictos downloaded: " + result.length());
} catch (JSONException e) { } catch (JSONException e) {
...@@ -255,19 +256,20 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -255,19 +256,20 @@ 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(); this.pictos.clear();
for (Picto updated_picto: updated_collection) { for (Picto updated_picto: updated_collection) {
LinkedList<Picto> pictos_cat; LinkedList<Picto> pictos_cat;
Log.i("TAG_PRUEBAS","ID: "+updated_picto.get_id()); //Log.i("TAG_PRUEBAS","URL: "+updated_picto.get_url());
Picto picto = new Picto(updated_picto.get_id(), Picto picto = new Picto(updated_picto.get_id(),
updated_picto.get_url(), updated_picto.get_url(),
updated_picto.get_translation(), updated_picto.get_translation(),
updated_picto.get_json_attrs()); updated_picto.get_json_attrs());
if (pictos.containsKey(picto.get_category())) { if (pictos.containsKey(picto.get_category())) {
pictos_cat = pictos.get(picto.get_category()); pictos_cat = pictos.get(picto.get_category());
Log.i("TAG_PRUEBAS","Tiene categoria: "+pictos_cat);
}else { }else {
pictos_cat = new LinkedList<>(); pictos_cat = new LinkedList<>();
pictos.put(new Integer(picto.get_category()),pictos_cat); pictos.put(picto.get_category(),pictos_cat);
} }
pictos_cat.add(picto); pictos_cat.add(picto);
imgs.add(picto); imgs.add(picto);
......
...@@ -21,13 +21,13 @@ public class VocabularyIterator implements Iterator<Picto> { ...@@ -21,13 +21,13 @@ public class VocabularyIterator implements Iterator<Picto> {
int location; int location;
VocabularyIterator(Hashtable<Integer,LinkedList<Picto>> pictos) { VocabularyIterator(Hashtable<Integer,LinkedList<Picto>> pictos) {
this.keys = pictos.keys(); this.keys = pictos.keys();
if (pictos.size()>1) { if (pictos.size()>=1) {
this.pictos=pictos; this.pictos=pictos;
this.category = this.keys.nextElement(); this.category = this.keys.nextElement();
} }
else { else {
this.category=-1; this.category=-2;
this.pictos=new Hashtable<>(1); this.pictos=new Hashtable<>(1);
this.pictos.put(this.category, new LinkedList<Picto>()); this.pictos.put(this.category, new LinkedList<Picto>());
} }
...@@ -47,7 +47,8 @@ public class VocabularyIterator implements Iterator<Picto> { ...@@ -47,7 +47,8 @@ public class VocabularyIterator implements Iterator<Picto> {
this.location = 0; this.location = 0;
this.category = this.keys.nextElement(); this.category = this.keys.nextElement();
} }
picto=pictos.get(category).get(location++);
picto=pictos.get(category).get(location++);
return picto; return picto;
} }
......
...@@ -5,7 +5,7 @@ DROP TABLE IF EXISTS params ...@@ -5,7 +5,7 @@ DROP TABLE IF EXISTS params
;-- ;--
CREATE TABLE params ( CREATE TABLE params (
key TEXT(12) CHECK (key in ('serial','deviceID', 'last__stu_id', 'last__sup_id','token', 'keyword')) UNIQUE, key TEXT(12) CHECK (key in ('db_version', 'last__sup_id', 'last__stu_id', 'keyword')) UNIQUE,
value TEXT(40) NOT NULL value TEXT(40) NOT NULL
) )
;-- ;--
...@@ -68,14 +68,28 @@ constraint ck_users UNIQUE(id_stu,id_sup) ...@@ -68,14 +68,28 @@ constraint ck_users UNIQUE(id_stu,id_sup)
) )
;-- ;--
DROP TABLE IF EXISTS scene
;--
CREATE TABLE scene (
id INTEGER PRIMARY KEY,
id_sup INTEGER NOT NULL REFERENCES supervisor,
id_stu INTEGER NOT NULL REFERENCES student,
name TEXT(100) NOT NULL,
active BOOLEAN NOT NULL,
categories BOOLEAN NOT NULL
)
;--
DROP TABLE IF EXISTS collection DROP TABLE IF EXISTS collection
;-- ;--
CREATE TABLE collection ( CREATE TABLE collection (
id_stu INTEGER NOT NULL REFERENCES student ON DELETE CASCADE, id_stu INTEGER NOT NULL REFERENCES student ON DELETE CASCADE,
id_picto INTEGER NOT NULL REFERENCES picto ON DELETE CASCADE, id_picto INTEGER NOT NULL REFERENCES picto ON DELETE CASCADE,
id_scene INTEGER NOT NULL REFERENCES scene ON DELETE CASCADE,
attributes VARCHAR(1024), attributes VARCHAR(1024),
constraint ck_collection UNIQUE(id_stu,id_picto,attributes) constraint ck_collection UNIQUE(id_stu,id_picto,id_scene)
) )
;-- ;--
...@@ -143,7 +157,7 @@ DROP VIEW IF EXISTS collection_detail ...@@ -143,7 +157,7 @@ DROP VIEW IF EXISTS collection_detail
;-- ;--
CREATE VIEW collection_detail AS CREATE VIEW collection_detail AS
SELECT id_stu, id_picto, b.url, translation,attributes SELECT id_stu, id_picto, id_scene, b.url, translation, attributes
FROM collection a, picto b FROM collection a, picto b
WHERE a.id_picto=b.id WHERE a.id_picto=b.id
;-- ;--
...@@ -344,6 +358,6 @@ INSTEAD OF INSERT ON collection_detail ...@@ -344,6 +358,6 @@ INSTEAD OF INSERT ON collection_detail
FOR EACH ROW FOR EACH ROW
BEGIN BEGIN
INSERT OR REPLACE INTO picto VALUES (NEW.id_picto,NEW.url, NEW.translation); INSERT OR REPLACE INTO picto VALUES (NEW.id_picto,NEW.url, NEW.translation);
INSERT INTO collection VALUES (NEW.id_stu,NEW.id_picto,NEW.attributes); INSERT INTO collection VALUES (NEW.id_stu,NEW.id_picto,NEW.id_scene,NEW.attributes);
END END
;-- ;--
...@@ -18,6 +18,7 @@ import android.widget.LinearLayout; ...@@ -18,6 +18,7 @@ import android.widget.LinearLayout;
import android.widget.ListView; import android.widget.ListView;
import android.widget.Toast; import android.widget.Toast;
import com.yottacode.pictogram.dao.Device;
import com.yottacode.pictogram.dao.User; import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.dao.UserLogin; import com.yottacode.pictogram.dao.UserLogin;
import com.yottacode.pictogram.tabletlibrary.R; import com.yottacode.pictogram.tabletlibrary.R;
...@@ -35,7 +36,7 @@ import java.util.Vector; ...@@ -35,7 +36,7 @@ import java.util.Vector;
*/ */
public class SerialActivity extends Activity { public class SerialActivity extends Activity {
public static final String PREFS_NAME = "MyPrefsFile";
// String constant for logs // String constant for logs
private final String LOG_TAG = this.getClass().getSimpleName(); // Or .getCanonicalName() private final String LOG_TAG = this.getClass().getSimpleName(); // Or .getCanonicalName()
...@@ -56,7 +57,7 @@ public class SerialActivity extends Activity { ...@@ -56,7 +57,7 @@ public class SerialActivity extends Activity {
String password = intent.getStringExtra("switch_pwd"); String password = intent.getStringExtra("switch_pwd");
if (username==null || password==null) { if (username==null || password==null) {
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); SharedPreferences settings = getSharedPreferences(Device.PREFS_NAME, 0);
username = settings.getString("username", ""); username = settings.getString("username", "");
password = settings.getString("password", ""); password = settings.getString("password", "");
} }
...@@ -92,7 +93,7 @@ public class SerialActivity extends Activity { ...@@ -92,7 +93,7 @@ public class SerialActivity extends Activity {
toast.show(); toast.show();
} else { } else {
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); SharedPreferences settings = getSharedPreferences(Device.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit(); SharedPreferences.Editor editor = settings.edit();
editor.putString("username", supUsers.elementAt(position).get_email_sup()); editor.putString("username", supUsers.elementAt(position).get_email_sup());
editor.putString("password", supUsers.elementAt(position).get_pwd_sup()); editor.putString("password", supUsers.elementAt(position).get_pwd_sup());
...@@ -126,7 +127,7 @@ public class SerialActivity extends Activity { ...@@ -126,7 +127,7 @@ public class SerialActivity extends Activity {
listaStu.setOnItemClickListener(new AdapterView.OnItemClickListener() { listaStu.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); SharedPreferences settings = getSharedPreferences(Device.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit(); SharedPreferences.Editor editor = settings.edit();
editor.putString("username", stuUsers.elementAt(position).get_nickname_stu()); editor.putString("username", stuUsers.elementAt(position).get_nickname_stu());
editor.putString("password", stuUsers.elementAt(position).get_pwd_stu()); editor.putString("password", stuUsers.elementAt(position).get_pwd_stu());
...@@ -165,7 +166,7 @@ public class SerialActivity extends Activity { ...@@ -165,7 +166,7 @@ public class SerialActivity extends Activity {
String username = mSerialViewMail.getText().toString(); String username = mSerialViewMail.getText().toString();
String password = mSerialViewPass.getText().toString(); String password = mSerialViewPass.getText().toString();
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); SharedPreferences settings = getSharedPreferences(Device.PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit(); SharedPreferences.Editor editor = settings.edit();
editor.putString("username", username); editor.putString("username", username);
editor.putString("password", password); editor.putString("password", password);
......
...@@ -189,10 +189,11 @@ ...@@ -189,10 +189,11 @@
"licenses": "Licenses", "licenses": "Licenses",
"license_already_activated": "License already activated", "license_already_activated": "License already activated",
"license_created": "License created", "license_created": "License created",
"license_expires": "License expires on ", "license_expires": "PRO license expires on ",
"license_expired": "License expired on ", "license_expired": "PRO license expired, you can",
"license_expired_renew": "renew it",
"license_invalid": "Invalid license number", "license_invalid": "Invalid license number",
"license_missing": "Account without license", "license_missing": "Account without PRO license",
"license_number": "License number", "license_number": "License number",
"license_pro": "Pictogram PRO license", "license_pro": "Pictogram PRO license",
"license_warning": "Only available for professional licenses (Pictogram Pro).", "license_warning": "Only available for professional licenses (Pictogram Pro).",
......
...@@ -189,14 +189,15 @@ ...@@ -189,14 +189,15 @@
"licenses": "Licencias", "licenses": "Licencias",
"licenses_left": "{{number}} licencias disponibles", "licenses_left": "{{number}} licencias disponibles",
"license_already_activated": "Licencia ya activada previamente", "license_already_activated": "Licencia ya activada previamente",
"license_expires": "La licencia expira el ", "license_expires": "La licencia PRO expira el ",
"license_expired": "La licencia expiró el ", "license_expired": "La licencia PRO expiró, puede",
"license_expired_renew": "renovarla",
"license_created": "Licencia creada", "license_created": "Licencia creada",
"license_invalid": "Licencia inválida", "license_invalid": "Licencia inválida",
"license_number": "Número de licencia", "license_number": "Número de licencia",
"license_pro": "Licencia Pictogram PRO", "license_pro": "Licencia Pictogram PRO",
"license_warning": "Sólo disponible para licencias profesionales (Pictogram Pro).", "license_warning": "Sólo disponible para licencias profesionales (Pictogram Pro).",
"license_missing": "Cuenta sin licencia", "license_missing": "Cuenta sin licencia PRO",
"licenses_created": "Licencias creadas", "licenses_created": "Licencias creadas",
"light_up": "Iluminar", "light_up": "Iluminar",
"link": "Vincular", "link": "Vincular",
......
...@@ -29,11 +29,13 @@ ...@@ -29,11 +29,13 @@
<!-- END select to add new method --> <!-- END select to add new method -->
<!-- Method instructions --> <!-- Method instructions -->
<div class="method_details" ng-repeat="m in methods"> <div class="method" ng-repeat="m in methods">
<div class="method-header"> <div class="method-header">
<input type="text" class="editable title" ng-model="m.name " ng-blur="update_method(m)"/> <div class="col-sm-6">
<div class="method-header-options"> <input type="text" class="editable title" ng-model="m.name " ng-blur="update_method(m)"/>
</div>
<div class="col-sm-6 text-right">
<a ng-click="save_as_template(m)" popover="{{ 'save_as_template' | translate}}" popover-trigger="mouseenter"><span class="text_medium color_black glyphicon glyphicon-floppy-disk options-button" aria-hidden="true"></span></a> <a ng-click="save_as_template(m)" popover="{{ 'save_as_template' | translate}}" popover-trigger="mouseenter"><span class="text_medium color_black glyphicon glyphicon-floppy-disk options-button" aria-hidden="true"></span></a>
<a ng-click="delete_method(m)" popover="{{ 'delete' | translate}}" popover-trigger="mouseenter"><span class="text_medium delete color_red glyphicon glyphicon-remove-circle options-button" aria-hidden="true"></span></a> <a ng-click="delete_method(m)" popover="{{ 'delete' | translate}}" popover-trigger="mouseenter"><span class="text_medium delete color_red glyphicon glyphicon-remove-circle options-button" aria-hidden="true"></span></a>
</div> </div>
...@@ -57,19 +59,19 @@ ...@@ -57,19 +59,19 @@
<td> <td>
<a ng-click="open_instruction(i)"><span class="glyphicon glyphicon-file text_medium" aria-hidden="true"></span></a> <a ng-click="open_instruction(i)"><span class="glyphicon glyphicon-file text_medium" aria-hidden="true"></span></a>
</td> </td>
<td><input class="editable" type="text" ng-model="i.name" ng-blur="update_instruction(i)" /></td> <td><input class="editable" type="text" ng-model="i.name" ng-blur="update_instruction(i)" /></td>
<td><input class="elipsis editable" type="text" ng-model="i.objective" ng-blur="update_instruction(i)" /></td> <td><input class="elipsis editable" type="text" ng-model="i.objective" ng-blur="update_instruction(i)" /></td>
<td class="editable"> <td class="editable">
<div class="text-center"> <div class="text-center">
<span class="color_blue">{{ i.begin | date:"dd-MM-yyyy" }}</span> <span class="color_blue">{{ i.begin | date:"dd-MM-yyyy" }}</span>
<br /> <br>
{{ i.begin | date:"HH:mm:ss" }} {{ i.begin | date:"HH:mm:ss" }}
</div> </div>
</td> </td>
<td class="editable"> <td class="editable">
<div class="text-center" ng-class="{ color_green : i.id == m.last_ins }"> <div class="text-center" ng-class="{ color_green : i.id == m.last_ins }">
<span ng-class="{ color_green : i.id == m.last_ins, color_blue : i.id != m.last_ins }">{{ i.end | date:"dd-MM-yyyy" }}</span> <span ng-class="{ color_green : i.id == m.last_ins, color_blue : i.id != m.last_ins }">{{ i.end | date:"dd-MM-yyyy" }}</span>
<br/> <br>
{{ i.end | date:"HH:mm:ss" }} {{ i.end | date:"HH:mm:ss" }}
</div> </div>
</td> </td>
...@@ -82,7 +84,11 @@ ...@@ -82,7 +84,11 @@
'glyphicon-minus': i.status == null 'glyphicon-minus': i.status == null
}" aria-hidden="true" popover="{{(i.status || 'nobegin') | translate}}" popover-trigger="mouseenter" ng-click="change_status(i)"></span> }" aria-hidden="true" popover="{{(i.status || 'nobegin') | translate}}" popover-trigger="mouseenter" ng-click="change_status(i)"></span>
</td> </td>
<td><a confirmed-click="delete_instruction(i);" ng-confirm-click="{{ 'confirmation' | translate}}" class="delete_instruction"><span class="text_medium delete color_red glyphicon glyphicon-remove-circle options-button" aria-hidden="true"></span></a></td> <td>
<a confirmed-click="delete_instruction(i);" ng-confirm-click="{{ 'confirmation' | translate}}" class="delete_instruction">
<span class="text_medium delete color_red glyphicon glyphicon-remove-circle options-button" aria-hidden="true"></span>
</a>
</td>
</tr> </tr>
</table> </table>
...@@ -93,7 +99,7 @@ ...@@ -93,7 +99,7 @@
</a> </a>
</p> </p>
</div> </div>
<!-- Fin de .method_details --> <!-- Fin de .method -->
</div> </div>
......
...@@ -55,10 +55,10 @@ ...@@ -55,10 +55,10 @@
<i class="fa fa-info-circle" aria-hidden="true"></i> {{ 'license_expires' | translate }} {{ studentData.expiration_date }} <i class="fa fa-info-circle" aria-hidden="true"></i> {{ 'license_expires' | translate }} {{ studentData.expiration_date }}
</div> </div>
<div ng-show="studentData.license && studentData.license_expired" class="alert alert-warning" role="alert"> <div ng-show="studentData.license && studentData.license_expired" class="alert alert-warning" role="alert">
<i class="fa fa-exclamation-circle" aria-hidden="true"></i> {{ 'license_expired' | translate }} {{ studentData.expiration_date }} <i class="fa fa-exclamation-circle" aria-hidden="true"></i> {{ 'license_expired' | translate }} <a href="http://pictogramweb.com/caracteristicas-de-pictogram/">{{ 'license_expired_renew' | translate }}</a>
</div> </div>
<div ng-show="!studentData.license" class="alert alert-danger" role="alert"> <div ng-show="!studentData.license" class="alert alert-danger" role="alert">
<i class="fa fa-exclamation-circle" aria-hidden="true"></i> {{ 'license_missing' | translate }} <i class="fa fa-exclamation-circle" aria-hidden="true"></i> {{ 'license_missing' | translate }}. <a href="http://pictogramweb.com/caracteristicas-de-pictogram/">{{ 'more_info' | translate }}</a>
</div> </div>
<!-- VERSION SOLO TEXTO <!-- VERSION SOLO TEXTO
<span ng-show="studentData.license && !studentData.license_expired" class="text-info"> <span ng-show="studentData.license && !studentData.license_expired" class="text-info">
......
...@@ -16,15 +16,18 @@ ...@@ -16,15 +16,18 @@
<!-- END select to add new method --> <!-- END select to add new method -->
<!-- Method instructions --> <!-- Method instructions -->
<div class="method_details" ng-repeat="m in methods"> <div class="method" ng-repeat="m in methods">
<input type="text" class="editable title" ng-model="m.name " ng-blur="update_method(m)"/> <div class="method-header">
<div class="col-sm-6">
<input type="text" class="editable title" ng-model="m.name " ng-blur="update_method(m)"/>
</div>
<div class="col-sm-6 text-right">
<a ng-click="delete_method(m)" popover="{{ 'delete' | translate}}" popover-trigger="mouseenter"><span class="text_medium delete color_red glyphicon glyphicon-remove-circle options-button" aria-hidden="true"></span></a>
</div>
</div>
<div class="options"> <textarea class="editable" ng-model="m.description " placeholder="{{'description' | translate}}" ng-blur="update_method(m)"></textarea>
<a ng-click="delete_method(m)" popover="{{ 'delete' | translate}}" popover-trigger="mouseenter"><span class="text_medium delete color_red glyphicon glyphicon-remove-circle" aria-hidden="true"></span></a>
</div>
<textarea class="editable" ng-model="m.description " placeholder="{{'description' | translate}}" ng-blur="update_method(m)"></textarea>
<!-- Tabla método --> <!-- Tabla método -->
<table class="table_instructions table"> <table class="table_instructions table">
...@@ -36,7 +39,7 @@ ...@@ -36,7 +39,7 @@
<tr ng-repeat="i in m.metainstructions"> <tr ng-repeat="i in m.metainstructions">
<td><input class="editable" type="text" ng-model="i.name" ng-blur="update_instruction(i)" /></td> <td><input class="editable" type="text" ng-model="i.name" ng-blur="update_instruction(i)" /></td>
<td><input class="elipsis editable" type="text" ng-model="i.objective" ng-blur="update_instruction(i)" /></td> <td><input class="elipsis editable" type="text" ng-model="i.objective" ng-blur="update_instruction(i)" /></td>
<td><a confirmed-click="delete_instruction(i);" ng-confirm-click="{{ 'confirmation' | translate}}" class="delete_instruction"><span class="text_medium delete color_red glyphicon glyphicon-remove-circle" aria-hidden="true"></span></a></td> <td><a confirmed-click="delete_instruction(i);" ng-confirm-click="{{ 'confirmation' | translate}}" class="delete_instruction"><span class="text_medium delete color_red glyphicon glyphicon-remove-circle options-button" aria-hidden="true"></span></a></td>
</tr> </tr>
</table> </table>
...@@ -47,7 +50,7 @@ ...@@ -47,7 +50,7 @@
</a> </a>
</p> </p>
</div> </div>
<!-- Fin de .method_details --> <!-- Fin de .method -->
</div> </div>
......
...@@ -264,9 +264,10 @@ tr:hover .ops a{ ...@@ -264,9 +264,10 @@ tr:hover .ops a{
border: 1px solid #DDDDDD; border: 1px solid #DDDDDD;
border-top-left-radius: 10px; border-top-left-radius: 10px;
border-top-right-radius: 10px; border-top-right-radius: 10px;
min-height: 45px;
} }
.method_details { .method {
margin-bottom: 30px; margin-bottom: 30px;
} }
...@@ -276,9 +277,6 @@ tr:hover .ops a{ ...@@ -276,9 +277,6 @@ tr:hover .ops a{
padding-top: 2px; padding-top: 2px;
} }
.method-header-options{
float: right;
}
.options-button{ .options-button{
opacity: .2; opacity: .2;
} }
...@@ -321,7 +319,8 @@ td.editable input{ ...@@ -321,7 +319,8 @@ td.editable input{
} }
input.editable{ input.editable{
min-width: 400px; /*min-width: 400px;*/
width: 100%;
border: none; border: none;
background: none; background: none;
padding: 6px; padding: 6px;
......
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