Commit d3e25034 by Sebastián Collado Montañez

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

parents 5df925fa 1ccebd59
Showing with 73 additions and 54 deletions
......@@ -8,10 +8,10 @@ android {
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
versionName "1.2"
resValue "string", "db_name", "PCB.db"
resValue "integer", "db_version", "7"
resValue "string", "app_version", "1.1"
resValue "integer", "db_version", "8"
//resValue "string", "app_version", "1.1"
resValue "string", "core_vocabulary", "core_vocabulary"
resValue "string", "apk", "to_be_set_in_subproject"
resValue "string", "VersionManagerClass", "to_be_set_in_subproject"
......
......@@ -310,7 +310,7 @@ public class Device extends SQLiteOpenHelper {
(user.get_pwd_stu()==null || user.get_pwd_stu().length()==0 ? "NULL" : "'"+user.get_pwd_stu()+"'") + ", "+
"'" + user.get_name_stu() + "', " +
"'" + user.get_surname_stu() + "', "
+ user.get_active_scene() + ", " +
+ user.get_active_scene() + ", " +
"'" + user.get_url_img_stu() + "', " +
"'" + user.get_gender_stu() + "', " +
"'" + user.get_lang_stu() + "', " +
......@@ -327,7 +327,7 @@ public class Device extends SQLiteOpenHelper {
"'" + user.get_office() + "'" +
")";
db.execSQL(sentence);
Log.e(LOG_TAG,"LLAMA A INSERT USER->"+sentence);
db.setTransactionSuccessful();
db.endTransaction();
//db.close(); <--no es necesario cerrar la bbdd https://groups.google.com/forum/#!msg/android-developers/NwDRpHUXt0U/jIam4Q8-cqQJ
......
package com.yottacode.pictogram.dao;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.util.Log;
import com.yottacode.pictogram.BuildConfig;
import com.yottacode.pictogram.R;
import android.util.Log;
import com.yottacode.pictogram.tools.PCBcontext;
import java.io.InputStream;
......@@ -16,7 +20,9 @@ import java.io.InputStream;
* @version 1.0
*/
public class DeviceHelper {
public static float version= Float.valueOf(PCBcontext.getContext().getResources().getString(R.string.app_version)).floatValue();
public static float version= Float.valueOf(BuildConfig.VERSION_NAME).floatValue();
//Float.valueOf(PCBcontext.getContext().getResources().getString(R.string.app_version)).floatValue();
public static String getDBName(Context context) {
return context.getResources().getString(R.string.db_name);
}
......
......@@ -172,7 +172,7 @@ public class PCBDBHelper extends SQLiteOpenHelper {
getWritableDatabase().execSQL(sql_scene);
//Added
PCBcontext.getPcbdb().getCurrentUser().set_active_scene(params.getInt("id"));
//PCBcontext.getPcbdb().getCurrentUser().set_active_scene(params.getInt("id"));
} catch (JSONException e) {
e.printStackTrace();
Log.e(LOG_TAG,"Error setting active scene:"+e.getMessage());
......
......@@ -201,7 +201,7 @@ public class UserLogin {
st_lang,
st_attributes,
User.NO_SUPERVISOR, "", "", "", "", "", "M", "es-es", "", "");
newStu.set_active_scene(st_id_scene);
//newStu.set_active_scene(st_id_scene);
set_student_oline(newStu
, result.getString(TAG_TOKEN)
, pictogramActivity, activity);
......
......@@ -78,7 +78,6 @@ public class Vocabulary implements Iterable<Picto> {
case update:{
Log.i(this.getClass().getCanonicalName(), "Picto update "+args.toString());
try {
Log.i("TAG_PRUEBAS","Mensaje update: "+args.getJSONObject("attributes").toString());
modifyAttsPicto(picto_cat, picto_id, args.getJSONObject("attributes"));
} catch (JSONException e) {
e.printStackTrace();
......@@ -195,8 +194,6 @@ public class Vocabulary implements Iterable<Picto> {
JSONObject stupicto = null;
try {
setHas_categories(result.getBoolean("categories"));
//PCBcontext.getPcbdb().getCurrentUser().set_active_scene(result.getInt("id"));
JSONArray stu_pictos = result.getJSONArray("pictos"); //Obtengo el JSONArray de los stupictos
Picto[] pictos = new Picto[stu_pictos.length()];
......@@ -205,7 +202,6 @@ public class Vocabulary implements Iterable<Picto> {
picto = stupicto.getJSONObject("picto");
attributes = stupicto.getJSONObject("attributes");
attributes.put(Picto.JSON_ATTTRS.STUPICTO_ID, stupicto.getInt("id"));
//OK AQUI Log.i("TAG_PRUEBAS","stupictoid: "+stupicto.getInt("id")+"--PictoId: "+picto.getInt("id"));
pictos[i] = new Picto(picto.getInt("id"),
picto.getString("uri"),
stupicto.getInt("id"),
......@@ -225,8 +221,6 @@ public class Vocabulary implements Iterable<Picto> {
Log.e(this.getClass().getName(), " Picto JSON error from server: " + stupicto.toString());
this.error(new RestapiWrapper.HTTPException("JSON Error:" + e.getMessage(), -1));
}
}else{
Log.i("TAG_PRUEBAS","result null");
}
}
......@@ -409,8 +403,6 @@ public class Vocabulary implements Iterable<Picto> {
} else {
LinkedList<Picto> freePictos = new LinkedList<>();
LinkedList<Picto> category=pictos.get(new Integer(Picto.NO_CATEGORY));
//for (Picto picto : category) {
for (Picto picto: category) {
if (picto.getFreeRow() != -1 && picto.getFreeColumn() != -1) {
freePictos.add(picto);
......
......@@ -99,7 +99,7 @@ public class PictoUploader {
if (!extension.equalsIgnoreCase("mp3"))
throw new UnsupportedEncodingException("Extension "+extension+" is not supported. Only mp3 files");
String url=PCBcontext.getContext().getResources().getString(R.string.server) + "/"+PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu()+"/upload_sound/"+picto.get_id();
Log.e(LOG_TAG,"Upload "+audioFile);
Ion ion = Ion.getDefault(PCBcontext.getContext());
try {
response=ion.with(PCBcontext.getContext())
......@@ -181,9 +181,7 @@ public class PictoUploader {
public void result(JSONObject result) {
Log.i(LOG_TAG, " Attributes uploaded: " + result.toString());
if(PictoUploader.this.picto.get_audioFile()!=null) {
Log.i(LOG_TAG,"Uploading sound "+PictoUploader.this.picto.get_audioFile());
File file = picto.get_audioFile(); //Obtengo el fichero de audio local
//Llamo a la subida
File file = picto.get_audioFile();
try {
if(uploadSound(file)) {
Log.i(LOG_TAG,"Sound uploaded");
......@@ -218,7 +216,6 @@ public class PictoUploader {
params.put("picto", Integer.toString(id_picto));
params.put("lang", PCBcontext.getPcbdb().getCurrentUser().get_lang_stu());
params.put("text", picto.get_translation());
Log.i(LOG_TAG, "Uploading translation: " + picto.get_translation());
PCBcontext.getRestapiWrapper().ask("picto/exp", params, "post", new RestapiWrapper.iRestapiListener() {
@Override
......@@ -319,13 +316,11 @@ public class PictoUploader {
public void uploadState( ){
Hashtable<String, String> params = new Hashtable<String, String>(1);
Log.i(LOG_TAG,"Picto con id stupicto: "+picto.get_stupicto_id());
params.put("attributes", picto.get_json_server_attrs());
params.put("id_stu", Integer.toString(PCBcontext.getPcbdb().getCurrentUser().get_id_stu()));
//params.put("id_pic", Integer.toString(this.picto.get_id()));
//params.put("id_scene" , Integer.toString(PCBcontext.getPcbdb().getCurrentUser().get_active_scene()));
params.put("id_stuPicto", Integer.toString(this.picto.get_stupicto_id()));
Log.i(LOG_TAG, "Picto "+ this.picto.get_id()+" stupicto id:"+this.picto.get_stupicto_id()+" Uploading " + params.toString());
PCBcontext.getRestapiWrapper().ask(
PCBcontext.getPcbdb().getCurrentUser().get_restapi_operation_stu() + "/picto",
params, "put", new RestapiWrapper.iRestapiListener() {
......
......@@ -36,13 +36,13 @@ public class StudentTalk implements Emitter.Listener {
String username=msg.getString("username");
String name=msg.getString("name");
String surname=msg.getString("surname");
//int id_active_scene = msg.getInt("id_active_scene");
int id_active_scene = msg.getInt("id_active_scene");
String gender=msg.getString("gender");
String pic=msg.getString("pic");
String lang=msg.getString("lang");
String attributes=msg.getString("attributes");
User user=PCBcontext.getPcbdb().getCurrentUser();
User updatedUser=new User(id, username, user.get_pwd_stu(), name, surname,user.get_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_lang_sup(), user.get_tts_engine_sup(), user.get_office());
Log.i(this.getClass().getName(), "Attributes" +attributes+" listeners:"+listeners.length);
......
......@@ -53,8 +53,6 @@ public class VocabularyTalk implements Emitter.Listener {
int picto_cat = attrs_stu_picto!=null ? attrs_stu_picto.optInt(param_picto_cat, Picto.NO_CATEGORY) : 0;
if(PCBcontext.getPcbdb().getCurrentUser().get_active_scene() == msg.getJSONObject("attributes").getInt("id_scene")) {
PCBcontext.getNetService().nextSynchro(new Date().getTime() + PCBcontext.getNetService().getSynchroTimingLength() * 2); //nos saltamos una sincronización para evitar que llegue antes que los websockets
Log.i(LOG_TAG, "Received message '" + action +
"' for picto " + picto_id + " (cat " + picto_cat + ", picto: " + picto_stupicto);
for (iVocabularyListener listener : this.listeners)
listener.change(action.equals(action_update) ? iVocabularyListener.action.update
: action.equals(action_update_category) ? iVocabularyListener.action.update_category
......
......@@ -73,21 +73,23 @@ public final class PCBcontext {
actionLog = new ActionLog();
vocabulary = new Vocabulary(listener);
getNetService().notifyStatus();
studentTalk=new StudentTalk(room, new StudentTalk.iStudentListener[] {new StudentTalk.iStudentListener() {
@Override
public void change(User updatedStudent) {
//ID ANTIGUO
PCBcontext.getDevice().insertUser(updatedStudent);
//ID NUEVO
Log.i("TAG_PRUEBAS","nuevo: "+ updatedStudent.get_active_scene() +"--Anterior: "+PCBcontext.getPcbdb().getCurrentUser().get_active_scene());
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()) {
PCBcontext.getNetService().restart_app(false);
}else {
PCBcontext.getPcbdb().setCurrentUser(updatedStudent);
PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent);
}
Log.i(getClass().getCanonicalName(),"ID: "+updatedStudent.get_active_scene()+"--ID_UPDAT:"+PCBcontext.getPcbdb().getCurrentUser().get_active_scene());
PCBcontext.getDevice().insertUser(updatedStudent);
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()){
PCBcontext.getNetService().restart_app(false);
}else {
PCBcontext.getPcbdb().setCurrentUser(updatedStudent);
PCBcontext.getNetService().getNetServiceDevice().updateUserConfig(updatedStudent);
}
}
}});
......
......@@ -161,12 +161,9 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
this.vocabulary.listen(PCBcontext.getRoom(), this, new ActionTalk.iActionListener() {
@Override
public void action(action action, int picto_cat, int picto_id, JSONObject msg) {
/* if(msg == null)
Log.i("TAG_PRUEBAS","No viene nada de mensaje");*/
Log.i(this.getClass().getCanonicalName(), action + " from " + picto_cat + "," + picto_id + " catched");
if (action==ActionTalk.iActionListener.action.show) {
/*Log.i("TAG_PRUEBAS","Llega aqui");
Log.i("TAG_PRUEBAS","show message received:"+msg.toString());
/* TODO: Para la siguiente version, codigo para mostrar los mensajes privados
try {
//Log.i("TAG_PRUEBAS","show message received:"+msg.get("expression"));
JSONObject msg_attrs = msg.getJSONObject("attributes");
......@@ -1214,9 +1211,6 @@ protected void showOnlyTape(boolean onlyTape) {
final int category, final String legend,final String path_sound ,final String user_avatar) {
// Set up the buttons
Log.i("TAG_PRUEBAS","Uploading "+legend+" at row "+row+"/"+freeRow+", col "+col+"/"+freeColumn+" sound "+path_sound +" user_avatar: "+user_avatar);
PCBcontext.getVocabulary().saveLocalPicto(
selectedImagePath,
legend,
......@@ -1247,11 +1241,6 @@ protected void showOnlyTape(boolean onlyTape) {
public void launchEditPictoActivity(Bitmap image){
Intent intent = new Intent(this, EditPictoActivity.class);
/* ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
intent.putExtra(PictoMenu.IMAGE_PICTO, byteArray);*/
BitmapTools.save_temporal(image);
startActivityForResult(intent, EditPictoActivity.EDIT_PICTO_REQUEST);
......
......@@ -4,9 +4,13 @@ package com.yottacode.pictogram.tabletlibrary.gui.login;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.Window;
import android.widget.TextView;
import com.yottacode.pictogram.tabletlibrary.BuildConfig;
import com.yottacode.pictogram.tabletlibrary.R;
import java.util.Timer;
......@@ -30,6 +34,16 @@ public class SplashScreenActivity extends Activity {
setContentView(R.layout.activity_splash_screen);
TextView version = (TextView) findViewById(R.id.labelVersion);
PackageInfo pInfo = null;
try {
pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
String versionName = pInfo.versionName;
version.setText(getResources().getString(R.string.version_label)+" "+BuildConfig.VERSION_NAME);
TimerTask task = new TimerTask() {
@Override
public void run() {
......
......@@ -32,4 +32,18 @@
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<TextView
android:id="@+id/labelVersion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/imageView2"
android:layout_alignParentStart="true"
android:layout_alignTop="@+id/imageView2"
android:layout_marginStart="37dp"
android:gravity="center"
android:paddingTop="15dp"
android:text="@string/version_label"
android:textAlignment="center"
android:textColor="@color/black" />
</RelativeLayout>
......@@ -43,10 +43,11 @@
<!-- Cropper -->
<string name="crop_TextRequired">Por favor, introduzca una leyenda para el pictograma</string>
<string name="uploadingImage">Subiendo imagen al servidor</string>
<string name="uploadingImage">Uploading image to server</string>
<string name="titleCropperEdit">Edit Picto</string>
<string name="titleCropperNew">New Picto</string>
<string name="insertPasswordLogin">Insert Password</string>
<string name="version_label">Version:</string>
</resources>
......@@ -46,6 +46,7 @@
<string name="titleCropperEdit">Editar Pictograma</string>
<string name="titleCropperNew">Nuevo Pictograma</string>
<string name="insertPasswordLogin">Inserte Contraseña</string>
<string name="version_label">Versión:</string>
</resources>
<resources>
<string name="app_name">com.yottacode.pictogram.Tablet</string>
<string name="version_label">Versión:</string>
<string name="alumnos">Alumnos</string>
<string name="supervisores">Supervisores</string>
<item name="maxInTape" type="integer">8</item>
......
......@@ -76,16 +76,22 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<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/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 24 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
......
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