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 {
Bitmap imagePicto = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
cropImageView.setImageBitmap(imagePicto);
/* byteArray = getIntent().getByteArrayExtra("imageBackground");
/*byteArray = getIntent().getByteArrayExtra("imageBackground");
Bitmap imageBackground = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
backgroundImage.setImageBitmap(imageBackground);*/
......
......@@ -63,7 +63,9 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
......@@ -74,6 +76,7 @@ import java.util.concurrent.TimeUnit;
public class PictogramActivity extends Activity implements VocabularyTalk.iVocabularyListener {
private Picto picto = null;
private static final int CAMERA_PIC_REQUEST = 1;
private static final int GALLERY_PIC_REQUEST = 2;
// Main layout for this activity
......@@ -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
* ********************************************************************************************/
......@@ -1090,7 +1101,7 @@ protected void showOnlyTape(boolean onlyTape) {
case CAMERA_PIC_REQUEST: //Captura de foto
if (data != null) {
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?¿?¿*/
Log.i("DETALLES","Llega el intent del menú, con texto: " + legend);
......@@ -1100,6 +1111,19 @@ protected void showOnlyTape(boolean onlyTape) {
break;
case GALLERY_PIC_REQUEST: //Galeria
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};
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
......@@ -1109,32 +1133,22 @@ protected void showOnlyTape(boolean onlyTape) {
String filePath = cursor.getString(columnIndex);
cursor.close();
imagen = BitmapFactory.decodeFile(filePath);
imagen = BitmapFactory.decodeFile(filePath);*/
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 */
this.launchActivity(legend != null ? legend : null, imagen);
this.launchActivity(imagen);
}
/**Para cambiar la activity de PictogramActivity a EditPictoActivity
*
* @param textLegend
* @param image
*/
public void launchActivity(String textLegend, Bitmap image){
//Para hacer el pantallazo
/*View v1 = getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);*/
public void launchActivity(Bitmap image){
Intent intent = new Intent(this, EditPictoActivity.class);
finish();
......@@ -1149,9 +1163,9 @@ protected void showOnlyTape(boolean onlyTape) {
byte[] byteArray = stream.toByteArray();
intent.putExtra("imagePicto",byteArray);
if(textLegend!=null) { //Si es editar un picto anterior
Log.i("DETALLES", "Lanza el intent a recortar con texto: " + textLegend);
intent.putExtra("textPicto", textLegend);
if(picto != null) { //Si es editar un picto anterior
intent.putExtra("textPicto", picto.get_translation());
picto = null;
}
}else{
Log.i("Detalles","Activity sin imagen");
......
......@@ -56,7 +56,6 @@
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="centerInside"
app:srcCompat="@drawable/descarga"
android:layout_marginLeft="5dp"
android:maxWidth="650px"
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