Issue #97 por terminar (Comprobar si hay audio ya en el picto al editar)

parent 26298f5c
......@@ -351,7 +351,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,null);
return this.attributes.optString(JSON_ATTTRS.URI_SOUND);
}
/**
......@@ -359,7 +359,7 @@ public class Picto extends Img {
* @return the associated user avatar of the picto
*/
public String getUserAvatar(){
return this.attributes.optString(JSON_ATTTRS.USER_AVATAR,null);
return this.attributes.optString(JSON_ATTTRS.USER_AVATAR);
}
/**
......
......@@ -107,11 +107,12 @@ public class PictoMenu {
}
public void setPicto(int row, int col, int cat, String expression, Bitmap bitmap, int id_picto){
public void setPicto(int row, int col, int cat, String expression, Bitmap bitmap, int id_picto, String uri_sound, String user_avatar){
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);
//Enviar al PictogramActivity los datos necesarios para editar el picto despues
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) {
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, cat);
......@@ -298,7 +299,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());
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());
} catch (IOException e) {
e.printStackTrace();
}
......
......@@ -1155,14 +1155,14 @@ protected void showOnlyTape(boolean onlyTape) {
int freeRow = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.FREE_ROW) : getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_ROW, -1);
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 uri_sound = edit ? data.getExtras().getString(Picto.JSON_ATTTRS.URI_SOUND) : getIntent().getStringExtra(Picto.JSON_ATTTRS.URI_SOUND);
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, null/*uri_sound*/, null);
chooseTextAndSavePicto(path, row, col, freeRow, freeColumn, cat, legend, uri_sound, null);
refresh();
}
break;
......
......@@ -289,6 +289,7 @@ public class EditPictoActivity extends Activity {
tiempoReproducir = 0;
tiempoTotal = 0;
Log.i(DEBUG_MESSAGE,getIntent().getExtras().get(Picto.JSON_ATTTRS.URI_SOUND).toString()!=null ? "Tiene Sonido"+getIntent().getExtras().get(Picto.JSON_ATTTRS.URI_SOUND).toString(): "No tiene sonido");
//TODO: Aqui comprobar si ya hay grabación
//if (hayGrabacionAnterior){
layoutGrabacion.setVisibility(View.VISIBLE);
......@@ -306,11 +307,13 @@ public class EditPictoActivity extends Activity {
if (legend.getText().toString().trim().length() > 0) {
//Guardar imagen en galeria y obtener la ruta
String filepath = null;
String audioPath = null;
try {
id_picto = getIntent().getExtras().getInt(Picto.JSON_ATTTRS.STUPICTO_ID);
String filepath = editar ? dirImagePath + File.separator + legend.getText().toString() + "_" + id_picto + ".png"
filepath = editar ? dirImagePath + File.separator + legend.getText().toString() + "_" + id_picto + ".png"
: dirImagePath + File.separator + legend.getText().toString() + "_new_" + pathNumber+ ".png";
File imageFile = new File(filepath);
......@@ -329,12 +332,7 @@ public class EditPictoActivity extends Activity {
outputStream.flush();
outputStream.close();
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(Picto.JSON_ATTTRS.CATEGORY, getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1));
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);
} catch (FileNotFoundException e) {
e.printStackTrace();
......@@ -349,10 +347,23 @@ public class EditPictoActivity extends Activity {
File from = new File(previewAudioPath);
File to = new File(editar ? dirAudioPath + File.separator + legend.getText().toString() + "_" + id_picto + "_audio.3gp" :
dirAudioPath + File.separator + legend.getText().toString() + "_new_" + pathNumber + "_audio.3gp");
if (from.exists())
if (from.exists()){
from.renameTo(to);
Log.i(DEBUG_MESSAGE,to.getPath().toString());
audioPath = to.getPath().toString();
}
}
}
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(Picto.JSON_ATTTRS.CATEGORY, getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1));
intent.putExtra(Picto.JSON_ATTTRS.URI_SOUND,audioPath);
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);
finish(); //Termina la actividad de editar
} else
......@@ -379,7 +390,7 @@ public class EditPictoActivity extends Activity {
recordSoundOn.play(MediaActionSound.START_VIDEO_RECORDING);
tareaGrabacion = (RecordTask) new RecordTask().execute(tiempoGrabado);
gifRecord.setBackgroundResource(R.drawable.record_animation);
try { //Para que no capture el sonido del sistema
try { //Para que no capture el sonido del sistema
sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
......
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