Commit ac2cc386 by Sebastián Collado Montañez

Merge branch 'develop' of http://gitlab.ujaen.es/yotta/pictogram into develop

parents 3ddf2fec 636f7328
......@@ -31,4 +31,5 @@ dependencies {
compile project(':commonlibrary')
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
}
......@@ -87,7 +87,7 @@ public class PictoMenu {
activity.getIntent().putExtra(Picto.JSON_ATTTRS.EXPRESSION, expression);
//Enviar al PictogramActivity los datos necesarios para crear el picto despues
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) {
activity.getIntent().putExtra("cat", cat);
activity.getIntent().putExtra(Picto.JSON_ATTTRS.CATEGORY, cat);
activity.getIntent().putExtra(Picto.JSON_ATTTRS.ROW, row);
activity.getIntent().putExtra(Picto.JSON_ATTTRS.COLUMN, col);
} else {
......@@ -113,7 +113,7 @@ public class PictoMenu {
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, expression);
//Enviar al PictogramActivity los datos necesarios para editar el picto despues
if (PCBcontext.getPcbdb().getCurrentUser().has_categories()) {
intent.putExtra("cat", cat);
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY, cat);
intent.putExtra(Picto.JSON_ATTTRS.ROW, row);
intent.putExtra(Picto.JSON_ATTTRS.COLUMN, col);
} else {
......@@ -140,11 +140,6 @@ public class PictoMenu {
}
intent.putExtra("tipo",true);
Log.i("TAG_PRUEBAS","---setPicto---");
Log.i("TAG_PRUEBAS","row: "+row);
Log.i("TAG_PRUEBAS","col: "+col);
Log.i("TAG_PRUEBAS","expression: "+expression);
activity.startActivityForResult(intent,EditPictoActivity.EDIT_PICTO_REQUEST);
}
......
......@@ -1127,8 +1127,6 @@ protected void showOnlyTape(boolean onlyTape) {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
int cat = getIntent().getIntExtra("cat", -1);
Bitmap imagen = null;
switch(requestCode) {
case CAMERA_PIC_REQUEST: //Captura de foto
......@@ -1151,12 +1149,14 @@ protected void showOnlyTape(boolean onlyTape) {
break;
case EditPictoActivity.EDIT_PICTO_REQUEST:
if (resultCode == RESULT_OK) {
Log.i("TAG_PRUEBAS","---REQUEST_OK_EDIT----");
int row = data.getExtras().getInt(Picto.JSON_ATTTRS.ROW, -1);
int col = data.getExtras().getInt(Picto.JSON_ATTTRS.COLUMN);
int freeRow = data.getExtras().getInt(Picto.JSON_ATTTRS.FREE_ROW, -1);
int freeColumn = data.getExtras().getInt(Picto.JSON_ATTTRS.FREE_COLUMN, -1);
boolean edit = data.getBooleanExtra("tipo",false);
int row = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.ROW) : getIntent().getIntExtra(Picto.JSON_ATTTRS.ROW, -1);
int col = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.COLUMN) : getIntent().getIntExtra(Picto.JSON_ATTTRS.COLUMN, -1);
int freeRow = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.FREE_ROW) : getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_ROW, -1);
int freeColumn = edit ? data.getExtras().getInt(Picto.JSON_ATTTRS.FREE_COLUMN) : getIntent().getIntExtra(Picto.JSON_ATTTRS.FREE_COLUMN, -1);
int cat = edit ? data.getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1) : getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1);
String path = data.getExtras().getString(EditPictoActivity.PATH);
String legend = data.getExtras().getString(Picto.JSON_ATTTRS.EXPRESSION);
......
......@@ -31,7 +31,7 @@ import com.yottacode.pictogram.tabletlibrary.gui.communicator.cropper.util.Paint
*
* Class to see it on the image to crop
*/
public class CropImageView extends ImageView {
public class CropImageView extends android.support.v7.widget.AppCompatImageView {
......
......@@ -19,6 +19,7 @@ import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
......@@ -45,6 +46,8 @@ import com.yottacode.tools.GUITools;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import pl.droidsonroids.gif.GifTextView;
import static java.lang.Thread.sleep;
/**
......@@ -92,6 +95,8 @@ public class EditPictoActivity extends Activity {
BotonCircular botonReproducir;
BotonCircular botonBorrar;
GifTextView gifRecord;
SeekBar barraReproducir;
TextView textoTTotal;
TextView textoTGrabacion;
......@@ -214,7 +219,7 @@ public class EditPictoActivity extends Activity {
cropImageView.setFixedAspectRatio(true);
cropImageView.setGuidelines(2);
cropImageView.setAspectRatio(1, 1);
//cropImageView.setAspectRatio(cropImageView.getWidth(),cropImageView.getHeight());
if (transcription != null && transcription.length() > 0)
legend.setText(transcription);
......@@ -222,9 +227,13 @@ public class EditPictoActivity extends Activity {
legend.setMaxLines(1);
legend.setSingleLine(true);
editar = getIntent().getBooleanExtra("tipo",false);
titulo.setText(editar ? R.string.titleCropperEdit : R.string.titleCropperNew);
//Obtener imagen del intent
byte[] byteArray = getIntent().getByteArrayExtra(EditPictoActivity.IMAGE_PICTO);
Bitmap imagePicto = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
cropImageView.setAspectRatio(editar ? imagePicto.getWidth() : 4,editar ? imagePicto.getHeight() : 3); //Si es editar un picto la ventana de recorte mantiene el tamaño de la imagen, sino 4:3
cropImageView.setImageBitmap(imagePicto);
cropImageView.setMaxWidth(imagePicto.getWidth());
cropImageView.setMaxHeight(imagePicto.getHeight());
......@@ -241,24 +250,22 @@ public class EditPictoActivity extends Activity {
if (legend.getText().toString().trim().length() > 0) {
final Bitmap croppedImage = cropImageView.getCroppedImage();
//Escalar imagen
Bitmap finalImage = croppedImage.createScaledBitmap(croppedImage, 100, 100, true);
//Guardar imagen en galeria y obtener la ruta
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
finalImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
croppedImage.compress(Bitmap.CompressFormat.PNG, 100, bytes);
String title = getResources().getString(R.string.app_name) + ' ' + legend.getText().toString();
String path = MediaStore.Images.Media.insertImage(PCBcontext.getContext().getContentResolver(), finalImage, title, null);
String path = MediaStore.Images.Media.insertImage(getContentResolver(), croppedImage, title, null);
path = getRealPathFromURI(Uri.parse(path));
Log.i(LOG_PATH, " New image " + title + " saved at " + path);
Intent intent = getIntent(); //Mandar a pictogram activity el path y el texto de la imagen
intent.putExtra(PATH, path);
intent.putExtra(Picto.JSON_ATTTRS.EXPRESSION, legend.getText().toString());
intent.putExtra(Picto.JSON_ATTTRS.CATEGORY,getIntent().getIntExtra(Picto.JSON_ATTTRS.CATEGORY, -1));
intent.putExtra("tipo",editar); //Para saber despues si estas editando o añadiendo nuevo y coger los datos de intent o de data en OnActivityResult
setResult(RESULT_OK, intent);
cropImageView.setImageBitmap(finalImage);
Log.i("TAG_PRUEBAS","Lanza ok de editar");
cropImageView.setImageBitmap(croppedImage);
finish(); //Termina la actividad de editar
} else
......@@ -290,8 +297,10 @@ public class EditPictoActivity extends Activity {
botonBorrar = (BotonCircular) findViewById(R.id.botonBorrar);
camara = (BotonCircular) findViewById(R.id.camara);
galeria = (BotonCircular) findViewById(R.id.galeria);
gifRecord = (GifTextView) findViewById(R.id.recordImage);
barraReproducir = (SeekBar) findViewById(R.id.barraReproducir);
textoTTotal = (TextView) findViewById(R.id.tiempoTotal);
textoTGrabacion = (TextView) findViewById(R.id.tiempoActual);
layoutPreview = (LinearLayout) findViewById(R.id.layoutPreview);
layoutGrabacion = (LinearLayout) findViewById(R.id.layout_record);
......@@ -320,9 +329,11 @@ public class EditPictoActivity extends Activity {
case MotionEvent.ACTION_DOWN:
tareaGrabacion = (RecordTask) new RecordTask().execute(tiempoGrabado);
startRecording();
gifRecord.setBackgroundResource(R.drawable.record_animation);
Log.i(DEBUG_MESSAGE,"Grabando..");
return true;
case MotionEvent.ACTION_UP:
gifRecord.setBackgroundResource(R.color.white);
tareaGrabacion.cancel(true);
return true;
}
......@@ -480,10 +491,20 @@ public class EditPictoActivity extends Activity {
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
finish();
setResult(RESULT_CANCELED, getIntent());
return true;
}
return super.onKeyDown(keyCode, event);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
int cat = getIntent().getIntExtra("cat", -1);
//int cat = getIntent().getIntExtra("cat", -1);
Bitmap imagen = null;
Bitmap rescaled = null;
......
......@@ -22,7 +22,7 @@ public class PaintUtil {
final Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(resources.getDimension(R.dimen.border_thickness));
paint.setColor(resources.getColor(R.color.border));
paint.setColor(resources.getColor(R.color.VerdeApp));
return paint;
}
......@@ -35,7 +35,7 @@ public class PaintUtil {
final Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(resources.getDimension(R.dimen.guideline_thickness));
paint.setColor(resources.getColor(R.color.guideline));
paint.setColor(resources.getColor(R.color.VerdeApp));
return paint;
}
......@@ -62,7 +62,7 @@ public class PaintUtil {
final Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(resources.getDimension(R.dimen.corner_thickness));
paint.setColor(resources.getColor(R.color.corner));
paint.setColor(resources.getColor(R.color.VerdeApp));
return paint;
}
......
......@@ -147,28 +147,27 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal"
android:paddingTop="5dp"
android:visibility="visible"
android:weightSum="1">
<com.yottacode.pictogram.tabletlibrary.gui.communicator.BotonCircular
android:id="@+id/gifGrabar"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentBottom="false"
android:layout_centerHorizontal="false"
<pl.droidsonroids.gif.GifTextView
android:id="@+id/recordImage"
android:layout_width="14dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:layout_weight="0.38"
android:background="#00ffffff"
android:src="@android:drawable/ic_menu_delete" />
android:layout_weight="0.36"
android:background="@color/white" />
<TextView
android:id="@+id/tiempoActual"
android:layout_width="125dp"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:paddingLeft="16dp"
android:paddingLeft="5dp"
android:paddingRight="16dp"
android:text="00:00 | 00:10"
android:textColor="@color/VerdeApp" />
......
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