working on several issues

parent 80feaacd
...@@ -330,7 +330,7 @@ public class Device extends SQLiteOpenHelper { ...@@ -330,7 +330,7 @@ public class Device extends SQLiteOpenHelper {
"'" + user.get_lang_sup() + "'," + "'" + user.get_lang_sup() + "'," +
"'" + user.get_tts_engine_sup() + "'," + "'" + user.get_tts_engine_sup() + "'," +
"'" + user.get_office() + "'" + "'" + user.get_office() + "'" +
")"; Log.e(LOG_TAG,sentence); ")";
db.execSQL(sentence); db.execSQL(sentence);
db.setTransactionSuccessful(); db.setTransactionSuccessful();
......
...@@ -5,7 +5,6 @@ import android.util.Log; ...@@ -5,7 +5,6 @@ import android.util.Log;
import com.yottacode.net.RestapiWrapper; import com.yottacode.net.RestapiWrapper;
import com.yottacode.pictogram.R; import com.yottacode.pictogram.R;
import com.yottacode.pictogram.action.PictoAction;
import com.yottacode.pictogram.action.VocabularyAction; import com.yottacode.pictogram.action.VocabularyAction;
import com.yottacode.pictogram.dao.Picto; import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.net.ImgDownloader; import com.yottacode.pictogram.net.ImgDownloader;
...@@ -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.Arrays;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -169,7 +169,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -169,7 +169,7 @@ public class Vocabulary implements Iterable<Picto> {
*/ */
public void synchronize() { public void synchronize() {
Log.e(LOG_TAG,"SYNCRO from "+ Arrays.toString(Thread.currentThread().getStackTrace()));
boolean upload_pending=synchronize_upload(); // (i) uploading boolean upload_pending=synchronize_upload(); // (i) uploading
// and (ii) downloading // and (ii) downloading
...@@ -189,7 +189,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -189,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 && PCBcontext.is_user_logged()) {
JSONObject picto, attributes; JSONObject picto, attributes;
JSONObject stupicto = null; JSONObject stupicto = null;
try { try {
...@@ -207,12 +207,11 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -207,12 +207,11 @@ public class Vocabulary implements Iterable<Picto> {
stupicto.getInt("id"), stupicto.getInt("id"),
attributes); attributes);
} }
synchronizeImgs(pictos); synchronizeImgs(pictos);
if (PCBcontext.is_user_logged()) { PCBcontext.getPcbdb().setStudentVocabulary(Vocabulary.this);
PCBcontext.getPcbdb().setStudentVocabulary(Vocabulary.this); PCBcontext.getPcbdb().setActiveSceneForStudent(result); //Aqui inserto en scene los datos que llegan de la activa
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(), " Pictos downloaded: " + result.getJSONArray("pictos").length()); Log.i(this.getClass().getName(), " Pictos downloaded: " + result.getJSONArray("pictos").length());
} catch (JSONException e) { } catch (JSONException e) {
StackTraceElement traces[] = e.getStackTrace(); StackTraceElement traces[] = e.getStackTrace();
...@@ -222,6 +221,7 @@ public class Vocabulary implements Iterable<Picto> { ...@@ -222,6 +221,7 @@ public class Vocabulary implements Iterable<Picto> {
this.error(new RestapiWrapper.HTTPException("JSON Error:" + e.getMessage(), -1)); 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 @Override
......
...@@ -80,7 +80,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin { ...@@ -80,7 +80,7 @@ public class NetService implements Runnable, RestapiWrapper.iSilentLogin {
@Override @Override
public void error(RestapiWrapper.HTTPException e) { public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getSimpleName(), "Error un when server login:" + e.getMessage()+"( error "+e.getCode()+")"); Log.e(this.getClass().getSimpleName(), "Error when server login:" + e.getMessage()+"( error "+e.getCode()+")");
if (e instanceof LoginException) if (e instanceof LoginException)
for (iNetServiceStatus listener: listeners) for (iNetServiceStatus listener: listeners)
if (listener instanceof iNetServiceDevice) ((iNetServiceDevice)listener).restart_app(false); if (listener instanceof iNetServiceDevice) ((iNetServiceDevice)listener).restart_app(false);
...@@ -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(); //PCBcontext.getVocabulary().synchronize();
synchronizeStudentAttributes(); synchronizeStudentAttributes();
nextSynchro(now+restfullSynchroTimming); nextSynchro(now+restfullSynchroTimming);
} }
......
...@@ -47,7 +47,7 @@ public class ServerLogin { ...@@ -47,7 +47,7 @@ public class ServerLogin {
try { try {
if (PCBcontext.is_user_offline()) { if (PCBcontext.is_user_offline()) {
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(); PCBcontext.getVocabulary().synchronize();
PCBcontext.getRoom().connect(); PCBcontext.getRoom().connect();
......
...@@ -41,7 +41,9 @@ public class StudentTalk implements Emitter.Listener { ...@@ -41,7 +41,9 @@ public class StudentTalk implements Emitter.Listener {
String pic=msg.getString("pic"); String pic=msg.getString("pic");
String lang=msg.getString("lang"); String lang=msg.getString("lang");
String attributes=msg.getString("attributes"); String attributes=msg.getString("attributes");
JSONObject license=msg.getJSONObject("license"); //JSONObject license= msg.getJSONObject("license");
Log.e("STUDENT","change...remove license in hard when lincense is not null");
JSONObject license=new JSONObject().put("isValid",true);
User user=PCBcontext.getPcbdb().getCurrentUser(); User user=PCBcontext.getPcbdb().getCurrentUser();
User updatedUser=new User(id, username, user.get_pwd_stu(), name, surname, id_active_scene, pic, gender, lang, attributes, User updatedUser=new User(id, username, user.get_pwd_stu(), name, surname, id_active_scene, pic, gender, lang, attributes,
user.get_id_sup(), user.get_email_sup(), user.get_pwd_sup(), user.get_name_sup(), user.get_surname_sup(), user.get_url_img_sup(), user.get_gender_sup(), user.get_id_sup(), user.get_email_sup(), user.get_pwd_sup(), user.get_name_sup(), user.get_surname_sup(), user.get_url_img_sup(), user.get_gender_sup(),
......
...@@ -23,6 +23,7 @@ import org.json.JSONException; ...@@ -23,6 +23,7 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
public final class PCBcontext { public final class PCBcontext {
private static final String LOG_TAG =PCBcontext.class.getName();
private static Context context; private static Context context;
private static PCBDBHelper pcbdb; private static PCBDBHelper pcbdb;
private static Device device=null; private static Device device=null;
...@@ -72,7 +73,7 @@ public final class PCBcontext { ...@@ -72,7 +73,7 @@ public final class PCBcontext {
wrapper.setToken(token); wrapper.setToken(token);
pcbdb = new PCBDBHelper(null, 2, student); pcbdb = new PCBDBHelper(null, 2, student);
pcbdb.user_online(token!=null);Log.e("pcbcontextborra", "JSON:"); pcbdb.user_online(token!=null);
room = new Room(); room = new Room();
actionLog = new ActionLog(); actionLog = new ActionLog();
vocabulary = new Vocabulary(listener); vocabulary = new Vocabulary(listener);
...@@ -107,8 +108,10 @@ public final class PCBcontext { ...@@ -107,8 +108,10 @@ public final class PCBcontext {
PCBcontext.getDevice().insertUser(updatedStudent); PCBcontext.getDevice().insertUser(updatedStudent);
if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big() || PCBcontext.getVocabulary().has_categories() != vocabulary.has_categories() if (updatedStudent.is_picto_size_big()!=getPcbdb().getCurrentUser().is_picto_size_big() || PCBcontext.getVocabulary().has_categories() != vocabulary.has_categories()
|| updatedStudent.get_active_scene() != PCBcontext.getPcbdb().getCurrentUser().get_active_scene()) || updatedStudent.get_active_scene() != PCBcontext.getPcbdb().getCurrentUser().get_active_scene()) {
PCBcontext.getNetService().restart_app(false); Log.e(LOG_TAG, "Major config modification. Restarting is mandatory");
PCBcontext.getNetService().restart_app(false);
}
else { else {
PCBcontext.getPcbdb().setCurrentUser(updatedStudent); PCBcontext.getPcbdb().setCurrentUser(updatedStudent);
PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent, valid_license); PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent, valid_license);
......
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
<string name="fa_flask">&#xf0c3;</string> <string name="fa_flask">&#xf0c3;</string>
<string name="fa_exclamation_triangle">&#xf071;</string> <string name="fa_exclamation_triangle">&#xf071;</string>
<string name="fa_user_plus">&#xf234;</string> <string name="fa_user_plus">&#xf234;</string>
<string name="fa_question_circle">&#xf059;</string>
<string name="google_play_student_apk">https://play.google.com/store/apps/details?id=com.yottacode.yotta_tablet</string> <string name="google_play_student_apk">https://play.google.com/store/apps/details?id=com.yottacode.yotta_tablet</string>
<string name="google_play_supervisor_apk">https://play.google.com/store/apps/details?id=com.yottacode.supervisor_tablet</string> <string name="google_play_supervisor_apk">https://play.google.com/store/apps/details?id=com.yottacode.supervisor_tablet</string>
......
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
<string name="fa_certificate">&#xf0a3;</string> <string name="fa_certificate">&#xf0a3;</string>
<string name="fa_flask">&#xf0c3;</string> <string name="fa_flask">&#xf0c3;</string>
<string name="fa_exclamation_triangle">&#xf071;</string> <string name="fa_exclamation_triangle">&#xf071;</string>
<string name="fa_question_circle">&#xf059;</string>
<string name="fa_user_plus">&#xf234;</string> <string name="fa_user_plus">&#xf234;</string>
<string name="google_play_student_apk">https://play.google.com/store/apps/details?id=com.yottacode.yotta_tablet</string> <string name="google_play_student_apk">https://play.google.com/store/apps/details?id=com.yottacode.yotta_tablet</string>
<string name="google_play_supervisor_apk">https://play.google.com/store/apps/details?id=com.yottacode.supervisor_tablet</string> <string name="google_play_supervisor_apk">https://play.google.com/store/apps/details?id=com.yottacode.supervisor_tablet</string>
......
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
<string name="fa_flask">&#xf0c3;</string> <string name="fa_flask">&#xf0c3;</string>
<string name="fa_exclamation_triangle">&#xf071;</string> <string name="fa_exclamation_triangle">&#xf071;</string>
<string name="fa_user_plus">&#xf234;</string> <string name="fa_user_plus">&#xf234;</string>
<string name="fa_question_circle">&#xf059;</string>
<string name="google_play_student_apk">https://play.google.com/store/apps/details?id=com.yottacode.yotta_tablet</string> <string name="google_play_student_apk">https://play.google.com/store/apps/details?id=com.yottacode.yotta_tablet</string>
<string name="google_play_supervisor_apk">https://play.google.com/store/apps/details?id=com.yottacode.supervisor_tablet</string> <string name="google_play_supervisor_apk">https://play.google.com/store/apps/details?id=com.yottacode.supervisor_tablet</string>
</resources> </resources>
...@@ -2,12 +2,8 @@ package com.yottacode.pictogram.tabletlibrary.gui.login; ...@@ -2,12 +2,8 @@ package com.yottacode.pictogram.tabletlibrary.gui.login;
import android.app.Activity; import android.app.Activity;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.provider.ContactsContract;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -22,9 +18,8 @@ import java.util.Vector; ...@@ -22,9 +18,8 @@ import java.util.Vector;
import static com.yottacode.pictogram.R.string.fa_certificate; import static com.yottacode.pictogram.R.string.fa_certificate;
import static com.yottacode.pictogram.R.string.fa_flask; import static com.yottacode.pictogram.R.string.fa_flask;
import static com.yottacode.pictogram.R.string.fa_exclamation_triangle;
import static com.yottacode.pictogram.R.string.fa_user_plus; import static com.yottacode.pictogram.R.string.fa_user_plus;
import static com.yottacode.pictogram.R.string.fa_question_circle;
/** /**
* Creates a View for each student on the list with a photo and his/her name. * Creates a View for each student on the list with a photo and his/her name.
* It uses list_single.xml for the layout creation. * It uses list_single.xml for the layout creation.
...@@ -73,8 +68,10 @@ public class CustomList extends ArrayAdapter<String>{ ...@@ -73,8 +68,10 @@ public class CustomList extends ArrayAdapter<String>{
// License, except add student view // License, except add student view
TextView licenseView = (TextView) rowView.findViewById(R.id.loginStudentLicense); TextView licenseView = (TextView) rowView.findViewById(R.id.loginStudentLicense);
licenseView.setTypeface(fontAwesome); licenseView.setTypeface(fontAwesome);
if (!PCBcontext.getNetService().online()) {
if(licenses[position].equals("pro")) { licenseView.setText(fa_question_circle);
licenseView.setTextColor(getContext().getResources().getColor(R.color.text_danger));
}else if(licenses[position].equals("pro")) {
licenseView.setText(fa_certificate); licenseView.setText(fa_certificate);
licenseView.setTextColor(getContext().getResources().getColor(R.color.text_primary)); licenseView.setTextColor(getContext().getResources().getColor(R.color.text_primary));
}else if (licenses[position].equals("trial")) { }else if (licenses[position].equals("trial")) {
......
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