Cambios en PictogramActivity, para dejar esta actividad lista para el modo…

Cambios en PictogramActivity, para dejar esta actividad lista para el modo administrador (habilitar/deshabilitar/añadir pictogramas)
parent b249f8b3
......@@ -268,6 +268,7 @@ public class LoginActivity extends FragmentActivity implements iRestapiListener{
progressDialog.dismiss();
Intent pictogramActivity = new Intent(this, PictogramActivity.class);
pictogramActivity.putExtra("isSupervisor",true);
startActivity(pictogramActivity);
}
} else {
......
......@@ -4,6 +4,7 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.content.ServiceConnection;
import android.database.Cursor;
import android.graphics.Color;
import android.graphics.Point;
......@@ -12,7 +13,9 @@ import android.content.ClipDescription;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.provider.Settings;
import android.speech.tts.TextToSpeech;
import android.util.Log;
......@@ -81,6 +84,10 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
private int count_deletelong = 0;
private boolean isSupervisor = false;
private String selectedImagePath;
private static final int SELECT_PICTURE = 1;
/*
float xAxis = 0f;
float yAxis = 0f;
......@@ -95,6 +102,13 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_pictogram);
Intent intent=getIntent();
isSupervisor = intent.getBooleanExtra("isSupervisor", false);
//isSupervisor = true;// QUITAR
//Log.d(LOG_TAG, "isSupervisor vale " + isSupervisor);
context = this;
actualCategory = null; // this for refresh vocabulary when a websocket action arrived from the dashboard
......@@ -288,6 +302,26 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
panelGridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
if (isSupervisor){
// Si es supervisor al hacer longClick deshabilito ese pictograma o lo habilito
Picto p = panelAdapter.getItem(position);
if (p==null){
// No tengo pictograma. Abro una nueva ventana de selección desde el Carrete del device
Log.d(LOG_TAG, "No tengo pictograma. Abro carrete...");
chooseImage();
// ...
}
else if (p.is_enabled()){
// Lo deshabilito
Log.d(LOG_TAG, "Lo deshabilitaría");
// ....
} else if (!p.is_enabled()){
// Lo habilito
Log.d(LOG_TAG, "Lo habilitaría");
// ....
}
} else{
ClipData.Item item = new ClipData.Item("" + position);
String[] mimeTypes = {ClipDescription.MIMETYPE_TEXT_PLAIN};
ClipData data = new ClipData("" + position, mimeTypes, item);
......@@ -310,11 +344,13 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
//view.setVisibility(View.INVISIBLE);
}
}
}
return true;
}
});
// onLongClick picto del tapeGridView (para empezar a arrastrarlo fuera del tape y eliminar de ahí)
/*
tapeGridView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
......@@ -334,6 +370,7 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
return true;
}
});
*/
// onClick ttsButton (enviar frase a server o guardar en log local)
ttsButton.setOnClickListener(new View.OnClickListener() {
......@@ -401,6 +438,57 @@ public class PictogramActivity extends Activity implements iVocabularyListener,
});
}
/**
* función para la selección de una foto del carrete
*/
public void chooseImage(){
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, SELECT_PICTURE);
}
/**
* Función para la selección de una foto del carrete
* @param requestCode
* @param resultCode
* @param data
*/
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == SELECT_PICTURE) {
Uri selectedImageUri = data.getData();
selectedImagePath = getPath(selectedImageUri);
Log.d(LOG_TAG, "selectedImagePath:" + selectedImagePath);
// Ahora guardaría la imagen en la bbdd local y habría que subirla al server y sincronizar las bbdd
// ...
}
}
}
/**
* Función para la selección de una foto del carrete
* @param uri
* @return
*/
public String getPath(Uri uri) {
if( uri == null ) {
return null;
}
// this will only work for images selected from gallery
String[] projection = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(uri, projection, null, null, null);
if( cursor != null ){
int column_index = cursor
.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
return cursor.getString(column_index);
}
return uri.getPath();
}
@Override
public void onInit(int status) {
if (status == TextToSpeech.SUCCESS) {
......
......@@ -191,10 +191,10 @@ public class SerialActivity extends Activity implements iRestapiListener {
// DE PRUEBA
// Alumno
//username = "faf0001";
//password = "faf000";
//password = "faf0001";
// Supervisor
username = "dofer@ujaen.es";
password = "dofer";
//username = "dofer@ujaen.es";
//password = "dofer";
RestapiWrapper wrapper = PCBcontext.getRestapiWrapper();
if (username.contains("@")){
......
......@@ -146,6 +146,7 @@ public class StudentFragmentGrid extends Fragment{
//Log.d(LOG_TAG, "Vocabulario de tam:" + vocabulary.size());
progressDialog.dismiss();
Intent pictogramActivity = new Intent(getActivity(), PictogramActivity.class);
pictogramActivity.putExtra("isSupervisor",true);
startActivity(pictogramActivity);
}
......
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