Issue #125 arreglado.

Persona asociada a picto casi terminado (falla funcion alter_associated_person de Picto), no lo cambia en tiempo de ejecucion como ocurre con alter_atributes
parent d8822393
......@@ -52,6 +52,7 @@ public class Picto extends Img {
public static String LEGEND = "legend";
public static String URI_SOUND = "uri_sound";
public static String USER_AVATAR = "user_avatar";
public static String ASSOCIATED_PERSON = "associated_person";
}
......@@ -103,6 +104,7 @@ public class Picto extends Img {
.put(JSON_ATTTRS.EXPRESSION,translation)
.put(JSON_ATTTRS.URI_SOUND,uri_sound)
.put(JSON_ATTTRS.USER_AVATAR,user_avatar)
.put(JSON_ATTTRS.ASSOCIATED_PERSON,null)
);
}
public Picto(int id, String url,String translation, String attributes) throws JSONException {
......@@ -301,6 +303,30 @@ public class Picto extends Img {
/**
*
* @return the associated person of a picto
*/
public String get_associated_person() {
return JSON_ATTTRS.ASSOCIATED_PERSON;
}
/**
*
* Change the associated person of a picto
*/
public void alter_associated_person(String associated_person) {
try {
this.attributes.put(JSON_ATTTRS.ASSOCIATED_PERSON, associated_person);
set_local_status(true);
if (!is_local()) {
new PictoUploader(this).uploadState();
PCBcontext.getActionLog().log(new VocabularyAction(VocabularyAction.ALTERATTRS, this));
}
} catch (JSONException e) {
e.printStackTrace();
}
}
/**
*
* @return the row of the picto
*/
public int get_row() {
......@@ -351,7 +377,7 @@ public class Picto extends Img {
* @return the uri of associated sound of the picto
*/
public String getUriSound(){
return this.attributes.optString(JSON_ATTTRS.URI_SOUND);
return this.attributes.optString(JSON_ATTTRS.URI_SOUND) == null ? null : this.attributes.optString(JSON_ATTTRS.URI_SOUND);
}
/**
......
......@@ -50,7 +50,6 @@ public class User {
private JSONObject attributes_stu;
private Img img_sup;
private String email_sup, pwd_sup, name_sup, surname_sup, gender_sup, lang_sup, tts_engine_sup, office_sup;
private String supervisors;
private boolean mirror_mode=false;
......@@ -269,11 +268,22 @@ public class User {
}
public String get_Supervisors(){
return this.supervisors;
String supervisors = null;
try {
if(this.attributes_stu.getString(JSON_STUDENT_ATTTRS.SUPERVISORS) != "supervisors")
supervisors = this.attributes_stu.getString(JSON_STUDENT_ATTTRS.SUPERVISORS);
} catch (JSONException e) {
e.printStackTrace();
}
return supervisors;
}
public void set_Supervisors(String newSup){
this.supervisors = newSup;
try {
this.attributes_stu.put(JSON_STUDENT_ATTTRS.SUPERVISORS, newSup);
} catch (JSONException e) {
e.printStackTrace();
}
}
/**
*
......
......@@ -301,6 +301,13 @@ public class Vocabulary implements Iterable<Picto> {
return picto;
}
/**
*
* @param pic_cat Category id of the picto
* @param pic_id Id image of the picto
* @description Obtain the id of picto with "picto.get_id()"
* @return
*/
public Picto get_picto(int pic_cat, int pic_id) {
Picto picto=null;
LinkedList<Picto> pictos_cat=this.pictos.get(pic_cat);
......@@ -308,6 +315,7 @@ public class Vocabulary implements Iterable<Picto> {
if (pictos_cat.get(i).get_id()==pic_id) picto=pictos_cat.get(i);
return picto;
}
/**
* It removes de given pic from the user collection
* @param pic_id
......@@ -399,7 +407,7 @@ public class Vocabulary implements Iterable<Picto> {
/*
* It saves locally a new picto obtained from the PCB
*/
public void saveLocalPicto(String url, String exp, int cat, int coord_x, int coord_y, int free_category_coord_x, int free_category_coord_y,String uri_sound,String user_avatar, final iLocalPicto listener) {
public void saveLocalPicto(String url, String exp, int cat, int coord_x, int coord_y, int free_category_coord_x, int free_category_coord_y,String uri_sound,String user_avatar,String associated_person, final iLocalPicto listener) {
Picto prev_picto=find_picto(cat, coord_x,coord_y); //¿estamos reemplazanddo un picto que ya existe?
......
......@@ -27,6 +27,7 @@ import static android.graphics.Color.argb;
public class PictoMenu {
private static final String LOG_TAG = PictoMenu.class.getName();
public static final String ID_PICTO_IMAGE = "id_imagen_picto";
PictogramActivity activity;
//Variables used on the picto menu (only supervisors)
......@@ -107,12 +108,17 @@ public class PictoMenu {
}
public void setPicto(int row, int col, int cat, String expression, Bitmap bitmap, int id_picto, String uri_sound, String user_avatar){
public void setPicto(int row, int col, int cat, String expression, Bitmap bitmap, int id_picto, String uri_sound, String user_avatar, int id_imagen_picto/*, String associated_person*/){
Intent intent = new Intent(activity, EditPictoActivity.class);
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, expression);
intent.putExtra(Picto.JSON_ATTTRS.STUPICTO_ID,id_picto);
intent.putExtra(Picto.JSON_ATTTRS.URI_SOUND,uri_sound);
intent.putExtra(ID_PICTO_IMAGE,id_imagen_picto);
//intent.putExtra(Picto.JSON_ATTTRS.ASSOCIATED_PERSON,associated_person);
Log.i(EditPictoActivity.DEBUG_MESSAGE,"Guarda en los intents: id_cat: " +cat+"---id_pic: "+id_picto + "---id_imag: "+id_imagen_picto);
//Enviar al PictogramActivity los datos necesarios para editar el picto despues
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) {
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, cat);
......@@ -299,7 +305,7 @@ public class PictoMenu {
ll.removeAllViewsInLayout();
try {
setPicto(p.get_row(),p.get_column(),p.get_category(),p.get_translation(),p.get_bitmap(PCBcontext.getContext()),p.get_stupicto_id(),p.getUriSound(),p.getUserAvatar());
setPicto(p.get_row(),p.get_column(),p.get_category(),p.get_translation(),p.get_bitmap(PCBcontext.getContext()),p.get_stupicto_id(),p.getUriSound(),p.getUserAvatar(),p.get_id());
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -1156,13 +1156,14 @@ protected void showOnlyTape(boolean onlyTape) {
int freeColumn = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.FREE_COLUMN) : getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_COLUMN, -1);
String uri_sound = edit ? data.getExtras().getString(Picto.JSON_ATTTRS.URI_SOUND) : getIntent().getStringExtra(Picto.JSON_ATTTRS.URI_SOUND);
String associated_person = edit ? data.getExtras().getString(Picto.JSON_ATTTRS.ASSOCIATED_PERSON) : getIntent().getStringExtra(Picto.JSON_ATTTRS.ASSOCIATED_PERSON);
int cat = edit ? data.getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1) : getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1);
String path = data.getExtras().getString(EditPictoActivity.PATH);
String legend = data.getExtras().getString(Picto.JSON_ATTTRS.EXPRESSION);
//TODO: COGER URI DEL SONIDO Y EL USER AVATAR
chooseTextAndSavePicto(path, row, col, freeRow, freeColumn, cat, legend, uri_sound, null);
//TODO: COGER URI DEL SONIDO,EL USER AVATAR Y LA PERSONA ASOCIADA AL PICTO
chooseTextAndSavePicto(path, row, col, freeRow, freeColumn, cat, legend, uri_sound, null,associated_person);
refresh();
}
break;
......@@ -1174,7 +1175,7 @@ protected void showOnlyTape(boolean onlyTape) {
* función para la edición de un texto asociado a una nueva imagen y guardar el nuevo picto
*/
public void chooseTextAndSavePicto(final String selectedImagePath, final int row, final int col, final int freeRow, final int freeColumn,
final int category, final String legend,final String uri_sound,final String user_avatar) {
final int category, final String legend,final String uri_sound,final String user_avatar, String associated_person) {
// Set up the buttons
int cat = category != -1 ? category : Picto.NO_CATEGORY;
......@@ -1190,6 +1191,7 @@ protected void showOnlyTape(boolean onlyTape) {
freeColumn,
uri_sound,
user_avatar,
associated_person,
new iLocalPicto() {
@Override
public void saved(Picto localPicto) {
......
......@@ -41,11 +41,15 @@ import android.widget.Toast;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.grammar.Vocabulary;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictoMenu;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.GUITools;
import org.json.JSONException;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
......@@ -142,6 +146,7 @@ public class EditPictoActivity extends Activity {
int tiempoReproducir;
int tiempoTotal;
int id_pic, id_cat;
// Requesting permission to RECORD_AUDIO
private boolean permissionToRecordAccepted = false;
private String [] permissions = {Manifest.permission.RECORD_AUDIO};
......@@ -365,6 +370,7 @@ public class EditPictoActivity extends Activity {
//}
pathNumber = nRandom.nextInt();
desplegableSupervisores.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
......@@ -379,7 +385,16 @@ public class EditPictoActivity extends Activity {
mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(EditPictoActivity.this, "Supervisor: " + mDrawerList.getAdapter().getItem(position), Toast.LENGTH_SHORT).show();
String[] assocciated_person = mDrawerList.getAdapter().getItem(position).toString().split("\n");
Picto p = PCBcontext.getVocabulary().get_picto((int)getIntent().getExtras().get(Picto.JSON_ATTTRS.CATEGORY),
(int)getIntent().getExtras().get(PictoMenu.ID_PICTO_IMAGE));
Log.i(DEBUG_MESSAGE, "Supervisor Asociado Actual: " + p.get_associated_person());
p.alter_associated_person(assocciated_person[1]); //cambiar el la persona asociada
Log.i(DEBUG_MESSAGE,"String: "+assocciated_person[1]);
Log.i(DEBUG_MESSAGE, "Supervisor Asociado Nuevo: " + p.get_associated_person());
}
});
......@@ -393,7 +408,7 @@ public class EditPictoActivity extends Activity {
String filepath = null;
String audioPath = null;
try {
id_picto = getIntent().getExtras().getInt(Picto.JSON_ATTTRS.STUPICTO_ID);
id_picto = getIntent().getExtras().getInt(PictoMenu.ID_PICTO_IMAGE);
filepath = editar ? dirImagePath + File.separator + legend.getText().toString() + "_" + id_picto + ".png"
......@@ -415,8 +430,6 @@ public class EditPictoActivity extends Activity {
outputStream.flush();
outputStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
......@@ -440,10 +453,10 @@ public class EditPictoActivity extends Activity {
}
Intent intent = getIntent(); //Mandar a pictogram activity el path y el texto de la imagen
intent.putExtra(PATH, filepath);
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, legend.getText().toString());
intent.putExtra(PATH, filepath); //Mandar Path imagen
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, legend.getText().toString()); //Mandar expresion nueva
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1));
intent.putExtra(Picto.JSON_ATTTRS.URI_SOUND,audioPath);
intent.putExtra(Picto.JSON_ATTTRS.URI_SOUND,audioPath); //Mandar el path del audio
intent.putExtra("tipo", editar); //Para saber despues si estas editando o añadiendo nuevo y coger los datos de intent o de data en OnActivityResult
setResult(RESULT_OK, intent);
......
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