Pictogram 1.6, Beta 2, issue #421

parent ffdb3acd
...@@ -166,7 +166,12 @@ public class RestapiWrapper { ...@@ -166,7 +166,12 @@ public class RestapiWrapper {
JSONresponse = new JSONObject("{ "+SERVER_RESULT+": " + response + (responseCode == HttpURLConnection.HTTP_OK JSONresponse = new JSONObject("{ "+SERVER_RESULT+": " + response + (responseCode == HttpURLConnection.HTTP_OK
? "}" ? "}"
: ", "+SERVER_ERROR+": " + responseCode +"}")); : ", "+SERVER_ERROR+": " + responseCode +"}"));
Log.i(LOG_TAG, "Server answer: " + JSONresponse.toString()); int i=0;
String sresponse=JSONresponse.toString();
do {
Log.i(LOG_TAG, "Server answer("+i+"):" + sresponse.substring(i*1000,((i+1)*1000)>sresponse.length() ? sresponse.length() : (i+1)*1000));
i++;
}while (i*1000<sresponse.length());
} catch (JSONException e) { } catch (JSONException e) {
JSONresponse = null; JSONresponse = null;
Log.e(RestapiWrapper.class.getCanonicalName(),e.getMessage()); Log.e(RestapiWrapper.class.getCanonicalName(),e.getMessage());
......
...@@ -6,6 +6,7 @@ import android.database.Cursor; ...@@ -6,6 +6,7 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper; import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Color;
import android.util.Log; import android.util.Log;
import com.yottacode.pictogram.action.Action; import com.yottacode.pictogram.action.Action;
...@@ -194,15 +195,13 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -194,15 +195,13 @@ public class PCBDBHelper extends SQLiteOpenHelper {
public void saveGridForStudent(JSONObject grid, SQLiteDatabase db) { public void saveGridForStudent(JSONObject grid, SQLiteDatabase db) {
try { try {
int id_sup = -1; int id_sup = grid.optInt("supervisor",-1);
if(!grid.get("supervisor").equals(null)){
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")
+"')"; +"')";
...@@ -212,7 +211,7 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -212,7 +211,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
} }
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); Log.e(LOG_TAG,"Error saving grid "+grid.toString());
} }
} }
...@@ -220,15 +219,20 @@ public class PCBDBHelper extends SQLiteOpenHelper { ...@@ -220,15 +219,20 @@ public class PCBDBHelper extends SQLiteOpenHelper {
* Get the pictos of a grid * Get the pictos of a grid
* *
* @param id_grid Id of the grid to recover * @param id_grid Id of the grid to recover
* @param id_stu Id of stu
*/ */
public void getGrid(int id_grid,int id_stu) { public int getGridColor(int id_grid) {
SQLiteDatabase db = this.getReadableDatabase(); SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery("SELECT * from collection_detail WHERE id_stu =" +id_stu+" AND id_grid = "+id_grid,null); String[] columns={"color"};
Log.i(LOG_TAG, "Local recovering " + cursor.getCount() + " pictos for student " + id_stu + " from local DB Scene:"+id_grid); Cursor cursor =db.query("grid", columns, "id="+id_grid,null,null,null,null,null);
String query="SELECT color from grid where id="+id_grid;
cursor=db.rawQuery(query,null);
cursor.moveToFirst(); cursor.moveToFirst();
try {
return Color.parseColor(cursor.getString(0));
}catch(Exception e) {
return Color.TRANSPARENT;
}
} }
public void deleteVocabulary(SQLiteDatabase db) { public void deleteVocabulary(SQLiteDatabase db) {
......
...@@ -379,5 +379,4 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -379,5 +379,4 @@ public class Vocabulary implements Iterable<Picto> {
return vocabulary; return vocabulary;
} }
} }
package com.yottacode.pictogram.grammar; package com.yottacode.pictogram.grammar;
import android.util.Log;
import com.yottacode.pictogram.dao.Picto; import com.yottacode.pictogram.dao.Picto;
import java.util.Enumeration; import java.util.Enumeration;
...@@ -45,10 +43,10 @@ public class VocabularyIterator implements Iterator<Picto> { ...@@ -45,10 +43,10 @@ public class VocabularyIterator implements Iterator<Picto> {
if ( this.location==pictos.get(child_grid).size()) { if ( this.location==pictos.get(child_grid).size()) {
this.location = 0; this.location = 0;
this.child_grid = this.keys.nextElement(); this.child_grid = this.keys.nextElement();
} }
picto=pictos.get(child_grid).get(location++); picto=pictos.get(child_grid).get(location++);
return picto; return picto;
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
android:icon="@drawable/ic_launcher" android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true" android:supportsRtl="true"
android:testOnly="true"
android:theme="@style/AppTheme" > android:theme="@style/AppTheme" >
<activity <activity
android:name="com.yottacode.pictogram.tabletlibrary.gui.login.SplashScreenActivity" android:name="com.yottacode.pictogram.tabletlibrary.gui.login.SplashScreenActivity"
......
...@@ -2,6 +2,9 @@ apply plugin: 'com.android.application' ...@@ -2,6 +2,9 @@ apply plugin: 'com.android.application'
android { android {
lintOptions{
checkReleaseBuilds false
}
compileSdkVersion 24 compileSdkVersion 24
buildToolsVersion '25.0.0' buildToolsVersion '25.0.0'
......
...@@ -79,7 +79,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab ...@@ -79,7 +79,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
// Grid showing pictos from a category (initially hidden) // Grid showing pictos from a category (initially hidden)
GridView pictoCategoryGridView; GridView pictoCategoryGridView;
// Current picto category, if not null the corresponding category grid will be shown // Current picto category, if not null the corresponding category grid will be shown
private Picto currentCategory; private int currentGrid;
// Element used for loading new pictos (while changing categories) // Element used for loading new pictos (while changing categories)
Vocabulary vocabulary; Vocabulary vocabulary;
...@@ -123,7 +123,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab ...@@ -123,7 +123,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
setContentView(PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big() ? R.layout.vocabulary_manager_big : R.layout.vocabulary_manager); setContentView(PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big() ? R.layout.vocabulary_manager_big : R.layout.vocabulary_manager);
this.mainLayout = (RelativeLayout) findViewById(R.id.pictogramLayout); this.mainLayout = (RelativeLayout) findViewById(R.id.pictogramLayout);
this.currentCategory = null; this.currentGrid = PCBcontext.getPcbdb().getCurrentUser().get_active_grid();
if (!PCBcontext.is_user_logged()) { if (!PCBcontext.is_user_logged()) {
Log.i(LOG_TAG, "No user logged. Restarting app"); Log.i(LOG_TAG, "No user logged. Restarting app");
...@@ -237,7 +237,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab ...@@ -237,7 +237,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
this.generateAnimations(); this.generateAnimations();
if (this.getCurrentCategory() != null) { if (this.currentGrid != PCBcontext.getPcbdb().getCurrentUser().get_active_grid()) {
this.hidePictoMainGridView(); this.hidePictoMainGridView();
} else { } else {
this.showPictoMainGridView(); this.showPictoMainGridView();
...@@ -415,7 +415,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab ...@@ -415,7 +415,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
this.pictoMainGridView.startAnimation(this.showPictoMainViewAnimation); this.pictoMainGridView.startAnimation(this.showPictoMainViewAnimation);
} }
this.currentCategory = null; this.currentGrid = PCBcontext.getPcbdb().getCurrentUser().get_active_grid();
} }
/** /**
...@@ -424,11 +424,10 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab ...@@ -424,11 +424,10 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
private void hidePictoMainGridView() { private void hidePictoMainGridView() {
this.pictoCategoryGridAdapter.clear(); this.pictoCategoryGridAdapter.clear();
this.pictoCategoryGridAdapter.addAll(this.sort(this.vocabulary.next(this.getCurrentCategory()))); this.pictoCategoryGridAdapter.addAll(this.sort(this.vocabulary.next(this.currentGrid)));
this.pictoCategoryGridAdapter.notifyDataSetChanged(); this.pictoCategoryGridAdapter.notifyDataSetChanged();
Log.e(LOG_TAG,"Grid color:"+PCBcontext.getPcbdb().getGridColor(currentGrid));
if (this.getCurrentCategory().get_color() != -1) this.pictoCategoryGridView.setBackgroundColor(PCBcontext.getPcbdb().getGridColor(currentGrid));
this.pictoCategoryGridView.setBackgroundColor(this.getCurrentCategory().get_color());
this.pictoMainGridView.setEnabled(false); this.pictoMainGridView.setEnabled(false);
this.pictoCategoryGridView.setEnabled(true); this.pictoCategoryGridView.setEnabled(true);
...@@ -442,7 +441,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab ...@@ -442,7 +441,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
* Returns pictoCategoryGridAdapter or pictoMainGridAdapter depending on the current View * Returns pictoCategoryGridAdapter or pictoMainGridAdapter depending on the current View
*/ */
protected PictoGridAdapter getCurrentPictoGridAdapter() { protected PictoGridAdapter getCurrentPictoGridAdapter() {
return (getCurrentCategory() == null) ? this.pictoMainGridAdapter : this.pictoCategoryGridAdapter; return (this.currentGrid == PCBcontext.getPcbdb().getCurrentUser().get_active_grid()) ? this.pictoMainGridAdapter : this.pictoCategoryGridAdapter;
} }
/** /**
...@@ -493,7 +492,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab ...@@ -493,7 +492,7 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (getCurrentCategory() != null) { if (VocabularyManager.this.currentGrid != PCBcontext.getPcbdb().getCurrentUser().get_active_grid()) {
hidePictoMainGridView(); hidePictoMainGridView();
} else { } else {
showPictoMainGridView(); showPictoMainGridView();
...@@ -527,12 +526,6 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab ...@@ -527,12 +526,6 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
} }
} }
/**
* @return
*/
public Picto getCurrentCategory() {
return currentCategory;
}
/* ********************************************************************************************* /* *********************************************************************************************
...@@ -548,13 +541,11 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab ...@@ -548,13 +541,11 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
if (inserting) return; if (inserting) return;
Picto p = getCurrentPictoGridAdapter().getItem(position); Picto p = getCurrentPictoGridAdapter().getItem(position);
if (p != null && p.get_ImgId() != 0 && !p.is_invisible() && p.is_enabled()) { if (p != null && p.get_ImgId() != 0 ) {
p.set_mirror(false, false);
// If the has an associated grid // If the has an associated grid
if (p.has_child_grid()) { if (p.has_child_grid()) {
currentCategory = vocabulary.get_stupicto(p.get_child_grid()); currentGrid = p.get_child_grid();
PCBcontext.getActionLog().log(new TalkAction(TalkAction.SELECT, p)); PCBcontext.getActionLog().log(new TalkAction(TalkAction.SELECT, p));
hidePictoMainGridView(); hidePictoMainGridView();
} }
...@@ -614,8 +605,8 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab ...@@ -614,8 +605,8 @@ public class VocabularyManager extends Activity implements VocabularyTalk.iVocab
Log.e(LOG_TAG,"PREV:"+p+(p!=null ? p.get_legend() : "->nulo")); Log.e(LOG_TAG,"PREV:"+p+(p!=null ? p.get_legend() : "->nulo"));
if (p == null) { if (p == null) {
// No tengo pictograma. Abro una nueva ventana de selección desde el Carrete // No tengo pictograma. Abro una nueva ventana de selección desde el Carrete
int cat = currentCategory.get_stupicto_id();
new PictoMenu(VocabularyManager.this).createMenuForNewPicto(position % maxColumns, (int) (position / maxColumns), cat); new PictoMenu(VocabularyManager.this).createMenuForNewPicto(position % maxColumns, (int) (position / maxColumns), currentGrid);
} else { } else {
//Si es supervisor hacer aparecer el menú de opciones del picto //Si es supervisor hacer aparecer el menú de opciones del picto
......
...@@ -72,6 +72,7 @@ public class PictoGridAdapter extends ArrayAdapter { ...@@ -72,6 +72,7 @@ public class PictoGridAdapter extends ArrayAdapter {
public void pictoInGrid(Picto p) { public void pictoInGrid(Picto p) {
p.set_visible(true);
pictoLinkedList_inGrid.add(p); pictoLinkedList_inGrid.add(p);
notifyDataSetChanged(); notifyDataSetChanged();
} }
...@@ -82,9 +83,10 @@ public class PictoGridAdapter extends ArrayAdapter { ...@@ -82,9 +83,10 @@ public class PictoGridAdapter extends ArrayAdapter {
public void allPictosInGrid() { public void allPictosInGrid() {
for (Picto picto: pictoLinkedList_inTape) { for (Picto picto: pictoLinkedList_inTape)
pictoLinkedList_inGrid.add(picto); picto.set_visible(true);
} pictoLinkedList_inTape.clear();
pictoLinkedList_inGrid.clear();
notifyDataSetChanged(); notifyDataSetChanged();
} }
......
...@@ -81,7 +81,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -81,7 +81,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
// Tape view (list of pictos to send to the server) // Tape view (list of pictos to send to the server)
GridView tapeGridView; GridView tapeGridView;
// Current picto category, if not null the corresponding category grid will be shown // Current picto category, if not null the corresponding category grid will be shown
private Picto currentCategory; private int currentGrid;
// Object used for reading text // Object used for reading text
TTSHelper tts; TTSHelper tts;
// Element used for loading new pictos (while changing categories) // Element used for loading new pictos (while changing categories)
...@@ -129,7 +129,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -129,7 +129,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
setContentView(PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big() ? R.layout.voca_big : R.layout.voca); setContentView(PCBcontext.getPcbdb().getCurrentUser().is_picto_size_big() ? R.layout.voca_big : R.layout.voca);
this.mainLayout = (RelativeLayout) findViewById(R.id.pictogramLayout); this.mainLayout = (RelativeLayout) findViewById(R.id.pictogramLayout);
this.currentCategory = null; this.currentGrid = PCBcontext.getPcbdb().getCurrentUser().get_active_grid();
this.count_deletelong = 0; this.count_deletelong = 0;
if (!PCBcontext.is_user_logged()) { if (!PCBcontext.is_user_logged()) {
Log.i(LOG_TAG, "No user logged. Restarting app"); Log.i(LOG_TAG, "No user logged. Restarting app");
...@@ -289,7 +289,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -289,7 +289,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
this.generateAnimations(); this.generateAnimations();
if (this.getCurrentCategory() != null) { if (this.currentGrid != PCBcontext.getPcbdb().getCurrentUser().get_active_grid()) {
this.hidePictoMainGridView(); this.hidePictoMainGridView();
} else { } else {
this.showPictoMainGridView(); this.showPictoMainGridView();
...@@ -510,7 +510,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -510,7 +510,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
this.pictoMainGridView.startAnimation(this.showPictoMainViewAnimation); this.pictoMainGridView.startAnimation(this.showPictoMainViewAnimation);
} }
this.currentCategory = null; this.currentGrid = PCBcontext.getPcbdb().getCurrentUser().get_active_grid();
} }
/** /**
...@@ -519,11 +519,9 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -519,11 +519,9 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
private void hidePictoMainGridView() { private void hidePictoMainGridView() {
this.pictoCategoryGridAdapter.clear(); this.pictoCategoryGridAdapter.clear();
this.pictoCategoryGridAdapter.addAll(this.sort(this.vocabulary.next(this.getCurrentCategory()))); this.pictoCategoryGridAdapter.addAll(this.sort(this.vocabulary.next(currentGrid)));
this.pictoCategoryGridAdapter.notifyDataSetChanged(); this.pictoCategoryGridAdapter.notifyDataSetChanged();
this.pictoCategoryGridView.setBackgroundColor(PCBcontext.getPcbdb().getGridColor(currentGrid));
if (this.getCurrentCategory().get_color() != -1)
this.pictoCategoryGridView.setBackgroundColor(this.getCurrentCategory().get_color());
this.pictoMainGridView.setEnabled(false); this.pictoMainGridView.setEnabled(false);
this.pictoCategoryGridView.setEnabled(true); this.pictoCategoryGridView.setEnabled(true);
...@@ -537,7 +535,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -537,7 +535,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
* Returns pictoCategoryGridAdapter or pictoMainGridAdapter depending on the current View * Returns pictoCategoryGridAdapter or pictoMainGridAdapter depending on the current View
*/ */
protected PictoGridAdapter getCurrentPictoGridAdapter() { protected PictoGridAdapter getCurrentPictoGridAdapter() {
return (getCurrentCategory() == null) ? this.pictoMainGridAdapter : this.pictoCategoryGridAdapter; return (currentGrid == PCBcontext.getPcbdb().getCurrentUser().get_active_grid()) ? this.pictoMainGridAdapter : this.pictoCategoryGridAdapter;
} }
/** /**
...@@ -598,7 +596,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -598,7 +596,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
if (getCurrentCategory() != null) { if (currentGrid!=PCBcontext.getPcbdb().getCurrentUser().get_active_grid() ) {
hidePictoMainGridView(); hidePictoMainGridView();
} else { } else {
showPictoMainGridView(); showPictoMainGridView();
...@@ -663,13 +661,6 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -663,13 +661,6 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
} }
} }
/**
* @return
*/
public Picto getCurrentCategory() {
return currentCategory;
}
/* ********************************************************************************************* /* *********************************************************************************************
* Event listener classes * Event listener classes
...@@ -754,7 +745,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -754,7 +745,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
// If the picto is a category // If the picto is a category
if (p.has_child_grid()) { if (p.has_child_grid()) {
currentCategory = p; currentGrid = p.get_child_grid();
PCBcontext.getActionLog().log(new TalkAction(TalkAction.SELECT, p)); PCBcontext.getActionLog().log(new TalkAction(TalkAction.SELECT, p));
hidePictoMainGridView(); hidePictoMainGridView();
...@@ -782,7 +773,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular ...@@ -782,7 +773,7 @@ public abstract class VOCA extends Activity implements VocabularyTalk.iVocabular
private void addPictoWord(View view, Picto p) { private void addPictoWord(View view, Picto p) {
tapeAdapter.addItem(p); tapeAdapter.addItem(p);
getCurrentPictoGridAdapter().pictoInTape(view, p); getCurrentPictoGridAdapter().pictoInTape(view, p);
currentCategory = null;
tapeAdapter.notifyDataSetChanged(); tapeAdapter.notifyDataSetChanged();
showPictoMainGridView(); showPictoMainGridView();
PCBcontext.getActionLog().log(new TalkAction(TalkAction.ADD, p)); PCBcontext.getActionLog().log(new TalkAction(TalkAction.ADD, p));
......
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