Commit d2c1a88e by german

Interfaz del menu de los pictos modificado, añadido abrir desde galeria(falta funcionalidad)

parent de4d53ee
...@@ -59,7 +59,7 @@ public class EditPictoActivity extends Activity { ...@@ -59,7 +59,7 @@ public class EditPictoActivity extends Activity {
Bitmap imagePicto = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length); Bitmap imagePicto = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
cropImageView.setImageBitmap(imagePicto); cropImageView.setImageBitmap(imagePicto);
/* byteArray = getIntent().getByteArrayExtra("imageBackground"); /*byteArray = getIntent().getByteArrayExtra("imageBackground");
Bitmap imageBackground = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length); Bitmap imageBackground = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
backgroundImage.setImageBitmap(imageBackground);*/ backgroundImage.setImageBitmap(imageBackground);*/
......
...@@ -63,7 +63,9 @@ import org.json.JSONException; ...@@ -63,7 +63,9 @@ import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -74,6 +76,7 @@ import java.util.concurrent.TimeUnit; ...@@ -74,6 +76,7 @@ import java.util.concurrent.TimeUnit;
public class PictogramActivity extends Activity implements VocabularyTalk.iVocabularyListener { public class PictogramActivity extends Activity implements VocabularyTalk.iVocabularyListener {
private Picto picto = null;
private static final int CAMERA_PIC_REQUEST = 1; private static final int CAMERA_PIC_REQUEST = 1;
private static final int GALLERY_PIC_REQUEST = 2; private static final int GALLERY_PIC_REQUEST = 2;
// Main layout for this activity // Main layout for this activity
...@@ -684,6 +687,14 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab ...@@ -684,6 +687,14 @@ public class PictogramActivity extends Activity implements VocabularyTalk.iVocab
} }
} }
public Picto getPicto() {
return picto;
}
public void setPicto(Picto picto) {
this.picto = picto;
}
/* ********************************************************************************************* /* *********************************************************************************************
* Event listener classes * Event listener classes
* ********************************************************************************************/ * ********************************************************************************************/
...@@ -1090,7 +1101,7 @@ protected void showOnlyTape(boolean onlyTape) { ...@@ -1090,7 +1101,7 @@ protected void showOnlyTape(boolean onlyTape) {
case CAMERA_PIC_REQUEST: //Captura de foto case CAMERA_PIC_REQUEST: //Captura de foto
if (data != null) { if (data != null) {
imagen = (Bitmap) data.getExtras().get("data"); imagen = (Bitmap) data.getExtras().get("data");
legend = data.getExtras().getString("pictoText"); /**AQUI DEBERIA OBTENER EL LEGEND EN EL CASO DE QUE QUIERA EDITAR LA IMAGEN DE UN PICTO legend = data.getExtras().getString("pictoLegend"); /**AQUI DEBERIA OBTENER EL LEGEND EN EL CASO DE QUE QUIERA EDITAR LA IMAGEN DE UN PICTO
NO FUNCIONA DEVUELVE NULL ¿?¿?¿WHY?¿?¿*/ NO FUNCIONA DEVUELVE NULL ¿?¿?¿WHY?¿?¿*/
Log.i("DETALLES","Llega el intent del menú, con texto: " + legend); Log.i("DETALLES","Llega el intent del menú, con texto: " + legend);
...@@ -1100,6 +1111,19 @@ protected void showOnlyTape(boolean onlyTape) { ...@@ -1100,6 +1111,19 @@ protected void showOnlyTape(boolean onlyTape) {
break; break;
case GALLERY_PIC_REQUEST: //Galeria case GALLERY_PIC_REQUEST: //Galeria
Uri selectedImage = data.getData(); Uri selectedImage = data.getData();
if (selectedImage != null) {
InputStream imageStream = null;
try {
imageStream = getContentResolver().openInputStream(selectedImage);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
// Transformamos la URI de la imagen a inputStream y este a un Bitmap
imagen = BitmapFactory.decodeStream(imageStream);
}
/*Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA}; String[] filePathColumn = {MediaStore.Images.Media.DATA};
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
...@@ -1109,32 +1133,22 @@ protected void showOnlyTape(boolean onlyTape) { ...@@ -1109,32 +1133,22 @@ protected void showOnlyTape(boolean onlyTape) {
String filePath = cursor.getString(columnIndex); String filePath = cursor.getString(columnIndex);
cursor.close(); cursor.close();
imagen = BitmapFactory.decodeFile(filePath); imagen = BitmapFactory.decodeFile(filePath);*/
break; break;
} }
/** Tras echar foto llamar a la actividad de recortar y le paso la leyenda para si tiene anteriormente o null, y la imagen a recortar */ /** Tras echar foto llamar a la actividad de recortar y le paso la leyenda para si tiene anteriormente o null, y la imagen a recortar */
this.launchActivity(legend != null ? legend : null, imagen); this.launchActivity(imagen);
} }
/**Para cambiar la activity de PictogramActivity a EditPictoActivity /**Para cambiar la activity de PictogramActivity a EditPictoActivity
* *
* @param textLegend
* @param image * @param image
*/ */
public void launchActivity(String textLegend, Bitmap image){ public void launchActivity(Bitmap image){
//Para hacer el pantallazo
/*View v1 = getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);*/
Intent intent = new Intent(this, EditPictoActivity.class); Intent intent = new Intent(this, EditPictoActivity.class);
finish(); finish();
...@@ -1149,9 +1163,9 @@ protected void showOnlyTape(boolean onlyTape) { ...@@ -1149,9 +1163,9 @@ protected void showOnlyTape(boolean onlyTape) {
byte[] byteArray = stream.toByteArray(); byte[] byteArray = stream.toByteArray();
intent.putExtra("imagePicto",byteArray); intent.putExtra("imagePicto",byteArray);
if(textLegend!=null) { //Si es editar un picto anterior if(picto != null) { //Si es editar un picto anterior
Log.i("DETALLES", "Lanza el intent a recortar con texto: " + textLegend); intent.putExtra("textPicto", picto.get_translation());
intent.putExtra("textPicto", textLegend); picto = null;
} }
}else{ }else{
Log.i("Detalles","Activity sin imagen"); Log.i("Detalles","Activity sin imagen");
......
...@@ -56,7 +56,6 @@ ...@@ -56,7 +56,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:adjustViewBounds="true" android:adjustViewBounds="true"
android:scaleType="centerInside" android:scaleType="centerInside"
app:srcCompat="@drawable/descarga"
android:layout_marginLeft="5dp" android:layout_marginLeft="5dp"
android:maxWidth="650px" android:maxWidth="650px"
android:maxHeight="250px" android:maxHeight="250px"
......
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