Commit c5510d07 by german

Modificado atributo de User para guardar la lista de sus supervisores (Queda…

Modificado atributo de User para guardar la lista de sus supervisores (Queda reparar obtener el listado cuando haces login)
parent c97a6cb5
......@@ -37,6 +37,7 @@ public class User {
static String TTS_ENGINE = "tts engine";
static String TTS_VOICE = "tts voice";
static String DELIVERY = "delivery";
static String SUPERVISORS = "supervisors";
}
public final static class JSON_STUDENT_INPUT_FEEDBACK {
public static String VIBRATION="vibration";
......@@ -49,6 +50,7 @@ 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;
......@@ -266,7 +268,13 @@ public class User {
}
}
public String get_Supervisors(){
return this.supervisors;
}
public void set_Supervisors(String newSup){
this.supervisors = newSup;
}
/**
*
* @return delivery method
......
......@@ -33,8 +33,10 @@ import android.widget.TextView;
import android.widget.Toast;
import com.yottacode.pictogram.dao.Picto;
import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.GUITools;
import java.io.ByteArrayOutputStream;
......@@ -87,6 +89,7 @@ public class EditPictoActivity extends Activity {
//For Legend//////////////////////////////////////////////////////////////////////////
EditText legend;
Button desplegableSupervisores;
//For Audio///////////////////////////////////////////////////////////////////////////
private static final int REQUEST_RECORD_AUDIO_PERMISSION = 200;
......@@ -107,6 +110,7 @@ public class EditPictoActivity extends Activity {
SeekBar barraReproducir;
TextView textoTTotal;
TextView textoTGrabacion;
LinearLayout layoutPreview;
LinearLayout layoutGrabacion;
......@@ -237,6 +241,9 @@ public class EditPictoActivity extends Activity {
legend = (EditText) findViewById(R.id.edtLegend);
okButton = (Button) findViewById(R.id.okButton);
cancelButton = (Button) findViewById(R.id.cancelButton);
desplegableSupervisores = (Button) findViewById(R.id.botonDesplegable);
String transcription = getIntent().getExtras().getString(Picto.JSON_ATTTRS.EXPRESSION);
cropImageView.setFixedAspectRatio(true);
......@@ -300,6 +307,13 @@ public class EditPictoActivity extends Activity {
//}
pathNumber = nRandom.nextInt();
desplegableSupervisores.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
User currentUser = PCBcontext.getPcbdb().getCurrentUser();
Log.i(DEBUG_MESSAGE,"Supervisores:"+currentUser.get_Supervisors());
}
});
//Gestion de botones
okButton.setOnClickListener(new View.OnClickListener() {
@Override
......
......@@ -18,6 +18,7 @@ import com.yottacode.pictogram.dao.User;
import com.yottacode.pictogram.net.ImgDownloader;
import com.yottacode.pictogram.tabletlibrary.R;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.PictogramActivity;
import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.EditPictoActivity;
import com.yottacode.pictogram.tools.Img;
import com.yottacode.pictogram.tools.PCBcontext;
import com.yottacode.tools.GUITools;
......@@ -27,6 +28,8 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
/**
......@@ -80,8 +83,21 @@ public class StudentFragmentGrid extends Fragment{
PCBcontext.set_user(currentUser, null, null);
Intent pictogramActivity = new Intent(getActivity(), PictogramActivity.class);
startActivity(pictogramActivity);
} else
} else {
new_user(i);
User currentUser = PCBcontext.getPcbdb().getCurrentUser();
Log.i(EditPictoActivity.DEBUG_MESSAGE,"Usuario: "+ currentUser.get_name_stu());
ArrayList<String> listaSup = download_supervisors(currentUser.get_id_stu());
String cadenaTotal ="";
if(listaSup.isEmpty()) Log.i(EditPictoActivity.DEBUG_MESSAGE,"Lista Vacia");
for(String cadena: listaSup){
Log.i(EditPictoActivity.DEBUG_MESSAGE,"Cadena de array: "+cadena);
cadenaTotal+=cadena;
}
Log.i(EditPictoActivity.DEBUG_MESSAGE,"Cadena total: "+cadenaTotal);
currentUser.set_Supervisors(cadenaTotal);
Log.i(EditPictoActivity.DEBUG_MESSAGE,"Cadena: "+ cadenaTotal);
}
}
private void new_user(int i) {
......@@ -198,6 +214,50 @@ public class StudentFragmentGrid extends Fragment{
downloader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, imgs);
}
private ArrayList<String> download_supervisors(int stu_id) {
String token = getActivity().getIntent().getExtras().getString("token");
final ArrayList<String> datosSup = new ArrayList<>();
RestapiWrapper wrapper = PCBcontext.getRestapiWrapper();
wrapper.setToken(token);
String operation = "stu/" + stu_id + "/supervisors";
wrapper.ask(operation, new RestapiWrapper.iRestapiListener() {
@Override
public void error(RestapiWrapper.HTTPException e) {
Log.e(this.getClass().getName(), " Server restapi error: " + e.getLocalizedMessage());
GUITools.show_alert(getActivity(), R.string.loginErrorTxt, getString(R.string.serverError), new GUITools.iOKListener() {
@Override
public void ok() {
PCBcontext.getNetService().restart_app(false);
}
});
}
@Override
public void preExecute() {
}
@Override
public void result(JSONArray supervisors) {
for (int i=0;i<supervisors.length();i++) {
JSONObject supervisor;
String datos;
try {
supervisor = supervisors.getJSONObject(i);
datos = supervisor.get("name") +" " + supervisor.get("surname") + "," + supervisor.get("email") + ";";
//Log.i(EditPictoActivity.DEBUG_MESSAGE,"Datos: "+datos);
datosSup.add(datos);
} catch (JSONException e) {
e.printStackTrace();
}
}
}
@Override
public void result(JSONObject result) {
}
});
return datosSup;
}
private void download_students(int sup_id ) {
String token = getActivity().getIntent().getExtras().getString("token");
......
......@@ -104,6 +104,20 @@
android:orientation="vertical">
<TextView
android:id="@+id/textAssociated"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Asociar a:"
android:textColor="@color/gray"
android:textSize="20sp" />
<Button
android:id="@+id/botonDesplegable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Ver" />
<TextView
android:id="@+id/textLegend"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......
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