Asignar supervisor a picto funcionando

parent f82b517c
...@@ -113,7 +113,7 @@ public class Picto extends Img { ...@@ -113,7 +113,7 @@ public class Picto extends Img {
public Picto(int id, String url, JSONObject attributes) { public Picto(int id, String url, JSONObject attributes) {
super(id,url,Img.VOCABULARY);; super(id,url,Img.VOCABULARY);
this.attributes = attributes; this.attributes = attributes;
try { try {
if (this.attributes.get(JSON_ATTTRS.CATEGORY)==null) if (this.attributes.get(JSON_ATTTRS.CATEGORY)==null)
...@@ -306,25 +306,15 @@ public class Picto extends Img { ...@@ -306,25 +306,15 @@ public class Picto extends Img {
* @return the associated person of a picto * @return the associated person of a picto
*/ */
public String get_associated_person() { public String get_associated_person() {
return JSON_ATTTRS.ASSOCIATED_PERSON != "associated_person" ? JSON_ATTTRS.ASSOCIATED_PERSON : null; String ass_person = null;
}
/**
*
* Change the associated person of a picto
*/
public void alter_associated_person(String associated_person) {
try { try {
this.attributes.put(JSON_ATTTRS.ASSOCIATED_PERSON, associated_person); ass_person = this.attributes.getString(JSON_ATTTRS.ASSOCIATED_PERSON);
set_local_status(true);
if (!is_local()) {
new PictoUploader(this).uploadState();
PCBcontext.getActionLog().log(new VocabularyAction(VocabularyAction.ALTERATTRS, this));
}
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
return ass_person;
} }
/** /**
* *
* @return the row of the picto * @return the row of the picto
...@@ -377,7 +367,12 @@ public class Picto extends Img { ...@@ -377,7 +367,12 @@ public class Picto extends Img {
* @return the uri of associated sound of the picto * @return the uri of associated sound of the picto
*/ */
public String getUriSound(){ public String getUriSound(){
return this.attributes.optString(JSON_ATTTRS.URI_SOUND) == null ? null : this.attributes.optString(JSON_ATTTRS.URI_SOUND); try {
return this.attributes.getString(JSON_ATTTRS.URI_SOUND);
} catch (JSONException e) {
e.printStackTrace();
}
return null;
} }
/** /**
......
...@@ -269,9 +269,8 @@ public class User { ...@@ -269,9 +269,8 @@ public class User {
public String get_Supervisors(){ public String get_Supervisors(){
String supervisors = null; String supervisors = null;
try { try{
if(this.attributes_stu.getString(JSON_STUDENT_ATTTRS.SUPERVISORS) != "supervisors") supervisors = this.attributes_stu.getString(JSON_STUDENT_ATTTRS.SUPERVISORS);
supervisors = this.attributes_stu.getString(JSON_STUDENT_ATTTRS.SUPERVISORS);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -280,7 +279,8 @@ public class User { ...@@ -280,7 +279,8 @@ public class User {
public void set_Supervisors(String newSup){ public void set_Supervisors(String newSup){
try { try {
this.attributes_stu.put(JSON_STUDENT_ATTTRS.SUPERVISORS, newSup); this.attributes_stu.remove(JSON_STUDENT_ATTTRS.SUPERVISORS);
this.attributes_stu.put(JSON_STUDENT_ATTTRS.SUPERVISORS,newSup);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -1127,7 +1127,7 @@ protected void showOnlyTape(boolean onlyTape) { ...@@ -1127,7 +1127,7 @@ protected void showOnlyTape(boolean onlyTape) {
protected void onActivityResult(int requestCode, int resultCode, Intent data) { protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
Bitmap imagen = null; Bitmap imagen;
switch(requestCode) { switch(requestCode) {
case CAMERA_PIC_REQUEST: //Captura de foto case CAMERA_PIC_REQUEST: //Captura de foto
if (data != null && resultCode==RESULT_OK) { if (data != null && resultCode==RESULT_OK) {
...@@ -1157,12 +1157,14 @@ protected void showOnlyTape(boolean onlyTape) { ...@@ -1157,12 +1157,14 @@ protected void showOnlyTape(boolean onlyTape) {
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);
String associated_person = edit ? data.getExtras().getString(Picto.JSON_ATTTRS.ASSOCIATED_PERSON) : getIntent().getStringExtra(Picto.JSON_ATTTRS.ASSOCIATED_PERSON); String associated_person = edit ? data.getExtras().getString(Picto.JSON_ATTTRS.ASSOCIATED_PERSON) : getIntent().getStringExtra(Picto.JSON_ATTTRS.ASSOCIATED_PERSON);
Log.i(EditPictoActivity.DEBUG_MESSAGE,"Antes de chooseText..."+associated_person);
int cat = edit ? data.getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1) : getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1); int cat = edit ? data.getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1) : getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1);
String path = data.getExtras().getString(PictoMenu.PATH); String path = data.getExtras().getString(PictoMenu.PATH);
String legend = data.getExtras().getString(Picto.JSON_ATTTRS.EXPRESSION); String legend = data.getExtras().getString(Picto.JSON_ATTTRS.EXPRESSION);
Log.i(EditPictoActivity.DEBUG_MESSAGE,"Antes de chooseText...DATOS--> ASS_PERSON: "+associated_person+"..URI_SOUND: "+uri_sound+"..PATH_IMAGE: "+path+"..EXPRESION: "+legend);
//TODO: COGER URI DEL SONIDO,EL USER AVATAR Y LA PERSONA ASOCIADA AL PICTO //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); chooseTextAndSavePicto(path, row, col, freeRow, freeColumn, cat, legend, uri_sound, null, associated_person);
refresh(); refresh();
...@@ -1218,7 +1220,7 @@ protected void showOnlyTape(boolean onlyTape) { ...@@ -1218,7 +1220,7 @@ protected void showOnlyTape(boolean onlyTape) {
image.compress(Bitmap.CompressFormat.PNG, 100, stream); image.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray(); byte[] byteArray = stream.toByteArray();
intent.putExtra(PictoMenu.IMAGE_PICTO, byteArray); intent.putExtra(PictoMenu.IMAGE_PICTO, byteArray);
startActivityForResult(intent, EditPictoActivity.EDIT_PICTO_REQUEST); startActivityForResult(intent, EditPictoActivity.EDIT_PICTO_REQUEST);
} }
......
...@@ -227,24 +227,19 @@ public class EditPictoActivity extends Activity { ...@@ -227,24 +227,19 @@ public class EditPictoActivity extends Activity {
requestWindowFeature(Window.FEATURE_NO_TITLE); requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.edit_picto_layout); setContentView(R.layout.edit_picto_layout);
Log.i(DEBUG_MESSAGE,"EDITAR ABIERTO");
//Persmisos para grabar audio //Persmisos para grabar audio
ActivityCompat.requestPermissions(this, permissions, REQUEST_RECORD_AUDIO_PERMISSION); ActivityCompat.requestPermissions(this, permissions, REQUEST_RECORD_AUDIO_PERMISSION);
//Aplicar medidas a los elementos de la vista
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
LinearLayout ll = (LinearLayout) findViewById(R.id.image_layout);
ll.getLayoutParams().width = (int) (metrics.widthPixels * 0.65) - (int) getResources().getDimension(R.dimen.activity_vertical_margin) * 2;
ll.requestLayout();
FrameLayout fl = (FrameLayout) findViewById(R.id.legend_menu);
fl.getLayoutParams().width = (int) (metrics.widthPixels * 0.25) - (int) getResources().getDimension(R.dimen.activity_vertical_margin);
fl.requestLayout();
//Editar la lista desplegable de supervisores asociados //Editar la lista desplegable de supervisores asociados
mDrawerList = (ListView)findViewById(R.id.navList); mDrawerList = (ListView)findViewById(R.id.navList);
/**Obtener la lista de supervisores y aplicarle formato*/ /**Obtener la lista de supervisores y aplicarle formato*/
Log.i(DEBUG_MESSAGE,"Usuario: "+ PCBcontext.getPcbdb().getCurrentUser().get_name_stu());
String supervisors = PCBcontext.getPcbdb().getCurrentUser().get_Supervisors(); String supervisors = PCBcontext.getPcbdb().getCurrentUser().get_Supervisors();
Log.i(DEBUG_MESSAGE,"Supervisores: "+ supervisors); Log.i(DEBUG_MESSAGE,"Supervisores: "+ supervisors);
ArrayList<String> supervisores = new ArrayList<>(); ArrayList<String> supervisores = new ArrayList<>();
...@@ -283,6 +278,18 @@ public class EditPictoActivity extends Activity { ...@@ -283,6 +278,18 @@ public class EditPictoActivity extends Activity {
mDrawerToggle.setDrawerIndicatorEnabled(true); mDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerLayout.setDrawerListener(mDrawerToggle); mDrawerLayout.setDrawerListener(mDrawerToggle);
//Aplicar medidas a los elementos de la vista
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
LinearLayout ll = (LinearLayout) findViewById(R.id.image_layout);
ll.getLayoutParams().width = (int) (metrics.widthPixels * 0.65) - (int) getResources().getDimension(R.dimen.activity_vertical_margin) * 2;
ll.requestLayout();
FrameLayout fl = (FrameLayout) findViewById(R.id.legend_menu);
fl.getLayoutParams().width = (int) (metrics.widthPixels * 0.25) - (int) getResources().getDimension(R.dimen.activity_vertical_margin);
fl.requestLayout();
//Definir rutas de almacenado de imagen y audio //Definir rutas de almacenado de imagen y audio
dirImagePath = Environment.getExternalStorageDirectory() + File.separator + Environment.DIRECTORY_DCIM; dirImagePath = Environment.getExternalStorageDirectory() + File.separator + Environment.DIRECTORY_DCIM;
dirImagePath += "/PictoImages"; dirImagePath += "/PictoImages";
...@@ -661,6 +668,8 @@ public class EditPictoActivity extends Activity { ...@@ -661,6 +668,8 @@ public class EditPictoActivity extends Activity {
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) { if (keyCode == KeyEvent.KEYCODE_BACK) {
if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT))
mDrawerLayout.closeDrawer(Gravity.RIGHT);
finish(); finish();
setResult(RESULT_CANCELED, getIntent()); setResult(RESULT_CANCELED, getIntent());
return true; return true;
......
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