Pictogram 1.6: soporte a tableros Beta 1, modo offline en progreso

parent dae25ad5
......@@ -8,7 +8,7 @@ android {
minSdkVersion 21
targetSdkVersion 21
versionCode 3
versionName "1.5"
versionName "1.6"
resValue "string", "db_name", "PCB.db"
resValue "integer", "db_version", "11"
//resValue "string", "app_version", "1.1"
......
......@@ -33,7 +33,6 @@ 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.
*
......@@ -159,28 +158,10 @@ public class PCBDBHelper extends SQLiteOpenHelper {
*/
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);
}
/**
* Return the active scene for an student (Actually only find by id_stu cause table scene means activeScene of the student)
* @return active grid
*/
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;
}
/**
/**
* the collection (set of pictos) of the current student
*
* @see com.yottacode.pictogram.dao.Picto
......@@ -189,16 +170,16 @@ 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);
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,null);
Log.i(LOG_TAG, "Local recovering " + cursor.getCount() + " pictos for student " + id_stu + " from local DB Scene:"+id_grid);
cursor.moveToFirst();
if (cursor.getCount()>0) do{
Picto picto = new Picto(cursor.getInt(1), cursor.getString(5),cursor.getInt(4),cursor.getInt(2),cursor.getInt(3),new JSONObject(cursor.getString(7)));
vocabulary.addPicto(picto);
}while (cursor.moveToNext());
cursor.close();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
......@@ -265,14 +246,19 @@ public class PCBDBHelper extends SQLiteOpenHelper {
}
public void deleteVocabulary() {
SQLiteDatabase db = this.getWritableDatabase();
int id_stu = this.getCurrentUser().get_id_stu();
Log.i(LOG_TAG,"Delete vocabulary for student "+id_stu);
db.delete("collection", "id_stu=" + id_stu, null);
}
/**
* Set/update the set of pictos of the current student. Pictos which are no longer used are dropped from the DB
*
* @param vocabulary the vocabulary, the configuration of the Student
* @param vocabulary_grid the vocabulary, the configuration of the Student
* @see com.yottacode.pictogram.dao.Picto
*/
public void setStudentVocabulary(Vocabulary vocabulary) {
public void saveVocabularyGrid(Picto vocabulary_grid[]) {
SQLiteDatabase db = this.getWritableDatabase();
int id_stu = this.getCurrentUser().get_id_stu();
db.delete("collection", "id_stu=" + id_stu, null);
......@@ -280,7 +266,9 @@ public class PCBDBHelper extends SQLiteOpenHelper {
ContentValues values=new ContentValues(7);
values.put("id_stu", id_stu);
db.beginTransaction();
for (Picto picto : vocabulary) {
int n=0;
for (Picto picto : vocabulary_grid) {
n++;
Log.d(LOG_TAG,"inserting "+picto.get_ImgId()+":"+picto.get_translation()+":"+picto.get_json_attrs()+"-id_sce: "+PCBcontext.getPcbdb().getCurrentUser().get_active_grid());
values.put("id_picto", picto.get_ImgId());
values.put("id_grid", picto.get_grid());
......@@ -291,7 +279,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
values.put("attributes",picto.get_json_attrs());
db.insert("collection_detail", null, values);
}
Log.i(LOG_TAG,"Storage "+n+" pictos for student "+id_stu);
db.setTransactionSuccessful();
db.endTransaction();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
......
......@@ -208,8 +208,9 @@ public class Vocabulary implements Iterable<Picto> {
}
public void synchronize() {
this.pictos.clear();
PCBcontext.getPcbdb().deleteVocabulary();
synchronize(Picto.ACTIVE_GRID);
PCBcontext.getPcbdb().setStudentVocabulary(Vocabulary.this);
}
public void synchronize(final int id_grid) {
boolean upload_pending=synchronize_upload(); // (i) uploading
......@@ -252,11 +253,10 @@ public class Vocabulary implements Iterable<Picto> {
}
PCBcontext.getPcbdb().saveGridForStudent(result);
synchronizeImgs(pictos_list);
PCBcontext.getPcbdb().saveVocabularyGrid(pictos_list);
for (int i = 0; i < stu_pictos.length(); i++)
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());
if (pictos_list[i].has_child_grid() && !find_scene(pictos_list[i].get_child_grid()))
synchronize(pictos_list[i].get_child_grid());
}
Log.i(this.getClass().getName(), " Pictos downloaded: " + result.getJSONArray("pictos").length());
} catch (JSONException e) {
......@@ -472,7 +472,7 @@ public class Vocabulary implements Iterable<Picto> {
startpictos=null;
else {
startpictos = new LinkedList<>();
LinkedList<Picto> pictos = this.pictos.get(PCBcontext.getPcbdb().getActiveGrid());
LinkedList<Picto> pictos = this.pictos.get(PCBcontext.getPcbdb().getCurrentUser().get_active_grid());
for (Picto picto : pictos) {
startpictos.add(picto);
}
......@@ -488,7 +488,7 @@ public class Vocabulary implements Iterable<Picto> {
public boolean isVisibleAnyPicto() {
boolean visible = false;
if (this.pictos.size()>0)
for (Picto picto : this.pictos.get(PCBcontext.getPcbdb().getActiveGrid())) {
for (Picto picto : this.pictos.get(PCBcontext.getPcbdb().getCurrentUser().get_active_grid())) {
visible = !picto.is_invisible();
if (visible) break;
}
......
......@@ -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)*100000;
private static final long restfullSynchroTimming=PCBcontext.getContext().getResources().getInteger(R.integer.netservice_force_restfull_synchro)*1000;
private long nextRestfullSynchro;
public NetService(int delay, iNetServiceStatus listener) {
this.updated=RestapiWrapper.ping(PCBcontext.getContext().getResources().getString(R.string.server), ping_session);
......
......@@ -8,6 +8,6 @@ public final class BuildConfig {
public static final String APPLICATION_ID = "com.yottacode.pictogram.yotta_tablet";
public static final String BUILD_TYPE = "debug";
public static final String FLAVOR = "DevFlavor";
public static final int VERSION_CODE = 4;
public static final String VERSION_NAME = "1.5";
public static final int VERSION_CODE = 6;
public static final String VERSION_NAME = "1.6";
}
/**
* Automatically generated file. DO NOT MODIFY
*/
package com.yottacode.pictogram.communicator.test;
public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.yottacode.pictogram.communicator.test";
public static final String BUILD_TYPE = "debug";
public static final String FLAVOR = "DevFlavor";
public static final int VERSION_CODE = 1;
public static final String VERSION_NAME = "1.0";
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yottacode.pictogram.yotta_tablet"
android:versionCode="4"
android:versionName="1.5" >
android:versionCode="6"
android:versionName="1.6" >
<uses-sdk
android:minSdkVersion="21"
......
......@@ -9,8 +9,8 @@ android {
applicationId "com.yottacode.pictogram.supervisor"
minSdkVersion 21
targetSdkVersion 22
versionCode 4
versionName "1.5"
versionCode 6
versionName "1.6"
resValue "bool","NotifyAllwaysVisible","false"
resValue "string", "VersionManagerClass", "com.yottacode.pictogram.supervisor.net.VersionManager"
resValue "string","apk","pictograms.apk"
......
......@@ -40,13 +40,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavorDebug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavorDebug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavorDebug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/DevFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/DevFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/DevFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/DevFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/DevFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/DevFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/DevFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavorDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavorDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavorDebug/assets" type="java-test-resource" />
......@@ -54,6 +47,13 @@
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavorDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavorDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDevFlavorDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/DevFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/DevFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/DevFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/DevFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/DevFlavor/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/DevFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/DevFlavor/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/DevFlavor/assets" type="java-resource" />
......
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